Skip to content

Commit

Permalink
chore: initial upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Sep 28, 2023
1 parent ebe67c2 commit debba9e
Show file tree
Hide file tree
Showing 84 changed files with 1,023 additions and 1,086 deletions.
45 changes: 45 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { cucumberPreprocessor, chromeAllowXSiteCookies } = require('@dhis2/cypress-plugins');
const { defineConfig } = require('cypress');
const getCypressEnvVariables = require('./cypress/support/getCypressEnvVariables');
const path = require('path');

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

on('before:browser:launch', (browser, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
launchOptions.extensions.push(path.join(__dirname, '/ignore-x-frame-headers'));
launchOptions
.args
.push('--disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure,SameSiteDefaultChecksMethodRigorously');
}
return launchOptions;
});

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
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
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 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
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

Given('you are in the search page with Ngelehun and MNCH / PNC context', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { v4 as uuid } from 'uuid';
import '../sharedSteps';

Expand Down
File renamed without changes.
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 moment from 'moment';
import { getCurrentYear } from '../../support/date';
import '../sharedSteps';
Expand Down
File renamed without changes.
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 Down Expand Up @@ -231,12 +232,6 @@ Then('you are navigated to the search page with the same org unit and program Ch
cy.url().should('eq', `${Cypress.config().baseUrl}/#/search?orgUnitId=DiszpKrYNg8&programId=IpHINAT79UW`);
});

Then('there should be visible a title with Child Program', () => {
cy.get('[data-test="search-page-content"]')
.contains('person in program: Child Programme')
.should('exist');
});

And('there should be Child Programme domain forms visible to search with', () => {
cy.get('[data-test="search-page-content"]')
.find('[data-test="capture-ui-input"]')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { When, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

And('you fill in the first name with values that have duplicates', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Given, Then, When, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

Given('you are on the default search page', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { When, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import '../sharedSteps';

And('you select search scope TB program', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';

Then('you should see the app main selections', () => {
cy.get('[data-test="org-unit-selector-container"]');
cy.get('[data-test="program-selector-container"]');
});

Given('you open the App without auth cookie', () => {
cy.clearCookies();
cy.visit('/');
});

Expand Down Expand Up @@ -36,12 +39,6 @@ When('you sign in', () => {
.submit();
});

Then('you should see the app main selections', () => {
cy.get('[data-test="org-unit-selector-container"]');

cy.get('[data-test="program-selector-container"]');
});

Then('you should see the header bar', () => {
cy.get('[data-test="headerbar-title"]');
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';

Given('you are visiting Stage Event List Page by url', () => {
cy.visit('/#/enrollment/stageEvents?enrollmentId=wBU0RAsYjKE&stageId=A03MvHHogjR&orgUnitId=DiszpKrYNg8&programId=IpHINAT79UW');
});
Expand Down
File renamed without changes.
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';

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

When('you click the enrollment widget toggle open close button', () => {
cy.get('[data-test="widget-enrollment"]').within(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';

Then('the stages and events should be loaded', () => {
cy.contains('Stages and Events').should('exist');
});


When(/^you fill in the comment: (.*)$/, (comment) => {
cy.get('[data-test="enrollment-comment-widget"]').within(() => {
cy.get('[data-test="comment-textfield"]').type(comment);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';

Then('the enrollment widget should be loaded', () => {
cy.contains('The enrollment event data could not be found').should('not.exist');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Then } from '@badeball/cypress-cucumber-preprocessor';
import '../../sharedSteps';

Then('the profile details should be displayed', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { getCurrentYear } = require('../../../support/date');
import { When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor';
import { getCurrentYear } from '../../../support/date';

Then(/you should see tabs: (.*)/, (tabNames) => {
const tabs = tabNames.split(',');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import moment from 'moment';
import '../sharedSteps';
import '../WidgetEnrollment';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
import { getCurrentYear } from '../../../support/date';
import '../sharedSteps';
import '../WidgetTab';
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 enrollment (.*) page by having typed (.*)$/, (_, url) => {
cy.visit(url);
});
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';

Given('you open the main page with Ngelehun and malaria case context', () => {
Expand Down Expand Up @@ -112,20 +113,6 @@ Then('active events that are assigned to anyone should be retrieved from the api
cy.get('@result').its('response.body.instances').as('events');
});

When('you set the age filter to 10-20', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Age (years)')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.find('input[placeholder="Min"]')
.type('10');

cy.get('[data-test="list-view-filter-contents"]')
.find('input[placeholder="Max"]')
.type('20');
});

When('you apply the current filter on the event working list', () => {
cy.route('GET', '**/tracker/events**').as('getEvents');

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 { v4 as uuid } from 'uuid';
import '../../sharedSteps';
import '../../../sharedSteps';
Expand Down Expand Up @@ -106,20 +107,6 @@ Then('the list should display active events that are assigned to anyone', () =>
});
});

When('you set the age filter to 10-20', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Age (years)')
.click();

cy.get('[data-test="list-view-filter-contents"]')
.find('input[placeholder="Min"]')
.type('10');

cy.get('[data-test="list-view-filter-contents"]')
.find('input[placeholder="Max"]')
.type('20');
});

Then('the age filter button should show that the filter is in effect', () => {
cy.get('[data-test="event-working-lists"]')
.contains('Age (years): 10 to 20')
Expand Down Expand Up @@ -439,8 +426,7 @@ When(/^you save the view as (.*)$/, (name) => {
cy.get('[data-test="view-name-content"]')
.type(name);

cy.server();
cy.route('POST', '**/eventFilters**').as('newEventFilter');
cy.intercept('POST', '**/eventFilters**').as('newEventFilter');

cy.get('button')
.contains('Save')
Expand Down
Loading

0 comments on commit debba9e

Please sign in to comment.