nextjs-starter-medusa

Форк
0
582 строки · 26.3 Кб
1
import { test, expect } from "../../index"
2
import { compareFloats, getFloatValue } from "../../utils"
3

4
test.describe("Checkout flow tests", async () => {
5
  test("Default checkout flow", async ({
6
    cartPage,
7
    checkoutPage,
8
    orderPage,
9
    productPage,
10
    storePage,
11
  }) => {
12
    await test.step("Navigate to a product page", async () => {
13
      await storePage.goto()
14
      const product = await storePage.getProduct("Sweatshirt")
15
      await product.locator.highlight()
16
      await product.locator.click()
17
      await productPage.container.waitFor({ state: "visible" })
18
    })
19

20
    await test.step("Add the product to the cart and goto checkout", async () => {
21
      await productPage.selectOption("M")
22
      await productPage.clickAddProduct()
23
      await productPage.cartDropdown.navCartLink.click()
24
      await productPage.cartDropdown.goToCartButton.click()
25
      await cartPage.container.waitFor({ state: "visible" })
26
      await cartPage.checkoutButton.click()
27
      await checkoutPage.container.waitFor({ state: "visible" })
28
    })
29

30
    await test.step("Enter in the first step of the checkout process", async () => {
31
      await test.step("Enter in the shipping address info", async () => {
32
        await checkoutPage.shippingFirstNameInput.fill("First")
33
        await checkoutPage.shippingLastNameInput.fill("Last")
34
        await checkoutPage.shippingCompanyInput.fill("MyCorp")
35
        await checkoutPage.shippingAddressInput.fill("123 Fake street")
36
        await checkoutPage.shippingPostalCodeInput.fill("80010")
37
        await checkoutPage.shippingCityInput.fill("Denver")
38
        await checkoutPage.shippingProvinceInput.fill("Colorado")
39
        await checkoutPage.shippingCountrySelect.selectOption("United States")
40
      })
41

42
      await test.step("Enter in the contact info and open the billing info form", async () => {
43
        await checkoutPage.shippingEmailInput.fill("test@example.com")
44
        await checkoutPage.shippingPhoneInput.fill("3031112222")
45
        await checkoutPage.billingAddressCheckbox.uncheck()
46
      })
47

48
      await test.step("Enter in the billing address info", async () => {
49
        await checkoutPage.billingFirstNameInput.fill("First")
50
        await checkoutPage.billingLastNameInput.fill("Last")
51
        await checkoutPage.billingCompanyInput.fill("MyCorp")
52
        await checkoutPage.billingAddressInput.fill("123 Fake street")
53
        await checkoutPage.billingPostalInput.fill("80010")
54
        await checkoutPage.billingCityInput.fill("Denver")
55
        await checkoutPage.billingProvinceInput.fill("Colorado")
56
        await checkoutPage.billingCountrySelect.selectOption("United States")
57
        await checkoutPage.submitAddressButton.click()
58
      })
59
    })
60

61
    await test.step("Complete the rest of the payment process", async () => {
62
      await checkoutPage.selectDeliveryOption("FakeEx Standard")
63
      await checkoutPage.submitDeliveryOptionButton.click()
64
      await checkoutPage.submitPaymentButton.click()
65
      await checkoutPage.submitOrderButton.click()
66
      await orderPage.container.waitFor({ state: "visible" })
67
    })
68

69
    await test.step("Verify the products ordered are correct", async () => {
70
      const product = await orderPage.getProduct("Sweatshirt", "M")
71
      await expect(product.name).toContainText("Sweatshirt")
72
      await expect(product.variant).toContainText("M")
73
      await expect(product.quantity).toContainText("1")
74
    })
75

76
    await test.step("Verify the shipping info is correct", async () => {
77
      const address = orderPage.shippingAddressSummary
78
      await expect(address).toContainText("First")
79
      await expect(address).toContainText("Last")
80
      await expect(address).toContainText("123 Fake street")
81
      await expect(address).toContainText("80010")
82
      await expect(address).toContainText("Denver")
83
      await expect(address).toContainText("US")
84

85
      const contact = orderPage.shippingContactSummary
86
      await expect(contact).toContainText("test@example.com")
87
      await expect(contact).toContainText("3031112222")
88

89
      const method = orderPage.shippingMethodSummary
90
      await expect(method).toContainText("FakeEx Standard")
91
    })
92
  })
93

94
  test("Editing checkout steps works as expected", async ({
95
    cartPage,
96
    checkoutPage,
97
    productPage,
98
    storePage,
99
  }) => {
100
    await test.step("Navigate to a product page", async () => {
101
      await storePage.goto()
102
      const product = await storePage.getProduct("Sweatshirt")
103
      await product.locator.highlight()
104
      await product.locator.click()
105
      await productPage.container.waitFor({ state: "visible" })
106
    })
107

108
    await test.step("Add the product to the cart and goto checkout", async () => {
109
      await productPage.selectOption("M")
110
      await productPage.clickAddProduct()
111
      await productPage.cartDropdown.navCartLink.click()
112
      await productPage.cartDropdown.goToCartButton.click()
113
      await cartPage.container.waitFor({ state: "visible" })
114
      await cartPage.checkoutButton.click()
115
      await checkoutPage.container.waitFor({ state: "visible" })
116
    })
117

118
    await test.step("Enter in the first step of the checkout process", async () => {
119
      await test.step("Enter in the shipping address info", async () => {
120
        await checkoutPage.shippingFirstNameInput.fill("First")
121
        await checkoutPage.shippingLastNameInput.fill("Last")
122
        await checkoutPage.shippingCompanyInput.fill("MyCorp")
123
        await checkoutPage.shippingAddressInput.fill("123 Fake street")
124
        await checkoutPage.shippingPostalCodeInput.fill("80010")
125
        await checkoutPage.shippingCityInput.fill("Denver")
126
        await checkoutPage.shippingProvinceInput.fill("Colorado")
127
        await checkoutPage.shippingCountrySelect.selectOption("United States")
128
      })
129

130
      await test.step("Enter in the contact info and open the billing info form", async () => {
131
        await checkoutPage.shippingEmailInput.fill("test@example.com")
132
        await checkoutPage.shippingPhoneInput.fill("3031112222")
133
        await checkoutPage.billingAddressCheckbox.uncheck()
134
      })
135

136
      await test.step("Enter in the billing address info", async () => {
137
        await checkoutPage.billingFirstNameInput.fill("First")
138
        await checkoutPage.billingLastNameInput.fill("Last")
139
        await checkoutPage.billingCompanyInput.fill("MyCorp")
140
        await checkoutPage.billingAddressInput.fill("123 Fake street")
141
        await checkoutPage.billingPostalInput.fill("80010")
142
        await checkoutPage.billingCityInput.fill("Denver")
143
        await checkoutPage.billingProvinceInput.fill("Colorado")
144
        await checkoutPage.billingCountrySelect.selectOption("United States")
145
        await checkoutPage.submitAddressButton.click()
146
      })
147
    })
148

149
    await test.step("Submit the delivery and payment options", async () => {
150
      await checkoutPage.selectDeliveryOption("FakeEx Standard")
151
      await checkoutPage.submitDeliveryOptionButton.click()
152
      await checkoutPage.submitPaymentButton.click()
153
    })
154

155
    await test.step("Edit the shipping info", async () => {
156
      await checkoutPage.editAddressButton.click()
157
      await test.step("Edit the shipping address", async () => {
158
        await checkoutPage.shippingFirstNameInput.fill("First1")
159
        await checkoutPage.shippingLastNameInput.fill("Last1")
160
        await checkoutPage.shippingCompanyInput.fill("MeCorp")
161
        await checkoutPage.shippingAddressInput.fill("123 Fake Road")
162
        await checkoutPage.shippingPostalCodeInput.fill("80011")
163
        await checkoutPage.shippingCityInput.fill("Donver")
164
        await checkoutPage.shippingProvinceInput.fill("CO")
165
        await checkoutPage.shippingCountrySelect.selectOption("Canada")
166
      })
167

168
      await test.step("Edit the shipping contact info", async () => {
169
        await checkoutPage.shippingEmailInput.fill("tester@example.com")
170
        await checkoutPage.shippingPhoneInput.fill("3231112222")
171
      })
172

173
      await test.step("Edit the billing info", async () => {
174
        await checkoutPage.billingFirstNameInput.fill("Farst")
175
        await checkoutPage.billingLastNameInput.fill("List")
176
        await checkoutPage.billingCompanyInput.fill("MistCorp")
177
        await checkoutPage.billingAddressInput.fill("321 Fake street")
178
        await checkoutPage.billingPostalInput.fill("80110")
179
        await checkoutPage.billingCityInput.fill("Denvur")
180
        await checkoutPage.billingProvinceInput.fill("AB")
181
        await checkoutPage.billingCountrySelect.selectOption("Canada")
182
      })
183
      await checkoutPage.submitAddressButton.click()
184
    })
185

186
    await test.step("Make sure the edits are reflected in the container", async () => {
187
      await test.step("Check shipping address summary", async () => {
188
        const shippingColumn = checkoutPage.shippingAddressSummary
189
        await expect(shippingColumn).toContainText("First1")
190
        await expect(shippingColumn).toContainText("Last1")
191
        await expect(shippingColumn).toContainText("123 Fake Road")
192
        await expect(shippingColumn).toContainText("80011")
193
        await expect(shippingColumn).toContainText("Donver")
194
        await expect(shippingColumn).toContainText("CA")
195
      })
196

197
      await test.step("Check shipping contact summary", async () => {
198
        const contactColumn = checkoutPage.shippingContactSummary
199
        await expect(contactColumn).toContainText("tester@example.com")
200
        await expect(contactColumn).toContainText("3231112222")
201
      })
202

203
      await test.step("Check billing summary", async () => {
204
        const billingColumn = checkoutPage.billingAddressSummary
205
        await expect(billingColumn).toContainText("Farst")
206
        await expect(billingColumn).toContainText("List")
207
        await expect(billingColumn).toContainText("321 Fake street")
208
        await expect(billingColumn).toContainText("Denvur")
209
        await expect(billingColumn).toContainText("CA")
210
      })
211
    })
212
  })
213

214
  test("Shipping info saved is filled back into the forms after clicking edit", async ({
215
    cartPage,
216
    checkoutPage,
217
    productPage,
218
    storePage,
219
  }) => {
220
    await test.step("Navigate to a product page", async () => {
221
      await storePage.goto()
222
      const product = await storePage.getProduct("Sweatshirt")
223
      await product.locator.highlight()
224
      await product.locator.click()
225
      await productPage.container.waitFor({ state: "visible" })
226
    })
227

228
    await test.step("Add the product to the cart and goto checkout", async () => {
229
      await productPage.selectOption("M")
230
      await productPage.clickAddProduct()
231
      await productPage.cartDropdown.navCartLink.click()
232
      await productPage.cartDropdown.goToCartButton.click()
233
      await cartPage.container.waitFor({ state: "visible" })
234
      await cartPage.checkoutButton.click()
235
      await checkoutPage.container.waitFor({ state: "visible" })
236
    })
237

238
    await test.step("Enter in the first step of the checkout process", async () => {
239
      await test.step("Enter in the shipping address info", async () => {
240
        await checkoutPage.shippingFirstNameInput.fill("First")
241
        await checkoutPage.shippingLastNameInput.fill("Last")
242
        await checkoutPage.shippingCompanyInput.fill("MyCorp")
243
        await checkoutPage.shippingAddressInput.fill("123 Fake street")
244
        await checkoutPage.shippingPostalCodeInput.fill("80010")
245
        await checkoutPage.shippingCityInput.fill("Denver")
246
        await checkoutPage.shippingProvinceInput.fill("Colorado")
247
        await checkoutPage.shippingCountrySelect.selectOption("United States")
248
      })
249

250
      await test.step("Enter in the contact info and open the billing info form", async () => {
251
        await checkoutPage.shippingEmailInput.fill("test@example.com")
252
        await checkoutPage.shippingPhoneInput.fill("3031112222")
253
        await checkoutPage.billingAddressCheckbox.uncheck()
254
      })
255

256
      await test.step("Enter in the billing address info", async () => {
257
        await checkoutPage.billingFirstNameInput.fill("First")
258
        await checkoutPage.billingLastNameInput.fill("Last")
259
        await checkoutPage.billingCompanyInput.fill("MyCorp")
260
        await checkoutPage.billingAddressInput.fill("123 Fake street")
261
        await checkoutPage.billingPostalInput.fill("80010")
262
        await checkoutPage.billingCityInput.fill("Denver")
263
        await checkoutPage.billingProvinceInput.fill("Colorado")
264
        await checkoutPage.billingCountrySelect.selectOption("United States")
265
        await checkoutPage.submitAddressButton.click()
266
      })
267
    })
268

269
    await test.step("Click the edit address form and ensure the fields are filled correctly", async () => {
270
      await checkoutPage.editAddressButton.click()
271
      await test.step("Check the shipping address", async () => {
272
        await expect(checkoutPage.shippingFirstNameInput).toHaveValue("First")
273
        await expect(checkoutPage.shippingLastNameInput).toHaveValue("Last")
274
        await expect(checkoutPage.shippingCompanyInput).toHaveValue("MyCorp")
275
        await expect(checkoutPage.shippingAddressInput).toHaveValue(
276
          "123 Fake street"
277
        )
278
        await expect(checkoutPage.shippingPostalCodeInput).toHaveValue("80010")
279
        await expect(checkoutPage.shippingCityInput).toHaveValue("Denver")
280
        await expect(checkoutPage.shippingProvinceInput).toHaveValue("Colorado")
281
        await expect(checkoutPage.shippingCountrySelect).toHaveValue("us")
282
      })
283

284
      await test.step("Check the shipping contact", async () => {
285
        await expect(checkoutPage.shippingEmailInput).toHaveValue(
286
          "test@example.com"
287
        )
288
        await expect(checkoutPage.shippingPhoneInput).toHaveValue("3031112222")
289
      })
290

291
      await test.step("Check the billing address", async () => {
292
        await expect(checkoutPage.billingFirstNameInput).toHaveValue("First")
293
        await expect(checkoutPage.billingLastNameInput).toHaveValue("Last")
294
        await expect(checkoutPage.billingCompanyInput).toHaveValue("MyCorp")
295
        await expect(checkoutPage.billingAddressInput).toHaveValue(
296
          "123 Fake street"
297
        )
298
        await expect(checkoutPage.billingPostalInput).toHaveValue("80010")
299
        await expect(checkoutPage.billingCityInput).toHaveValue("Denver")
300
        await expect(checkoutPage.billingProvinceInput).toHaveValue("Colorado")
301
        await expect(checkoutPage.billingCountrySelect).toHaveValue("us")
302
      })
303
    })
304

305
    await test.step("Set the billing info to the same as checked and perform checks", async () => {
306
      await checkoutPage.billingAddressCheckbox.check()
307
      await checkoutPage.submitAddressButton.click()
308
      await checkoutPage.editAddressButton.click()
309
      await expect(checkoutPage.billingAddressCheckbox).toBeChecked()
310
    })
311
  })
312

313
  test("Shipping info in the checkout page is correctly reflected in the summary", async ({
314
    cartPage,
315
    checkoutPage,
316
    productPage,
317
    storePage,
318
  }) => {
319
    await test.step("Navigate to a product page", async () => {
320
      await storePage.goto()
321
      const product = await storePage.getProduct("Sweatshirt")
322
      await product.locator.highlight()
323
      await product.locator.click()
324
      await productPage.container.waitFor({ state: "visible" })
325
    })
326

327
    await test.step("Add the product to the cart and goto checkout", async () => {
328
      await productPage.selectOption("M")
329
      await productPage.clickAddProduct()
330
      await productPage.cartDropdown.navCartLink.click()
331
      await productPage.cartDropdown.goToCartButton.click()
332
      await cartPage.container.waitFor({ state: "visible" })
333
      await cartPage.checkoutButton.click()
334
      await checkoutPage.container.waitFor({ state: "visible" })
335
    })
336

337
    await test.step("Enter in the first step of the checkout process", async () => {
338
      await test.step("Enter in the shipping address info", async () => {
339
        await checkoutPage.shippingFirstNameInput.fill("First")
340
        await checkoutPage.shippingLastNameInput.fill("Last")
341
        await checkoutPage.shippingCompanyInput.fill("MyCorp")
342
        await checkoutPage.shippingAddressInput.fill("123 Fake street")
343
        await checkoutPage.shippingPostalCodeInput.fill("80010")
344
        await checkoutPage.shippingCityInput.fill("Denver")
345
        await checkoutPage.shippingProvinceInput.fill("Colorado")
346
        await checkoutPage.shippingCountrySelect.selectOption("United States")
347
      })
348

349
      await test.step("Enter in the contact info and open the billing info form", async () => {
350
        await checkoutPage.shippingEmailInput.fill("test@example.com")
351
        await checkoutPage.shippingPhoneInput.fill("3031112222")
352
        await checkoutPage.billingAddressCheckbox.uncheck()
353
      })
354

355
      await test.step("Enter in the billing address info", async () => {
356
        await checkoutPage.billingFirstNameInput.fill("First")
357
        await checkoutPage.billingLastNameInput.fill("Last")
358
        await checkoutPage.billingCompanyInput.fill("MyCorp")
359
        await checkoutPage.billingAddressInput.fill("123 Fake street")
360
        await checkoutPage.billingPostalInput.fill("80010")
361
        await checkoutPage.billingCityInput.fill("Denver")
362
        await checkoutPage.billingProvinceInput.fill("Colorado")
363
        await checkoutPage.billingCountrySelect.selectOption("United States")
364
        await checkoutPage.submitAddressButton.click()
365
      })
366
    })
367

368
    await test.step("Ensure the shipping column reflects the entered data", async () => {
369
      const shippingColumn = checkoutPage.shippingAddressSummary
370
      await expect(shippingColumn).toContainText("First")
371
      await expect(shippingColumn).toContainText("Last")
372
      await expect(shippingColumn).toContainText("123 Fake street")
373
      await expect(shippingColumn).toContainText("80010")
374
      await expect(shippingColumn).toContainText("Denver")
375
      await expect(shippingColumn).toContainText("US")
376
    })
377

378
    await test.step("Ensure the contact column reflects the entered data", async () => {
379
      const contactColumn = checkoutPage.shippingContactSummary
380
      await expect(contactColumn).toContainText("test@example.com")
381
      await expect(contactColumn).toContainText("3031112222")
382
    })
383

384
    await test.step("Ensure the billing column reflects the entered data", async () => {
385
      const billingColumn = checkoutPage.billingAddressSummary
386
      await expect(billingColumn).toContainText("First")
387
      await expect(billingColumn).toContainText("Last")
388
      await expect(billingColumn).toContainText("123 Fake street")
389
      await expect(billingColumn).toContainText("Denver")
390
      await expect(billingColumn).toContainText("US")
391
    })
392

393
    await test.step("Edit the billing info so it is the same as the billing address", async () => {
394
      await checkoutPage.editAddressButton.click()
395
      await checkoutPage.billingAddressCheckbox.check()
396
      await checkoutPage.submitAddressButton.click()
397
      const billingColumn = checkoutPage.billingAddressSummary
398
      await expect(billingColumn).toContainText("are the same.")
399
    })
400
  })
401

402
  test("Entering checkout, leaving, then returning takes you back to the correct checkout spot", async ({
403
    cartPage,
404
    checkoutPage,
405
    productPage,
406
    storePage,
407
  }) => {
408
    await test.step("Navigate to a product page", async () => {
409
      await storePage.goto()
410
      const product = await storePage.getProduct("Sweatshirt")
411
      await product.locator.highlight()
412
      await product.locator.click()
413
      await productPage.container.waitFor({ state: "visible" })
414
    })
415

416
    await test.step("Add the product to the cart and goto checkout", async () => {
417
      await productPage.selectOption("M")
418
      await productPage.clickAddProduct()
419
      await productPage.cartDropdown.navCartLink.click()
420
      await productPage.cartDropdown.goToCartButton.click()
421
      await cartPage.container.waitFor({ state: "visible" })
422
      await cartPage.checkoutButton.click()
423
      await checkoutPage.container.waitFor({ state: "visible" })
424
    })
425

426
    await test.step("Navigate away and back to the checkout page", async () => {
427
      await checkoutPage.backToCartLink.click()
428
      await cartPage.checkoutButton.click()
429
      await checkoutPage.container.waitFor({ state: "visible" })
430
      await expect(checkoutPage.submitAddressButton).toBeVisible()
431
    })
432

433
    await test.step("Enter in the first step of the checkout process", async () => {
434
      await test.step("Enter in the shipping address info", async () => {
435
        await checkoutPage.shippingFirstNameInput.fill("First")
436
        await checkoutPage.shippingLastNameInput.fill("Last")
437
        await checkoutPage.shippingCompanyInput.fill("MyCorp")
438
        await checkoutPage.shippingAddressInput.fill("123 Fake street")
439
        await checkoutPage.shippingPostalCodeInput.fill("80010")
440
        await checkoutPage.shippingCityInput.fill("Denver")
441
        await checkoutPage.shippingProvinceInput.fill("Colorado")
442
        await checkoutPage.shippingCountrySelect.selectOption("United States")
443
      })
444

445
      await test.step("Enter in the contact info and open the billing info form", async () => {
446
        await checkoutPage.shippingEmailInput.fill("test@example.com")
447
        await checkoutPage.shippingPhoneInput.fill("3031112222")
448
        await checkoutPage.billingAddressCheckbox.uncheck()
449
      })
450

451
      await test.step("Enter in the billing address info", async () => {
452
        await checkoutPage.billingFirstNameInput.fill("First")
453
        await checkoutPage.billingLastNameInput.fill("Last")
454
        await checkoutPage.billingCompanyInput.fill("MyCorp")
455
        await checkoutPage.billingAddressInput.fill("123 Fake street")
456
        await checkoutPage.billingPostalInput.fill("80010")
457
        await checkoutPage.billingCityInput.fill("Denver")
458
        await checkoutPage.billingProvinceInput.fill("Colorado")
459
        await checkoutPage.billingCountrySelect.selectOption("United States")
460
      })
461
      await checkoutPage.submitAddressButton.click()
462
      await checkoutPage.deliveryOptionRadio
463
        .first()
464
        .waitFor({ state: "visible" })
465
    })
466

467
    await test.step("Navigate away and back to the checkout page", async () => {
468
      await checkoutPage.backToCartLink.click()
469
      await cartPage.checkoutButton.click()
470
      await checkoutPage.container.waitFor({ state: "visible" })
471
      await expect(checkoutPage.submitDeliveryOptionButton).toBeVisible()
472
    })
473

474
    await test.step("Submit the delivery choice and navigate back and forth", async () => {
475
      await checkoutPage.selectDeliveryOption("FakeEx Standard")
476
      await checkoutPage.submitDeliveryOptionButton.click()
477
      await checkoutPage.submitPaymentButton.waitFor({ state: "visible" })
478
      await checkoutPage.backToCartLink.click()
479
      await cartPage.checkoutButton.click()
480
      await checkoutPage.container.waitFor({ state: "visible" })
481
      await expect(checkoutPage.submitPaymentButton).toBeVisible()
482
    })
483

484
    await test.step("Submit the payment info and navigate back and forth", async () => {
485
      await checkoutPage.submitPaymentButton.click()
486
      await checkoutPage.submitOrderButton.waitFor({ state: "visible" })
487
      await checkoutPage.backToCartLink.click()
488
      await cartPage.checkoutButton.click()
489
      await checkoutPage.container.waitFor({ state: "visible" })
490
      await expect(checkoutPage.submitPaymentButton).toBeVisible()
491
    })
492

493
    await test.step("Click edit on the shipping info and navigate back and forth", async () => {
494
      await checkoutPage.editAddressButton.click()
495
      await checkoutPage.backToCartLink.click()
496
      await cartPage.checkoutButton.click()
497
      await checkoutPage.container.waitFor({ state: "visible" })
498
      await expect(checkoutPage.submitPaymentButton).toBeVisible()
499
    })
500

501
    await test.step("Click edit on the shipping choice and navigate back and forth", async () => {
502
      await checkoutPage.editDeliveryButton.click()
503
      await checkoutPage.backToCartLink.click()
504
      await cartPage.checkoutButton.click()
505
      await checkoutPage.container.waitFor({ state: "visible" })
506
      await expect(checkoutPage.submitPaymentButton).toBeVisible()
507
    })
508
  })
509

510
  test("Verify the prices carries over to checkout", async ({
511
    cartPage,
512
    checkoutPage,
513
    productPage,
514
    storePage,
515
  }) => {
516
    await test.step("Navigate to the product page - go to the store page and click on the Sweatshirt product", async () => {
517
      await storePage.goto()
518
      const product = await storePage.getProduct("Sweatshirt")
519
      await product.locator.click()
520
      await productPage.container.waitFor({ state: "visible" })
521
    })
522

523
    let sweatshirtSmallPrice = 0
524
    let sweatshirtMediumPrice = 0
525
    await test.step("Add the sweatshirts to the cart", async () => {
526
      await productPage.selectOption("S")
527
      sweatshirtSmallPrice = getFloatValue(
528
        (await productPage.productPrice.getAttribute("data-value")) || "0"
529
      )
530
      await productPage.clickAddProduct()
531
      await productPage.cartDropdown.close()
532
      await productPage.selectOption("M")
533
      sweatshirtMediumPrice = getFloatValue(
534
        (await productPage.productPrice.getAttribute("data-value")) || "0"
535
      )
536
      await productPage.clickAddProduct()
537
      await productPage.cartDropdown.close()
538
    })
539

540
    await test.step("Navigate to another product - Sweatpants", async () => {
541
      await storePage.goto()
542
      const product = await storePage.getProduct("Sweatpants")
543
      await product.locator.click()
544
      await productPage.container.waitFor({ state: "visible" })
545
    })
546

547
    let sweatpantsSmallPrice = 0
548
    await test.step("Add the small sweatpants to the cart", async () => {
549
      await productPage.selectOption("S")
550
      sweatpantsSmallPrice = getFloatValue(
551
        (await productPage.productPrice.getAttribute("data-value")) || "0"
552
      )
553
      await productPage.clickAddProduct()
554
      await productPage.cartDropdown.close()
555
      await productPage.selectOption("S")
556
      await productPage.clickAddProduct()
557
      await productPage.cartDropdown.goToCartButton.click()
558
      await productPage.cartDropdown.close()
559
      await cartPage.container.waitFor({ state: "visible" })
560
    })
561

562
    await test.step("Verify the price in the cart is the expected value", async () => {
563
      const total = getFloatValue(
564
        (await cartPage.cartSubtotal.getAttribute("data-value")) || "0"
565
      )
566
      const calculatedTotal =
567
        2 * sweatpantsSmallPrice + sweatshirtSmallPrice + sweatshirtMediumPrice
568
      expect(compareFloats(total, calculatedTotal)).toBe(0)
569
      await cartPage.checkoutButton.click()
570
      await checkoutPage.container.waitFor({ state: "visible" })
571
    })
572

573
    await test.step("Go to checkout and verify the price in the checkout is the expected value", async () => {
574
      const total = getFloatValue(
575
        (await checkoutPage.cartSubtotal.getAttribute("data-value")) || "0"
576
      )
577
      const calculatedTotal =
578
        2 * sweatpantsSmallPrice + sweatshirtSmallPrice + sweatpantsSmallPrice
579
      expect(compareFloats(total, calculatedTotal)).toBe(0)
580
    })
581
  })
582
})
583

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.