- /api (v1) answers 410 API_V1_REMOVED, except provider webhooks (/api/webhooks/*, /api/whatsapp/webhook) and links in sent messages (308s, one-click POST). 43 v1 route files and deprecation.ts removed; /docs redirects to /docs/v2; API_DOCUMENTATION.md points there. - Read-only and impersonation lists name v2 paths only. The campus scope route test now runs over v2 routes (v2CampusScope.test.ts). - Passwords hashed with Argon2id (@node-rs/argon2); bcrypt hashes still sign in and are re-hashed at the next sign-in. - e2e on /api/v2 only (v2() helper); Playwright waits on /api/v2. - MIGRATING-TO-2.md with the full v1 -> v2 table. - Two documented response shapes corrected. Backend 690 tests and e2e 102/102 (PayFast sandbox skipped) pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
94 lines
4.9 KiB
TypeScript
94 lines
4.9 KiB
TypeScript
import { test, expect, seed, loginAs, api, pickEvent, v2 } from "./fixtures";
|
|
|
|
type Registration = { id: string; eventId: string; user?: { name: string }; registrationOptions: { sessionId?: string | null; sessionIds?: string[]; priceSnapshot: number; quantity: number }[] };
|
|
type WaitlistEntry = { eventId: string; sessionId: string | null; quantity: number };
|
|
|
|
test.describe("pick sessions", () => {
|
|
test("book two classes of a drop-in event; a full class can't be ticked", async ({ page }) => {
|
|
await loginAs(page, "user");
|
|
await page.goto(`/register/${seed().events.dropIn}`);
|
|
await expect(page.getByText("R50.00 per session").first()).toBeVisible();
|
|
await page.getByRole("button", { name: /^Add one / }).first().click();
|
|
|
|
const picker = page.getByRole("group", { name: "Choose sessions" });
|
|
await expect(picker.getByText("Full")).toBeVisible();
|
|
await expect(picker.getByRole("checkbox").first()).toBeDisabled();
|
|
await picker.getByRole("checkbox").nth(1).check();
|
|
await picker.getByRole("checkbox").nth(2).check();
|
|
await expect(page.getByText("Total: R100.00")).toBeVisible();
|
|
|
|
await page.getByRole("button", { name: "Register", exact: true }).click();
|
|
await page.waitForURL(/\/registration\/success/);
|
|
|
|
const regs = await v2<Registration[]>(page, "user", "GET", "/api/v2/me/registrations/full");
|
|
const reg = regs.find((r) => r.eventId === seed().events.dropIn);
|
|
expect(reg?.registrationOptions.filter((o) => o.sessionId)).toHaveLength(2);
|
|
});
|
|
|
|
test("an all-sessions pass: tick the days, pay one price", async ({ page }) => {
|
|
await loginAs(page, "user");
|
|
await page.goto(`/register/${seed().events.conference}`);
|
|
await expect(page.getByText("R200.00", { exact: true })).toBeVisible();
|
|
await expect(page.getByText("per session")).toHaveCount(0);
|
|
|
|
const picker = page.getByRole("group", { name: "Choose sessions" });
|
|
await picker.getByRole("checkbox").nth(0).check();
|
|
await picker.getByRole("checkbox").nth(2).check();
|
|
await expect(page.getByText("Total: R200.00")).toBeVisible();
|
|
|
|
await page.getByRole("button", { name: "Register", exact: true }).click();
|
|
await page.waitForURL(/\/registration\/success/);
|
|
|
|
const regs = await v2<Registration[]>(page, "user", "GET", "/api/v2/me/registrations/full");
|
|
const line = regs.find((r) => r.eventId === seed().events.conference)?.registrationOptions[0];
|
|
expect(line?.sessionId ?? null).toBeNull();
|
|
expect(line?.sessionIds).toHaveLength(2);
|
|
expect(line?.priceSnapshot).toBe(200);
|
|
expect(line?.quantity).toBe(1);
|
|
});
|
|
|
|
test("join the waitlist for a full class", async ({ page }) => {
|
|
await loginAs(page, "admin");
|
|
await page.goto(`/register/${seed().events.dropIn}`);
|
|
await page.getByRole("button", { name: /^Add one / }).first().click();
|
|
|
|
const picker = page.getByRole("group", { name: "Choose sessions" });
|
|
await picker.getByRole("button", { name: "Join waitlist" }).click();
|
|
await expect(page.getByText(/Drop-in — Class 1/)).toBeVisible();
|
|
await page.locator("form").filter({ hasText: "Join the waitlist" }).getByRole("button", { name: "Join waitlist" }).click();
|
|
await expect(page.getByText(/You're on the waitlist/)).toBeVisible();
|
|
|
|
const mine = await v2<WaitlistEntry[]>(page, "admin", "GET", "/api/v2/me/waitlist");
|
|
const entry = mine.find((e) => e.eventId === seed().events.dropIn);
|
|
expect(entry?.sessionId).toBeTruthy();
|
|
expect(entry?.quantity).toBe(1);
|
|
});
|
|
|
|
test("at the door: book a class for a walk-in", async ({ page }) => {
|
|
await loginAs(page, "supervisor");
|
|
await page.goto("/dashboard/supervisor/at-the-door");
|
|
// The page picks a default event once its list loads; choose ours after that.
|
|
await page.waitForLoadState("networkidle");
|
|
await pickEvent(page, "E2E Drop-in Class");
|
|
await page.waitForLoadState("networkidle");
|
|
await expect(page.getByRole("button", { name: /^Event: E2E Drop-in Class/ })).toBeVisible();
|
|
|
|
await page.getByPlaceholder("Name, email or phone…").fill("Door Walk In");
|
|
await page.getByText('New attendee "Door Walk In"…').click();
|
|
await page.getByPlaceholder("Email address").fill("door-walkin@e2e.test");
|
|
await page.getByRole("button", { name: "Next — Choose Items" }).click();
|
|
|
|
await expect(page.getByText("R 50.00 per session")).toBeVisible();
|
|
await page.getByRole("button", { name: /^Add one / }).first().click();
|
|
const picker = page.getByRole("group", { name: "Choose sessions" });
|
|
await picker.getByRole("checkbox").nth(1).check();
|
|
await expect(page.getByText("Total: R 50.00")).toBeVisible();
|
|
await page.getByRole("button", { name: "Confirm Registration" }).click();
|
|
await expect(page.getByText("Select Items")).toBeHidden();
|
|
|
|
const regs = await v2<Registration[]>(page, "supervisor", "GET", `/api/v2/events/${seed().events.dropIn}/registrations`);
|
|
const reg = regs.find((r) => r.user?.name === "Door Walk In");
|
|
expect(reg?.registrationOptions.filter((o) => o.sessionId)).toHaveLength(1);
|
|
});
|
|
});
|