Add Playwright E2E testing infrastructure
- New apps/e2e workspace with @playwright/test - playwright.config.ts targeting Docker Compose stack (http://localhost:8080) - navigation.spec.ts: smoke tests for all pages - book.spec.ts: full booking wizard happy-path with API mocking - clients.spec.ts: client list and detail panel tests - CI job: spins up docker compose, installs Playwright chromium, runs tests - Playwright report uploaded as artifact on failure - README docs for running E2E tests locally Closes #40 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
committed by
Groom Book CTO
parent
cba502e35f
commit
a045749673
@@ -0,0 +1,59 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
|
||||
/**
|
||||
* Client management E2E tests.
|
||||
*
|
||||
* API calls are mocked so tests run without a live backend.
|
||||
*/
|
||||
|
||||
const MOCK_CLIENTS = [
|
||||
{
|
||||
id: "client-1",
|
||||
name: "Alice Johnson",
|
||||
email: "alice@example.com",
|
||||
phone: "555-0101",
|
||||
address: null,
|
||||
notes: null,
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "client-2",
|
||||
name: "Bob Williams",
|
||||
email: "bob@example.com",
|
||||
phone: null,
|
||||
address: null,
|
||||
notes: null,
|
||||
createdAt: "2026-01-02T00:00:00.000Z",
|
||||
updatedAt: "2026-01-02T00:00:00.000Z",
|
||||
},
|
||||
];
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.route("/api/clients**", (route) =>
|
||||
route.fulfill({ json: MOCK_CLIENTS })
|
||||
);
|
||||
// Pets loaded when a client is selected
|
||||
await page.route("/api/clients/*/pets", (route) =>
|
||||
route.fulfill({ json: [] })
|
||||
);
|
||||
});
|
||||
|
||||
test("clients page shows client list", async ({ page }) => {
|
||||
await page.goto("/clients");
|
||||
await expect(page.getByText("Alice Johnson")).toBeVisible();
|
||||
await expect(page.getByText("Bob Williams")).toBeVisible();
|
||||
});
|
||||
|
||||
test("clients page shows search input", async ({ page }) => {
|
||||
await page.goto("/clients");
|
||||
await expect(page.getByPlaceholder(/search/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test("clicking a client shows their details", async ({ page }) => {
|
||||
await page.goto("/clients");
|
||||
await expect(page.getByText("Alice Johnson")).toBeVisible();
|
||||
await page.getByText("Alice Johnson").click();
|
||||
// Client detail panel shows their email
|
||||
await expect(page.getByText("alice@example.com")).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user