Skip to content

Commit

Permalink
updating specs (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
BMayhew authored Apr 23, 2024
1 parent 0fb1567 commit decb80e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/scenarios/addToCart.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { test, expect } from "@playwright/test";

test("Validate cart is updated from product details page", async ({ page }) => {
const productName = "Claw Hammer with Shock Reduction Grip";
await page.goto("https://practicesoftwaretesting.com/#/");
await page.getByTestId("nav-categories").click();
await page.getByTestId("nav-hand-tools").click();
await page.getByTestId("product-01HW1VY6EF69H453A43ZASG43C").click();
await expect(page.getByTestId("product-name")).toContainText(
"Claw Hammer with Shock Reduction Grip"
);
// create a playwright locator that will find a link with a child div that has text of "Claw Hammer with Shock Reduction Grip" and click the link
await page
.locator('a >> div:has-text("Claw Hammer with Shock Reduction Grip")')
.click();
// await page.getByTestId("product-01HW4EAZ6N8RP9NNC55NT5AXPW").click();
await expect(page.getByTestId("product-name")).toContainText(productName);
await expect(page.locator("app-detail")).toContainText("Hammer");
await expect(page.getByLabel("brand")).toContainText("ForgeFlex Tools");
await page.getByTestId("increase-quantity").click();
Expand All @@ -16,7 +19,5 @@ test("Validate cart is updated from product details page", async ({ page }) => {
await expect(page.getByTestId("cart-quantity")).toContainText("2");
await page.getByTestId("nav-cart").click();
await expect(page.getByRole("spinbutton")).toHaveValue("2");
await expect(page.locator("tbody")).toContainText(
"Claw Hammer with Shock Reduction Grip"
);
await expect(page.locator("tbody")).toContainText(productName);
});

0 comments on commit decb80e

Please sign in to comment.