From 83779162b243d71a107826ea58009e765d537c1b Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Tue, 19 Mar 2024 17:22:36 +0100 Subject: [PATCH] 1.7.8.x : BO : Close Onboarding Welcome popup --- src/pages/BO/login/index.ts | 10 ++-- src/versions/1.7.8/pages/BO/login/index.ts | 53 ++++++++++++++++++++ src/versions/develop/pages/BO/login/index.ts | 5 +- 3 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 src/versions/1.7.8/pages/BO/login/index.ts diff --git a/src/pages/BO/login/index.ts b/src/pages/BO/login/index.ts index f08a4ad6..7c398580 100644 --- a/src/pages/BO/login/index.ts +++ b/src/pages/BO/login/index.ts @@ -4,13 +4,13 @@ import semver from 'semver'; const psVersion = testContext.getPSVersion(); -/* eslint-disable global-require */ +/* eslint-disable global-require, @typescript-eslint/no-var-requires */ function requirePage(): LoginPageInterface { - if (semver.gte(psVersion, '0.0.0')) { - return require('@versions/develop/pages/BO/login'); + if (semver.lt(psVersion, '8.0.0')) { + return require('@versions/1.7.8/pages/BO/login'); } - return require('@versions/develop/pages/BO/login'); + return require('@versions/develop/pages/BO/login').loginPage; } -/* eslint-enable global-require */ +/* eslint-enable global-require, @typescript-eslint/no-var-requires */ export default requirePage(); diff --git a/src/versions/1.7.8/pages/BO/login/index.ts b/src/versions/1.7.8/pages/BO/login/index.ts new file mode 100644 index 00000000..5a7a0739 --- /dev/null +++ b/src/versions/1.7.8/pages/BO/login/index.ts @@ -0,0 +1,53 @@ +// Import pages +import type {LoginPageInterface} from '@interfaces/BO/login'; +import {Page} from '@playwright/test'; +import {LoginPage} from '@versions/develop/pages/BO/login'; + +/** + * Order confirmation page, contains functions that can be used on the page + * @class + * @extends OrderConfirmationPage + */ +class Login extends LoginPage implements LoginPageInterface { + private readonly onboardingCloseButton: string; + + private readonly onboardingStopButton: string; + + /** + * @constructs + * Setting up texts and selectors to use on order confirmation page + */ + constructor() { + super(); + + // welcome module + this.onboardingCloseButton = 'button.onboarding-button-shut-down'; + this.onboardingStopButton = 'a.onboarding-button-stop'; + } + + /** + * Fill login form and success login + * @param page {Page} Browser tab + * @param email {string} String of employee email + * @param password {string} String of employee password + * @returns {Promise} + */ + async successLogin(page: Page, email: string, password: string): Promise { + await super.successLogin(page, email, password); + + // closeOnboardingModal + if (await this.elementVisible(page, this.onboardingCloseButton, 3000)) { + // Close popup + await page.locator(this.onboardingCloseButton).click(); + await this.waitForHiddenSelector(page, this.onboardingCloseButton); + + // Close menu block + if (await this.elementVisible(page, this.onboardingStopButton, 3000)) { + await page.locator(this.onboardingStopButton).click(); + await this.waitForHiddenSelector(page, this.onboardingStopButton); + } + } + } +} + +module.exports = new Login(); diff --git a/src/versions/develop/pages/BO/login/index.ts b/src/versions/develop/pages/BO/login/index.ts index deb67dce..bc2cab65 100644 --- a/src/versions/develop/pages/BO/login/index.ts +++ b/src/versions/develop/pages/BO/login/index.ts @@ -9,7 +9,7 @@ import type {Page} from 'playwright'; * @class * @extends BOBasePage */ -class Login extends BOBasePage implements LoginPageInterface { +class LoginPage extends BOBasePage implements LoginPageInterface { public readonly pageTitle: string; public readonly loginErrorText: string; @@ -184,4 +184,5 @@ class Login extends BOBasePage implements LoginPageInterface { } } -module.exports = new Login(); +const loginPage = new LoginPage(); +export {loginPage, LoginPage};