STF_01.spec.ts 973 B

1234567891011121314151617181920212223242526272829
  1. import { expect, test } from "@playwright/test";
  2. import {
  3. addCurrentProductToCart,
  4. clickOnRandomProductElement,
  5. getCurrentProductPrice,
  6. openCart,
  7. selectRandomAvailableVariant,
  8. } from "./utils";
  9. test("STF_01: Add items to the basket", async ({ page }) => {
  10. await page.goto("/");
  11. const product = await clickOnRandomProductElement({ page });
  12. await selectRandomAvailableVariant({ page });
  13. const price = await getCurrentProductPrice({ page });
  14. await expect(page.getByTestId("CartNavItem")).toContainText("0 items");
  15. await addCurrentProductToCart({ page });
  16. await expect(page.getByTestId("CartNavItem")).toContainText("1 item");
  17. await openCart({ page });
  18. const productInCart = page.getByTestId("CartProductList").getByRole("listitem");
  19. await expect(productInCart).toHaveCount(1);
  20. await expect(productInCart).toContainText(product.name);
  21. await expect(productInCart).toContainText(`Qty: 1`);
  22. await expect(productInCart).toContainText(price.toFixed(2));
  23. });