Skip to content

Commit

Permalink
chore: fix e2e tests post chrome update (#8654)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianabarsan authored and m5r committed Nov 20, 2023
1 parent 274d456 commit d4f3bb7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
8 changes: 3 additions & 5 deletions tests/e2e/default/enketo/unauthorized-form.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ describe('Unauthorized form', () => {
afterEach(async () => await utils.revertSettings(true));

it('should display unauthorized error message in reports tab when form expression does not match', async () => {
await commonPage.goToReports();

await browser.url('#/reports/add/pregnancy');
await browser.url('/#/reports/add/pregnancy');
await commonPage.waitForPageLoaded();

expect(await genericFormPage.getErrorMessage()).to.equal(EXPECTED_UNAUTHORIZED_MESSAGE);
Expand All @@ -50,7 +48,7 @@ describe('Unauthorized form', () => {
await commonPage.goToPeople();
await updateSettings(customPlaceType);

await browser.url(`#/contacts/add/${customPlaceType.id}`);
await commonPage.goToUrl(`#/contacts/add/${customPlaceType.id}`);
await commonPage.waitForPageLoaded();

expect(await genericFormPage.getErrorMessage()).to.equal(EXPECTED_UNAUTHORIZED_MESSAGE);
Expand All @@ -60,7 +58,7 @@ describe('Unauthorized form', () => {
await commonPage.goToPeople();
await updateSettings(customPlaceType, { can_create_clinic: [ 'chw' ] });

await browser.url(`#/contacts/add/${customPlaceType.id}`);
await commonPage.goToUrl(`#/contacts/add/${customPlaceType.id}`);
await commonPage.waitForPageLoaded();

expect(await genericFormPage.getFormTitle()).to.equal('contact.type.unauthorized-contact-form.new');
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/default/sms/gateway.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const pollSmsApi = body => {
describe('sms-gateway api', () => {
before(async () => {
await loginPage.cookieLogin();
await commonElements.waitForPageLoaded();
});

describe('- gateway submits new WT sms messages', () => {
Expand Down
26 changes: 19 additions & 7 deletions tests/page-objects/default/common/common.wdio.page.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const modalPage = require('./modal.wdio.page');
const constants = require('@constants');

const hamburgerMenu = () => $('#header-dropdown-link');
const userSettingsMenuOption = () => $('[test-id="user-settings-menu-option"]');
Expand Down Expand Up @@ -183,47 +184,57 @@ const getLogoutMessage = async () => {
return modal.body;
};

const goToUrl = async (url) => {
const currentUrl = await browser.getUrl();
const desiredUrl = `${constants.BASE_URL}${url}`;
if (currentUrl === desiredUrl) {
await browser.refresh();
} else {
await browser.url(url);
}
};

const refresh = async () => {
await browser.refresh();
await waitForPageLoaded();
};

const goToBase = async () => {
await browser.url('/');
await goToUrl('/');
await waitForPageLoaded();
};

const goToReports = async () => {
await browser.url('/#/reports');
await goToUrl('/#/reports');
await waitForPageLoaded();
};

const goToPeople = async (contactId = '', shouldLoad = true) => {
await browser.url(`/#/contacts/${contactId}`);
await goToUrl(`/#/contacts/${contactId}`);
if (shouldLoad) {
await waitForPageLoaded();
}
};

const goToMessages = async () => {
await browser.url(`/#/messages`);
await goToUrl(`/#/messages`);
await (await messagesTab()).waitForDisplayed();
};

const goToTasks = async () => {
await browser.url(`/#/tasks`);
await goToUrl(`/#/tasks`);
await (await taskTab()).waitForDisplayed();
await waitForPageLoaded();
};

const goToAnalytics = async () => {
await browser.url(`/#/analytics`);
await goToUrl(`/#/analytics`);
await (await analyticsTab()).waitForDisplayed();
await waitForPageLoaded();
};

const goToAboutPage = async () => {
await browser.url(`/#/about`);
await goToUrl(`/#/about`);
await waitForLoaders();
};

Expand Down Expand Up @@ -449,4 +460,5 @@ module.exports = {
closeReportBug,
getAllButtonLabelsNames,
loadNextInfiniteScrollPage,
goToUrl,
};
4 changes: 2 additions & 2 deletions tests/page-objects/default/users/user.wdio.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const failedUploadedUsers = () => $('p.text-danger');
const backToUserListButton = () => $('a#back-to-app-btn');

const goToAdminUser = async () => {
await browser.url('/admin/#/users');
await commonElements.goToUrl('/admin/#/users');
};

const goToAdminUpgrade = async () => {
await browser.url('/admin/#/upgrade');
await commonElements.goToUrl('/admin/#/upgrade');
};

const openAddUserDialog = async () => {
Expand Down

0 comments on commit d4f3bb7

Please sign in to comment.