Skip to content

Commit

Permalink
gitops cypress cucumber setup
Browse files Browse the repository at this point in the history
  • Loading branch information
makambalaji committed Feb 23, 2021
1 parent 74b0498 commit 4e340c4
Show file tree
Hide file tree
Showing 24 changed files with 399 additions and 108 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export enum devNavigationMenu {
ConfigMaps = 'Config Maps',
Secrets = 'Secrets',
GitOps = 'GitOps',
Environments = 'Environments',
}

export enum switchPerspective {
Expand All @@ -24,4 +25,5 @@ export enum operators {
VirtualizationOperator = 'Virtualization',
KnativeCamelOperator = 'Knative Apache Camel K',
EclipseCheOperator = 'Eclipse Che',
GitOpsOperator = 'GitOps',
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export const pageTitle = {
AddHealthChecks: 'Add health checks',
InstallOperator: 'Install Operator',
InstalledOperators: 'Installed Operators',
Environments: 'Environments',
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const devNavigationMenuPO = {
configMaps: '#ConfigMap',
secret: '#Secret',
dropdownButton: '[data-test-id="dropdown-button"]',
environments: '[data-test-id="environments-header"]',
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const operatorsPO = {
virtualizationOperatorCard: '[data-test^="kubevirt-hyperconverged"]',
knativeCamelOperatorCard: '[data-test^="red-hat-camel-k"]',
installingOperatorModal: '#operator-install-page',
gitOpsOperatorCard: '[data-test^="openshift-gitops-operator"]',
},
subscription: {
logo: 'h1.co-clusterserviceversion-logo__name__clusterserviceversion',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export const navigateTo = (opt: devNavigationMenu) => {
cy.testA11y('Secrets Page in dev perspective');
break;
}
case devNavigationMenu.Environments: {
cy.get(devNavigationMenuPO.environments).click();
detailsPage.titleShouldContain(pageTitle.Environments);
cy.testA11y('Environments Page in dev perspective');
break;
}
default: {
throw new Error('Option is not available');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const operatorsPage = {
detailsPage.titleShouldContain(pageTitle.InstalledOperators);
},

searchOperator: (operatorName: string) => {
searchOperator: (operatorName: string | operators) => {
cy.get(operatorsPO.search)
.should('be.visible')
.clear()
Expand Down Expand Up @@ -73,6 +73,11 @@ export const operatorsPage = {
cy.byTestID('eclipse-che-community-operators-openshift-marketplace').click();
break;
}
case 'GitOps':
case operators.GitOpsOperator: {
cy.get(operatorsPO.operatorHub.gitOpsOperatorCard).click();
break;
}
default: {
throw new Error('operator is not available');
}
Expand Down
15 changes: 15 additions & 0 deletions frontend/packages/gitops-plugin/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"
}
}
52 changes: 52 additions & 0 deletions frontend/packages/gitops-plugin/integration-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Getting Started

- Guidelines related to Setup, Standards, Review process are present in [README.md](frontend/packages/dev-console/integration-tests/README.md)

## Directory Structure

Folder structure of cypress cucumber framework for gitops-plugin

```
frontend/packages/gitops-plugin/integration-tests/
├── features
| ├── gitops <--- gitOps gherkin scenarios
| | └──add-manifest-url.feature
| | └──linkArgoCD.feature
| ├── BestPractices.md <--- Gherkin script standards
├── plugins <--- Plugins provide a way to support and extend the behavior of cypress
| | └── index.ts
├── 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
| ├── page-objects <--- helper objects
| | └── environments-po.ts <--- helper objects related to gitops etc...
| ├── constants <--- enums required for gitOps scripts
| | | └──gitops.ts <--- environments page related text or messages or field names etc..
| ├── pages <--- page functions
| | | environments-page.ts <--- environments page related text or messages or field names etc..
| | └── app.ts <--- Re-usable helper objects and page functions
| ├── step-definitions <--- cucumber step implementations
│ | ├── gitops <--- Re-usable gitOps step definitions
| | | └──common.ts
├── testData <--- Test data required for scripts and installation yaml files
| ├── install-gitops-operator.yaml <--- GitOps installation yaml file
├── cypress.json <--- cypress configuration file
├── tsconfig.json <--- typescript configuration file
├── reporter-config.json <--- reporter configuration file
```

### Execution process

Feature file - "regression" suite - execution from Cypress Dashboard

1. Update the TAGS under env section in config file [Cypress.json file](frontend/packages/gitops-plugin/integration-tests/cypress.json) as
"env": { "TAGS": "@regression and not @manual and not @to-do" }
2. In command prompt, navigate to frontend folder
3. Execute command `yarn run test-cypress-gitops` and select that particular file or run all files in cypress dashboard

Feature file - "regression" suite - execution from command line

1. Open the [frontend/package.json](../../../package.json) and update `test-cypress-gitops-headless` as per requirement
2. In command line, navigate to frontend folder and execute the command `yarn run test-cypress-gitops-headless`
3. All the regression scenarios get executed as per the configuration
32 changes: 32 additions & 0 deletions frontend/packages/gitops-plugin/integration-tests/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"integrationFolder": "features",
"testFiles": "**/*.{feature,features}",
"defaultCommandTimeout": 40000,
"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": "@gitOps and @smoke and not @manual and not @to-do"
},
"retries": {
"runMode": 1,
"openMode": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gherkin Scenarios designing Best Practices

Follow the rules present in [BestPractices.md](frontend/packages/dev-console/integration-tests/features/BestPractices.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@gitOps
Feature: Applications managed by GitOps and Create secret
User should be able to see list of applications managed by GitOps


Background:
Given user has installed gitOps operator
And user is at developer perspective


@smoke
Scenario: No GitOps Manifest URLs found
When user navigates to Environments page
Then user will see the message No GitOps manifest URLs found


@regression @manual
Scenario: Create Secret
Given user has imported gitops repo
When user creates the namespace in pattern of "pipelines-{username}-github"
And user creates the secret in pattern of "{username}-github-token"
And user navigates to Environments page
Then user will see the list GitOps application groupings on the page


@regression @manual
Scenario: Application Details page for Applications
Given user is on the Environments page
And user can see the Applications on the page
When user clicks on the application
Then user can see the application Details page
And user can see various environments for that application
And user can see how many application or workloads are deployed in each environment
And user can see status of the application or workloads


# scenario is commented, as we don't need to add Manifest URLs manually now
# @regression @manual
# Scenario: Add Manifest URL and No Application groups found message
# When user has created namespace "aut-addflow-catalog"
# And user navigates to Search page
# And user selects "Namespaces" on Resources dropdown
# And user selects Namespace "aut-addflow-catalog"
# And user clicks on YAML tab
# And user adds annotation "app.openshift.io/vcs-uri"
# And user adds the Manifest URL under annotation "app.openshift.io/vcs-uri"
# And user saves the YAML
# And user reloads the YAML to see the changes
# And user navigates to Environments page
# Then user will see No Application groups found message
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@gitOps
Feature: External Argo CD Link for Argo CD Dashboard
As a developer, I want a way to navigate to Argo CD from the Deploy Stages page of the OpenShift console so that I can get insight on the sync status of my application.


Background:
Given user has installed gitOps operator
And user is at administrator perspective


@regression @manual
Scenario: External link to the ArgoCD Dashboard
Given user has logged in to cluster using CLI
And user has created namespace "test-argocd"
And user has imported a gitops repo using kam command to namespace "test-aregocd"
Then user will see external link to the ArgoCD dashboard in Application Launcher
And user will see external link to the ArgoCD dashboard on Environments page on DevConsole
And user will see external link to the ArgoCD dashboard on each Environment on Environments page on DevConsole
And user will see external link to the ArgoCD dashboard in Launcher card on Projects page
And user will see external link to the ArgoCD dashboard in Launcher Section on Projects Details page

#Follow below document for setup
#https://docs.google.com/document/d/1JTvo51vJrLV-L10GTa7kTGYTOrB5OuyZ-zBIMU7eVfc/edit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@gitops-plugin/integration-tests",
"version": "0.0.1",
"description": "GitOps Cypress tests",
"private": true,
"cypress-cucumber-preprocessor": {
"step_definitions": "support/step-definitions/*/"
}
}
Loading

0 comments on commit 4e340c4

Please sign in to comment.