import { test, expect, seed, loginAs, api } from "./fixtures"; type Registration = { id: string; eventId: string; registrationOptions: { sessionId?: string | null; priceSnapshot: 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: "+" }).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 api(page, "user", "GET", "/api/registrations/myregistrations"); const reg = regs.find((r) => r.eventId === seed().events.dropIn); expect(reg?.registrationOptions.filter((o) => o.sessionId)).toHaveLength(2); }); });