Skip to content

Commit a7e8d98

Browse files
committed
test(e2e): update fixtures used throughout checkout process
1 parent 32409d8 commit a7e8d98

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

e2e/fixtures/account/orders-page.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { Locator, Page } from "@playwright/test"
22
import { AccountPage } from "./account-page"
33

44
export class OrdersPage extends AccountPage {
5+
ordersWrapper: Locator
56
noOrdersContainer: Locator
67
continueShoppingButton: Locator
78
orderCard: Locator
89
orderDisplayId: Locator
910

1011
constructor(page: Page) {
1112
super(page)
13+
this.ordersWrapper = page.getByTestId("orders-page-wrapper")
1214
this.noOrdersContainer = page.getByTestId("no-orders-container")
1315
this.continueShoppingButton = page.getByTestId("continue-shopping-button")
1416
this.orderCard = page.getByTestId("order-card")
@@ -38,4 +40,10 @@ export class OrdersPage extends AccountPage {
3840
items,
3941
}
4042
}
43+
44+
async goto() {
45+
await super.goto()
46+
await this.ordersLink.click()
47+
await this.ordersWrapper.waitFor({ state: "visible" })
48+
}
4149
}

e2e/fixtures/checkout-page.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class CheckoutPage extends BasePage {
1313
shippingAddressOptions: Locator
1414
shippingAddressOption: Locator
1515

16+
billingAddressCheckbox: Locator
1617
billingAddressInput: Locator
1718
billingCityInput: Locator
1819
billingCompanyInput: Locator
@@ -24,6 +25,7 @@ export class CheckoutPage extends BasePage {
2425
shippingAddressInput: Locator
2526
shippingCityInput: Locator
2627
shippingCompanyInput: Locator
28+
shippingEmailInput: Locator
2729
shippingFirstNameInput: Locator
2830
shippingLastNameInput: Locator
2931
shippingPhoneInput: Locator
@@ -67,6 +69,7 @@ export class CheckoutPage extends BasePage {
6769
cartGiftCardAmount: Locator
6870
cartShipping: Locator
6971
cartTaxes: Locator
72+
cartTotal: Locator
7073
itemsTable: Locator
7174
itemRow: Locator
7275
itemTitle: Locator
@@ -96,6 +99,9 @@ export class CheckoutPage extends BasePage {
9699
this.shippingAddressOption = this.container.getByTestId(
97100
"shipping-address-option"
98101
)
102+
this.billingAddressCheckbox = this.container.getByTestId(
103+
"billing-address-checkbox"
104+
)
99105
this.billingAddressInput = this.container.getByTestId(
100106
"billing-address-input"
101107
)
@@ -118,7 +124,10 @@ export class CheckoutPage extends BasePage {
118124
"shipping-address-input"
119125
)
120126
this.shippingCityInput = this.container.getByTestId("shipping-city-input")
121-
this.shippingCompanyInput = this.container.getByTestId("shipping-company-input")
127+
this.shippingCompanyInput = this.container.getByTestId(
128+
"shipping-company-input"
129+
)
130+
this.shippingEmailInput = this.container.getByTestId("shipping-email-input")
122131
this.shippingFirstNameInput = this.container.getByTestId(
123132
"shipping-first-name-input"
124133
)
@@ -158,7 +167,7 @@ export class CheckoutPage extends BasePage {
158167
)
159168

160169
this.deliveryOptionRadio = this.container.getByTestId(
161-
"deliver-option-radio"
170+
"delivery-option-radio"
162171
)
163172
this.deliveryOptionErrorMessage = this.container.getByTestId(
164173
"delivery-option-error-message"
@@ -214,6 +223,7 @@ export class CheckoutPage extends BasePage {
214223
)
215224
this.cartShipping = this.container.getByTestId("cart-shipping")
216225
this.cartTaxes = this.container.getByTestId("cart-taxes")
226+
this.cartTotal = this.container.getByTestId("cart-total")
217227
this.itemsTable = this.container.getByTestId("items-table")
218228
this.itemRow = this.container.getByTestId("item-row")
219229
this.itemTitle = this.container.getByTestId("item-title")
@@ -241,7 +251,7 @@ export class CheckoutPage extends BasePage {
241251
(opts) => {
242252
const select = opts[0]
243253
const choice = opts[1]
244-
return (select.textContent||"").includes(choice)
254+
return (select.textContent || "").includes(choice)
245255
},
246256
[selectHandle, address] as [ElementHandle, string]
247257
)

e2e/fixtures/order-page.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,16 @@ export class OrderPage extends BasePage {
6161
async getProduct(title: string, variant: string) {
6262
const productRow = this.productRow
6363
.filter({
64-
has: this.productTitle.filter({ hasText: title }),
64+
hasText: title,
6565
})
6666
.filter({
67-
has: this.productVariant.filter({ hasText: variant }),
67+
hasText: `Variant: ${variant}`,
6868
})
6969
return {
7070
productRow,
71-
title: productRow.getByTestId("product-title"),
71+
name: productRow.getByTestId("product-name"),
7272
variant: productRow.getByTestId("product-variant"),
73-
deleteButton: productRow.getByTestId("delete-button"),
74-
quantitySelect: productRow.getByTestId("quantity-select"),
73+
quantity: productRow.getByTestId("product-quantity"),
7574
price: productRow.getByTestId("product-unit-price"),
7675
total: productRow.getByTestId("product-price"),
7776
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default async function Orders() {
1717
}
1818

1919
return (
20-
<div className="w-full">
20+
<div className="w-full" data-testid="orders-page-wrapper">
2121
<div className="mb-8 flex flex-col gap-y-4">
2222
<h1 className="text-2xl-semi">Orders</h1>
2323
<p className="text-base-regular">

src/modules/checkout/components/shipping-address/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const ShippingAddress = ({
175175
value={formData.email}
176176
onChange={handleChange}
177177
required
178-
dat-testid="shipping-email-input"
178+
data-testid="shipping-email-input"
179179
/>
180180
<Input
181181
label="Phone"

src/modules/common/components/checkbox/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ type CheckboxProps = {
66
onChange?: () => void
77
label: string
88
name?: string
9+
'data-testid'?: string
910
}
1011

1112
const CheckboxWithLabel: React.FC<CheckboxProps> = ({
1213
checked = true,
1314
onChange,
1415
label,
1516
name,
17+
'data-testid': dataTestId
1618
}) => {
1719
return (
1820
<div className="flex items-center space-x-2 ">
@@ -25,6 +27,7 @@ const CheckboxWithLabel: React.FC<CheckboxProps> = ({
2527
aria-checked={checked}
2628
onClick={onChange}
2729
name={name}
30+
data-testid={dataTestId}
2831
/>
2932
<Label
3033
htmlFor="checkbox"

0 commit comments

Comments
 (0)