Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [TECH-1654] upgrade cypress to v12 #3429

Merged
merged 29 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
debba9e
chore: initial upgrade
eirikhaugstulen Sep 28, 2023
bc37417
chore: tests
eirikhaugstulen Oct 2, 2023
afcd64e
Merge remote-tracking branch 'origin/master' into eh/TECH/upgrade_cyp…
eirikhaugstulen Oct 2, 2023
33ddee5
chore: tests
eirikhaugstulen Oct 3, 2023
7d8f39f
chore: temp
eirikhaugstulen Oct 8, 2023
5456f2a
feat: add aoc and first stage
eirikhaugstulen Oct 9, 2023
b149324
feat: custom preprocessor
eirikhaugstulen Oct 10, 2023
ec609e2
chore: test
eirikhaugstulen Oct 19, 2023
84d5066
chore: test
eirikhaugstulen Oct 19, 2023
6a4a0f0
chore: test
eirikhaugstulen Oct 19, 2023
e3eed12
chore: test
eirikhaugstulen Oct 19, 2023
9c529c7
chore: test
eirikhaugstulen Oct 19, 2023
c9f2076
chore: test
eirikhaugstulen Oct 19, 2023
a4112f7
chore: test
eirikhaugstulen Oct 19, 2023
0f2272a
chore: test
eirikhaugstulen Oct 19, 2023
bdfc2d8
chore: test
eirikhaugstulen Oct 19, 2023
7b4be22
chore: test
eirikhaugstulen Oct 19, 2023
38202ee
chore: test
eirikhaugstulen Oct 20, 2023
bb177f9
Merge remote-tracking branch 'origin/master' into eh/TECH/upgrade_cyp…
eirikhaugstulen Oct 20, 2023
06f9bf1
chore: test
eirikhaugstulen Oct 20, 2023
99313fd
chore: test
eirikhaugstulen Oct 20, 2023
8503cdb
chore: test
eirikhaugstulen Oct 20, 2023
9924c8b
chore: test
eirikhaugstulen Oct 20, 2023
92c46cd
chore: test
eirikhaugstulen Oct 20, 2023
0fa8da8
chore: test
eirikhaugstulen Oct 20, 2023
f2ef341
chore: comment out BTG
eirikhaugstulen Oct 23, 2023
e60c3d4
Merge remote-tracking branch 'origin/master' into eh/TECH/upgrade_cyp…
eirikhaugstulen Oct 24, 2023
df5950c
Merge remote-tracking branch 'origin/master' into eh/TECH/upgrade_cyp…
eirikhaugstulen Oct 24, 2023
0fa4c35
chore: change tests
eirikhaugstulen Oct 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cypress-cucumber-preprocessorrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"nonGlobalStepDefinitions": true
}
}
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
REACT_APP_CACHE_VERSION=$npm_package_cacheVersion
REACT_APP_SERVER_VERSION=$npm_package_serverVersion
REACT_APP_VERSION=$npm_package_version
# TODO: Remove this when upgrading to react-scripts 5 (and webpack 5)
NODE_OPTIONS=--openssl-legacy-provider
10 changes: 5 additions & 5 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,17 @@ jobs:
needs: prerequisites
if: contains(fromJson(needs.prerequisites.outputs.json-labels), github.event.label.name)
runs-on: ubuntu-latest
container: cypress/browsers:node14.7.0-chrome84
strategy:
fail-fast: false
matrix:
versions: ${{ fromJSON(needs.prerequisites.outputs.versions) }}
containers: ${{ fromJSON(needs.prerequisites.outputs.matrix-containers) }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- name: compute-instance-url
id: instance-url
Expand All @@ -98,7 +97,7 @@ jobs:
version: ${{ matrix.versions }}

- name: Cypress run
uses: cypress-io/github-action@v4
uses: cypress-io/github-action@v6
with:
record: true
parallel: true
Expand All @@ -115,6 +114,7 @@ jobs:
CYPRESS_dhis2InstanceVersion: ${{matrix.versions}}
CYPRESS_dhis2Username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
CYPRESS_dhis2Password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
NODE_OPTIONS: "--openssl-legacy-provider"

call-e2e-tests-result:
needs: cypress
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ on:
pull_request:
types: [ labeled ]

jobs:
jobs:
preview:
runs-on: ubuntu-latest
if: (github.event.label.name == 'preview' || github.event.label.name == 'testing') && !github.event.push.repository.fork && github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
Expand Down
50 changes: 25 additions & 25 deletions .github/workflows/verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
Expand All @@ -40,10 +40,10 @@ jobs:
needs: install
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
Expand All @@ -59,10 +59,10 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: install
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
Expand All @@ -78,10 +78,10 @@ jobs:
needs: install
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
Expand All @@ -91,7 +91,7 @@ jobs:

- name: Unit tests
run: yarn test

instance-version:
runs-on: ubuntu-latest
needs: [lint, flow, unit-tests]
Expand All @@ -105,11 +105,10 @@ jobs:
instance-url: ${{ secrets.CYPRESS_DHIS2_INSTANCES_BASE_URL }}/ca-test-dev
username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}

cypress-dev:
runs-on: ubuntu-latest
needs: instance-version
container: cypress/browsers:node14.7.0-chrome84
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
Expand All @@ -119,13 +118,13 @@ jobs:
matrix:
containers: [1, 2, 3, 4, 5]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- name: Cypress run
uses: cypress-io/github-action@v4
uses: cypress-io/github-action@v6
with:
record: true
parallel: true
Expand All @@ -142,16 +141,17 @@ jobs:
CYPRESS_dhis2InstanceVersion: ${{ needs.instance-version.outputs.version }}
CYPRESS_dhis2Username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
CYPRESS_dhis2Password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
NODE_OPTIONS: "--openssl-legacy-provider"

build:
runs-on: ubuntu-latest
needs: [lint, flow, unit-tests]
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/cache@v2
id: yarn-cache
Expand All @@ -175,13 +175,13 @@ jobs:
needs: build
if: "!github.event.push.repository.fork && !contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'dependabot[bot]'"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
token: ${{ env.GH_TOKEN }}

- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

- uses: actions/download-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion config/eslint/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ if (fileExists(path.resolve(__dirname, '../../src/core_modules/capture-core')))
alias['capture-core-utils'] = path.resolve(__dirname, '../../src/core_modules/capture-core-utils');
}

module.exports = alias;
module.exports = alias;
35 changes: 35 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { chromeAllowXSiteCookies } = require('@dhis2/cypress-plugins');
const { defineConfig } = require('cypress');
const getCypressEnvVariables = require('./cypress/support/getCypressEnvVariables');
const cucumberPreprocessor = require('./cypress/support/cucumberPreprocessor');

async function setupNodeEvents(on, config) {
await chromeAllowXSiteCookies(on);
await cucumberPreprocessor(on, config);

config.env = getCypressEnvVariables(config);
return config;
}

module.exports = defineConfig({
video: true,
dhis2_datatest_prefix: 'dhis2-capture',
chromeWebSecurityComment:
'chromeWebSecurity should removed once https://github.com/cypress-io/cypress/issues/4220 is fixed',
chromeWebSecurity: false,
defaultCommandTimeout: 25000,
projectId: '322xnh',
experimentalFetchPolyfill: true,
retries: {
runMode: 3,
},
env: {
dhis2DataTestPrefix: 'capture-app',
networkMode: 'live',
},
e2e: {
setupNodeEvents,
baseUrl: 'http://localhost:3000',
specPattern: 'cypress/e2e/**/*.feature',
},
});
18 changes: 0 additions & 18 deletions cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';

import '../sharedSteps';

Given('the user is on the the main page', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

const showAllEventsInProgramStage = () => {
Expand Down Expand Up @@ -58,19 +59,6 @@ When(/^you click the checkbox number (.*)$/, (eq) => {
.click();
});

When(/^you click the (.*) button/, (buttonText) => {
cy.intercept({
method: 'POST',
url: '**/tracker?async=false',
}).as('postEvents');

cy.get('[data-test="dhis2-uicore-button"]')
.contains(buttonText)
.click();

cy.wait('@postEvents');
});

When(/^you click the button to (.*) without post request/, (buttonText) => {
cy.get('[data-test="dhis2-uicore-button"]')
.contains(buttonText)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

Given(/^you land on the enrollment (.*) page by having typed (.*)$/, (_, url) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';

Given('you land on the EnrollmentEventNew-page without a stageId', () => {
cy.visit('/#/enrollmentEventNew?programId=IpHINAT79UW&orgUnitId=DiszpKrYNg8&teiId=x2kJgpb0XQC&enrollmentId=RiNIt1yJoge');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';

Then(/^you see the following (.*)$/, (message) => {
cy.contains(message);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { getCurrentYear } from '../../../support/date';
import '../../sharedSteps';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';

Given(/^you land on the enrollment event page by having typed (.*)$/, (url) => {
cy.visit(url);
cy.get('[data-test="person-selector-container"]').contains('Person');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Feature: Breaking the glass page

# TODO - Flaky tests should be fixed by TECH-1662
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you merge the PR, can you add this test and ticket to the Cypress tests wiki? Thanks!

@skip
Scenario: User with search scope access tries to access an enrollment in a protected program
Given the tei created by this test is cleared from the database
And you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

Given('the tei created by this test is cleared from the database', () => {
Expand Down Expand Up @@ -89,6 +90,7 @@ And('you log out', () => {
});

And('you log in as tracker2 user', () => {
cy.clearCookies();
cy.visit('/').then(() => {
cy.get('#j_username').type('tracker2');
cy.get('#j_password').type('Tracker@123');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../../sharedSteps';

Given('you are on an enrollment page', () => {
Expand Down Expand Up @@ -105,10 +106,6 @@ When('you reset the tei selection', () => {
Then('you are navigated to the main page', () => {
cy.url().should('include', `${Cypress.config().baseUrl}/#/?orgUnitId=UgYg0YW7ZIh&programId=IpHINAT79UW`);
});
When('you reset the program selection', () => {
cy.get('[data-test="program-selector-container-clear-icon"]')
.click();
});

Then('you see message explaining you need to select a program', () => {
cy.url().should('not.include', 'programId');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';

Given('you are on an enrollment page with stage available', () => {
cy.visit('/#/enrollment?programId=ur1Edk5Oe2n&orgUnitId=UgYg0YW7ZIh&teiId=zmgVvEZ91Kg&enrollmentId=xRnBV5aJDeF');
cy.get('[data-test="enrollment-page-content"]')
Expand Down
Loading
Loading