STF_05.spec.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { expect, test } from "@playwright/test";
  2. import {
  3. addCurrentProductToCart,
  4. clickOnNthProductElement,
  5. openCart,
  6. selectRandomAvailableVariant,
  7. } from "./utils";
  8. test("STF_05: Checkout as a unlogged user", async ({ page }) => {
  9. await page.goto("/");
  10. const product = await clickOnNthProductElement({ page, nth: 0 });
  11. await selectRandomAvailableVariant({ page });
  12. await addCurrentProductToCart({ page });
  13. await openCart({ page });
  14. await page.getByTestId("CheckoutLink").click();
  15. await page.getByTestId("shippingAddressSection").waitFor();
  16. await page.getByLabel("Email").pressSequentially("example@saleor.io", { delay: 50 });
  17. await page.getByLabel("Country").selectOption("Poland");
  18. await page.getByTestId("shippingAddressSection").waitFor();
  19. await page.getByLabel("First name").pressSequentially("Jan", { delay: 50 });
  20. await page.getByLabel("Last name").pressSequentially("Kowalski", { delay: 50 });
  21. await page.getByLabel("Street address").first().pressSequentially("Ojcowska 23", { delay: 50 });
  22. await page.getByRole("textbox", { name: "City" }).pressSequentially("Gdańsk", { delay: 50 });
  23. await page.getByLabel("Postal code").pressSequentially("80-146", { delay: 50 });
  24. await page.getByLabel("Postal code").blur();
  25. await page.getByTestId("deliveryMethods").waitFor();
  26. await page.getByLabel("DHL").click();
  27. await page.getByLabel("DHL").blur();
  28. await page.getByTestId("paymentMethods").waitFor();
  29. const stripeIframe = page.getByTestId("paymentMethods").frameLocator("iframe");
  30. await stripeIframe.getByLabel("Card number").fill("4242424242424242");
  31. await stripeIframe.getByLabel("Expiration").fill("03/30");
  32. await stripeIframe.getByLabel("CVC").fill("737");
  33. await page.getByRole("button", { name: "Pay now" }).click();
  34. await page.getByText("Thank you for placing your order.", { exact: false }).waitFor();
  35. const summaryProductList = page.getByTestId("SummaryProductList");
  36. await expect(summaryProductList.getByTestId("SummaryItem")).toHaveCount(1);
  37. await expect(summaryProductList).toContainText(product.name);
  38. });