WIP 2.0.0: v1 removed; Argon2id passwords; node-fetch gone

- /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>
This commit is contained in:
2026-11-02 16:35:06 +02:00
co-authored by Claude Opus 5.5
parent 57b3c41067
commit 3f59164ab2
97 changed files with 1099 additions and 4398 deletions
+9 -9
View File
@@ -1,4 +1,4 @@
import { test, expect, seed, loginAs, api } from "./fixtures";
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 };
@@ -14,7 +14,7 @@ test.describe("registration → payment → ticket → check-in → cashup", ()
await page.getByRole("button", { name: "Register", exact: true }).click();
await page.waitForURL(/\/registration\/success/);
const tickets = await api<Ticket[]>(page, "user", "GET", "/api/tickets/mytickets");
const tickets = await v2<Ticket[]>(page, "user", "GET", "/api/v2/me/tickets");
expect(tickets.some((t) => t.eventId === seed().events.free)).toBe(true);
});
@@ -26,14 +26,14 @@ test.describe("registration → payment → ticket → check-in → cashup", ()
await page.getByRole("button", { name: "Register", exact: true }).click();
await page.waitForURL(/\/registration\/success/);
const regs = await api<Registration[]>(page, "user", "GET", "/api/registrations/myregistrations");
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 api<Ticket[]>(page, "user", "GET", "/api/tickets/mytickets")).some((t) => t.eventId === seed().events.paid)).toBe(false);
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 api(page, "supervisor", "POST", "/api/payments", { amount: 150, method: "cash", registrationId: reg!.id, eventId: seed().events.paid, userId: seed().users.user.id });
const ticket = (await api<Ticket[]>(page, "user", "GET", "/api/tickets/mytickets")).find((t) => t.eventId === seed().events.paid);
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.
@@ -41,11 +41,11 @@ test.describe("registration → payment → ticket → check-in → cashup", ()
await expect(page.getByText("E2E Paid Conference").first()).toBeVisible();
// Staff check it in; a second scan is refused.
await api(page, "staff", "POST", `/api/tickets/scan/${ticket!.qrCode}`, { qty: 1 });
await expect(api(page, "staff", "POST", `/api/tickets/scan/${ticket!.qrCode}`, { qty: 1 })).rejects.toThrow(/403.*fully used/);
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 api<CashByUser>(page, "supervisor", "GET", `/api/cashups/event/${seed().events.paid}/cash-by-user`);
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);