Files
joshuaandClaude Opus 5.5 3f59164ab2 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>
2026-11-02 16:35:06 +02:00

53 lines
2.8 KiB
TypeScript

import { test, expect, seed, api, loginAs, API, v2 } from "./fixtures";
// Campus-scoped staff (1.44.0): the seeded staff member and supervisor are limited to E2E South
// for these tests; afterwards the limits are cleared and campuses turned off again.
test.describe("campus-scoped staff", () => {
test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
await v2(page, "admin", "PUT", "/api/v2/campuses/enabled", { enabled: true });
for (const role of ["staff", "supervisor"] as const) {
await v2(page, "admin", "PATCH", `/api/v2/users/${seed().users[role].id}`, { scopedCampusIds: [seed().campuses.south.id] });
}
await page.close();
});
test.afterAll(async ({ browser }) => {
const page = await browser.newPage();
for (const role of ["staff", "supervisor"] as const) {
await v2(page, "admin", "PATCH", `/api/v2/users/${seed().users[role].id}`, { scopedCampusIds: [] });
}
await v2(page, "admin", "PUT", "/api/v2/campuses/enabled", { enabled: false });
await page.close();
});
test("the scanner refuses another campus's ticket and says which campus", async ({ page }) => {
const scan = (qr: string) => page.request.get(`${API}/api/v2/checkin/${encodeURIComponent(qr)}`, { headers: { Authorization: `Bearer ${seed().users.staff.token}` } });
const north = await scan(seed().northTicketQr);
expect(north.status()).toBe(403);
expect((await north.json()).error.message).toBe("This ticket is for an event at E2E North.");
// The course is for all campuses, so it scans.
expect((await scan(seed().course.qrCode)).status()).toBe(200);
});
test("a scoped supervisor sees their campus and church-wide events, and can't edit church-wide ones", async ({ page }) => {
await loginAs(page, "supervisor");
await page.goto("/dashboard/supervisor");
await expect(page.getByText("You work with E2E South, and events for all campuses.")).toBeVisible();
await page.goto("/dashboard/supervisor/events");
await expect(page.getByText("E2E Paid Conference")).toBeVisible(); // South
await expect(page.getByText("E2E Alpha Course")).toBeVisible(); // all campuses
await expect(page.getByText("E2E Free Evening")).toBeHidden(); // North
await page.getByText("E2E Alpha Course").click();
await expect(page.getByText(/This is an event for all campuses — only admins and supervisors for every campus can change it/)).toBeVisible();
await expect(page.getByRole("button", { name: "Save Changes" })).toBeDisabled();
});
test("another campus's registrations are not found for a scoped supervisor", async ({ page }) => {
const res = await page.request.get(`${API}/api/v2/events/${seed().events.free}/registrations`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
expect(res.status()).toBe(404);
});
});