-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from Progi1984/@pages/FO/hummingbird/myAccount
Migrate `@pages/FO/{classic|hummingbird}/myAccount` from Core
- Loading branch information
Showing
6 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
173
src/versions/develop/pages/FO/classic/myAccount/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
src/versions/develop/pages/FO/hummingbird/myAccount/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |