Skip to content

Commit

Permalink
cypress-cucumber-automation-framework
Browse files Browse the repository at this point in the history
updated Read-Me document, package.json and Report file name

updated test attributes in add page.ts and added data test atttibutes in dev code for monitoring page

commented a11y vaidations and raised the defects for the same

Updated .git-ignore with package-lock.json because it is not listed in our dependencies
  • Loading branch information
makambalaji committed Nov 3, 2020
1 parent 242d2f4 commit b0858af
Show file tree
Hide file tree
Showing 28 changed files with 2,349 additions and 227 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
/frontend/@types/gql
/frontend/gui_test_screenshots
/frontend/packages/integration-tests-cypress/cypress-a11y-report.json
/frontend/packages/dev-console/integration-tests/cypress-a11y-report.json
/frontend/@types
/frontend/package-lock.json
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ Examples:

[**_More information on Console's Cypress usage_**](frontend/packages/integration-tests-cypress/README.md)

[**_More information on DevConsole's Cypress usage_**](frontend/packages/dev-console/integration-tests/README.md)

#### Protractor

Integration tests are run in a headless browser driven by [protractor](http://www.protractortest.org/#/).
Expand Down
4 changes: 4 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"test-cypress-olm": "cd packages/operator-lifecycle-manager/integration-tests-cypress && ../../../node_modules/.bin/cypress open --config-file cypress-olm.json --env openshift=true",
"test-cypress-console-headless": "cd packages/integration-tests-cypress && node --max-old-space-size=4096 ../../node_modules/.bin/cypress run --env openshift=true --browser ${BRIDGE_E2E_BROWSER_NAME:=chrome} --headless",
"test-cypress-olm-headless": "cd packages/operator-lifecycle-manager/integration-tests-cypress && node --max-old-space-size=4096 ../../../node_modules/.bin/cypress run --config-file cypress-olm.json --env openshift=true --browser ${BRIDGE_E2E_BROWSER_NAME:=chrome} --headless",
"test-cypress-devconsole": "cd packages/dev-console/integration-tests && ../../../node_modules/.bin/cypress open --env openshift=true",
"test-cypress-devconsole-headless": "cd packages/dev-console/integration-tests && node --max-old-space-size=4096 ../../../node_modules/.bin/cypress run --env openshift=true --browser ${BRIDGE_E2E_BROWSER_NAME:=chrome} --headless --spec \"features/project-creation.feature\";",
"cypress-merge": "mochawesome-merge ./gui_test_screenshots/cypress_report*.json > ./gui_test_screenshots/cypress.json",
"cypress-generate": "marge -o ./gui_test_screenshots/ -f cypress-report -t 'OpenShift Console Cypress Test Results' -p 'OpenShift Cypress Test Results' --showPassed false --assetsDir ./gui_test_screenshots/cypress/assets ./gui_test_screenshots/cypress.json",
"cypress-a11y-report": "echo '\nA11y Test Results:' && mv packages/integration-tests-cypress/cypress-a11y-report.json ./gui_test_screenshots/ && node -e \"console.table(JSON.parse(require('fs').readFileSync(process.argv[1])));\" ./gui_test_screenshots/cypress-a11y-report.json",
Expand Down Expand Up @@ -226,12 +228,14 @@
"css-loader": "0.28.x",
"cypress": "^5.0.0",
"cypress-axe": "^0.8.1",
"cypress-cucumber-preprocessor": "latest",
"cypress-jest-adapter": "^0.1.1",
"cypress-multi-reporters": "^1.4.0",
"enzyme": "3.10.x",
"enzyme-adapter-react-16": "1.15.2",
"eslint-plugin-cypress": "^2.10.3",
"eslint-plugin-graphql": "^4.0.0",
"eslint-plugin-import": "^2.22.1",
"file-loader": "1.x",
"find-up": "4.x",
"fork-ts-checker-webpack-plugin": "4.x",
Expand Down
15 changes: 15 additions & 0 deletions frontend/packages/dev-console/integration-tests/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"cypress/globals": true,
"node": true
},
"extends": ["../../.eslintrc", "plugin:cypress/recommended", "plugin:prettier/recommended"],
"plugins": ["cypress"],
"rules": {
"no-console": "off",
"no-namespace": "off",
"no-redeclare": "off",
"promise/catch-or-return": "off",
"promise/no-nesting": "off"
}
}
4 changes: 0 additions & 4 deletions frontend/packages/dev-console/integration-tests/.eslintrc.js

This file was deleted.

59 changes: 50 additions & 9 deletions frontend/packages/dev-console/integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
# This file consists of guide lines to create automation scripts
# Getting Started

## Directory Structure

Folder structure of cypress cucumber framework

```
frontend/packages/dev-console/integration-tests/
├── support <--- cypress cucumber support configurations
| ├── commands <--- add commands to Cypress 'cy.' global, other support configurations
|  | └── index.ts
|  | └── app.ts <--- hooks are added in this file
| ├── constants <--- enums required for dev-console scripts
│   | └── add.ts
| | └── global.ts
| ├── pages <--- helper objects and page functions
│   | ├── add-flow <--- Add flow related helper objects and page functions
| | | └──add-page.ts
| | └── app.ts <--- Re-usable helper objects and page functions
| ├── step-definitions <--- cucumber step implementations
│   | ├── common <--- Re-usable dev-console step definitions
| | └──common.ts
| | └──project-creation.ts
├── features
| ├── addFlow <--- Add flow gherkin scenarios
| | └──create-from-git.feature
| ├── topology <--- Topology gherkin scenarios
| | └──chart-area-visual.feature
| ├── pipelines <--- Pipelines gherkin scenarios
| | └──create-from-builder-page.feature
| ├── knative <--- Knative gherkin scenarios
| | └──create-event-sources.feature
| ├── helm <--- Helm gherkin scenarios
| | └──helm-navigation.feature
| ├── BestPractices.md <--- Gherkin script standards
├── fixtures <--- Test data required for scripts
├── cypress.json <--- cypress configuration file
```

## This file consists of guide lines to create automation scripts

## Scenario files

Expand All @@ -8,14 +48,15 @@
## View files

1. Page objects should be id, css selectors, buttontext etc.. [No XPath]- Already following
* Each section should have one object as shown below (It helps to reduce the import list in scenarios)

export const deleteDeployPopupObj = {
form: element(by.css('form.modal-content')),
checkbox: element(by.css('input[type="checkbox"]')),
cancel: element(by.css('[data-test-id="modal-cancel-action"]')),
delete: element(by.css('#confirm-action'))
}

- Each section should have one object as shown below (It helps to reduce the import list in scenarios)

export const deleteDeployPopupObj = {
form: element(by.css('form.modal-content')),
checkbox: element(by.css('input[type="checkbox"]')),
cancel: element(by.css('[data-test-id="modal-cancel-action"]')),
delete: element(by.css('#confirm-action'))
}

2. Use arrow functions which helps to reduce the lines of code and it has other benefits as well
3. Logics should be implemented within these files
Expand Down
32 changes: 32 additions & 0 deletions frontend/packages/dev-console/integration-tests/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"integrationFolder": "features",
"testFiles": "**/*.{feature,features}",
"defaultCommandTimeout": 30000,
"viewportWidth": 1920,
"viewportHeight": 1080,
"watchForFileChanges": true,
"chromeWebSecurity": true,
"waitForAnimation": true,
"animationDistanceThreshold": 20,
"execTimeout": 90000,
"pageLoadTimeout": 90000,
"requestTimeout": 15000,
"responseTimeout": 15000,
"supportFile": "support/commands/index.ts",
"pluginsFile": "plugins/index.js",
"fixturesFolder": "testData",
"video": true,
"reporter": "../../../node_modules/cypress-multi-reporters",
"reporterOptions": {
"configFile": "reporter-config.json"
},
"screenshotsFolder": "../../../gui_test_screenshots/cypress/screenshots",
"videosFolder": "../../../gui_test_screenshots/cypress/videos",
"env": {
"TAGS": "@smoke and not @manual"
},
"retries": {
"runMode": 1,
"openMode": 0
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
Feature: OpenShift Namespaces
As a user, I want to create the namespace to group and isolate related objects

@e2e, @4.5
Scenario Outline: Create the namespace
Given user is at developer perspecitve
@smoke
Scenario: Create the namespace
Given user is at developer perspective
When user selects the Create Project option from Projects dropdown on top navigation bar
And user enters project name as "<project_name>" in Create Project modal
And user enters project name as "aut-project" in Create Project modal
And user clicks Create button present in Create Project modal
Then modal will get closed
And topology page displays with message "No workloads found"
And topology page displays with message "No resources found"
And topology page have cards from Add page

Examples:
| project_name |
| aut-mb-project |
9 changes: 9 additions & 0 deletions frontend/packages/dev-console/integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@dev-console/integration-tests",
"version": "0.0.1",
"description": "OpenShift Developer Perspective Cypress tests",
"private": true,
"cypress-cucumber-preprocessor": {
"step_definitions": "support/step-definitions/*/"
}
}
78 changes: 78 additions & 0 deletions frontend/packages/dev-console/integration-tests/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const webpack = require('@cypress/webpack-preprocessor');
const fs = require('fs');

module.exports = (on, config) => {
const options = {
webpackOptions: {
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
node: { fs: 'empty', child_process: 'empty', readline: 'empty' },
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: { transpileOnly: true },
},
{
test: /\.feature$/,
use: [
{
loader: 'cypress-cucumber-preprocessor/loader',
},
],
},
{
test: /\.features$/,
use: [
{
loader: 'cypress-cucumber-preprocessor/lib/featuresLoader',
},
],
},
],
},
},
};
// `on` is used to hook into various events Cypress emits
on('task', {
log(message) {
console.log(message);
return null;
},
logError(message) {
console.error(message);
return null;
},
logTable(data) {
console.table(data);
return null;
},
readFileIfExists(filename) {
if (fs.existsSync(filename)) {
return fs.readFileSync(filename, 'utf8');
}
return null;
},
});
on('file:preprocessor', webpack(options));
/* In a Docker container, the default size of the /dev/shm shared memory space is 64MB. This is not typically enough
to run Chrome and can cause the browser to crash. You can fix this by passing the --disable-dev-shm-usage flag to
Chrome with the following workaround: */
on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.args.push('--disable-dev-shm-usage');
}
return launchOptions;
});
// `config` is the resolved Cypress config
config.baseUrl = `${process.env.BRIDGE_BASE_ADDRESS || 'http://localhost:9000'}${(
process.env.BRIDGE_BASE_PATH || '/'
).replace(/\/$/, '')}`;
config.env.BRIDGE_HTPASSWD_IDP = process.env.BRIDGE_HTPASSWD_IDP;
config.env.BRIDGE_HTPASSWD_USERNAME = process.env.BRIDGE_HTPASSWD_USERNAME;
config.env.BRIDGE_HTPASSWD_PASSWORD = process.env.BRIDGE_HTPASSWD_PASSWORD;
config.env.BRIDGE_KUBEADMIN_PASSWORD = process.env.BRIDGE_KUBEADMIN_PASSWORD;
return config;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"reporterEnabled": "mocha-junit-reporter, mochawesome",
"mochaJunitReporterReporterOptions": {
"mochaFile": "../../../gui_test_screenshots/junit_cypress-[hash].xml",
"toConsole": false
},
"mochawesomeReporterOptions": {
"reportDir": "../../../gui_test_screenshots/",
"reportFilename": "cypress_report_devconsole",
"overwrite": false,
"html": false,
"json": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { checkErrors } from '../../../../integration-tests-cypress/support';

before(() => {
cy.login();
cy.visit('');
});

after(() => {
cy.logout();
});

afterEach(() => {
checkErrors();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Include the cypress customized commands related files
import '../../../../integration-tests-cypress/support/selectors';
import '../../../../integration-tests-cypress/support/a11y';
import './app';
import '../../../../integration-tests-cypress/support/login';
import '../../../../integration-tests-cypress/support/project';
import '../../../../integration-tests-cypress/support/index';
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export enum addOptions {
Git = 'From Git',
ContainerImage = 'Container Image',
DockerFile = 'From Dockerfile',
YAML = 'YAML',
DeveloperCatalog = 'From Catalog',
Database = 'Database',
OperatorBacked = 'Operator Backed',
HelmChart = 'Helm Chart',
Pipeline = 'Pipeline',
EventSource = 'Event Source',
}

export enum buildConfigOptions {
webhookBuildTrigger = 'Configure a webhook build trigger',
automaticBuildImage = 'Automatically build a new image when the builder image changes',
launchBuildOnCreatingBuildConfig = 'Launch the first build when the build configuration is created',
}

export enum resourceTypes {
Deployment = 'Deployment',
DeploymentConfig = 'Deployment Config',
knativeService = 'knative',
}

export enum gitAdvancedOptions {
Routing = 'Developer Perspective',
BuildConfig = ' Administrator Perspective',
Deployment = 'Deployment',
Scaling = 'Scaling',
ResourceLimits = 'Resource Limits',
Labels = 'Labels',
HealthChecks = 'Health Checks',
}

export enum caatalogCards {
mariaDB = 'MariaDB',
dotnetCoreExample = '.NET Core Example',
cakePhp = 'CakePHP + MySQL',
nodeJs = 'Node.js',
}

export enum catalogTypes {
OperatorBacked = 'Operator Backed',
HelmCharts = 'Helm Charts',
BuilderImage = 'Builder Image',
Template = 'Template',
ServiceClass = 'Service Class',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export enum devNavigationMenu {
Add = '+Add',
Topology = ' Topology',
Monitoring = 'Monitoring',
Builds = 'Builds',
Search = 'Search',
Helm = 'Helm',
Project = 'Project',
ProjectAccess = 'Project Access',
Pipelines = 'Pipelines',
ConfigMaps = 'Config Maps',
Secrets = 'Secrets',
GitOps = 'GitOps',
}

export enum switchPerspective {
Developer = 'Developer Perspective',
Administrator = ' Administrator Perspective',
}

export enum operators {
pipelineOperator = 'Pipeline Operator',
serverlessOperator = 'Serverless Operator',
virtualizationOperator = 'Virtualization Operator',
knativeCamelOperator = 'knative Apache Camel Operator',
eclipseCheOperator = 'Eclipse Che',
}
Loading

0 comments on commit b0858af

Please sign in to comment.