Skip to content

Commit

Permalink
chore(#9577): clean up and organize page-object files from /common fo…
Browse files Browse the repository at this point in the history
…lder (#9591)
  • Loading branch information
tatilepizs authored and sugat009 committed Nov 18, 2024
1 parent 0f528c3 commit e7e7571
Show file tree
Hide file tree
Showing 43 changed files with 442 additions and 527 deletions.
32 changes: 16 additions & 16 deletions tests/e2e/default-mobile/navigation/more-options-menu.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('More Options Menu - Offline User', () => {
describe('Message tab', () => {
it('should hide the kebab menu.', async () => {
await sms.sendSms('testing', contact.phone);
expect(await (await commonPage.moreOptionsMenu()).isExisting()).to.be.false;
expect(await commonPage.isMoreOptionsMenuPresent()).to.be.false;
});
});

Expand All @@ -73,44 +73,44 @@ describe('More Options Menu - Offline User', () => {
await commonPage.goToPeople();
await contactsPage.selectLHSRowByText(patient.name);
await commonPage.openMoreOptionsMenu();
expect(await commonPage.isMenuOptionVisible('export', 'contacts')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('edit', 'contacts')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('delete', 'contacts')).to.be.true;
expect(await commonPage.isMenuOptionVisible('export')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('edit')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('delete')).to.be.true;
});

it('should hide the \'export\' and \'edit\' options and ' +
'disable the \'delete\' option when the offline user\'s place is selected', async () => {
await commonPage.goToPeople();
await contactsPage.selectLHSRowByText(health_center.name);
await commonPage.openMoreOptionsMenu();
expect(await commonPage.isMenuOptionVisible('export', 'contacts')).to.be.false;
expect(await commonPage.isMenuOptionVisible('edit', 'contacts')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('delete', 'contacts')).to.be.false;
expect(await commonPage.isMenuOptionVisible('export')).to.be.false;
expect(await commonPage.isMenuOptionVisible('edit')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('delete')).to.be.false;
});
});

describe('Report tab', () => {
it('should hide the \'export\' and \'edit\' options and ' +
'enable the \'delete\' and \'review\' options when the sms report is opened', async () => {
await commonPage.goToReports();
expect(await (await commonPage.moreOptionsMenu()).isExisting()).to.be.false;
expect(await commonPage.isMoreOptionsMenuPresent()).to.be.false;

await reportPage.goToReportById(smsReportId);
await commonPage.openMoreOptionsMenu();
expect(await commonPage.isMenuOptionVisible('export', 'reports')).to.be.false;
expect(await commonPage.isMenuOptionVisible('edit', 'reports')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('delete', 'reports')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('review', 'report')).to.be.true;
expect(await commonPage.isMenuOptionVisible('export')).to.be.false;
expect(await commonPage.isMenuOptionVisible('edit',)).to.be.false;
expect(await commonPage.isMenuOptionEnabled('delete')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('review')).to.be.true;
});

it('should hide the \'export\' option and ' +
'enable the \'edit\', \'delete\' and \'review\' options when the xml report is opened', async () => {
await reportPage.goToReportById(xmlReportId);
await commonPage.openMoreOptionsMenu();
expect(await commonPage.isMenuOptionVisible('export', 'reports')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('edit', 'reports')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('delete', 'reports')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('review', 'report')).to.be.true;
expect(await commonPage.isMenuOptionVisible('export')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('edit')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('delete')).to.be.true;
expect(await commonPage.isMenuOptionEnabled('review')).to.be.true;
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const pregnancyFactory = require('@factories/cht/reports/pregnancy');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const oldNavigationPage = require('@page-objects/default/old-navigation/old-navigation.wdio.page');
const messagesPage = require('@page-objects/default/sms/messages.wdio.page');
const commonPage = require('@page-objects/default/common/common.wdio.page');
const taskPage = require('@page-objects/default/tasks/tasks.wdio.page');
const reportsPage = require('@page-objects/default/reports/reports.wdio.page');
const contactPage = require('@page-objects/default/contacts/contacts.wdio.page');
Expand Down Expand Up @@ -56,7 +55,7 @@ describe('Old Navigation', () => {
await messagesPage.sendMessageOnMobile(message, person.name, person.phone );
await messagesPage.openMessage(person._id);

const { name } = await commonPage.getHeaderTitleOnMobile();
const { name } = await oldNavigationPage.getHeaderTitleOnMobile();
expect(name).to.equal(person.name);

const messages = await messagesPage.getAmountOfMessagesByPhone();
Expand All @@ -71,7 +70,7 @@ describe('Old Navigation', () => {
pregnancyReport._id,
'~pregnancy-danger-sign-follow-up~anc.pregnancy_danger_sign_followup'
);
const { name } = await commonPage.getHeaderTitleOnMobile();
const { name } = await oldNavigationPage.getHeaderTitleOnMobile();
expect(name).to.equal('Pregnancy danger sign follow-up');
});

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/default-mobile/reports/send-message.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const placeFactory = require('@factories/cht/contacts/place');
const userFactory = require('@factories/cht/users/users');
const personFactory = require('@factories/cht/contacts/person');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const commonElements = require('@page-objects/default/common/common.wdio.page');
const commonPage = require('@page-objects/default/common/common.wdio.page');
const reportsPage = require('@page-objects/default/reports/reports.wdio.page');
const pregnancyFactory = require('@factories/cht/reports/pregnancy');

Expand Down Expand Up @@ -39,12 +39,12 @@ describe('Report - Send message action', () => {
});

it('should display option to send message', async () => {
await commonElements.goToReports();
await commonPage.goToReports();
const firstReport = await reportsPage.leftPanelSelectors.firstReport();
await reportsPage.openSelectedReport(firstReport);

expect(await commonElements.isReportActionDisplayed()).to.equal(true);
expect(await commonElements.reportsFastActionFAB().getAttribute('class'))
expect(await commonPage.isReportActionDisplayed()).to.equal(true);
expect(await commonPage.fabSelectors.reportsFastActionFAB().getAttribute('class'))
.to.include('fa-envelope');
});
});
1 change: 1 addition & 0 deletions tests/e2e/default-mobile/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports.config = Object.assign(wdioBaseConfig.config, {
'../default/navigation/navigation.wdio-spec.js',
'../default/reports/delete.wdio-spec.js',
'../default/enketo/training-cards.wdio-spec.js',
'./**/more-options-menu.wdio-spec.js',
]
},
beforeSuite: async () => {
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/default/admin/admin-access.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ describe('Acessing the admin app', () => {
await common.waitForLoaders();
await browser.url('/admin/#/forms');
expect(await (await adminPage.adminNavbarLogo()).isDisplayed()).to.equal(false);
expect(await common.jsonError()).to.equal(error);
expect(await common.getJsonErrorText()).to.equal(error);

await browser.url('/admin');
expect(await (await adminPage.adminNavbarLogo()).isDisplayed()).to.equal(false);
expect(await common.jsonError()).to.equal(error);
expect(await common.getJsonErrorText()).to.equal(error);

await browser.url('/medic/_design/medic-admin/_rewrite/');
expect(await (await adminPage.adminNavbarLogo()).isDisplayed()).to.equal(false);
expect(await common.jsonError()).to.equal(error);
expect(await common.getJsonErrorText()).to.equal(error);

await browser.url('/medic/_design/medic-admin/_rewrite/#/authorization/permissions');
expect(await (await adminPage.adminNavbarLogo()).isDisplayed()).to.equal(false);
expect(await common.jsonError()).to.equal(error);
expect(await common.getJsonErrorText()).to.equal(error);
});

it('should allow admins to access the page', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/default/analytics/analytics.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('Targets', () => {
await sentinelUtils.waitForSentinel();

await loginPage.login(chw);
await (await commonPage.analyticsTab()).waitForDisplayed();
await (await commonPage.tabsSelector.analyticsTab()).waitForDisplayed();
});

afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ describe('User Test Cases -> Creating Users ->', () => {
await contactPage.selectLHSRowByText(districtHospital2.name);
await commonPage.openMoreOptionsMenu();

expect(await commonPage.isMenuOptionEnabled('delete', 'contacts')).to.be.false;
expect(await commonPage.isMenuOptionEnabled('delete')).to.be.false;
});
});
9 changes: 4 additions & 5 deletions tests/e2e/default/contacts/export.wdio-spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const moment = require('moment');
const contactPage = require('@page-objects/default/contacts/contacts.wdio.page');
const userFactory = require('@factories/cht/users/users');
const placeFactory = require('@factories/cht/contacts/place');
const personFactory = require('@factories/cht/contacts/person');
const commonElements = require('@page-objects/default/common/common.wdio.page');
const commonPage = require('@page-objects/default/common/common.wdio.page');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const fileDownloadUtils = require('@utils/file-download');
const utils = require('@utils');
Expand All @@ -23,12 +22,12 @@ describe('Export Contacts ', () => {
contactDocs.forEach(savedContact => savedContactIds.push(savedContact.id));
await utils.createUsers([ onlineUser ]);
await loginPage.login(onlineUser);
await commonElements.waitForPageLoaded();
await commonElements.goToPeople();
await commonPage.waitForPageLoaded();
await commonPage.goToPeople();
});

it('should download export file', async () => {
await contactPage.exportContacts();
await commonPage.accessExportOption();

const files = await fileDownloadUtils.waitForDownload(`contacts-${today.format('YYYYMMDD')}`);
expect(files).to.not.be.undefined;
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/default/db/db-sync.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('db-sync', () => {
});
await sentinelUtils.waitForSentinel();
await loginPage.login({ username: restrictedUserName, password: restrictedPass });
await (await commonElements.analyticsTab()).waitForDisplayed();
await (await commonElements.tabsSelector.analyticsTab()).waitForDisplayed();
});

after(async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/default/enketo/add-family.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Family form', () => {
await commonPage.openFastActionReport('add-family-multiple-repeats', false);
await familyForm.submitFamilyForm();
await familyForm.reportCheck('test Family', 'boreholes', 'true', 'true', 'ucid');
await reportsPage.editReport();
await commonPage.accessEditOption();
await commonEnketoPage.setInputValue('Names', 'modified');
await genericForm.nextPage(7);
await commonEnketoPage.selectCheckBox('What is the family\'s source of drinking water?', 'Spring');
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/default/enketo/death-report.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Submit a death report', () => {
expect((await reportsPage.getDetailReportRowContent('place_of_death')).rowValues[0]).to.equal('health_facility');

// Edit the report created
await reportsPage.editReport();
await commonPage.accessEditOption();
await commonEnketoPage.selectRadioButton('Place of death', 'Home');
await genericForm.nextPage();
await genericForm.submitForm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ describe('Edit report with attachment', () => {
await commonPage.goToReports();

await reportsPage.openReport(editReportWithAttachmentDoc._id);
await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.submitForm();

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

await reportsPage.openReport(editReportWithAttachmentDoc._id);
await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.submitForm();

const twiceEditedReport = await utils.getDoc(editReportWithAttachmentDoc._id);
Expand All @@ -50,7 +50,7 @@ describe('Edit report with attachment', () => {

await commonPage.goToReports();
await reportsPage.openReport(editReportWithAttachmentDoc._id);
await reportsPage.editReport();
await commonPage.accessEditOption();
await commonEnketoPage.setInputValue('Enter text', 'initial text updated');
await genericForm.submitForm();

Expand All @@ -59,7 +59,7 @@ describe('Edit report with attachment', () => {
expect(editedReport.fields).excludingEvery('meta').to.deep.equal({ intro: 'initial text updated' });

await reportsPage.openReport(editReportWithAttachmentDoc._id);
await reportsPage.editReport();
await commonPage.accessEditOption();
await commonEnketoPage.setInputValue('Enter text', 'initial text updated twice');
await genericForm.submitForm();

Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/default/enketo/phone-widget.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const reportsPage = require('@page-objects/default/reports/reports.wdio.page');
const utils = require('@utils');
const loginPage = require('@page-objects/default/login/login.wdio.page');
const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page');
const contactsPage = require('@page-objects/default/contacts/contacts.wdio.page');
const commonEnketoPage = require('@page-objects/default/enketo/common-enketo.wdio.page');
const personFactory = require('@factories/cht/contacts/person');
const { expect } = require('chai');
Expand Down Expand Up @@ -57,7 +56,7 @@ describe('Phone widget', () => {

it('can use duplicate phone number when editing contact with same number', async () => {
await commonPage.goToPeople(person1._id);
await contactsPage.openEditContactForm();
await commonPage.accessEditOption();

await (await genericForm.nextPage());
// Try setting phone to number of the other person
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('Contact Delivery Form', () => {
expect(_.uniq(aliveBabyUUIds).length).to.deep.equal(noOfAliveBabies);

await reportsPage.openReport(reportId);
await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.nextPage();
await genericForm.nextPage();
await genericForm.nextPage();
Expand Down Expand Up @@ -321,7 +321,7 @@ describe('Contact Delivery Form', () => {

// edit one field
await reportsPage.openReport(reportId);
await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.nextPage();
await genericForm.nextPage();
await commonEnketoPage.selectRadioButton('How did she deliver?', 'Cesarean');
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('Contact Delivery Form', () => {
expect(initialReport._attachments).to.equal(undefined);
await browser.refresh();

await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.nextPage();
await dangerSignPage.selectAllDangerSignsDelivery();
await genericForm.nextPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Pregnancy danger sign follow-up form', () => {
expect(initialReport._attachments).to.equal(undefined);

await reportsPage.openReport(reportId);
await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.nextPage();
await genericForm.submitForm();

Expand All @@ -63,7 +63,7 @@ describe('Pregnancy danger sign follow-up form', () => {
expect(initialReport._attachments).to.equal(undefined);

await reportsPage.openReport(reportId);
await reportsPage.editReport();
await commonPage.accessEditOption();
await fillPregnancyDangerSignFollowUpForm('No', 'Yes');
await dangerSignPage.selectAllDangerSignsPregnancy();
await genericForm.submitForm();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Submit Photo Upload form', () => {
expect(attachmentNames[0]).to.match(/^user-file-photo-for-upload-form-\d\d?_\d\d?_\d\d?\.png$/);

await reportsPage.openReport(reportId);
await reportsPage.editReport();
await commonPage.accessEditOption();
await (enketoWidgetsPage.imagePreview('photo-upload')).waitForDisplayed();
await genericForm.submitForm();

Expand All @@ -50,7 +50,7 @@ describe('Submit Photo Upload form', () => {
expect(attachmentNames[0]).to.match(/^user-file-photo-for-upload-form-\d\d?_\d\d?_\d\d?\.png$/);

await reportsPage.openReport(reportId);
await reportsPage.editReport();
await commonPage.accessEditOption();
await (enketoWidgetsPage.imagePreview('photo-upload')).waitForDisplayed();
await enketoWidgetsPage.selectImage('photo-upload', path.join(__dirname, '../../../../webapp/src/img/layers.png'));
await (enketoWidgetsPage.imagePreview('photo-upload')).waitForDisplayed();
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/default/enketo/submit-z-score-form.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('Submit Z-Score form', () => {
const reportId = await reportsPage.getCurrentReportId();
const initialReport = await utils.getDoc(reportId);

await reportsPage.editReport();
await commonPage.accessEditOption();
await genericForm.submitForm();

const updatedReport = await utils.getDoc(reportId);
Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/default/login/login-logout.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ describe('Login page funcionality tests', () => {

it('should log in using username and password fields', async () => {
await loginPage.login(auth);
await (await commonPage.analyticsTab()).waitForDisplayed();
await (await commonPage.messagesTab()).waitForDisplayed();
await (await commonPage.tabsSelector.analyticsTab()).waitForDisplayed();
await (await commonPage.tabsSelector.messagesTab()).waitForDisplayed();
});

it('should set correct cookies', async () => {
await loginPage.login(auth);
await (await commonPage.analyticsTab()).waitForDisplayed();
await (await commonPage.tabsSelector.analyticsTab()).waitForDisplayed();

const cookies = await browser.getCookies();
expect(cookies.length).to.equal(3);
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('Login page funcionality tests', () => {
it('should display the "session expired" modal and redirect to login page', async () => {
// Login and ensure it's redirected to webapp
await loginPage.login(auth);
await (await commonPage.messagesTab()).waitForDisplayed();
await (await commonPage.tabsSelector.messagesTab()).waitForDisplayed();
// Delete cookies and trigger a request to the server
await browser.deleteCookies('AuthSession');
await commonPage.goToReports();
Expand Down Expand Up @@ -163,7 +163,7 @@ describe('Login page funcionality tests', () => {
expect(revealedPassword.value).to.equal('pass-456');

await loginPage.login(auth);
await (await commonPage.messagesTab()).waitForDisplayed();
await (await commonPage.tabsSelector.messagesTab()).waitForDisplayed();
});
});
});
Loading

0 comments on commit e7e7571

Please sign in to comment.