website 1.12.0: three layouts for each page that lists something
- PAGE_VARIANTS: ministriesPage alternating/cards/list, leadershipPage grid/featured/list, eventsPage list/cards/months, messagesPage grid/featured/list, contactPage columns/map/cards. Kept in the design's variants beside the homepage sections', so each template recommends some and starts a new site on the first (its suggestion), PUT /design checks them, and a template switch moves an untouched one. - A design saved before has none: cleanDesign gives it LEGACY_PAGE_LAYOUTS (the look until now), and the site draws a snapshot without them the same way, so nothing changes until a church picks one. Contact's map layout without a place on the map draws as two columns. Ministries and messages keep their #slug anchors in every layout. - Admin: the layout at the top of a listing page in Pages, the suggestion marked; Template and style gets an Other pages tab with all five. - Tests: backend (156, five new); e2e page-layouts.spec.ts (every layout in every template, axe at phone and desktop; 60 passed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Every listing page layout in every template (backend variants.ts PAGE_VARIANTS): the demo
|
||||
* church's Ministries, Leadership, Events, Messages and Contact pages, one layout at a time. Each
|
||||
* page answers, shows what it lists, keeps the anchors the homepage links to, and axe finds no
|
||||
* violations (WCAG 2.2 AA) at phone and desktop width.
|
||||
*
|
||||
* PAGE_SHOTS=<folder> also saves a full-page screenshot of each, to look through by eye.
|
||||
*/
|
||||
import AxeBuilder from "@axe-core/playwright";
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { PAGE_LAYOUT_KEYS, PAGE_VARIANTS, TEMPLATE_VARIANTS } from "../backend/src/site/variants.js";
|
||||
|
||||
const BACKEND = "http://127.0.0.1:5310";
|
||||
const TEMPLATES = Object.keys(TEMPLATE_VARIANTS) as (keyof typeof TEMPLATE_VARIANTS)[];
|
||||
const WIDTHS = [["phone", { width: 390, height: 844 }], ["desktop", { width: 1366, height: 900 }]] as const;
|
||||
const SHOTS = process.env.PAGE_SHOTS;
|
||||
|
||||
/** The demo's page for each layout key, and something it must show. */
|
||||
const PAGES: Record<(typeof PAGE_LAYOUT_KEYS)[number], { path: string; shows: string }> = {
|
||||
ministriesPage: { path: "/ministries", shows: "main [id] h2" },
|
||||
leadershipPage: { path: "/leadership", shows: "main article h2" },
|
||||
eventsPage: { path: "/events", shows: 'main a[href]:not([href^="#"])' },
|
||||
messagesPage: { path: "/messages", shows: "main [id] h2" },
|
||||
contactPage: { path: "/contact", shows: 'main a[href^="mailto:"]' },
|
||||
};
|
||||
|
||||
for (const template of TEMPLATES) {
|
||||
test.describe(`${template} page layouts`, () => {
|
||||
test.beforeAll(async ({ request }) => {
|
||||
expect((await request.post(`${BACKEND}/test/demo?template=${template}`)).ok()).toBeTruthy();
|
||||
});
|
||||
|
||||
for (const key of PAGE_LAYOUT_KEYS) {
|
||||
for (const layout of PAGE_VARIANTS[key]) {
|
||||
test(`${key}: ${layout}`, async ({ page }) => {
|
||||
const res = await page.request.post(`${BACKEND}/test/design`, { data: { variants: { [key]: layout } } });
|
||||
expect(res.ok()).toBeTruthy();
|
||||
const { path, shows } = PAGES[key];
|
||||
for (const [name, size] of WIDTHS) {
|
||||
await page.setViewportSize(size);
|
||||
expect((await page.goto(path))?.status()).toBe(200);
|
||||
await expect(page.locator("html")).toHaveAttribute("data-template", template);
|
||||
await expect(page.locator(shows).first()).toBeVisible();
|
||||
const axe = await new AxeBuilder({ page }).withTags(["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"]).analyze();
|
||||
expect(axe.violations.map((v) => `${v.id} (${v.nodes.length}) ${v.nodes[0]?.target}`), name).toEqual([]);
|
||||
if (SHOTS) await page.screenshot({ path: `${SHOTS}/${template}-${key}-${layout}-${name}.png`, fullPage: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user