From c70ae474205d4afbcabdb8f686e1ed860f36652d Mon Sep 17 00:00:00 2001 From: vanpham-sw Date: Mon, 16 Dec 2024 14:00:40 +0700 Subject: [PATCH] feat: add account recover page (#235) --- src/page-objects/StorefrontPages.ts | 7 +++++ src/page-objects/storefront/AccountLogin.ts | 2 ++ src/page-objects/storefront/AccountRecover.ts | 27 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/page-objects/storefront/AccountRecover.ts diff --git a/src/page-objects/StorefrontPages.ts b/src/page-objects/StorefrontPages.ts index 33e21fa..f877f5c 100644 --- a/src/page-objects/StorefrontPages.ts +++ b/src/page-objects/StorefrontPages.ts @@ -11,6 +11,7 @@ import { CheckoutFinish } from './storefront/CheckoutFinish'; import { CheckoutRegister } from './storefront/CheckoutRegister'; import { Account } from './storefront/Account'; import { AccountLogin } from './storefront/AccountLogin'; +import { AccountRecover } from './storefront/AccountRecover'; import { AccountProfile } from './storefront/AccountProfile'; import { AccountOrder } from './storefront/AccountOrder'; import { AccountAddresses } from './storefront/AccountAddresses'; @@ -31,6 +32,7 @@ export interface StorefrontPageTypes { StorefrontCheckoutRegister: CheckoutRegister; StorefrontAccount: Account; StorefrontAccountLogin: AccountLogin; + StorefrontAccountRecover: AccountRecover; StorefrontAccountProfile: AccountProfile; StorefrontAccountOrder: AccountOrder; StorefrontAccountAddresses: AccountAddresses; @@ -52,6 +54,7 @@ export const StorefrontPageObjects = { CheckoutRegister, Account, AccountLogin, + AccountRecover, AccountProfile, AccountOrder, AccountAddresses, @@ -104,6 +107,10 @@ export const test = base.extend({ await use(new AccountLogin(StorefrontPage)); }, + StorefrontAccountRecover: async ({ StorefrontPage }, use) => { + await use(new AccountRecover(StorefrontPage)); + }, + StorefrontAccountProfile: async ({ StorefrontPage }, use) => { await use(new AccountProfile(StorefrontPage)); }, diff --git a/src/page-objects/storefront/AccountLogin.ts b/src/page-objects/storefront/AccountLogin.ts index 3e79db3..fabfaad 100644 --- a/src/page-objects/storefront/AccountLogin.ts +++ b/src/page-objects/storefront/AccountLogin.ts @@ -4,6 +4,7 @@ import type { PageObject } from '../../types/PageObject'; export class AccountLogin implements PageObject { public readonly emailInput: Locator; public readonly passwordInput: Locator; + public readonly forgotPasswordLink: Locator; public readonly loginButton: Locator; public readonly logoutLink: Locator; public readonly successAlert: Locator; @@ -30,6 +31,7 @@ export class AccountLogin implements PageObject { this.emailInput = page.getByLabel('Your email address'); this.passwordInput = page.getByLabel('Your password'); this.loginButton = page.getByRole('button', { name: 'Log in' }); + this.forgotPasswordLink = page.getByRole('link', { name: 'I have forgotten my password.' }); this.logoutLink = page.getByRole('link', { name: 'Log out'}); this.personalFormArea = page.locator('.register-personal'); diff --git a/src/page-objects/storefront/AccountRecover.ts b/src/page-objects/storefront/AccountRecover.ts new file mode 100644 index 0000000..69f1e73 --- /dev/null +++ b/src/page-objects/storefront/AccountRecover.ts @@ -0,0 +1,27 @@ +import type { Page, Locator } from '@playwright/test'; +import type { PageObject } from '../../types/PageObject'; + +export class AccountRecover implements PageObject { + public readonly passwordRecoveryForm: Locator; + public readonly title: Locator; + public readonly subtitle: Locator; + public readonly emailInput: Locator; + public readonly requestEmailButton: Locator; + public readonly backButton: Locator; + public readonly passwordResetEmailSentMessage: Locator; + + constructor(public readonly page: Page) { + this.passwordRecoveryForm = page.locator('.account-recover-password-form'); + const cardTitle = this.passwordRecoveryForm.locator('.card-title'); + this.title = cardTitle.getByText('Password recovery'); + this.subtitle = cardTitle.getByText('We will send you a confirmation email. Click the link in that email in order to change your password.'); + this.emailInput = this.passwordRecoveryForm.getByLabel('Your email address'); + this.requestEmailButton = this.passwordRecoveryForm.getByRole('button', { name: 'Request email' }); + this.backButton = this.passwordRecoveryForm.getByRole('link', { name: 'Back' }); + this.passwordResetEmailSentMessage = page.getByText('If the provided email address is registered, a confirmation email including a password reset link has been sent.'); + } + + url() { + return 'account/recover'; + } +}