- /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>
52 lines
2.6 KiB
TypeScript
52 lines
2.6 KiB
TypeScript
import { test, expect, seed, loginAs, api, pickEvent, v2 } from "./fixtures";
|
|
|
|
test.describe("multi-day events", () => {
|
|
test("check-in is once per session, and the register and certificates follow", async ({ page }) => {
|
|
const { course, events } = seed();
|
|
|
|
// Scanning today: Week 2.
|
|
const scan = await v2<{ session: { label: string } }>(page, "staff", "POST", `/api/v2/checkin/${course.qrCode}`, { people: 1 });
|
|
expect(scan.session.label).toBe("Week 2");
|
|
expect(await v2(page, "staff", "POST", `/api/v2/checkin/${course.qrCode}`, { people: 1 })).toMatchObject({ outcome: "already_used", message: expect.stringMatching(/Already checked in for Week 2/) });
|
|
|
|
// The register shows weeks 1 and 2 ticked.
|
|
await loginAs(page, "supervisor");
|
|
await page.goto(`/dashboard/supervisor/attendance?eventId=${events.course}`);
|
|
const row = page.locator("tr", { hasText: "Thandi Test" });
|
|
await expect(row.getByText("2/5")).toBeVisible();
|
|
|
|
// Tick week 3 by hand (e.g. let in without a scan), then untick it.
|
|
const week3 = row.locator("td").nth(3).getByRole("button");
|
|
await week3.click();
|
|
await expect(row.getByText("3/5")).toBeVisible();
|
|
await week3.click();
|
|
await expect(row.getByText("2/5")).toBeVisible();
|
|
|
|
// Two sessions meets the rule (at least 2), so a certificate can be issued now.
|
|
await page.getByRole("button", { name: "Issue now" }).click();
|
|
await expect(page.getByText("1 certificate issued.")).toBeVisible();
|
|
const code = (await row.locator("span.font-mono").innerText()).trim();
|
|
expect(code).toMatch(/^[A-Z0-9]{5}-[A-Z0-9]{5}$/);
|
|
|
|
// Anyone can check it.
|
|
await page.goto(`/certificates/verify/${code}`);
|
|
await expect(page.getByRole("heading", { name: "Valid certificate" })).toBeVisible();
|
|
await expect(page.getByText("Thandi Test")).toBeVisible();
|
|
});
|
|
|
|
test("the attendee sees their certificate on My Events", async ({ page }) => {
|
|
await loginAs(page, "user");
|
|
await page.goto("/dashboard/user");
|
|
await expect(page.getByRole("heading", { name: "My Certificates" })).toBeVisible();
|
|
await expect(page.getByText("E2E Alpha Course").first()).toBeVisible();
|
|
});
|
|
|
|
test("the scanner offers today's session for a multi-day event", async ({ page }) => {
|
|
await loginAs(page, "staff");
|
|
await page.goto("/dashboard/staff/ticket-scanning");
|
|
await pickEvent(page, "E2E Alpha Course");
|
|
await expect(page.locator("select", { has: page.locator("option", { hasText: "Today's session" }) })).toBeVisible();
|
|
await expect(page.getByText("Today's session (Week 2)")).toBeAttached();
|
|
});
|
|
});
|