This repository has been archived on 2026-05-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
app/apps/e2e/tests/clients.spec.ts
T
groombook-cto[bot] 6e087cc16b Fix pets API mock route in clients E2E test
The pets endpoint is /api/pets?clientId=... not /api/clients/*/pets.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-18 02:41:24 +00:00

60 lines
1.6 KiB
TypeScript

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/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();
});