nextjs-starter-medusa
92 строки · 3.3 Кб
1import { Locator, Page } from "@playwright/test"
2import { BasePage } from "./base/base-page"
3
4export class OrderPage extends BasePage {
5container: Locator
6cartSubtotal: Locator
7cartDiscount: Locator
8cartGiftCardAmount: Locator
9cartShipping: Locator
10cartTaxes: Locator
11cartTotal: Locator
12orderEmail: Locator
13orderDate: Locator
14orderId: Locator
15orderStatus: Locator
16orderPaymentStatus: Locator
17shippingAddressSummary: Locator
18shippingContactSummary: Locator
19shippingMethodSummary: Locator
20paymentMethod: Locator
21paymentAmount: Locator
22productsTable: Locator
23productRow: Locator
24productTitle: Locator
25productVariant: Locator
26productQuantity: Locator
27productOriginalPrice: Locator
28productPrice: Locator
29productUnitOriginalPrice: Locator
30productUnitPrice: Locator
31
32constructor(page: Page) {
33super(page)
34this.container = page.getByTestId("order-complete-container")
35this.orderEmail = this.container.getByTestId("order-email")
36this.orderDate = this.container.getByTestId("order-date")
37this.orderId = this.container.getByTestId("order-id")
38this.orderStatus = this.container.getByTestId("order-status")
39this.cartSubtotal = this.container.getByTestId("cart-subtotal")
40this.cartDiscount = this.container.getByTestId("cart-discount")
41this.cartGiftCardAmount = this.container.getByTestId(
42"cart-gift-card-amount"
43)
44this.cartShipping = this.container.getByTestId("cart-shipping")
45this.cartTaxes = this.container.getByTestId("cart-taxes")
46this.cartTotal = this.container.getByTestId("cart-total")
47this.orderPaymentStatus = this.container.getByTestId("order-payment-status")
48this.shippingAddressSummary = this.container.getByTestId(
49"shipping-address-summary"
50)
51this.shippingContactSummary = this.container.getByTestId(
52"shipping-contact-summary"
53)
54this.shippingMethodSummary = this.container.getByTestId(
55"shipping-method-summary"
56)
57this.paymentMethod = this.container.getByTestId("payment-method")
58this.paymentAmount = this.container.getByTestId("payment-amount")
59
60this.productsTable = this.container.getByTestId("products-table")
61this.productRow = this.container.getByTestId("product-row")
62this.productTitle = this.container.getByTestId("product-title")
63this.productVariant = this.container.getByTestId("product-variant")
64this.productQuantity = this.container.getByTestId("product-quantity")
65this.productOriginalPrice = this.container.getByTestId(
66"product-original-price"
67)
68this.productPrice = this.container.getByTestId("product-price")
69this.productUnitOriginalPrice = this.container.getByTestId(
70"product-unit-original-price"
71)
72this.productUnitPrice = this.container.getByTestId("product-unit-price")
73}
74
75async getProduct(title: string, variant: string) {
76const productRow = this.productRow
77.filter({
78hasText: title,
79})
80.filter({
81hasText: `Variant: ${variant}`,
82})
83return {
84productRow,
85name: productRow.getByTestId("product-name"),
86variant: productRow.getByTestId("product-variant"),
87quantity: productRow.getByTestId("product-quantity"),
88price: productRow.getByTestId("product-unit-price"),
89total: productRow.getByTestId("product-price"),
90}
91}
92}
93