website 1.10.0: the home page laid out from its editor; photos that match the layout

- Pages → Home: each section's layout and background when it's open, and move up, move down
  and show or hide on its header. They save straight to the design, as Template and style →
  Home page layout does (which keeps them too). Shared lists in admin/layouts.ts.
- A section offers only the photo fields its layout shows: a slot for each (hero: 1 for Photo,
  Video and Split, 3 for Collage, none for Text only); Welcome's photo and pastor and the
  Invitation's photo only for the layouts that use them. Photos for other layouts are kept.
- e2e: the hero opens with /^Top of the page/; a new test for the editor's layout controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 08:56:08 +02:00
co-authored by Claude Opus 5.5
parent 101248195f
commit 8b1d1da5a9
12 changed files with 264 additions and 66 deletions
+49 -1
View File
@@ -191,7 +191,7 @@ test("move and zoom a photo in its frame, then delete a photo nothing uses", asy
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: /^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();
@@ -245,3 +245,51 @@ test("move and zoom a ministry's, a leader's and an event's photo", async ({ pag
await expect(page.getByText("Moved and zoomed to 200%")).toBeVisible();
}
});
test("on the home page: each section's layout, background, place and showing, and only the photos its layout shows", 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-]+$/);
const preview = page.frameLocator('iframe[title="Live preview of this page"]');
// The top of the page: a slot for each photo the layout shows (the demo has three photos).
await page.getByRole("button", { name: /^Top of the page/ }).click();
const layout = page.getByLabel("Top of the page (hero): layout");
await layout.selectOption("collage");
await expect(page.getByText("Photo 3 of 3")).toBeVisible();
await layout.selectOption("photo");
await expect(page.getByText("Photo 1 of 3")).toHaveCount(0);
await expect(page.getByText("2 more photos are kept for a layout that shows more.")).toBeVisible();
await layout.selectOption("text");
await expect(page.getByText("This layout shows no photos.")).toBeVisible();
await expect(preview.locator(".cc-section-hero img")).toHaveCount(0);
// The welcome: its photo fields follow its layout, and it takes a background.
await page.getByRole("button", { name: /^Welcome/ }).click();
const welcome = page.locator("section").filter({ has: page.getByRole("button", { name: /^Welcome/ }) }).last();
await page.getByLabel("Welcome: layout").selectOption("text");
await expect(welcome.getByText("Pastor's photo and quote")).toHaveCount(0);
await page.getByLabel("Welcome: layout").selectOption("pastor");
await expect(welcome.getByText("Pastor's photo and quote")).toBeVisible();
await page.getByLabel("Welcome: background").selectOption("brand");
await expect(page.getByLabel("Welcome: background")).toHaveValue("brand");
await page.screenshot({ path: "e2e/test-results/home-sections.png", fullPage: true });
// Hide it, show it, and move it.
await page.getByRole("button", { name: "Hide Welcome" }).click();
await expect(welcome.getByText("Not shown")).toBeVisible();
await page.getByRole("button", { name: "Show Welcome" }).click();
await expect(welcome.getByText("Not shown")).toHaveCount(0);
const order = async () => page.locator("main section > div > button").evaluateAll((els) => els.map((e) => e.textContent?.split("·")[0]?.trim() ?? ""));
const before = await order();
const at = before.findIndex((t) => t.startsWith("Welcome"));
await page.getByRole("button", { name: "Move Welcome up" }).click();
await expect.poll(async () => (await order()).findIndex((t) => t.startsWith("Welcome"))).toBe(at - 1);
// Template and style shows the same.
await page.goto("/admin/template");
await page.getByRole("tab", { name: "Home page layout" }).click();
await expect(page.getByLabel("Top of the page layout")).toHaveValue("text");
await expect(page.getByLabel("Welcome background")).toHaveValue("brand");
});