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:
@@ -121,6 +121,10 @@ describe('editing, publishing, discarding, restoring (§4)', () => {
|
||||
assert.equal(r.body.design.variants.hero, 'video', 'moved to Bold\'s default');
|
||||
assert.ok(r.body.moved.some((m: { what: string }) => m.what === 'hero.variant'));
|
||||
assert.equal((await as.put('/design', { variants: { hero: 'spinning' } })).status, 400);
|
||||
const pages = await as.put('/design', { variants: { messagesPage: 'list' } });
|
||||
assert.equal(pages.status, 200, 'a listing page has a layout too');
|
||||
assert.equal(pages.body.design.variants.messagesPage, 'list');
|
||||
assert.equal((await as.put('/design', { variants: { messagesPage: 'months' } })).status, 400, "an events layout isn't a messages one");
|
||||
assert.equal((await as.put('/design', { style: { header: 'centred' } })).status, 400, 'a Heritage header on Bold');
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { WEBSITE_TEMPLATES } from '@crosscode/contracts';
|
||||
import {
|
||||
SECTION_TYPES, SECTION_VARIANTS, TEMPLATE_HEADERS, TEMPLATE_HOME_ORDER, TEMPLATE_STYLE, TEMPLATE_VARIANTS,
|
||||
LEGACY_PAGE_LAYOUTS, PAGE_LAYOUT_KEYS, PAGE_VARIANTS, SECTION_TYPES, SECTION_VARIANTS, TEMPLATE_HEADERS, TEMPLATE_HOME_ORDER, TEMPLATE_STYLE, TEMPLATE_VARIANTS,
|
||||
defaultDesign, defaultVariant, headerIsTransparent, isRecommended, isVariant, switchTemplate,
|
||||
} from '../src/site/variants.js';
|
||||
import { cleanDesign } from '../src/site/snapshot.js';
|
||||
@@ -103,6 +103,44 @@ describe('switching template', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('listing page layouts', () => {
|
||||
it('has at least three layouts for each listing page, and every template suggests real ones', () => {
|
||||
assert.deepEqual(PAGE_LAYOUT_KEYS, ['ministriesPage', 'leadershipPage', 'eventsPage', 'messagesPage', 'contactPage']);
|
||||
for (const k of PAGE_LAYOUT_KEYS) assert.ok(PAGE_VARIANTS[k].length >= 3, k);
|
||||
for (const t of WEBSITE_TEMPLATES) {
|
||||
for (const k of PAGE_LAYOUT_KEYS) {
|
||||
const rec = TEMPLATE_VARIANTS[t][k] as readonly string[];
|
||||
assert.ok(rec.length >= 2, `${t}.${k}`);
|
||||
assert.equal(new Set(rec).size, rec.length, `${t}.${k} repeats`);
|
||||
for (const v of rec) assert.ok(isVariant(k, v), `${t}.${k}: ${v}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it("starts a new site on the template's suggestion", () => {
|
||||
assert.equal(defaultDesign('community').variants.ministriesPage, 'cards');
|
||||
assert.equal(defaultDesign('bold').variants.contactPage, 'map');
|
||||
assert.equal(defaultDesign('clean').variants.messagesPage, 'list');
|
||||
});
|
||||
|
||||
it('keeps the look a design had before page layouts, until the church picks one', () => {
|
||||
const before = cleanDesign({ template: 'community', variants: { hero: 'photo' }, home: [], style: {} });
|
||||
assert.deepEqual(PAGE_LAYOUT_KEYS.map((k) => before.variants[k]), PAGE_LAYOUT_KEYS.map((k) => LEGACY_PAGE_LAYOUTS[k]));
|
||||
const picked = cleanDesign({ template: 'community', variants: { eventsPage: 'months' }, home: [], style: {} });
|
||||
assert.equal(picked.variants.eventsPage, 'months');
|
||||
assert.equal(picked.variants.ministriesPage, 'cards', 'the rest take the suggestion');
|
||||
assert.equal(cleanDesign({ template: 'clean', variants: { eventsPage: 'nope' }, home: [], style: {} }).variants.eventsPage, 'list');
|
||||
});
|
||||
|
||||
it('moves with a template switch when untouched, and stays when chosen', () => {
|
||||
const start = defaultDesign('heritage');
|
||||
start.variants.eventsPage = 'cards';
|
||||
const { design } = switchTemplate(start, 'community');
|
||||
assert.equal(design.variants.eventsPage, 'cards');
|
||||
assert.equal(design.variants.ministriesPage, 'cards', "moved from Heritage's list to Community's cards");
|
||||
});
|
||||
});
|
||||
|
||||
describe("a section's own background", () => {
|
||||
it('stays with its section through a template switch, whether the order moves or not', () => {
|
||||
const start = defaultDesign('heritage');
|
||||
|
||||
Reference in New Issue
Block a user