Website 1.7.0: move and zoom photos in their frame; delete unused photos

- A section's photo (hero, welcome, invitation, image-text) shows in the
  shape of its frame for the current template and layout, with a Move and
  zoom dialog: drag or arrow keys to choose what stays in view, zoom to
  300%. Saved with the section as data.framing ({ x, y, zoom } by media
  id), a draft until published. The site draws it with object-position
  and scale() around that point; Bold split/collage frames now clip, and
  a zoomed photo stays inside Heritage's mat. Framing for photos a section
  no longer shows is dropped on save.
- Media library: each photo says where it's used; one used nowhere can be
  deleted with its files (DELETE /admin/media/:id, 409 IN_USE otherwise,
  audited as media_deleted).

Checked: Website backend tests (135) and typecheck, frontend typecheck,
lint and production build, and an e2e test of both flows in Chromium.
Lighthouse not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 23:34:10 +02:00
co-authored by Claude Opus 5.5
parent 25100bd749
commit a9215ac4e4
22 changed files with 494 additions and 50 deletions
+39
View File
@@ -185,3 +185,42 @@ test("the admin's screens are accessible", async ({ page, context }) => {
const axe = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"]).analyze();
expect(axe.violations.map((v) => `editor: ${v.id} (${v.nodes.length}) ${v.nodes[0]?.target}`)).toEqual([]);
});
test("move and zoom a photo in its frame, then delete a photo nothing uses", async ({ page, context }) => {
await signIn(context);
await page.goto("/admin/pages");
await page.getByRole("link", { name: /^Home\b/ }).first().click();
await expect(page).toHaveURL(/\/admin\/pages\/[0-9a-f-]+$/);
await page.getByRole("button", { name: /Top of the page/ }).click();
await page.getByRole("button", { name: "Move and zoom" }).first().click();
const dialog = page.getByRole("dialog", { name: "Move and zoom the photo" });
await expect(dialog).toBeVisible();
await dialog.getByRole("slider").fill("2");
const box = (await dialog.getByLabel(/in its frame/).boundingBox())!;
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
await page.mouse.down();
await page.mouse.move(box.x + box.width / 2 + 80, box.y + box.height / 2 + 30, { steps: 5 });
await page.mouse.up();
await dialog.getByRole("button", { name: "Done" }).click();
await expect(page.getByText("Moved and zoomed to 200%")).toBeVisible();
await page.getByRole("button", { name: "Save", exact: true }).click();
await expect(page.getByText("Saved as a draft.")).toBeVisible();
// The live preview draws it the same way.
const frame = page.frameLocator('iframe[title="Live preview of this page"]');
await expect(frame.locator(".cc-section-hero img").first()).toHaveAttribute("style", /scale\(2\)/);
await page.screenshot({ path: "e2e/test-results/framing.png" });
// Upload one nothing uses, then delete it; one in use says where instead.
await page.goto("/admin/media");
const before = await page.locator("main li").count();
const png = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==", "base64");
await page.locator('input[type="file"]').setInputFiles({ name: "dot.png", mimeType: "image/png", buffer: png });
await page.getByLabel("What the photo shows").fill("A dot to delete");
await page.getByRole("button", { name: "Upload" }).click();
await expect(page.locator("main li")).toHaveCount(before + 1);
await expect(page.getByText("Used on:").first()).toBeVisible();
page.once("dialog", (d) => d.accept());
await page.locator("main li").filter({ has: page.locator('input[value="A dot to delete"]') }).getByRole("button", { name: "Delete" }).click();
await expect(page.getByText("Deleted.")).toBeVisible();
await expect(page.locator("main li")).toHaveCount(before);
});