Skip to content

Commit

Permalink
Merge pull request #84 from Progi1984/@pages/FO/hummingbird/myAccount
Browse files Browse the repository at this point in the history
Migrate `@pages/FO/{classic|hummingbird}/myAccount` from Core
  • Loading branch information
nesrineabdmouleh authored Jul 12, 2024
2 parents c33e081 + 4277a58 commit ef7f717
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';

Expand Down
18 changes: 18 additions & 0 deletions src/interfaces/FO/myAccount/index.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
goToAddressesPage(page: Page): Promise<void>;
goToCreditSlipsPage(page: Page): Promise<void>;
goToHistoryAndDetailsPage(page: Page): Promise<void>;
goToInformationPage(page: Page): Promise<void>;
goToMerchandiseReturnsPage(page: Page): Promise<void>;
goToMyGDPRPersonalDataPage(page: Page): Promise<void>;
goToMyWishlistsPage(page: Page): Promise<void>;
goToVouchersPage(page: Page): Promise<void>;
isAddFirstAddressLinkVisible(page: Page): Promise<boolean>;
}
9 changes: 9 additions & 0 deletions src/pages/FO/classic/myAccount/index.ts
Original file line number Diff line number Diff line change
@@ -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();
9 changes: 9 additions & 0 deletions src/pages/FO/hummingbird/myAccount/index.ts
Original file line number Diff line number Diff line change
@@ -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();
173 changes: 173 additions & 0 deletions src/versions/develop/pages/FO/classic/myAccount/index.ts
Original file line number Diff line number Diff line change
@@ -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<string>}
*/
async getSuccessMessageAlert(page: Page): Promise<string> {
return this.getTextContent(page, this.successMessageAlert);
}

/**
* Go to account information page
* @param page {Page} Browser tab
* @return {Promise<void>}
*/
async goToInformationPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.accountInformationLink);
}

/**
* Go to account credit slips page
* @param page {Page} Browser tab
* @return {Promise<void>}
*/
async goToCreditSlipsPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.orderSlipsLink);
}

/**
* Go to order history page
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToHistoryAndDetailsPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.accountHistoryLink);
}

/**
* Is add first address link visible
* @param page {Page} Browser tab
* @returns {Promise<boolean>}
*/
async isAddFirstAddressLinkVisible(page: Page): Promise<boolean> {
return this.elementVisible(page, this.accountFirstAddressLink);
}

/**
* Go to addresses page
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToAddressesPage(page: Page): Promise<void> {
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<void>}
*/
async goToVouchersPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.accountVouchersLink);
}

/**
* Go to merchandise returns page
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToMerchandiseReturnsPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.merchandiseReturnsLink);
}

/**
* Logout from FO
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async logout(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.logoutFooterLink);
}

/**
* Go to my GDPR personal data page
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToMyGDPRPersonalDataPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.psgdprLink);
}

/**
* Go to "My wishlists" page
* @param page {Page} Browser tab
* @returns {Promise<void>}
*/
async goToMyWishlistsPage(page: Page): Promise<void> {
await this.clickAndWaitForURL(page, this.myWishlistsLink, 'networkidle');
await this.elementVisible(page, foClassicMyWishlistsPage.wishlistListItemNthTitle(1), 5000);
}
}

const myAccountPage = new MyAccountPage();
export {myAccountPage, MyAccountPage};
22 changes: 22 additions & 0 deletions src/versions/develop/pages/FO/hummingbird/myAccount/index.ts
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit ef7f717

Please sign in to comment.