Campuses frontend, docs and e2e (1.43.0)
Site settings -> Campuses tab; campus picker in the event editor; campus filter and badges on the events list, public events page (remembered, starts on home campus) and reports/dashboards; /campus/<slug> pages and sitemap; home campus on the profile; "Everyone at a campus" in email and WhatsApp broadcasts. Help, FEATURES, SETTINGS, API docs, protocol doc (campusCount), handover and roadmap updated; campuses seeded for e2e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { test, expect, seed, api, API } from "./fixtures";
|
||||
|
||||
// Multi-campus. The campuses and the two events' campuses are seeded (e2e/support/prepare-db.js)
|
||||
// with campuses off; these tests turn them on, and off again afterwards so the other specs see a
|
||||
// single-campus church.
|
||||
test.describe("campuses", () => {
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
await api(page, "admin", "PUT", "/api/campuses/settings", { enabled: true });
|
||||
await page.close();
|
||||
});
|
||||
|
||||
test.afterAll(async ({ browser }) => {
|
||||
const page = await browser.newPage();
|
||||
await api(page, "admin", "PUT", "/api/campuses/settings", { enabled: false });
|
||||
await page.close();
|
||||
});
|
||||
|
||||
test("the events page filters by campus and keeps church-wide events", async ({ page }) => {
|
||||
await page.goto("/events");
|
||||
await expect(page.getByText("E2E Paid Conference")).toBeVisible();
|
||||
await page.getByLabel("Campus").selectOption({ label: "E2E North" });
|
||||
await expect(page.getByText("E2E Free Evening")).toBeVisible(); // North
|
||||
await expect(page.getByText("E2E Alpha Course")).toBeVisible(); // all campuses
|
||||
await expect(page.getByText("E2E Paid Conference")).toBeHidden(); // South
|
||||
// The choice is remembered.
|
||||
await page.reload();
|
||||
await expect(page.getByLabel("Campus")).toHaveValue(seed().campuses.north.id);
|
||||
await expect(page.getByText("E2E Paid Conference")).toBeHidden();
|
||||
});
|
||||
|
||||
test("a campus has its own page", async ({ page }) => {
|
||||
await page.goto(`/campus/${seed().campuses.north.slug}`);
|
||||
await expect(page.getByRole("heading", { name: "E2E North" })).toBeVisible();
|
||||
await expect(page.getByText("1 North Road")).toBeVisible();
|
||||
await expect(page.getByText("E2E Free Evening")).toBeVisible();
|
||||
await expect(page.getByText("E2E Paid Conference")).toBeHidden();
|
||||
});
|
||||
|
||||
test("a campus with events can't be deleted", async ({ page }) => {
|
||||
const res = await page.request.delete(`${API}/api/campuses/${seed().campuses.north.id}`, { headers: { Authorization: `Bearer ${seed().users.admin.token}` } });
|
||||
expect(res.status()).toBe(409);
|
||||
expect((await res.json()).code).toBe("CAMPUS_HAS_EVENTS");
|
||||
});
|
||||
});
|
||||
@@ -6,6 +6,7 @@ export type Role = "admin" | "supervisor" | "staff" | "user";
|
||||
export type Seed = {
|
||||
users: Record<Role, { id: string; name: string; email: string; token: string }>;
|
||||
events: { free: string; paid: string; course: string; dropIn: string; conference: string };
|
||||
campuses: Record<"north" | "south", { id: string; slug: string }>;
|
||||
course: { sessions: { id: string; label: string }[]; ticketId: string; qrCode: string };
|
||||
unsubscribeToken: string;
|
||||
newsPromptUser: { id: string; token: string };
|
||||
|
||||
@@ -68,8 +68,14 @@ async function seed(url) {
|
||||
return d;
|
||||
};
|
||||
|
||||
// Multi-campus: two campuses with campuses switched off (campuses.spec.ts turns them on).
|
||||
// Seeded here rather than in the test so pages built before the tests already carry them.
|
||||
const north = await prisma.campus.create({ data: { name: 'E2E North', slug: 'e2e-north', address: '1 North Road', order: 0 } });
|
||||
const south = await prisma.campus.create({ data: { name: 'E2E South', slug: 'e2e-south', order: 1 } });
|
||||
|
||||
const free = await prisma.event.create({
|
||||
data: {
|
||||
campusId: north.id,
|
||||
title: 'E2E Free Evening', description: 'A free evening for the tests.', startDate: at(1), endDate: at(1, 19),
|
||||
price: 0, location: '1 Test Street, Pretoria', createdById: users.supervisor.id,
|
||||
eventOptions: { create: [{ name: 'Entry', price: 0, isMainTicket: true }] },
|
||||
@@ -77,6 +83,7 @@ async function seed(url) {
|
||||
});
|
||||
const paid = await prisma.event.create({
|
||||
data: {
|
||||
campusId: south.id,
|
||||
title: 'E2E Paid Conference', description: 'A paid one-day conference.', startDate: at(3, 7), endDate: at(3, 15),
|
||||
price: 150, location: '1 Test Street, Pretoria', createdById: users.supervisor.id,
|
||||
eventOptions: { create: [{ name: 'Conference ticket', price: 150, isMainTicket: true }] },
|
||||
@@ -156,6 +163,7 @@ async function seed(url) {
|
||||
const out = {
|
||||
users: Object.fromEntries(Object.entries(users).map(([k, u]) => [k, { id: u.id, name: u.name, email: u.email, token: generateToken(u.id, u.role, u.tokenVersion || 0) }])),
|
||||
events: { free: free.id, paid: paid.id, course: course.id, dropIn: dropIn.id, conference: conference.id },
|
||||
campuses: { north: { id: north.id, slug: north.slug }, south: { id: south.id, slug: south.slug } },
|
||||
course: { sessions: course.sessions.map(s => ({ id: s.id, label: s.label })), ticketId: ticket.id, qrCode: ticket.qrCode },
|
||||
// An account that has never answered the news question (asked once after login).
|
||||
newsPromptUser: await (async () => {
|
||||
|
||||
Reference in New Issue
Block a user