From d6bf6f1110b41f4eae3c7b8870e00153b912efb3 Mon Sep 17 00:00:00 2001 From: Maria Lorena Rodriguez Viruel Date: Tue, 19 Nov 2024 13:47:43 -0300 Subject: [PATCH] create menu toggle and screenshot function and make contactsButton selector private --- .../contacts/list-view-login-visual.wdio-spec.js | 15 +++------------ .../default/common/common.wdio.page.js | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/e2e/visual/contacts/list-view-login-visual.wdio-spec.js b/tests/e2e/visual/contacts/list-view-login-visual.wdio-spec.js index 58cf84b0a9..9b0d0e1328 100644 --- a/tests/e2e/visual/contacts/list-view-login-visual.wdio-spec.js +++ b/tests/e2e/visual/contacts/list-view-login-visual.wdio-spec.js @@ -70,10 +70,7 @@ describe('Contact List Page', () => { await commonPage.goToMessages(); expect(await commonPage.isContactTabPresent()).to.be.false; await generateScreenshot('contact-page', 'no-tab-visible'); - await commonPage.openHamburgerMenu(); - await (await commonPage.contactsButton()).waitForClickable({ reverse: true }); - await generateScreenshot('contact-page', 'no-menu-option'); - await commonPage.closeHamburgerMenu(); + await commonPage.toggleMenuAndCaptureScreenshot('People', true, 'contact-page', 'no-menu-option'); await commonPage.goToReports(); await searchPage.performSearch('Amanda Allen'); await commonPage.waitForLoaders(); @@ -97,10 +94,7 @@ describe('Contact List Page', () => { await commonPage.goToMessages(); expect(await commonPage.isContactTabPresent()).to.be.false; await generateScreenshot('contact-page', 'no-tab-visible'); - await commonPage.openHamburgerMenu(); - await (await commonPage.contactsButton()).waitForClickable(); - await generateScreenshot('contact-page', 'menu-option-visible'); - await (await commonPage.contactsButton()).click(); + await commonPage.toggleMenuAndCaptureScreenshot('People', false, 'contact-page', 'menu-option-visible'); expect(await commonPage.isPeopleListPresent()).to.be.true; await commonPage.waitForPageLoaded(); await generateScreenshot('contact-page', 'contacts-in-people-list'); @@ -128,10 +122,7 @@ describe('Contact List Page', () => { await commonPage.goToMessages(); expect(await commonPage.isContactTabPresent()).to.be.false; await generateScreenshot('contact-page', 'no-tab-visible-oPerms'); - await commonPage.openHamburgerMenu(); - await (await commonPage.contactsButton()).waitForClickable({ reverse: true }); - await generateScreenshot('contact-page', 'no-menu-option-no-Perms'); - await commonPage.closeHamburgerMenu(); + await commonPage.toggleMenuAndCaptureScreenshot('People', true, 'contact-page', 'no-menu-option-no-Perms'); await commonPage.goToReports(); await searchPage.performSearch('Amanda Allen'); await commonPage.waitForLoaders(); diff --git a/tests/page-objects/default/common/common.wdio.page.js b/tests/page-objects/default/common/common.wdio.page.js index 9dcd91fcdf..38ed6592cd 100644 --- a/tests/page-objects/default/common/common.wdio.page.js +++ b/tests/page-objects/default/common/common.wdio.page.js @@ -1,6 +1,7 @@ const modalPage = require('./modal.wdio.page'); const constants = require('@constants'); const aboutPage = require('@page-objects/default/about/about.wdio.page'); +const { generateScreenshot } = require('@utils/screenshots'); const hamburgerMenu = () => $('aria/Application menu'); const closeSideBarMenu = () => $('.panel-header-close'); @@ -17,7 +18,7 @@ const moreOptionsMenu = () => $('aria/Actions menu'); const hamburgerMenuItemSelector = 'mat-sidenav-content'; const logoutButton = () => $('aria/Log out'); const syncButton = () => $('aria/Sync now'); -const contactsButton = () => $(hamburgerMenuItemSelector).$('//span[text()="People"]'); +const hamburguerMenuItemByOption = (menuOption) => $(hamburgerMenuItemSelector).$(`//span[text()="${menuOption}"]`); const messagesTab = () => $('#messages-tab'); const analyticsTab = () => $('#analytics-tab'); const taskTab = () => $('#tasks-tab'); @@ -65,6 +66,17 @@ const openMoreOptionsMenu = async () => { await (await moreOptionsMenu()).click(); }; +const toggleMenuAndCaptureScreenshot = async (menuOption, reverse, pageName, screenshotName) => { + await openHamburgerMenu(); + await hamburguerMenuItemByOption(menuOption).waitForClickable({ reverse }); + await generateScreenshot(pageName, screenshotName); + if (reverse) { + await closeHamburgerMenu(); + } else { + await hamburguerMenuItemByOption(menuOption).click(); + } +}; + const waitForSnackbarToClose = async () => { if (await (await snackbar()).isExisting()) { await (await snackbar()).waitForDisplayed({ reverse: true }); @@ -515,7 +527,7 @@ module.exports = { sync, syncAndNotWaitForSuccess, syncButton, - contactsButton, + toggleMenuAndCaptureScreenshot, closeReloadModal, goToMessages, goToTasks,