test: add E2E tests for dashboard and collection views
Covers dashboard card rendering (item count, nav links, active thread/setup counts) and collection page (gear display, search, category filter, tab switching). Updates playwright config to serve production build with pre-seeded test DB. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
56
e2e/dashboard.spec.ts
Normal file
56
e2e/dashboard.spec.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test.describe("Dashboard", () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await page.waitForLoadState("networkidle");
|
||||
});
|
||||
|
||||
test("shows GearBox heading", async ({ page }) => {
|
||||
await expect(page.getByText("GearBox")).toBeVisible();
|
||||
});
|
||||
|
||||
test("shows collection card with item count of 6", async ({ page }) => {
|
||||
// The Collection card link contains "Items" label and value "6"
|
||||
const collectionCard = page
|
||||
.getByRole("link", { name: /collection/i })
|
||||
.first();
|
||||
await expect(collectionCard).toBeVisible();
|
||||
await expect(collectionCard.getByText("6")).toBeVisible();
|
||||
});
|
||||
|
||||
test("shows Collection, Planning, and Setups card headings", async ({
|
||||
page,
|
||||
}) => {
|
||||
await expect(
|
||||
page.getByRole("heading", { name: "Collection" }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Planning" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "Setups" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("Collection card links to /collection", async ({ page }) => {
|
||||
const collectionLink = page
|
||||
.getByRole("link", { name: /collection/i })
|
||||
.first();
|
||||
await collectionLink.click();
|
||||
await page.waitForLoadState("networkidle");
|
||||
await expect(page).toHaveURL(/\/collection/);
|
||||
});
|
||||
|
||||
test("shows active thread count on Planning card", async ({ page }) => {
|
||||
// The Planning card is a link containing "Active threads"
|
||||
const planningCard = page.getByRole("link", { name: /planning/i });
|
||||
await expect(planningCard.getByText("Active threads")).toBeVisible();
|
||||
// Seed has 1 active thread
|
||||
await expect(planningCard.getByText("1")).toBeVisible();
|
||||
});
|
||||
|
||||
test("shows setup count on Setups card", async ({ page }) => {
|
||||
// The Setups card has a heading "Setups"
|
||||
await expect(page.getByRole("heading", { name: "Setups" })).toBeVisible();
|
||||
// Seed has 1 setup
|
||||
const setupsCard = page.getByRole("link", { name: /setups/i }).last();
|
||||
await expect(setupsCard.getByText("1")).toBeVisible();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user