STF_02.spec.ts 970 B

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