-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { | ||
addCurrentProductToCart, | ||
clickOnRandomProductElement, | ||
openCart, | ||
selectRandomAvailableVariant, | ||
} from "./utils"; | ||
|
||
test("STF_02: Remove items from the basket", async ({ page }) => { | ||
await page.goto("/"); | ||
|
||
const product = await clickOnRandomProductElement({ page }); | ||
await selectRandomAvailableVariant({ 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 productInCart.getByRole("button", { name: "Remove" }).click(); | ||
await expect(page.getByTestId("CartNavItem")).toContainText("0 items"); | ||
await expect(productInCart).toHaveCount(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { | ||
addCurrentProductToCart, | ||
clickOnRandomProductElement, | ||
getCurrentProductPrice, | ||
openCart, | ||
selectRandomAvailableVariant, | ||
} from "./utils"; | ||
|
||
test("STF_03: Check if price are calculating correctly", 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 addCurrentProductToCart({ page }); | ||
await expect(page.getByTestId("CartNavItem")).toContainText("2 items"); | ||
|
||
await openCart({ page }); | ||
|
||
const totalPrice = (price * 2).toFixed(2); | ||
await expect(page.getByTestId("CartProductList").getByRole("listitem")).toHaveCount(1); | ||
await expect(page.getByTestId("CartProductList").getByRole("listitem")).toContainText(product.name); | ||
await expect(page.getByTestId("CartProductList").getByRole("listitem")).toContainText(`Qty: 2`); | ||
await expect(page.getByTestId("CartProductList").getByRole("listitem")).toContainText(totalPrice); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters