Verify-suite work (this session):
- M package.json — added typecheck, test:e2e, verify scripts; added @playwright/test devDep - M pnpm-lock.yaml - M .gitignore — Playwright artifacts - M tsconfig.json — auto-modified by Next.js include path - ?? e2e/ — config + fixtures + 3 specs - ?? playwright.config.ts - ?? scripts/verify.sh, scripts/db-test-truncate.sql
This commit is contained in:
43
e2e/customer.spec.ts
Normal file
43
e2e/customer.spec.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { signInAs } from "./fixtures/auth";
|
||||
|
||||
test("customer can browse and reach the booking confirm page", async ({ page }) => {
|
||||
// /book/confirm requires an authenticated session, so sign in first.
|
||||
await signInAs(page, "customer", "/");
|
||||
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("heading", { name: /book a session/i })).toBeVisible();
|
||||
|
||||
// First service "Book" link → /book?serviceId=...
|
||||
const firstBook = page.locator('a[href^="/book?serviceId="]').first();
|
||||
await expect(firstBook).toBeVisible();
|
||||
await firstBook.click();
|
||||
await expect(page).toHaveURL(/\/book\?serviceId=/);
|
||||
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
|
||||
|
||||
// Pick a date a few days out so slots are likely available.
|
||||
const dateInput = page.locator('input[type="date"][name="date"]');
|
||||
await expect(dateInput).toBeVisible();
|
||||
const target = new Date();
|
||||
target.setDate(target.getDate() + 3);
|
||||
const iso = target.toISOString().slice(0, 10);
|
||||
await dateInput.fill(iso);
|
||||
await page.getByRole("button", { name: /show times/i }).click();
|
||||
await expect(page).toHaveURL(new RegExp(`date=${iso}`));
|
||||
|
||||
// Grab the first slot's href and visit it directly.
|
||||
const slot = page.locator('a[href^="/book/confirm?"]').first();
|
||||
await expect(slot, "expected at least one available slot").toBeVisible();
|
||||
const slotHref = await slot.getAttribute("href");
|
||||
expect(slotHref).toMatch(/^\/book\/confirm\?/);
|
||||
await page.goto(slotHref!);
|
||||
|
||||
// Already authenticated, so we land on the confirm form (not /login).
|
||||
await expect(page).toHaveURL(/\/book\/confirm\?/);
|
||||
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
|
||||
|
||||
// /account/bookings should be reachable while signed in.
|
||||
await page.goto("/account/bookings");
|
||||
await expect(page).toHaveURL(/\/account\/bookings/);
|
||||
await expect(page.getByRole("heading", { level: 1 })).toBeVisible();
|
||||
});
|
||||
Reference in New Issue
Block a user