Manage registrations: tick registrations (or all shown) and message them (email/WhatsApp event update), mark them paid (the balance, by method), move them to another ticket (same tickets and QR codes, repriced, places checked), put their people in a room or group, export to Excel, or cancel. Each runs the same handlers as doing it one at a time, with a result per registration. POST /api/registrations/bulk, campus-checked per id. Migration 20261028170000_registrations_bulk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
4.5 KiB
TypeScript
87 lines
4.5 KiB
TypeScript
import { test, expect, loginAs, api } from "./fixtures";
|
|
|
|
// Bulk actions on the registrations list (1.49.1): tick several, mark them paid, move them to
|
|
// another ticket, cancel — each through the same rules as one at a time.
|
|
type Ev = { id: string; eventOptions?: { id: string; name: string; isMainTicket?: boolean }[] };
|
|
type Reg = { id: string; status: string; registrationOptions?: { eventOptionId: string; quantity: number }[]; payments?: { amount: number; method: string }[] };
|
|
|
|
test.describe.serial("bulk actions on registrations", () => {
|
|
let event: Ev;
|
|
let main: string;
|
|
let vip: string;
|
|
const regs: string[] = [];
|
|
|
|
test.beforeAll(async ({ browser }) => {
|
|
const page = await browser.newPage();
|
|
const start = new Date(Date.now() + 20 * 864e5);
|
|
event = await api<Ev>(page, "admin", "POST", "/api/events", {
|
|
title: "E2E Bulk Night", startDate: start.toISOString(), endDate: new Date(start.getTime() + 3 * 3600e3).toISOString(),
|
|
price: 100, location: "Church hall",
|
|
});
|
|
const full = await api<Ev>(page, "admin", "GET", `/api/events/${event.id}`);
|
|
main = full.eventOptions!.find(o => o.isMainTicket)!.id;
|
|
vip = (await api<{ id: string }>(page, "admin", "POST", `/api/events/${event.id}/options`, { name: "VIP", price: 150, isMainTicket: true })).id;
|
|
for (const role of ["staff", "supervisor", "user"] as const) {
|
|
regs.push((await api<{ id: string }>(page, role, "POST", "/api/registrations", { eventId: event.id, options: [{ eventOptionId: main, quantity: 1 }] })).id);
|
|
}
|
|
await page.close();
|
|
});
|
|
|
|
const openList = async (page: import("@playwright/test").Page) => {
|
|
await loginAs(page, "admin");
|
|
await page.goto(`/dashboard/admin/registrations?event=${event.id}`);
|
|
await expect(page.getByText("3 of", { exact: false })).toBeVisible();
|
|
};
|
|
|
|
test("tick all and mark them paid in cash", async ({ page }) => {
|
|
await openList(page);
|
|
await page.getByLabel("Select all shown").check();
|
|
const bar = page.getByTestId("bulk-bar");
|
|
await expect(bar).toContainText("3 selected");
|
|
await bar.getByLabel("Bulk action").selectOption("markPaid");
|
|
await bar.getByLabel("Paid by").selectOption("cash");
|
|
page.once("dialog", d => d.accept());
|
|
await bar.getByRole("button", { name: /Mark paid/ }).click();
|
|
await expect(page.getByTestId("bulk-result")).toContainText("3 done");
|
|
|
|
for (const id of regs) {
|
|
const r = await api<Reg>(page, "admin", "GET", `/api/registrations/${id}`);
|
|
expect(r.status).toBe("paid");
|
|
expect(r.payments?.map(p => [p.amount, p.method])).toEqual([[100, "cash"]]);
|
|
}
|
|
});
|
|
|
|
test("move two to the VIP ticket; cancel the third", async ({ page }) => {
|
|
await openList(page);
|
|
const rows = page.locator("li").filter({ has: page.getByRole("checkbox", { name: /^Select / }) });
|
|
await rows.nth(0).getByRole("checkbox").check();
|
|
await rows.nth(1).getByRole("checkbox").check();
|
|
const bar = page.getByTestId("bulk-bar");
|
|
await bar.getByLabel("Bulk action").selectOption("moveOption");
|
|
await bar.getByLabel("Move from").selectOption(main);
|
|
await bar.getByLabel("Move to").selectOption(vip);
|
|
page.once("dialog", d => d.accept());
|
|
await bar.getByRole("button", { name: /Move to another ticket/ }).click();
|
|
await expect(page.getByTestId("bulk-result")).toContainText("2 done");
|
|
|
|
const moved = await Promise.all(regs.map(id => api<Reg>(page, "admin", "GET", `/api/registrations/${id}`)));
|
|
const onVip = moved.filter(r => r.registrationOptions?.some(o => o.eventOptionId === vip));
|
|
expect(onVip).toHaveLength(2);
|
|
// R150 now, R100 paid: they owe the difference.
|
|
expect(onVip.every(r => r.status === "partial_paid")).toBe(true);
|
|
|
|
await bar.getByRole("button", { name: "Clear selection" }).click();
|
|
const left = moved.find(r => !r.registrationOptions?.some(o => o.eventOptionId === vip))!;
|
|
await page.getByRole("checkbox", { name: /^Select / }).nth(2).check();
|
|
const selectedId = (await api<Reg>(page, "admin", "GET", `/api/registrations/${left.id}`)).id;
|
|
expect(selectedId).toBe(left.id);
|
|
const bar2 = page.getByTestId("bulk-bar");
|
|
await bar2.getByLabel("Bulk action").selectOption("cancel");
|
|
page.once("dialog", d => d.accept());
|
|
await bar2.getByRole("button", { name: /Cancel — 1/ }).click();
|
|
await expect(page.getByTestId("bulk-result")).toContainText("1 done");
|
|
const cancelled = (await Promise.all(regs.map(id => api<Reg>(page, "admin", "GET", `/api/registrations/${id}`)))).filter(r => r.status === "cancelled");
|
|
expect(cancelled).toHaveLength(1);
|
|
});
|
|
});
|