Skip to content

Commit

Permalink
chore(#8621): update WDIO to latest (#8658)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianabarsan authored Nov 2, 2023
1 parent 017f395 commit cf5b725
Show file tree
Hide file tree
Showing 31 changed files with 15,783 additions and 15,765 deletions.
31,290 changes: 15,646 additions & 15,644 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
"@types/sinon": "^10.0.16",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"@wdio/allure-reporter": "^8.3.0",
"@wdio/cli": "^8.3.3",
"@wdio/devtools-service": "^8.3.3",
"@wdio/local-runner": "^8.3.3",
"@wdio/allure-reporter": "^8.20.0",
"@wdio/cli": "^8.20.2",
"@wdio/devtools-service": "^8.20.0",
"@wdio/local-runner": "^8.20.0",
"@wdio/mocha-framework": "^8.3.0",
"@wdio/spec-reporter": "^8.3.0",
"allure-commandline": "^2.24.0",
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/default-mobile/contacts/delete.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const commonElements = require('@page-objects/default/common/common.wdio.page');
const contactPage = require('@page-objects/default/contacts/contacts.wdio.page');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const utils = require('@utils');
const commonPage = require('@page-objects/default/common/common.wdio.page');

describe('Delete Contacts', () => {
const places = placeFactory.generateHierarchy();
Expand All @@ -19,9 +18,7 @@ describe('Delete Contacts', () => {
patientDocs = await utils.saveDocs([ patient ]);
await utils.createUsers([ onlineUser ]);
await loginPage.login(onlineUser);
await commonElements.waitForPageLoaded();
await commonElements.goToPeople();
await commonPage.waitForPageLoaded();
});

it('Should delete contact', async () => {
Expand Down
13 changes: 9 additions & 4 deletions tests/e2e/default-mobile/reports/bulk-delete.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ const personFactory = require('@factories/cht/contacts/person');
describe('Bulk delete reports', () => {
const places = placeFactory.generateHierarchy();
const healthCenter = places.get('health_center');
const offlineUser = userFactory.build({ username: 'offline_chw_bulk_delete', place: healthCenter._id });
const patient = personFactory.build({ parent: { _id: healthCenter._id } });
const contact = personFactory.build({ parent: { _id: healthCenter._id, parent: healthCenter.parent } });
const offlineUser = userFactory.build({
username: 'offline_chw_bulk_delete',
place: healthCenter._id,
contact: contact._id,
});
const patient = personFactory.build({ parent: { _id: healthCenter._id, parent: healthCenter.parent } });
const reports = [
reportFactory
.report()
Expand All @@ -35,10 +40,10 @@ describe('Bulk delete reports', () => {

const savedUuids = [];
before(async () => {
await utils.saveDocs([ ...places.values(), patient ]);
await utils.saveDocs([ ...places.values(), contact, patient ]);
await utils.createUsers([ offlineUser ]);
await loginPage.login(offlineUser);
(await utils.saveDocs(reports)).forEach(savedReport => savedUuids.push(savedReport.id));
await loginPage.login(offlineUser);
});

it('should select, deselect and delete only selected reports', async () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/default-mobile/reports/delete.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ describe('Delete Reports', () => {
(await utils.saveDocs(reports)).forEach(savedReport => savedReportIds.push(savedReport.id));
await utils.createUsers([ onlineUser ]);
await loginPage.login(onlineUser);
await commonElements.waitForPageLoaded();
await commonElements.goToReports();
});

it('Should delete report', async () => {
await commonElements.goToReports();
await (await reportsPage.firstReport()).waitForDisplayed();

expect(await (await reportsPage.reportByUUID(savedReportIds[0])).isDisplayed()).to.be.true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Mute/Unmute contacts using a specific form.', () => {
await commonPage.goToPeople(person._id);
await commonPage.openFastActionReport('death_report');
await deathReportForm.submitDeathReport();
await commonPage.sync(true);
await commonPage.sync();

expect(await (await contactPage.contactMuted()).isDisplayed()).to.be.true;

Expand All @@ -56,14 +56,15 @@ describe('Mute/Unmute contacts using a specific form.', () => {
await undoDeathReportForm.setConfirmUndoDeathOption();
await genericForm.submitForm();
await commonPage.waitForPageLoaded();
await commonPage.sync(true);
await commonPage.sync();

expect(await (await contactPage.contactMuted()).isDisplayed()).to.be.false;

});

it('Should show a popup when trying to submit a non-unmuting form against a muted contact', async () => {
await utils.revertSettings(true);
await commonPage.sync(true);
await commonPage.goToPeople(mutePerson._id);

const modalDetails = await contactPage.openFormWithWarning('death_report');
Expand Down
26 changes: 17 additions & 9 deletions tests/e2e/default/enketo/edit-report-with-attachment.wdio-spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page');
const reportsPage = require('@page-objects/default/reports/reports.wdio.page');
const uuid = require('uuid').v4;
const common = require('@page-objects/default/common/common.wdio.page');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const utils = require('@utils');
const userData = require('@page-objects/default/users/user.data');
const fs = require('fs');
const commonElements = require('@page-objects/default/common/common.wdio.page');
const oneTextForm = fs.readFileSync(`${__dirname}/forms/one-text-form.xml`, 'utf8');

const instanceID = uuid();
Expand Down Expand Up @@ -59,16 +59,20 @@ const reportDoc ={
};


describe('Edit report with attachmnet', () => {
describe('Edit report with attachment', () => {
before(async () => {
await utils.seedTestData(userContactDoc, [...docs, formDoc]);
await loginPage.cookieLogin();
await common.hideSnackbar();
reportDoc._id = uuid();
await utils.saveDoc(reportDoc);
await commonElements.waitForPageLoaded();
await commonElements.hideSnackbar();
});

it('should remove attachment when saving', async () => {
reportDoc._id = uuid();
await utils.saveDoc(reportDoc);

await commonElements.goToReports();

await reportsPage.editReport(reportDoc._id);
await reportsPage.submitForm();

Expand All @@ -85,20 +89,24 @@ describe('Edit report with attachmnet', () => {
});

it('should save edits', async () => {
reportDoc._id = uuid();
await utils.saveDoc(reportDoc);

await commonElements.goToReports();
await reportsPage.editReport(reportDoc._id);
await (await genericForm.fieldByName(formDoc.internalId, 'intro')).setValue('updated text');
await (await genericForm.fieldByName(formDoc.internalId, 'intro')).addValue(' updated');
await reportsPage.submitForm();

const editedReport = await utils.getDoc(reportDoc._id);
expect(editedReport._attachments).to.be.undefined;
expect(editedReport.fields).excludingEvery('meta').to.deep.equal({ intro: 'updated text' });
expect(editedReport.fields).excludingEvery('meta').to.deep.equal({ intro: 'initial text updated' });

await reportsPage.editReport(reportDoc._id);
await (await genericForm.fieldByName(formDoc.internalId, 'intro')).setValue('twice updated text');
await (await genericForm.fieldByName(formDoc.internalId, 'intro')).addValue(' twice');
await reportsPage.submitForm();

const twiceEditedReport = await utils.getDoc(reportDoc._id);
expect(twiceEditedReport._attachments).to.be.undefined;
expect(twiceEditedReport.fields).excludingEvery('meta').to.deep.equal({ intro: 'twice updated text' });
expect(twiceEditedReport.fields).excludingEvery('meta').to.deep.equal({ intro: 'initial text updated twice' });
});
});
6 changes: 3 additions & 3 deletions tests/e2e/default/enketo/enketo-widgets.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Enketo Widgets', () => {
await commonPage.waitForPageLoaded();

const { senderName, senderPhone, reportName } = await reportsPage.getOpenReportInfo();
expect(senderName).to.equal(`Submitted by ${offlineUser.contact.name} `);
expect(senderName).to.equal(`Submitted by ${offlineUser.contact.name}`);
expect(senderPhone).to.equal(offlineUser.contact.phone);
expect(reportName).to.equal('Enketo Widgets Test');

Expand Down Expand Up @@ -110,13 +110,13 @@ describe('Enketo Widgets', () => {
.to.equal('option d');

// try to move to next page without filling the mandatory phone number field
await genericForm.nextPage();
await genericForm.nextPage(1, false);
expect(await enketoWidgetsPage.phoneFieldRequiredMessage().getAttribute('data-i18n'))
.to.equal('constraint.required');

// try to move to next page with an invalid phone number
await enketoWidgetsPage.setPhoneNumber('+4076');
await genericForm.nextPage();
await genericForm.nextPage(1, false);
expect(await enketoWidgetsPage.phoneFieldConstraintMessage().getAttribute('data-itext-id'))
.to.equal('/enketo_widgets/enketo_test_select/phone:jr:constraintMsg');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ describe('Contact Delivery Form', () => {
await utils.createUsers([offlineUser]);
await loginPage.login(offlineUser);
await commonPage.waitForPageLoaded();
await commonPage.hideSnackbar();
await commonPage.goToPeople(pregnantWoman._id);

await pregnancyForm.submitPregnancy();
await commonPage.waitForPageLoaded();
});

it('Complete a delivery: Process a delivery with a live child and facility birth.', async () => {
await pregnancyForm.submitPregnancy();

await commonPage.openFastActionReport('delivery');
await deliveryForm.selectDeliveryConditionWomanOutcome('alive_well');
await genericForm.nextPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ describe('Health Facility ANC Reminder task', () => {
await loginPage.login(offlineUser);
await commonPage.waitForPageLoaded();
await commonPage.goToPeople(pregnantWoman._id);
});

it('should submit the health facility ANC reminder task', async () => {
await pregnancyForm.submitPregnancy({futureVisitDate: ancDate.format('YYYY-MM-DD')});
await commonPage.waitForPageLoaded();

await commonPage.goToReports();
await reportsPage.openSelectedReport(await reportsPage.firstReport());
pregnancyId = await reportsPage.getCurrentReportId();
});

it('should submit the health facility ANC reminder task', async () => {
await commonPage.goToTasks();
await taskPage.openTaskById(pregnancyId, '~pregnancy-facility-visit-reminder~anc.facility_reminder');

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/default/enketo/pregnancy-visit.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Pregnancy Visit', () => {

//report details
const openReportInfo = await reportsPage.getOpenReportInfo();
expect(openReportInfo.senderName).to.equal(`Submitted by ${userData.userContactDoc.name} `);
expect(openReportInfo.senderName).to.equal(`Submitted by ${userData.userContactDoc.name}`);
expect(openReportInfo.senderPhone).to.equal(userData.userContactDoc.phone);
expect(openReportInfo.lineage).to.equal(userData.docs[0].name);
expect(await (await reportsPage.selectedCaseId()).getText()).to.match(/^\d{5}$/);
Expand Down
46 changes: 14 additions & 32 deletions tests/e2e/default/enketo/repeat.wdio-spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const fs = require('fs');

const constants = require('@constants');
const utils = require('@utils');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const commonPage = require('@page-objects/default/common/common.wdio.page');
const hierarchyFactory = require('@factories/cht/generate');

const readFormDocument = (formId) => {
const form = fs.readFileSync(`${__dirname}/forms/${formId}.xml`, 'utf8');
Expand All @@ -25,18 +25,9 @@ const readFormDocument = (formId) => {
const assertLabels = async ({ selector, count, labelText }) => {
const labels = await $$(selector);
expect(labels.length).to.equal(count);
await Promise.all(labels.map(
async label => expect(await label.getText()).to.equal(labelText),
));
};

const login = async () => {
await loginPage.login({
username: constants.USERNAME,
password: constants.PASSWORD,
createUser: true,
});
await commonPage.goToBase();
for (const label of labels) {
expect(await label.getText()).to.equal(labelText);
}
};

const openRepeatForm = async (formId) => {
Expand All @@ -57,23 +48,14 @@ const getField = async (fieldName, fieldValue) => {
const countFormDocument = readFormDocument('repeat-translation-count');
const buttonFormDocument = readFormDocument('repeat-translation-button');
const selectFormDocument = readFormDocument('repeat-translation-select');
const userContactDoc = {
_id: constants.USER_CONTACT_ID,
name: 'Jack',
date_of_birth: '',
phone: '+64274444444',
alternate_phone: '',
notes: '',
type: 'person',
reported_date: 1478469976421,
parent: {
_id: 'some_parent'
}
};

const hierarchy = hierarchyFactory.createHierarchy({ name: 'test', user: true, nbrClinics: 1, nbrPersons: 1 });

describe('RepeatForm', () => {
before(async () => {
await utils.seedTestData(userContactDoc, [countFormDocument, buttonFormDocument, selectFormDocument]);
await utils.saveDocs(hierarchy.places);
await utils.createUsers([hierarchy.user]);
await utils.saveDocs([countFormDocument, buttonFormDocument, selectFormDocument]);
});

afterEach(async () => {
Expand All @@ -99,7 +81,7 @@ describe('RepeatForm', () => {
it('should display the initial form and its repeated content in Nepali', async () => {
const neUserName = 'प्रयोगकर्ताको नाम';
await loginPage.changeLanguage('ne', neUserName);
await login();
await loginPage.login(hierarchy.user);
await openRepeatForm(countFormDocument.internalId);

const stateLabel = await $(stateLabelPath);
Expand All @@ -118,7 +100,7 @@ describe('RepeatForm', () => {
it('should display the initial form and its repeated content in English', async () => {
const enUserName = 'User name';
await loginPage.changeLanguage('en', enUserName);
await login();
await loginPage.login(hierarchy.user);
await openRepeatForm(countFormDocument.internalId);

const stateLabel = await $(stateLabelPath);
Expand All @@ -144,7 +126,7 @@ describe('RepeatForm', () => {
it('should display the initial form and its repeated content in Swahili', async () => {
const swUserName = 'Jina la mtumizi';
await loginPage.changeLanguage('sw', swUserName);
await login();
await loginPage.login(hierarchy.user);
await openRepeatForm(buttonFormDocument.internalId);

const stateLabel = await $(stateLabelPath);
Expand All @@ -163,7 +145,7 @@ describe('RepeatForm', () => {
it('should display the initial form and its repeated content in English', async () => {
const enUserName = 'User name';
await loginPage.changeLanguage('en', enUserName);
await login();
await loginPage.login(hierarchy.user);
await openRepeatForm(buttonFormDocument.internalId);

const stateLabel = await $(stateLabelPath);
Expand All @@ -184,7 +166,7 @@ describe('RepeatForm', () => {
it('should display the initial form and its repeated content in the default language', async () => {
const swUserName = 'Jina la mtumizi';
await loginPage.changeLanguage('sw', swUserName);
await login();
await loginPage.login(hierarchy.user);
await openRepeatForm(selectFormDocument.internalId);

const { input: washingtonInput, label: washingtonLabel } = await getField('selected_state', 'washington');
Expand Down
5 changes: 1 addition & 4 deletions tests/e2e/default/login/login-logout.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,15 @@ describe('Login page funcionality tests', () => {
const authSessionCookie = cookies.find(cookie => cookie.name === 'AuthSession');
expect(authSessionCookie).to.include({
httpOnly: true,
session: false,
sameSite: 'Lax',
domain: 'localhost',
secure: false,
path: '/'
});
expect(authSessionCookie.expires).to.be.greaterThan(0);
expect(authSessionCookie.expiry).to.be.greaterThan(0);

const userCtxCookie = cookies.find(cookie => cookie.name === 'userCtx');
expect(userCtxCookie).to.include({
session: false,
sameSite: 'Lax',
domain: 'localhost',
path: '/',
Expand All @@ -108,7 +106,6 @@ describe('Login page funcionality tests', () => {

const localeCookie = cookies.find(cookie => cookie.name === 'locale');
expect(localeCookie).to.include({
session: false,
sameSite: 'Lax',
domain: 'localhost',
path: '/',
Expand Down
Loading

0 comments on commit cf5b725

Please sign in to comment.