f7a0c8618f
CI / build (push) Has been cancelled
Event photos and videos are now stored only on the NFS/local share named in Settings -> Media storage. Uploads, photo editing, video processing and the per-event filing step refuse to run until that share is configured and writable, so nothing is silently written inside the container. Video originals, renditions, posters and sidecars share one folder on the share. Also adds volunteer growth goals with a mentor queue, an admin retention and storage sweep with a cron entry point, cached gallery thumbnails with per-folder ZIP downloads, a server-rendered booth-sheet PDF, and in-app confirm/release for every upcoming assignment. Service reminders now ignore the one-off event reminder rule, which had been queueing an extra bogus reminder for each published service. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
188 lines
7.3 KiB
TypeScript
188 lines
7.3 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { signInAs, resetDb, BASE } from "./dev";
|
|
|
|
/**
|
|
* Growth goals, the mentor queue, retention, and the server-rendered booth
|
|
* sheet. These surfaces turn existing rules/data into screens, so the point of
|
|
* this suite is that a volunteer can ask, a coordinator can resolve, and the
|
|
* derived artifacts (sweep report, PDF) are really produced.
|
|
*/
|
|
test.describe("growth goals and maintenance", () => {
|
|
test.beforeAll(async ({ browser }) => {
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
await resetDb(page);
|
|
await context.close();
|
|
});
|
|
|
|
test("volunteer requests a goal and admin resolves it in the mentor queue", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1280, height: 1000 });
|
|
await signInAs(page, "jordan@glenloch.local");
|
|
await page.goto(`${BASE}/profile`);
|
|
|
|
await expect(page.getByText("Growth goals", { exact: true })).toBeVisible();
|
|
|
|
const skillSelect = page.getByLabel("Skill", { exact: true });
|
|
const audio = skillSelect
|
|
.locator("option")
|
|
.filter({ hasText: /^Audio/ })
|
|
.first();
|
|
const audioValue = await audio.getAttribute("value");
|
|
expect(audioValue, "the seed should include an Audio skill").toBeTruthy();
|
|
await skillSelect.selectOption(audioValue!);
|
|
await page.getByLabel("Target level").selectOption("expert");
|
|
await page.getByRole("button", { name: "Request goal" }).click();
|
|
|
|
await expect(
|
|
page.getByText("Goal requested. A coordinator will pair you with a mentor."),
|
|
).toBeVisible();
|
|
await expect(page.getByText("Waiting for a mentor")).toBeVisible();
|
|
|
|
// The coordinator sees the same goal and can act on it.
|
|
await signInAs(page, "admin@glenloch.local");
|
|
await page.goto(`${BASE}/admin`);
|
|
await expect(page.getByText("Mentor queue", { exact: true })).toBeVisible();
|
|
await expect(
|
|
page.getByText(/Jordan.*Audio/).first(),
|
|
).toBeVisible();
|
|
|
|
await page.getByRole("button", { name: "Decline" }).first().click();
|
|
// The confirmation toast is transient (the page refreshes immediately), so
|
|
// assert the durable outcome instead.
|
|
await expect(page.getByText("No open growth goals.")).toBeVisible();
|
|
|
|
// Persisted: the volunteer now sees the declined state, not a pending goal.
|
|
await signInAs(page, "jordan@glenloch.local");
|
|
await page.goto(`${BASE}/profile`);
|
|
await expect(page.getByText("Declined", { exact: true })).toBeVisible();
|
|
});
|
|
|
|
test("admin sees retention counts and can run the sweep", async ({ page }) => {
|
|
await page.setViewportSize({ width: 1280, height: 1000 });
|
|
await signInAs(page, "admin@glenloch.local");
|
|
await page.goto(`${BASE}/admin`);
|
|
|
|
await expect(page.getByText("Retention & storage", { exact: true })).toBeVisible();
|
|
await expect(page.getByText("Upload volume", { exact: true })).toBeVisible();
|
|
|
|
const before = await page.request.get(`${BASE}/api/dev/retention`);
|
|
expect(before.ok(), "retention summary should require and accept an admin").toBe(true);
|
|
const summary = (await before.json()) as {
|
|
summary: { notifications: { total: number }; thresholds: { notificationDays: number } };
|
|
};
|
|
expect(summary.summary.thresholds.notificationDays).toBeGreaterThan(0);
|
|
|
|
await page.getByRole("button", { name: "Prune now" }).click();
|
|
await expect(
|
|
page.getByText(/Removed \d+ notification rows|Sweep complete/),
|
|
).toBeVisible();
|
|
});
|
|
|
|
test("booth sheet downloads as a real PDF", async ({ page }) => {
|
|
await signInAs(page, "admin@glenloch.local");
|
|
|
|
const res = await page.request.get(`${BASE}/api/dev/schedule/instances`);
|
|
expect(res.ok()).toBe(true);
|
|
const body = (await res.json()) as { instances: { id: string }[] };
|
|
const instance = body.instances[0];
|
|
expect(instance, "the seed should include a service instance").toBeTruthy();
|
|
|
|
const pdf = await page.request.get(
|
|
`${BASE}/api/run-sheet/${instance.id}/pdf`,
|
|
);
|
|
expect(pdf.status()).toBe(200);
|
|
expect(pdf.headers()["content-type"]).toContain("application/pdf");
|
|
expect(pdf.headers()["content-disposition"]).toContain("booth-sheet");
|
|
const bytes = await pdf.body();
|
|
expect(bytes.subarray(0, 5).toString()).toBe("%PDF-");
|
|
expect(bytes.length).toBeGreaterThan(1000);
|
|
});
|
|
|
|
test("media uploads and editing stay blocked until media storage is set", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1280, height: 1000 });
|
|
await signInAs(page, "admin@glenloch.local");
|
|
|
|
const archiveRoot = process.env.ARCHIVE_DIR ?? "/tmp/glenloch-e2e-archive";
|
|
// A writable path with no named share is not enough: the app must never
|
|
// fall back to storing event media inside the container.
|
|
const cleared = await page.request.put(`${BASE}/api/dev/storage`, {
|
|
data: { nfsShare: "", archivePath: archiveRoot, archiveFolder: "E2E Gate" },
|
|
});
|
|
expect(cleared.ok()).toBe(true);
|
|
|
|
const eventResponse = await page.request.post(`${BASE}/api/events`, {
|
|
data: {
|
|
title: "E2E storage gate",
|
|
eventType: "photoshoot",
|
|
startsAtLocal: "2026-11-22T10:00",
|
|
location: "Main campus",
|
|
},
|
|
});
|
|
expect(eventResponse.ok()).toBe(true);
|
|
const eventId = ((await eventResponse.json()) as { event: { id: string } })
|
|
.event.id;
|
|
const folderResponse = await page.request.post(
|
|
`${BASE}/api/events/${eventId}/folders`,
|
|
{ data: { name: "Originals", kind: "originals" } },
|
|
);
|
|
expect(folderResponse.ok()).toBe(true);
|
|
const folderId = (
|
|
(await folderResponse.json()) as { folder: { id: string } }
|
|
).folder.id;
|
|
|
|
const photo = await page.request.post(
|
|
`${BASE}/api/events/${eventId}/folders/${folderId}/photos?name=blocked.jpg`,
|
|
{
|
|
headers: { "content-type": "image/jpeg" },
|
|
data: Buffer.from([0xff, 0xd8, 0xff, 0xd9]),
|
|
},
|
|
);
|
|
expect(photo.status()).toBe(503);
|
|
expect(((await photo.json()) as { error: string }).error).toContain(
|
|
"No media storage share",
|
|
);
|
|
|
|
const video = await page.request.post(
|
|
`${BASE}/api/events/${eventId}/videos?name=blocked.mp4`,
|
|
{
|
|
headers: { "content-type": "video/mp4" },
|
|
data: Buffer.from("not-a-video"),
|
|
},
|
|
);
|
|
expect(video.status()).toBe(409);
|
|
expect(((await video.json()) as { error: string }).error).toContain(
|
|
"No media storage share",
|
|
);
|
|
|
|
await page.goto(`${BASE}/events/${eventId}/folders/${folderId}`);
|
|
await expect(page.getByRole("alert").first()).toContainText(
|
|
"Photo uploads and editing are disabled",
|
|
);
|
|
await page.goto(`${BASE}/events/${eventId}`);
|
|
await expect(page.getByRole("alert").first()).toContainText(
|
|
"Photo and video uploads are disabled",
|
|
);
|
|
|
|
// Leave a working destination behind for the specs that upload media.
|
|
const restored = await page.request.put(`${BASE}/api/dev/storage`, {
|
|
data: {
|
|
nfsShare: "e2e-nas:/export/church",
|
|
archivePath: archiveRoot,
|
|
archiveFolder: "E2E Archive",
|
|
},
|
|
});
|
|
expect(restored.ok()).toBe(true);
|
|
|
|
// With a usable share the Media page reports the archive's usage.
|
|
await page.goto(`${BASE}/media`);
|
|
await expect(
|
|
page.getByText("Original media storage", { exact: true }),
|
|
).toBeVisible();
|
|
await expect(page.getByText(/\bused of\b.*\bfree$/)).toBeVisible();
|
|
});
|
|
});
|