The rest of event set-up on API v2 (1.51.8)
- v2: event in full, calendar file, alias, ticket options and variants, attachments (multipart), sections, planned costs, image uploads. - src/services/eventDetails.ts and src/services/setup.ts; v1 uses them. - v2 routes can send files (fileResponse) and take uploads (documented as multipart). - Frontend: fetchEvent() everywhere, lib/eventSetup.ts for set-up calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -116,6 +116,38 @@ test.describe("API v2", () => {
|
||||
expect((await (await request.delete(`${API}/api/v2/events/${ev.id}`, { headers: admin })).json()).data).toEqual({ id: ev.id, isActive: false });
|
||||
});
|
||||
|
||||
test("an event in full, its calendar file, ticket options, sections and costs", async ({ request }) => {
|
||||
const sup = { Authorization: `Bearer ${seed().users.supervisor.token}` };
|
||||
const admin = { Authorization: `Bearer ${seed().users.admin.token}` };
|
||||
const full = (await (await request.get(`${API}/api/v2/events/${seed().events.conference}/full`)).json()).data;
|
||||
expect(full.eventOptions.length).toBeGreaterThan(0);
|
||||
expect(full).toHaveProperty("attachments");
|
||||
// The public don't see who gets the emails; staff do.
|
||||
expect(full.notifyRecipients).toBeUndefined();
|
||||
expect((await (await request.get(`${API}/api/v2/events/${seed().events.conference}/full`, { headers: sup })).json()).data).toHaveProperty("notifyRecipients");
|
||||
|
||||
const ics = await request.get(`${API}/api/v2/events/${seed().events.conference}/calendar.ics`);
|
||||
expect(ics.headers()["content-type"]).toContain("text/calendar");
|
||||
expect(await ics.text()).toContain("BEGIN:VCALENDAR");
|
||||
|
||||
const opt = (await (await request.post(`${API}/api/v2/events/${seed().events.conference}/ticket-options`, { headers: sup, data: { name: "E2E v2 Extra", price: 25 } })).json()).data;
|
||||
expect(opt).toMatchObject({ name: "E2E v2 Extra", price: 25, isMainTicket: false });
|
||||
const withVariant = (await (await request.patch(`${API}/api/v2/ticket-options/${opt.id}`, { headers: sup, data: { variants: [{ name: "Large", price: 30 }] } })).json()).data;
|
||||
expect(withVariant.variants.map((v: { name: string }) => v.name)).toEqual(["Large"]);
|
||||
expect((await request.delete(`${API}/api/v2/ticket-options/${opt.id}`, { headers: sup })).status()).toBe(403);
|
||||
expect((await (await request.delete(`${API}/api/v2/ticket-options/${opt.id}`, { headers: admin })).json()).data).toEqual({ id: opt.id, deleted: true });
|
||||
|
||||
const section = (await (await request.post(`${API}/api/v2/sections`, { headers: sup, data: { eventId: seed().events.conference, name: "E2E Side door", allowedOptionIds: [full.eventOptions[0].id] } })).json()).data;
|
||||
expect(section.allowedOptions).toHaveLength(1);
|
||||
const listed = (await (await request.get(`${API}/api/v2/sections?eventId=${seed().events.conference}`, { headers: sup })).json()).data;
|
||||
expect(listed.map((x: { id: string }) => x.id)).toContain(section.id);
|
||||
|
||||
const cost = await request.post(`${API}/api/v2/events/${seed().events.conference}/costs`, { headers: admin, data: { label: "E2E Hall", costType: "once_off", amount: 500 } });
|
||||
expect(cost.status()).toBe(201);
|
||||
const costs = (await (await request.get(`${API}/api/v2/events/${seed().events.conference}/costs`, { headers: sup })).json()).data;
|
||||
expect(costs.map((c: { label: string }) => c.label)).toContain("E2E Hall");
|
||||
});
|
||||
|
||||
test("an admin can read the OpenAPI reference at /docs/v2", async ({ page, request }) => {
|
||||
const headers = { Authorization: `Bearer ${seed().users.user.token}` };
|
||||
expect((await request.get(`${API}/api/v2/openapi.json`, { headers })).status()).toBe(403);
|
||||
|
||||
Reference in New Issue
Block a user