Skip to content

Commit 1df8fc5

Browse files
authored
Merge pull request #304 from QAComet/qacomet/checkout-tests
Checkout tests
2 parents fc8676c + f7b5539 commit 1df8fc5

File tree

7 files changed

+612
-10
lines changed

7 files changed

+612
-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
}

0 commit comments

Comments
 (0)