From 5a6197b09093f299bc973181975aeb3296ccb81f Mon Sep 17 00:00:00 2001 From: Aniekan Eshiet Date: Thu, 22 Aug 2024 20:54:32 +0100 Subject: [PATCH] chore: add new e2e test for old navigation on mobile --- .../old-navigation.wdio-spec.js | 50 ++++++++----------- .../default/common/common.wdio.page.js | 7 ++- .../default/sms/messages.wdio.page.js | 17 +++++++ .../default/tasks/tasks.wdio.page.js | 9 ++++ 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/tests/e2e/default-mobile/old-navigation/old-navigation.wdio-spec.js b/tests/e2e/default-mobile/old-navigation/old-navigation.wdio-spec.js index 74586a81338..f01dd60fab7 100644 --- a/tests/e2e/default-mobile/old-navigation/old-navigation.wdio-spec.js +++ b/tests/e2e/default-mobile/old-navigation/old-navigation.wdio-spec.js @@ -4,14 +4,12 @@ const userFactory = require('@factories/cht/users/users'); const personFactory = require('@factories/cht/contacts/person'); 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 taskPage = require('@page-objects/default/tasks/tasks.wdio.page'); -// const genericForm = require('@page-objects/default/enketo/generic-form.wdio.page'); -// const reportsPage = require('@page-objects/default/reports/reports.wdio.page'); -// const contactPage = require('@page-objects/default/contacts/contacts.wdio.page'); -// const targetAggregatesPage = require('@page-objects/default/targets/target-aggregates.wdio.page'); -// const { waitForPageLoaded } = require('@page-objects/default/common/common.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 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'); +const targetAggregatesPage = require('@page-objects/default/targets/target-aggregates.wdio.page'); describe('Old Navigation', () => { const places = placeFactory.generateHierarchy(); @@ -52,58 +50,52 @@ describe('Old Navigation', () => { }); it('should navigate to the Messages section and open a sent message', async () => { - await browser.pause(100); - /* const message = 'Navigations test'; + const message = 'Navigations test'; await oldNavigationPage.goToMessages(); - await messagesPage.sendMessage(message, person.name, person.phone ); + await messagesPage.sendMessageOnMobile(message, person.name, person.phone ); await messagesPage.openMessage(person._id); - const { name, phone } = await messagesPage.getMessageHeader(); + const { name } = await messagesPage.getMessageHeaderOnMobile(); expect(name).to.equal(person.name); - expect(phone).to.equal(person.phone); const messages = await messagesPage.getAmountOfMessagesByPhone(); const { content, state } = await messagesPage.getMessageContent(messages); expect(content).to.equal(message); - expect(state).to.equal('pending'); */ + expect(state).to.equal('pending'); }); it('should navigate to the Task section and open the first task listed', async () => { - await browser.pause(100); - /* await oldNavigationPage.goToTasks(); + await oldNavigationPage.goToTasks(); await taskPage.openTaskById( pregnancyReport._id, '~pregnancy-danger-sign-follow-up~anc.pregnancy_danger_sign_followup' ); - expect(await genericForm.getFormTitle()).to.equal('Pregnancy danger sign follow-up'); */ + const { name } = await taskPage.getTaskHeaderOnMobile(); + expect(name).to.equal('Pregnancy danger sign follow-up'); }); it('should navigate to the Reports section and open the first report listed', async () => { - await browser.pause(100); - /* await oldNavigationPage.goToReports(); + await oldNavigationPage.goToReports(); await reportsPage.openSelectedReport(await reportsPage.firstReport()); - await waitForPageLoaded(); const openReportInfo = await reportsPage.getOpenReportInfo(); expect(openReportInfo.patientName).to.equal(person.name); - expect(openReportInfo.reportName).to.equal('Pregnancy registration'); */ + expect(openReportInfo.reportName).to.equal('Pregnancy registration'); }); it('should navigate to the People section and open the created Health Center', async () => { - await browser.pause(100); - /* await oldNavigationPage.goToPeople(); + await oldNavigationPage.goToPeople(); await contactPage.selectLHSRowByText(healthCenter.name); - expect(await contactPage.getContactInfoName()).to.equal(healthCenter.name); */ + expect(await contactPage.getContactInfoName()).to.equal(healthCenter.name); }); it('should navigate to the Targets section, and open a target aggregate', async () => { - await browser.pause(100); - /* await oldNavigationPage.goToAnalytics(); + await oldNavigationPage.goToAnalytics(); await targetAggregatesPage.goToTargetAggregates(true); - await targetAggregatesPage.openTargetDetails(targetsConfig[0]); */ + await targetAggregatesPage.openTargetDetails(targetsConfig[0]); }); it('should successfully sync', async () => { - await browser.pause(100); - // await oldNavigationPage.sync(); + await oldNavigationPage.goToPeople(); + await oldNavigationPage.sync(); }); }); diff --git a/tests/page-objects/default/common/common.wdio.page.js b/tests/page-objects/default/common/common.wdio.page.js index 387b8cac210..ec7bb1c3126 100644 --- a/tests/page-objects/default/common/common.wdio.page.js +++ b/tests/page-objects/default/common/common.wdio.page.js @@ -40,6 +40,10 @@ const snackbar = () => $('#snackbar.active .snackbar-message'); const snackbarMessage = async () => (await $('#snackbar.active .snackbar-message')).getText(); const snackbarAction = () => $('#snackbar.active .snackbar-action'); +// Mobile +const MOBILE_FILTER_TOP_BAR = '.filters'; +const mobileTopBarTitle = () => $(`${MOBILE_FILTER_TOP_BAR} .ellipsis-title`); + //Hamburguer menu //User settings const USER_SETTINGS = '#header-dropdown a[routerlink="user"] i.fa-user'; @@ -528,5 +532,6 @@ module.exports = { goToUrl, getFastActionItemsLabels, getActionBarLabels, - getErrorLog + getErrorLog, + mobileTopBarTitle }; diff --git a/tests/page-objects/default/sms/messages.wdio.page.js b/tests/page-objects/default/sms/messages.wdio.page.js index bf0f0fbda1b..6100592776d 100644 --- a/tests/page-objects/default/sms/messages.wdio.page.js +++ b/tests/page-objects/default/sms/messages.wdio.page.js @@ -45,6 +45,12 @@ const getMessageHeader = async () => { }; }; +const getMessageHeaderOnMobile = async () => { + return { + name: await commonPage.mobileTopBarTitle().getText(), + }; +}; + const navigateFromConversationToContact = async () => { await $(`${MESSAGE_HEADER} a.name`).waitForClickable(); await $(`${MESSAGE_HEADER} a.name`).click(); @@ -78,6 +84,15 @@ const sendMessage = async (message, recipient, entryText) => { await modalPage.checkModalHasClosed(); }; +const sendMessageOnMobile = async (message, recipient, entryText) => { + await commonPage.clickFastActionFAB({ waitForList: false }); + await (await sendMessageModal()).waitForDisplayed(); + await searchSelect(recipient, entryText); + await (await messageText()).setValue(message); + await modalPage.submit(); + await modalPage.checkModalHasClosed(); +}; + const sendReplyNewRecipient = async (recipient, entryText) => { await searchSelect(recipient, entryText); await modalPage.submit(); @@ -138,6 +153,7 @@ module.exports = { getMessageHeader, getMessageContent, sendMessage, + sendMessageOnMobile, sendReplyNewRecipient, sendMessageToContact, exportMessages, @@ -148,4 +164,5 @@ module.exports = { getAmountOfMessagesByPhone, navigateFromConversationToContact, getMessagesModalDetails, + getMessageHeaderOnMobile }; diff --git a/tests/page-objects/default/tasks/tasks.wdio.page.js b/tests/page-objects/default/tasks/tasks.wdio.page.js index ae095a90cb8..43f53410316 100644 --- a/tests/page-objects/default/tasks/tasks.wdio.page.js +++ b/tests/page-objects/default/tasks/tasks.wdio.page.js @@ -1,3 +1,5 @@ +const commonPage = require('../common/common.wdio.page'); + const taskListSelector = '#tasks-list'; const taskFormSelector = '#task-report'; const tasksGroupSelector = '#tasks-group .item-content'; @@ -86,6 +88,12 @@ const openTaskById = async (id, taskType) => { await $(taskFormSelector).waitForDisplayed(); }; +const getTaskHeaderOnMobile = async () => { + return { + name: await commonPage.mobileTopBarTitle().getText(), + }; +}; + module.exports = { tasksList, getTasks, @@ -100,4 +108,5 @@ module.exports = { getTasksInGroup, noSelectedTask, openTaskById, + getTaskHeaderOnMobile };