Skip to content

Commit

Permalink
fix: merge conflict cypress upgrade v12
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Oct 20, 2023
1 parent ddd5a73 commit af0b29a
Show file tree
Hide file tree
Showing 91 changed files with 1,407 additions and 1,354 deletions.
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
52 changes: 26 additions & 26 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,10 +91,10 @@ jobs:

- name: Unit tests
run: yarn test

instance-version:
runs-on: ubuntu-latest
needs: [lint, flow, unit-tests]
needs: install # [lint, flow, unit-tests]
if: "!(startsWith(github.event.head_commit.message, 'fix(translations)') && github.actor == 'dhis2-bot') && !contains(github.event.head_commit.message, '[skip ci]')"
outputs:
version: ${{ steps.instance-version.outputs.version }}
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,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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
import moment from 'moment';

const cleanUpIfApplicable = () => {
Expand All @@ -7,13 +8,15 @@ const cleanUpIfApplicable = () => {
)
.then(url => cy.request(url))
.then(({ body }) => {
const enrollment = body.enrollments?.find(e => e.enrollment === 'fmhIsWXVDmS');
const event = enrollment?.events?.find(e => e.programStage === 'PFDfvmGpsR3');
// TODO - Cypress does not handle optional chaining - figure out why
const enrollment = body.enrollments && body.enrollments.find(e => e.enrollment === 'fmhIsWXVDmS');
const event = enrollment && enrollment.events && enrollment
.events
.find(e => e.programStage === 'PFDfvmGpsR3');
if (!event) {
return null;
}
return cy
.buildApiUrl('events', event.event)
return cy.buildApiUrl('events', event.event)
.then(eventUrl =>
cy.request('DELETE', eventUrl));
});
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 { getCurrentYear } from '../../../support/date';
import '../sharedSteps';

Expand All @@ -22,7 +23,6 @@ Then('the stages and events widget should be closed', () => {
cy.get('[data-test="stages-and-events-widget"]')
.within(() => {
cy.get('[data-test="widget-contents"]')
.children()
.should('not.exist');
cy.contains('Birth').should('not.exist');
});
Expand Down Expand Up @@ -114,23 +114,29 @@ Then('the default list should be displayed', () => {
});

When(/^you sort list asc by (.*)$/, (columnName) => {
cy.get('[data-test="stages-and-events-widget"]')
.find('[data-test="widget-contents"]')
cy.get('[data-test="stages-and-events-widget"]').should('exist')
.find('[data-test="widget-contents"]').should('exist')
.find('[data-test="stage-content"]')
.should('exist')
.eq(2)
.find('thead')
.should('exist')
.find('th')
.should('exist')
.contains(columnName)
.parent()
.should('exist')
.within(() => {
cy.contains('th', columnName)
.find('button')
.click();
cy.wait(100);
cy.contains('th', columnName)
.find('button')
.click();
cy.get('button').should('exist') // Use cy.get() instead of cy.find()
.click()
.then(() => {
// Perform further actions or assertions if needed
cy.get('button').should('exist').click();
});
});
});


Then(/^the sorted list by (.*) asc should be displayed$/, () => {
const rows = [
'07-13|Bumbeh MCHP',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Given } from '@badeball/cypress-cucumber-preprocessor';

Given('you open the enrollment page', () => {
cy.visit('#/enrollment?enrollmentId=wBU0RAsYjKE');
});
Expand Down
Loading

0 comments on commit af0b29a

Please sign in to comment.