Skip to content

Commit

Permalink
create menu toggle and screenshot function and make contactsButton se…
Browse files Browse the repository at this point in the history
…lector private
  • Loading branch information
Maria Lorena Rodriguez Viruel committed Nov 19, 2024
1 parent 6381967 commit d6bf6f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
15 changes: 3 additions & 12 deletions tests/e2e/visual/contacts/list-view-login-visual.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 14 additions & 2 deletions tests/page-objects/default/common/common.wdio.page.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -515,7 +527,7 @@ module.exports = {
sync,
syncAndNotWaitForSuccess,
syncButton,
contactsButton,
toggleMenuAndCaptureScreenshot,
closeReloadModal,
goToMessages,
goToTasks,
Expand Down

0 comments on commit d6bf6f1

Please sign in to comment.