Skip to content

Commit

Permalink
fix: playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronshaf committed Nov 23, 2024
1 parent e32d368 commit 1f66852
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
32 changes: 15 additions & 17 deletions packages/idb-cache-app/tests/test-1.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { test } from "@playwright/test";
import { test, expect } from "@playwright/test";

test("basics", async ({ page }) => {
await page.goto("http://localhost:3000/#size=32");
await page.getByTestId("reset-cacheBuster").click();
await page.getByRole("button", { name: "clear" }).click();
await page.getByRole("button", { name: "count" }).click();
await page.getByText("0", { exact: true }).click();
await page.getByRole("button", { name: "setItem" }).click();
await page.getByText("1vz68t").click();
await page.getByRole("button", { name: "getItem" }).click();
await page.getByText("1vz68t").nth(1).click();
await page.getByRole("button", { name: "setItem" }).click();
await page.getByText("zczdo4").click();
await page.getByRole("button", { name: "getItem" }).click();
await page.getByText("zczdo4").nth(1).click();
await page.getByRole("button", { name: "count" }).click();
await page.getByText("4", { exact: true }).click();
await page.getByRole("button", { name: "clear" }).click();
await page.getByRole("button", { name: "count" }).click();
await page.getByText("0", { exact: true }).click();
await page.getByTestId("clear-button").click();
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value")).toContainText("0");
await expect(page.getByTestId("count-time")).toContainText("ms");
await page.getByTestId("set-item-button").click();
await expect(page.getByTestId("hash1")).toContainText("nrhzjl");
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2")).toContainText("nrhzjl");
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value")).toContainText("2");
await page.getByTestId("set-item-button").click();
await expect(page.getByTestId("hash1")).toContainText("2h0z7s");
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2")).toContainText("2h0z7s");
});
8 changes: 4 additions & 4 deletions packages/idb-cache-app/tests/test-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ test("cache key (1)", async ({ page }) => {
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("------")).toBeVisible();
await page.getByTestId("set-item-button").click();
await expect(page.getByText("1vz68t")).toBeVisible();
await expect(page.getByText("nrhzjl")).toBeVisible();
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("1vz68t")).toBeVisible();
await expect(page.getByTestId("hash2").getByText("nrhzjl")).toBeVisible();
await page.getByTestId("reset-cacheKey").click();
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value").getByText("2")).toBeVisible();
Expand All @@ -21,9 +21,9 @@ test("cache key (1)", async ({ page }) => {
page.getByTestId("hash2").locator("div").filter({ hasText: "------" })
).toBeVisible();
await page.getByTestId("set-item-button").click();
await expect(page.getByText("1vz68t")).toBeVisible();
await expect(page.getByText("nrhzjl")).toBeVisible();
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("1vz68t")).toBeVisible();
await expect(page.getByTestId("hash2").getByText("nrhzjl")).toBeVisible();
await page.getByTestId("reset-cacheKey").click();
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value").getByText("4")).toBeVisible();
Expand Down
8 changes: 4 additions & 4 deletions packages/idb-cache-app/tests/test-3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ test("cache buster (1)", async ({ page }) => {
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value").getByText("0")).toBeVisible();
await page.getByTestId("set-item-button").click();
await expect(page.getByText("1vz68t")).toBeVisible();
await expect(page.getByText("nrhzjl")).toBeVisible();
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("1vz68t")).toBeVisible();
await expect(page.getByTestId("hash2").getByText("nrhzjl")).toBeVisible();
await page.getByTestId("reset-cacheBuster").click();
await page.getByTestId("cleanup-button").click();
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value").getByText("0")).toBeVisible();
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("------")).toBeVisible();
await page.getByTestId("set-item-button").click();
await expect(page.getByText("1vz68t")).toBeVisible();
await expect(page.getByText("nrhzjl")).toBeVisible();
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("1vz68t")).toBeVisible();
await expect(page.getByTestId("hash2").getByText("nrhzjl")).toBeVisible();
await page.getByTestId("count-button").click();
await expect(page.getByTestId("count-value").getByText("2")).toBeVisible();
await page.getByTestId("reset-cacheBuster").click();
Expand Down
4 changes: 2 additions & 2 deletions packages/idb-cache-app/tests/test-4.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ test("20mb size item", async ({ page }) => {
await page.getByTestId("reset-cacheBuster").click();
await page.getByTestId("clear-button").click();
await page.getByTestId("set-item-button").click();
await expect(page.getByText("6u81xr")).toBeVisible();
await expect(page.getByText("6ftozm")).toBeVisible();
await page.getByTestId("get-item-button").click();
await expect(page.getByTestId("hash2").getByText("6u81xr")).toBeVisible();
await expect(page.getByTestId("hash2").getByText("6ftozm")).toBeVisible();
// Ensures enough time for IDB to take effect
await page.getByTestId("count-button").click();
await page.getByTestId("count-button").click();
Expand Down

0 comments on commit 1f66852

Please sign in to comment.