Skip to content

Commit 7e27779

Browse files
committed
fix(e2e): Update data-testid locators to correct spots, add additional data-testid locators
1 parent 1751908 commit 7e27779

File tree

10 files changed

+19
-23
lines changed

10 files changed

+19
-23
lines changed

e2e/fixtures/base/nav-menu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class NavMenu {
2323
this.storeLink = this.navMenu.getByTestId("store-link")
2424
this.searchLink = this.navMenu.getByTestId("search-link")
2525
this.accountLink = this.navMenu.getByTestId("account-link")
26-
this.cartLink = this.navMenu.getByTestId("cart-link")
26+
this.cartLink = this.navMenu.getByTestId("nav-cart-link")
2727
this.closeButton = this.navMenu.getByTestId("close-menu-button")
2828
this.shippingToLink = this.navMenu.getByTestId("shipping-to-button")
2929
this.shippingToMenu = this.navMenu.getByTestId("shipping-to-choices")

e2e/fixtures/category-page.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export class CategoryPage extends BasePage {
55
container: Locator
66
sortByContainer: Locator
77

8+
pageTitle: Locator
89
pagination: Locator
910
productsListLoader: Locator
1011
productsList: Locator
@@ -13,6 +14,7 @@ export class CategoryPage extends BasePage {
1314
constructor(page: Page) {
1415
super(page)
1516
this.container = page.getByTestId("category-container")
17+
this.pageTitle = page.getByTestId("category-page-title")
1618
this.sortByContainer = page.getByTestId("sort-by-container")
1719
this.productsListLoader = this.container.getByTestId("products-list-loader")
1820
this.productsList = this.container.getByTestId("products-list")
@@ -21,14 +23,9 @@ export class CategoryPage extends BasePage {
2123
}
2224

2325
async getProduct(name: string) {
24-
const productTitle = await this.container
25-
.getByTestId("product-title")
26-
.filter({
27-
hasText: name,
28-
})
29-
const product = this.productWrapper.filter({ has: productTitle })
26+
const product = this.productWrapper.filter({ hasText: name })
3027
return {
31-
product,
28+
locator: product,
3229
title: product.getByTestId("product-title"),
3330
price: product.getByTestId("price"),
3431
originalPrice: product.getByTestId("original-price"),

e2e/fixtures/checkout-page.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export class CheckoutPage extends BasePage {
2121
billingPhoneInput: Locator
2222
billingPostalInput: Locator
2323
billingProvinceInput: Locator
24-
shippingAddress2Input: Locator
2524
shippingAddressInput: Locator
2625
shippingCityInput: Locator
26+
shippingCompanyInput: Locator
2727
shippingFirstNameInput: Locator
2828
shippingLastNameInput: Locator
2929
shippingPhoneInput: Locator
@@ -114,13 +114,11 @@ export class CheckoutPage extends BasePage {
114114
this.billingProvinceInput = this.container.getByTestId(
115115
"billing-province-input"
116116
)
117-
this.shippingAddress2Input = this.container.getByTestId(
118-
"shipping-address-2-input"
119-
)
120117
this.shippingAddressInput = this.container.getByTestId(
121118
"shipping-address-input"
122119
)
123120
this.shippingCityInput = this.container.getByTestId("shipping-city-input")
121+
this.shippingCompanyInput = this.container.getByTestId("shipping-company-input")
124122
this.shippingFirstNameInput = this.container.getByTestId(
125123
"shipping-first-name-input"
126124
)
@@ -237,15 +235,15 @@ export class CheckoutPage extends BasePage {
237235
hasText: address,
238236
})
239237
await addressOption.getByTestId("shipping-address-radio").click()
240-
const addressText = (await addressOption.getAttribute("value")) || ""
238+
241239
const selectHandle = await this.shippingAddressSelect.elementHandle()
242240
await this.page.waitForFunction(
243241
(opts) => {
244242
const select = opts[0]
245243
const choice = opts[1]
246-
return select.textContent === choice
244+
return (select.textContent||"").includes(choice)
247245
},
248-
[selectHandle, addressText] as [ElementHandle, string]
246+
[selectHandle, address] as [ElementHandle, string]
249247
)
250248
}
251249

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default async function Addresses() {
2323
}
2424

2525
return (
26-
<div className="w-full">
26+
<div className="w-full" data-testid="addresses-page-wrapper">
2727
<div className="mb-8 flex flex-col gap-y-4">
2828
<h1 className="text-2xl-semi">Shipping Addresses</h1>
2929
<p className="text-base-regular">

src/modules/account/components/address-card/add-address.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const AddAddress = ({ region }: { region: Region }) => {
120120
name="country_code"
121121
required
122122
autoComplete="country"
123+
data-testid="country-select"
123124
/>
124125
<Input label="Phone" name="phone" autoComplete="phone" data-testid="phone-input" />
125126
</div>

src/modules/categories/templates/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default function CategoryTemplate({
4545
/
4646
</span>
4747
))}
48-
<h1>{category.name}</h1>
48+
<h1 data-testid="category-page-title">{category.name}</h1>
4949
</div>
5050
{category.description && (
5151
<div className="mb-8 text-base-regular">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ const AddressSelect = ({ addresses, cart }: AddressSelectProps) => {
6565
>
6666
<Listbox.Options
6767
className="absolute z-20 w-full overflow-auto text-small-regular bg-white border border-top-0 max-h-60 focus:outline-none sm:text-sm"
68-
data-testid="shipping-options">
68+
data-testid="shipping-address-options">
6969
{addresses.map((address) => {
7070
return (
7171
<Listbox.Option
7272
key={address.id}
7373
value={address.id}
7474
className="cursor-default select-none relative pl-6 pr-10 hover:bg-gray-50 py-4"
75-
data-testid="shipping-option"
75+
data-testid="shipping-address-option"
7676
>
7777
<div className="flex gap-x-4 items-start">
7878
<Radio checked={selectedAddress?.id === address.id} data-testid="shipping-address-radio" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ const ShippingAddress = ({
118118
value={formData["shipping_address.company"]}
119119
onChange={handleChange}
120120
autoComplete="organization"
121-
data-testid="shipping-address-2-input"
121+
data-testid="shipping-company-input"
122122
/>
123123
<Input
124124
label="Postal code"

src/modules/layout/components/cart-dropdown/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const CartDropdown = ({
8181
<LocalizedClientLink
8282
className="hover:text-ui-fg-base"
8383
href="/cart"
84-
data-testid="cart-link"
84+
data-testid="nav-cart-link"
8585
>{`Cart (${totalItems})`}</LocalizedClientLink>
8686
</Popover.Button>
8787
<Transition

src/modules/store/templates/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ const StoreTemplate = ({
1818
const pageNumber = page ? parseInt(page) : 1
1919

2020
return (
21-
<div className="flex flex-col small:flex-row small:items-start py-6 content-container">
21+
<div className="flex flex-col small:flex-row small:items-start py-6 content-container" data-testid="category-container">
2222
<RefinementList sortBy={sortBy || "created_at"} />
2323
<div className="w-full">
2424
<div className="mb-8 text-2xl-semi">
25-
<h1>All products</h1>
25+
<h1 data-testid="store-page-title">All products</h1>
2626
</div>
2727
<Suspense fallback={<SkeletonProductGrid />}>
2828
<PaginatedProducts

0 commit comments

Comments
 (0)