Admin -> Users 'Limit to campuses'; staff campus pickers, reports, dashboards and audience picker follow the scope (useMyCampuses); scoped people pick one of their campuses for new events, and church-wide / other campuses' events open read-only; 'You work with ...' note; warning before turning campuses off while staff are limited. e2e: scanner refusal naming the campus, scoped events list and read-only editor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.8 KiB
TypeScript
53 lines
2.8 KiB
TypeScript
import { test, expect, seed, api, loginAs, API } 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 api(page, "admin", "PUT", "/api/campuses/settings", { enabled: true });
|
|
for (const role of ["staff", "supervisor"] as const) {
|
|
await api(page, "admin", "PUT", `/api/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 api(page, "admin", "PUT", `/api/users/${seed().users[role].id}`, { scopedCampusIds: [] });
|
|
}
|
|
await api(page, "admin", "PUT", "/api/campuses/settings", { 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/tickets/scan-preview/${encodeURIComponent(qr)}`, { headers: { Authorization: `Bearer ${seed().users.staff.token}` } });
|
|
const north = await scan(seed().northTicketQr);
|
|
expect(north.status()).toBe(403);
|
|
expect((await north.json()).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/registrations/event/${seed().events.free}`, { headers: { Authorization: `Bearer ${seed().users.supervisor.token}` } });
|
|
expect(res.status()).toBe(404);
|
|
});
|
|
});
|