From 4277a58cff9d8dd72c8be65e73925c77b72ac3d6 Mon Sep 17 00:00:00 2001 From: Progi1984 Date: Fri, 12 Jul 2024 15:35:41 +0200 Subject: [PATCH] Migrate `@pages/FO/{classic|hummingbird}/myAccount` from Core --- src/index.ts | 2 + src/interfaces/FO/myAccount/index.ts | 18 ++ src/pages/FO/classic/myAccount/index.ts | 9 + src/pages/FO/hummingbird/myAccount/index.ts | 9 + .../pages/FO/classic/myAccount/index.ts | 173 ++++++++++++++++++ .../pages/FO/hummingbird/myAccount/index.ts | 22 +++ 6 files changed, 233 insertions(+) create mode 100644 src/interfaces/FO/myAccount/index.ts create mode 100644 src/pages/FO/classic/myAccount/index.ts create mode 100644 src/pages/FO/hummingbird/myAccount/index.ts create mode 100644 src/versions/develop/pages/FO/classic/myAccount/index.ts create mode 100644 src/versions/develop/pages/FO/hummingbird/myAccount/index.ts diff --git a/src/index.ts b/src/index.ts index 55690ab2..0de1e8a2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -224,6 +224,7 @@ export {default as foClassicLoginPage} from '@pages/FO/classic/login'; export {default as foClassicModalBlockCartPage} from '@pages/FO/classic/modal/blockCart'; export {default as foClassicModalQuickViewPage} from '@pages/FO/classic/modal/quickView'; export {default as foClassicModalWishlistPage} from '@pages/FO/classic/modal/wishlist'; +export {default as foClassicMyAccountPage} from '@pages/FO/classic/myAccount'; export {default as foClassicMyWishlistsPage} from '@pages/FO/classic/myAccount/myWishlists'; export {default as foClassicMyWishlistsViewPage} from '@pages/FO/classic/myAccount/myWishlists/view'; export {default as foClassicProductPage} from '@pages/FO/classic/product'; @@ -233,6 +234,7 @@ export {default as foHummingbirdAboutUsPage} from '@pages/FO/hummingbird/aboutUs export {default as foHummingbirdCategoryPage} from '@pages/FO/hummingbird/category'; export {default as foHummingbirdLoginPage} from '@pages/FO/hummingbird/login'; export {default as foHummingbirdModalQuickViewPage} from '@pages/FO/hummingbird/modal/quickView'; +export {default as foHummingbirdMyAccountPage} from '@pages/FO/hummingbird/myAccount'; export {default as foHummingbirdMyWishlistsPage} from '@pages/FO/hummingbird/myAccount/myWishlists'; export {default as foHummingbirdSearchResultsPage} from '@pages/FO/hummingbird/searchResults'; diff --git a/src/interfaces/FO/myAccount/index.ts b/src/interfaces/FO/myAccount/index.ts new file mode 100644 index 00000000..ccd3d66c --- /dev/null +++ b/src/interfaces/FO/myAccount/index.ts @@ -0,0 +1,18 @@ +import {FOBasePagePageInterface} from '@interfaces/FO'; +import {type Page} from '@playwright/test'; + +export interface FoMyAccountPageInterface extends FOBasePagePageInterface { + readonly pageTitle: string; + readonly resetPasswordSuccessMessage: string; + + getSuccessMessageAlert(page: Page): Promise; + goToAddressesPage(page: Page): Promise; + goToCreditSlipsPage(page: Page): Promise; + goToHistoryAndDetailsPage(page: Page): Promise; + goToInformationPage(page: Page): Promise; + goToMerchandiseReturnsPage(page: Page): Promise; + goToMyGDPRPersonalDataPage(page: Page): Promise; + goToMyWishlistsPage(page: Page): Promise; + goToVouchersPage(page: Page): Promise; + isAddFirstAddressLinkVisible(page: Page): Promise; +} diff --git a/src/pages/FO/classic/myAccount/index.ts b/src/pages/FO/classic/myAccount/index.ts new file mode 100644 index 00000000..bb68dddd --- /dev/null +++ b/src/pages/FO/classic/myAccount/index.ts @@ -0,0 +1,9 @@ +import type {FoMyAccountPageInterface} from '@interfaces/FO/myAccount'; + +/* eslint-disable global-require, @typescript-eslint/no-var-requires */ +function requirePage(): FoMyAccountPageInterface { + return require('@versions/classic/pages/FO/hummingbird/myAccount').myAccountPage; +} +/* eslint-enable global-require, @typescript-eslint/no-var-requires */ + +export default requirePage(); diff --git a/src/pages/FO/hummingbird/myAccount/index.ts b/src/pages/FO/hummingbird/myAccount/index.ts new file mode 100644 index 00000000..967afa0b --- /dev/null +++ b/src/pages/FO/hummingbird/myAccount/index.ts @@ -0,0 +1,9 @@ +import type {FoMyAccountPageInterface} from '@interfaces/FO/myAccount'; + +/* eslint-disable global-require */ +function requirePage(): FoMyAccountPageInterface { + return require('@versions/develop/pages/FO/hummingbird/myAccount'); +} +/* eslint-enable global-require */ + +export default requirePage(); diff --git a/src/versions/develop/pages/FO/classic/myAccount/index.ts b/src/versions/develop/pages/FO/classic/myAccount/index.ts new file mode 100644 index 00000000..44f17dd2 --- /dev/null +++ b/src/versions/develop/pages/FO/classic/myAccount/index.ts @@ -0,0 +1,173 @@ +import {FoMyAccountPageInterface} from '@interfaces/FO/myAccount'; +import FOBasePage from '@pages/FO/FOBasePage'; +import {myWishlistsPage as foClassicMyWishlistsPage} from '@versions/develop/pages/FO/classic/myAccount/myWishlists'; + +import type {Page} from 'playwright'; + +/** + * My account page, contains functions that can be used on the page + * @class + * @extends FOBasePage + */ +class MyAccountPage extends FOBasePage implements FoMyAccountPageInterface { + public readonly pageTitle: string; + + public readonly resetPasswordSuccessMessage: string; + + private readonly accountInformationLink: string; + + private readonly accountHistoryLink: string; + + private readonly accountAddressesLink: string; + + private readonly accountFirstAddressLink: string; + + private readonly accountVouchersLink: string; + + private readonly merchandiseReturnsLink: string; + + protected orderSlipsLink: string; + + private readonly successMessageAlert: string; + + protected logoutFooterLink: string; + + private readonly myWishlistsLink: string; + + private readonly psgdprLink: string; + + /** + * @constructs + * Setting up texts and selectors to use on my account page + */ + constructor(theme: string = 'classic') { + super(theme); + + this.pageTitle = 'My account'; + this.resetPasswordSuccessMessage = 'Your password has been successfully reset and a confirmation has been sent to' + + ' your email address:'; + + // Selectors + this.accountInformationLink = '#identity-link'; + this.accountHistoryLink = '#history-link'; + this.accountAddressesLink = '#addresses-link'; + this.accountFirstAddressLink = '#address-link'; + this.accountVouchersLink = '#discounts-link'; + this.merchandiseReturnsLink = '#returns-link'; + this.orderSlipsLink = '#order-slips-link'; + this.successMessageAlert = '#notifications article.alert-success'; + this.logoutFooterLink = '#main footer a[href*="mylogout"]'; + this.myWishlistsLink = '#wishlist-link'; + this.psgdprLink = '#psgdpr-link'; + } + + /* + Methods + */ + /** + * Get success message + * @param page {Page} Browser tab + * @returns {Promise} + */ + async getSuccessMessageAlert(page: Page): Promise { + return this.getTextContent(page, this.successMessageAlert); + } + + /** + * Go to account information page + * @param page {Page} Browser tab + * @return {Promise} + */ + async goToInformationPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.accountInformationLink); + } + + /** + * Go to account credit slips page + * @param page {Page} Browser tab + * @return {Promise} + */ + async goToCreditSlipsPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.orderSlipsLink); + } + + /** + * Go to order history page + * @param page {Page} Browser tab + * @returns {Promise} + */ + async goToHistoryAndDetailsPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.accountHistoryLink); + } + + /** + * Is add first address link visible + * @param page {Page} Browser tab + * @returns {Promise} + */ + async isAddFirstAddressLinkVisible(page: Page): Promise { + return this.elementVisible(page, this.accountFirstAddressLink); + } + + /** + * Go to addresses page + * @param page {Page} Browser tab + * @returns {Promise} + */ + async goToAddressesPage(page: Page): Promise { + if (await this.elementVisible(page, this.accountFirstAddressLink, 2000)) { + await this.clickAndWaitForURL(page, this.accountFirstAddressLink); + } else { + await this.clickAndWaitForURL(page, this.accountAddressesLink); + } + } + + /** + * Go to vouchers page + * @param page {Page} Browser tab + * @returns {Promise} + */ + async goToVouchersPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.accountVouchersLink); + } + + /** + * Go to merchandise returns page + * @param page {Page} Browser tab + * @returns {Promise} + */ + async goToMerchandiseReturnsPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.merchandiseReturnsLink); + } + + /** + * Logout from FO + * @param page {Page} Browser tab + * @returns {Promise} + */ + async logout(page: Page): Promise { + await this.clickAndWaitForURL(page, this.logoutFooterLink); + } + + /** + * Go to my GDPR personal data page + * @param page {Page} Browser tab + * @returns {Promise} + */ + async goToMyGDPRPersonalDataPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.psgdprLink); + } + + /** + * Go to "My wishlists" page + * @param page {Page} Browser tab + * @returns {Promise} + */ + async goToMyWishlistsPage(page: Page): Promise { + await this.clickAndWaitForURL(page, this.myWishlistsLink, 'networkidle'); + await this.elementVisible(page, foClassicMyWishlistsPage.wishlistListItemNthTitle(1), 5000); + } +} + +const myAccountPage = new MyAccountPage(); +export {myAccountPage, MyAccountPage}; diff --git a/src/versions/develop/pages/FO/hummingbird/myAccount/index.ts b/src/versions/develop/pages/FO/hummingbird/myAccount/index.ts new file mode 100644 index 00000000..8e2289c0 --- /dev/null +++ b/src/versions/develop/pages/FO/hummingbird/myAccount/index.ts @@ -0,0 +1,22 @@ +import {FoMyAccountPageInterface} from '@interfaces/FO/myAccount'; +import {MyAccountPage as MyAccountPageVersion} from '@versions/develop/pages/FO/classic/myAccount/index'; + +/** + * My account page, contains functions that can be used on the page + * @class + * @extends FOBasePage + */ +class MyAccountPage extends MyAccountPageVersion implements FoMyAccountPageInterface { + /** + * @constructs + * Setting up texts and selectors to use on my account page + */ + constructor() { + super('hummingbird'); + + this.orderSlipsLink = '.account-menu #order-slips__link'; + this.logoutFooterLink = '#my-account .account-menu .account-menu--signout'; + } +} + +export default new MyAccountPage();