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>
151 lines
4.8 KiB
TypeScript
151 lines
4.8 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { access, mkdir, readFile, readdir, rm } from "node:fs/promises";
|
|
import path from "node:path";
|
|
import sharp from "sharp";
|
|
import { signInAs, resetDb, BASE } from "./dev";
|
|
|
|
/**
|
|
* The finish-workflow APIs: save an edit, export a delivery size, archive the
|
|
* event to the mounted destination, and remove the live event only after the
|
|
* archive is complete. Runs against the isolated `media_e2e` database.
|
|
*/
|
|
|
|
const ARCHIVE_ROOT = process.env.ARCHIVE_DIR ?? "/tmp/glenloch-e2e-archive";
|
|
const ARCHIVE_FOLDER = "E2E Archive";
|
|
// Live photos sit on the configured share too, under `<share>/<folder>/events`.
|
|
const MEDIA_ROOT = path.join(ARCHIVE_ROOT, ARCHIVE_FOLDER);
|
|
|
|
let photoBytes: Buffer;
|
|
|
|
test.beforeAll(async ({ browser }) => {
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
await resetDb(page);
|
|
await context.close();
|
|
|
|
photoBytes = await sharp({
|
|
create: {
|
|
width: 1200,
|
|
height: 800,
|
|
channels: 3,
|
|
background: { r: 80, g: 120, b: 160 },
|
|
},
|
|
})
|
|
.jpeg({ quality: 95 })
|
|
.toBuffer();
|
|
|
|
await mkdir(ARCHIVE_ROOT, { recursive: true });
|
|
await rm(path.join(ARCHIVE_ROOT, ARCHIVE_FOLDER), {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
});
|
|
|
|
test("exports a delivery size, then archives and removes the event", async ({
|
|
page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1200, height: 900 });
|
|
await signInAs(page, "admin@glenloch.local");
|
|
|
|
const configured = await page.request.put(`${BASE}/api/dev/storage`, {
|
|
data: {
|
|
nfsShare: "e2e-nas:/export/church",
|
|
archivePath: ARCHIVE_ROOT,
|
|
archiveFolder: ARCHIVE_FOLDER,
|
|
},
|
|
});
|
|
expect(configured.ok()).toBe(true);
|
|
const storage = (await configured.json()) as { status?: { ready: boolean } };
|
|
expect(storage.status?.ready).toBe(true);
|
|
|
|
const eventResponse = await page.request.post(`${BASE}/api/events`, {
|
|
data: {
|
|
title: "E2E archive workflow",
|
|
eventType: "photoshoot",
|
|
startsAtLocal: "2026-11-20T10:00",
|
|
location: "Main campus",
|
|
},
|
|
});
|
|
expect(eventResponse.ok()).toBe(true);
|
|
const event = (await eventResponse.json()) as { event: { id: string } };
|
|
|
|
const folderResponse = await page.request.post(
|
|
`${BASE}/api/events/${event.event.id}/folders`,
|
|
{ data: { name: "Originals", kind: "originals" } },
|
|
);
|
|
expect(folderResponse.ok()).toBe(true);
|
|
const folder = (await folderResponse.json()) as { folder: { id: string } };
|
|
|
|
const upload = await page.request.post(
|
|
`${BASE}/api/events/${event.event.id}/folders/${folder.folder.id}/photos?name=archive-test.jpg`,
|
|
{
|
|
headers: { "content-type": "image/jpeg" },
|
|
data: photoBytes,
|
|
},
|
|
);
|
|
expect(upload.ok()).toBe(true);
|
|
const uploaded = (await upload.json()) as { photo: { id: string } };
|
|
|
|
const edit = await page.request.post(
|
|
`${BASE}/api/events/${event.event.id}/folders/${folder.folder.id}/photos/${uploaded.photo.id}/edit`,
|
|
{
|
|
data: {
|
|
adjustments: {
|
|
exposure: 0.4,
|
|
contrast: 8,
|
|
blackPoint: 0,
|
|
brightness: 0,
|
|
curves: [
|
|
{ x: 0, y: 0 },
|
|
{ x: 1, y: 1 },
|
|
],
|
|
},
|
|
},
|
|
},
|
|
);
|
|
expect(edit.ok()).toBe(true);
|
|
|
|
const exported = await page.request.get(
|
|
`${BASE}/api/events/${event.event.id}/folders/${folder.folder.id}/photos/${uploaded.photo.id}/export?size=640`,
|
|
);
|
|
expect(exported.ok()).toBe(true);
|
|
expect(exported.headers()["content-disposition"]).toContain(
|
|
"archive-test-640.jpg",
|
|
);
|
|
const exportMeta = await sharp(await exported.body()).metadata();
|
|
expect(exportMeta.width).toBe(640);
|
|
expect(exportMeta.height).toBe(427);
|
|
|
|
const archived = await page.request.post(
|
|
`${BASE}/api/events/${event.event.id}/archive`,
|
|
);
|
|
expect(archived.ok()).toBe(true);
|
|
const archive = (await archived.json()) as {
|
|
archivePath: string;
|
|
files: number;
|
|
};
|
|
expect(archive.files).toBe(3);
|
|
|
|
const manifest = JSON.parse(
|
|
await readFile(path.join(archive.archivePath, "manifest.json"), "utf8"),
|
|
) as {
|
|
photos: { original: string; edited: string | null; editJson: string | null }[];
|
|
};
|
|
expect(manifest.photos).toHaveLength(1);
|
|
expect(manifest.photos[0].original).toContain("archive-test.jpg");
|
|
expect(manifest.photos[0].edited).toContain("archive-test-edited.jpg");
|
|
expect(manifest.photos[0].editJson).toContain('"exposure":0.4');
|
|
|
|
const entries = await readdir(archive.archivePath, { recursive: true });
|
|
expect(entries.some((entry) => entry.endsWith("archive-test.jpg"))).toBe(true);
|
|
expect(
|
|
entries.some((entry) => entry.endsWith("archive-test-edited.jpg")),
|
|
).toBe(true);
|
|
|
|
const gone = await page.goto(`${BASE}/events/${event.event.id}`);
|
|
expect(gone?.status()).toBe(404);
|
|
await expect(
|
|
access(path.join(MEDIA_ROOT, "events", event.event.id)),
|
|
).rejects.toThrow();
|
|
});
|