Skip to content

Commit 7ce66ed

Browse files
committed
test(e2e): write profile page tests
1 parent 279c0f1 commit 7ce66ed

File tree

13 files changed

+344
-12
lines changed

13 files changed

+344
-12
lines changed

e2e/fixtures/account/account-page.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,42 @@ import { BasePage } from "../base/base-page"
44
export class AccountPage extends BasePage {
55
container: Locator
66
accountNav: Locator
7-
mobileAccountNav: Locator
7+
88
overviewLink: Locator
99
profileLink: Locator
1010
addressesLink: Locator
1111
ordersLink: Locator
1212
logoutLink: Locator
1313

14+
mobileAccountNav: Locator
15+
mobileAccountMainLink : Locator
16+
mobileOverviewLink : Locator
17+
mobileProfileLink : Locator
18+
mobileAddressesLink : Locator
19+
mobileOrdersLink : Locator
20+
mobileLogoutLink : Locator
21+
1422
constructor(page: Page) {
1523
super(page)
1624
this.container = page.getByTestId("account-page")
1725
this.accountNav = this.container.getByTestId("account-nav")
26+
this.overviewLink = this.accountNav.getByTestId("overview-link")
27+
this.profileLink = this.accountNav.getByTestId("profile-link")
28+
this.addressesLink = this.accountNav.getByTestId("addresses-link")
29+
this.ordersLink = this.accountNav.getByTestId("orders-link")
30+
this.logoutLink = this.accountNav.getByTestId("logout-button")
31+
1832
this.mobileAccountNav = this.container.getByTestId("mobile-account-nav")
19-
this.overviewLink = this.container.getByTestId("overview-link")
20-
this.profileLink = this.container.getByTestId("profile-link")
21-
this.addressesLink = this.container.getByTestId("addresses-link")
22-
this.ordersLink = this.container.getByTestId("orders-link")
23-
this.logoutLink = this.container.getByTestId("logout-button")
33+
this.mobileAccountMainLink = this.mobileAccountNav.getByTestId("account-main-link")
34+
this.mobileOverviewLink = this.mobileAccountNav.getByTestId("overview-link")
35+
this.mobileProfileLink = this.mobileAccountNav.getByTestId("profile-link")
36+
this.mobileAddressesLink = this.mobileAccountNav.getByTestId("addresses-link")
37+
this.mobileOrdersLink = this.mobileAccountNav.getByTestId("orders-link")
38+
this.mobileLogoutLink = this.mobileAccountNav.getByTestId("logout-button")
39+
}
40+
41+
async goto() {
42+
await this.navMenu.navAccountLink.click()
43+
await this.container.waitFor({ state: "visible" })
2444
}
2545
}

e2e/fixtures/account/overview-page.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ export class OverviewPage extends AccountPage {
99
noOrdersMessage: Locator
1010
ordersWrapper: Locator
1111
orderWrapper: Locator
12+
overviewWrapper: Locator
1213

1314
constructor(page: Page) {
1415
super(page)
15-
this.welcomeMessage = this.container.getByTestId("welcome-message") // getAttribute("name")
16+
this.overviewWrapper = this.container.getByTestId("overview-page-wrapper")
17+
this.welcomeMessage = this.container.getByTestId("welcome-message")
1618
this.customerEmail = this.container.getByTestId("customer-email")
1719
this.profileCompletion = this.container.getByTestId(
1820
"customer-profile-completion"
@@ -36,4 +38,9 @@ export class OverviewPage extends AccountPage {
3638
openButton: order.getByTestId("open-order-button"),
3739
}
3840
}
41+
42+
async goto() {
43+
await this.navMenu.navAccountLink.click()
44+
await this.container.waitFor({ state: "visible" })
45+
}
3946
}

e2e/fixtures/account/profile-page.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AccountPage } from "./account-page"
33
import { camelCase } from "lodash"
44

55
export class ProfilePage extends AccountPage {
6+
profileWrapper: Locator
67
accountNameEditor: Locator
78
accountEmailEditor: Locator
89
accountPhoneEditor: Locator
@@ -21,6 +22,24 @@ export class ProfilePage extends AccountPage {
2122
passwordSaveButton: Locator
2223
billingAddressSaveButton: Locator
2324

25+
savedName: Locator
26+
savedEmail: Locator
27+
savedPhone: Locator
28+
savedPassword: Locator
29+
savedBillingAddress: Locator
30+
31+
nameSuccessMessage: Locator
32+
emailSuccessMessage: Locator
33+
phoneSuccessMessage: Locator
34+
passwordSuccessMessage: Locator
35+
billingAddressSuccessMessage: Locator
36+
37+
nameErrorMessage: Locator
38+
emailErrorMessage: Locator
39+
phoneErrorMessage: Locator
40+
passwordErrorMessage: Locator
41+
billingAddressErrorMessage: Locator
42+
2443
emailInput: Locator
2544
firstNameInput: Locator
2645
lastNameInput: Locator
@@ -43,6 +62,7 @@ export class ProfilePage extends AccountPage {
4362

4463
constructor(page: Page) {
4564
super(page)
65+
this.profileWrapper = page.getByTestId("profile-page-wrapper")
4666
this.accountNameEditor = this.container.getByTestId("account-name-editor")
4767
this.accountEmailEditor = this.container.getByTestId("account-email-editor")
4868
this.accountPhoneEditor = this.container.getByTestId("account-phone-editor")
@@ -69,6 +89,32 @@ export class ProfilePage extends AccountPage {
6989
this.billingAddressSaveButton =
7090
this.accountBillingAddressEditor.getByTestId("save-button")
7191

92+
this.savedName = this.accountNameEditor.getByTestId("current-info")
93+
this.savedEmail = this.accountEmailEditor.getByTestId("current-info")
94+
this.savedPhone = this.accountPhoneEditor.getByTestId("current-info")
95+
this.savedPassword = this.accountPasswordEditor.getByTestId("current-info")
96+
this.savedBillingAddress =
97+
this.accountBillingAddressEditor.getByTestId("current-info")
98+
this.nameSuccessMessage =
99+
this.accountNameEditor.getByTestId("success-message")
100+
this.emailSuccessMessage =
101+
this.accountEmailEditor.getByTestId("success-message")
102+
this.phoneSuccessMessage =
103+
this.accountPhoneEditor.getByTestId("success-message")
104+
this.passwordSuccessMessage =
105+
this.accountPasswordEditor.getByTestId("success-message")
106+
this.billingAddressSuccessMessage =
107+
this.accountBillingAddressEditor.getByTestId("success-message")
108+
this.nameErrorMessage = this.accountNameEditor.getByTestId("error-message")
109+
this.emailErrorMessage =
110+
this.accountEmailEditor.getByTestId("error-message")
111+
this.phoneErrorMessage =
112+
this.accountPhoneEditor.getByTestId("error-message")
113+
this.passwordErrorMessage =
114+
this.accountPasswordEditor.getByTestId("error-message")
115+
this.billingAddressErrorMessage =
116+
this.accountBillingAddressEditor.getByTestId("error-message")
117+
72118
this.firstNameInput = page.getByTestId("first-name-input")
73119
this.lastNameInput = page.getByTestId("last-name-input")
74120
this.emailInput = page.getByTestId("email-input")
@@ -111,4 +157,10 @@ export class ProfilePage extends AccountPage {
111157
}
112158
return o
113159
}
160+
161+
async goto() {
162+
super.goto()
163+
await this.profileLink.click()
164+
await this.profileWrapper.waitFor({ state: "visible" })
165+
}
114166
}

e2e/fixtures/base/nav-menu.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export class NavMenu {
44
page: Page
55
navMenuButton: Locator
66
navMenu: Locator
7+
navAccountLink: Locator
78
homeLink: Locator
89
storeLink: Locator
910
searchLink: Locator
@@ -17,6 +18,7 @@ export class NavMenu {
1718
this.page = page
1819
this.navMenuButton = page.getByTestId("nav-menu-button")
1920
this.navMenu = page.getByTestId("nav-menu-popup")
21+
this.navAccountLink = page.getByTestId("nav-account-link")
2022
this.homeLink = this.navMenu.getByTestId("home-link")
2123
this.storeLink = this.navMenu.getByTestId("store-link")
2224
this.searchLink = this.navMenu.getByTestId("search-link")

0 commit comments

Comments
 (0)