forked from saleor/storefront
-
Notifications
You must be signed in to change notification settings - Fork 0
/
STF_01.spec.ts
29 lines (23 loc) · 973 Bytes
/
STF_01.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { expect, test } from "@playwright/test";
import {
addCurrentProductToCart,
clickOnRandomProductElement,
getCurrentProductPrice,
openCart,
selectRandomAvailableVariant,
} from "./utils";
test("STF_01: Add items to the basket", async ({ page }) => {
await page.goto("/");
const product = await clickOnRandomProductElement({ page });
await selectRandomAvailableVariant({ page });
const price = await getCurrentProductPrice({ page });
await expect(page.getByTestId("CartNavItem")).toContainText("0 items");
await addCurrentProductToCart({ page });
await expect(page.getByTestId("CartNavItem")).toContainText("1 item");
await openCart({ page });
const productInCart = page.getByTestId("CartProductList").getByRole("listitem");
await expect(productInCart).toHaveCount(1);
await expect(productInCart).toContainText(product.name);
await expect(productInCart).toContainText(`Qty: 1`);
await expect(productInCart).toContainText(price.toFixed(2));
});