|
| 1 | +import { faker } from "@faker-js/faker" |
| 2 | +import { euAddress } from "specs/utils/addresses" |
| 3 | + |
| 4 | +import { test, expect } from "../fixtures/tokenizedPage" |
| 5 | + |
| 6 | +const customerEmail = faker.internet.email().toLocaleLowerCase() |
| 7 | + |
| 8 | +test.use({ |
| 9 | + defaultParams: { |
| 10 | + order: "with-items", |
| 11 | + lineItemsAttributes: [ |
| 12 | + { sku_code: "BABYONBU000000E63E7412MX", quantity: 2 }, |
| 13 | + ], |
| 14 | + orderAttributes: { |
| 15 | + customer_email: customerEmail, |
| 16 | + }, |
| 17 | + }, |
| 18 | +}) |
| 19 | + |
| 20 | +test("should execute a checkout with klarna", async ({ checkoutPage }) => { |
| 21 | + await checkoutPage.checkOrderSummary("Order Summary") |
| 22 | + |
| 23 | + await checkoutPage.setCustomerMail() |
| 24 | + await checkoutPage.setBillingAddress({ ...euAddress, phone: "+393293399456" }) |
| 25 | + |
| 26 | + await checkoutPage.checkStep("Customer", "open") |
| 27 | + |
| 28 | + await checkoutPage.save("Customer") |
| 29 | + |
| 30 | + await checkoutPage.checkStep("Shipping", "open") |
| 31 | + |
| 32 | + await checkoutPage.checkShippingSummary("To be calculated") |
| 33 | + |
| 34 | + await expect( |
| 35 | + checkoutPage.page.locator("text=Standard Shipping") |
| 36 | + ).toBeVisible() |
| 37 | + await checkoutPage.selectShippingMethod({ text: "Standard Shipping" }) |
| 38 | + |
| 39 | + await checkoutPage.checkShippingSummary("FREE") |
| 40 | + await checkoutPage.save("Shipping") |
| 41 | + |
| 42 | + await checkoutPage.checkStep("Payment", "open") |
| 43 | + |
| 44 | + await checkoutPage.selectPayment("klarna") |
| 45 | + |
| 46 | + await checkoutPage.save("Payment", undefined, true) |
| 47 | + |
| 48 | + await checkoutPage.completePayment({ type: "klarna" }) |
| 49 | + |
| 50 | + await checkoutPage.checkPaymentRecap("Klarna") |
| 51 | + |
| 52 | + await checkoutPage.page.reload() |
| 53 | + |
| 54 | + await checkoutPage.checkPaymentRecap("Klarna") |
| 55 | +}) |
0 commit comments