- /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>
54 lines
3.0 KiB
TypeScript
54 lines
3.0 KiB
TypeScript
import { test, expect, seed, loginAs, api, v2 } from "./fixtures";
|
|
|
|
type Registration = { id: string; status: string; eventId: string };
|
|
type Ticket = { id: string; qrCode: string; eventId: string };
|
|
|
|
type CashByUser = { rows: { userId: string | null; cash: { total: number; count: number } }[] };
|
|
|
|
test.describe("registration → payment → ticket → check-in → cashup", () => {
|
|
test("a free event: register and get a ticket straight away", async ({ page }) => {
|
|
await loginAs(page, "user");
|
|
await page.goto(`/register/${seed().events.free}`);
|
|
await expect(page.getByText("E2E Free Evening").first()).toBeVisible();
|
|
await page.getByRole("button", { name: /^Add one / }).first().click();
|
|
await page.getByRole("button", { name: "Register", exact: true }).click();
|
|
await page.waitForURL(/\/registration\/success/);
|
|
|
|
const tickets = await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets");
|
|
expect(tickets.some((t) => t.eventId === seed().events.free)).toBe(true);
|
|
});
|
|
|
|
test("a paid event: pending until paid, then a ticket that checks in once", async ({ page }) => {
|
|
await loginAs(page, "user");
|
|
await page.goto(`/register/${seed().events.paid}`);
|
|
await page.getByRole("button", { name: /^Add one / }).first().click();
|
|
await expect(page.getByText("Total: R150.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.paid);
|
|
expect(reg?.status).not.toBe("paid");
|
|
expect((await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets")).some((t) => t.eventId === seed().events.paid)).toBe(false);
|
|
|
|
// A supervisor records the cash payment at the desk.
|
|
await v2(page, "supervisor", "POST", "/api/v2/payments", { amount: 150, method: "cash", registrationId: reg!.id, eventId: seed().events.paid, userId: seed().users.user.id });
|
|
const ticket = (await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets")).find((t) => t.eventId === seed().events.paid);
|
|
expect(ticket).toBeTruthy();
|
|
|
|
// My Events shows it.
|
|
await page.goto("/dashboard/user");
|
|
await expect(page.getByText("E2E Paid Conference").first()).toBeVisible();
|
|
|
|
// Staff check it in; a second scan is refused.
|
|
expect((await v2<{ outcome: string }>(page, "staff", "POST", `/api/v2/checkin/${ticket!.qrCode}`, { people: 1 })).outcome).toBe("checked_in");
|
|
expect(await v2(page, "staff", "POST", `/api/v2/checkin/${ticket!.qrCode}`, { people: 1 })).toMatchObject({ outcome: "already_used", message: expect.stringMatching(/fully used/) });
|
|
|
|
// Cashup: the R150 cash is on the supervisor who took it.
|
|
const cash = await v2<CashByUser>(page, "supervisor", "GET", `/api/v2/events/${seed().events.paid}/cashup/cash-by-user`);
|
|
const mine = cash.rows.find((r) => r.userId === seed().users.supervisor.id);
|
|
expect(mine?.cash.total).toBe(150);
|
|
expect(mine?.cash.count).toBe(1);
|
|
});
|
|
});
|