Skip to content

Commit 7961ee7

Browse files
authored
Merge pull request #296 from QAComet/qacomet/logout-test
Added a logout test, improved some locators
2 parents 279c0f1 + a3263aa commit 7961ee7

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
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/base/nav-menu.ts

Lines changed: 7 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")
@@ -45,4 +47,9 @@ export class NavMenu {
4547
})
4648
await countryLink.click()
4749
}
50+
51+
async open() {
52+
await this.navMenuButton.click()
53+
await this.navMenu.waitFor({ state: "visible" })
54+
}
4855
}

e2e/tests/public/login.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,24 @@ test.describe("Login Page functionality", async () => {
4747
await loginPage.signInButton.click()
4848
await expect(accountOverviewPage.welcomeMessage).toBeVisible()
4949
})
50+
51+
test("logging out works correctly", async ({
52+
page,
53+
accountOverviewPage,
54+
loginPage,
55+
}) => {
56+
await loginPage.accountLink.click()
57+
await loginPage.container.waitFor({ state: "visible" })
58+
await loginPage.emailInput.fill("[email protected]")
59+
await loginPage.passwordInput.fill("password")
60+
await loginPage.signInButton.click()
61+
await expect(accountOverviewPage.welcomeMessage).toBeVisible()
62+
63+
await accountOverviewPage.logoutLink.highlight()
64+
await accountOverviewPage.logoutLink.click()
65+
await loginPage.container.waitFor({ state: "visible" })
66+
67+
await loginPage.accountLink.click()
68+
await loginPage.container.waitFor({ state: "visible" })
69+
})
5070
})

src/app/[countryCode]/(main)/account/@dashboard/profile/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default async function Profile() {
2323
}
2424

2525
return (
26-
<div className="w-full">
26+
<div className="w-full" data-testid="profile-page-wrapper">
2727
<div className="mb-8 flex flex-col gap-y-4">
2828
<h1 className="text-2xl-semi">Profile</h1>
2929
<p className="text-base-regular">
@@ -32,7 +32,7 @@ export default async function Profile() {
3232
your password.
3333
</p>
3434
</div>
35-
<div className="flex flex-col gap-y-8 w-full" data-testid="profile-wrapper">
35+
<div className="flex flex-col gap-y-8 w-full">
3636
<ProfileName customer={customer} />
3737
<Divider />
3838
<ProfileEmail customer={customer} />

0 commit comments

Comments
 (0)