Block library: fixes from the first visual test on the reference site

- CMSLink: a link that wraps content (a logo, a card) and leads nowhere keeps the
  content — an empty link group ({ type: 'internal' }) no longer hides logos
- entryList: field `collection` → `entryCollection` (Mongoose reserves
  `collection`; unreleased, snapshot updated) + a test against reserved names
- post template starts with a page hero holding the title (the page's h1)
- legal and cookie policy templates set noindex: true (AGENT.md §0c)
- hero background: a full bg-overlay scrim under the text
- MediaValue accepts any object (generated Media types fit without a cast)
- contact: Turnstile renders dark in an inverted section

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 15:03:39 +01:00
co-authored by Claude Opus 5.5
parent 51f80cea13
commit 29ede3ad4b
12 changed files with 85 additions and 30 deletions
+1 -1
View File
@@ -1300,7 +1300,7 @@
"header.intro": {
"type": "textarea"
},
"collection": {
"entryCollection": {
"type": "select",
"required": true,
"options": [
+20 -1
View File
@@ -119,6 +119,17 @@ describe('faqItemsFromLayout', () => {
})
})
describe('field names', () => {
// Mongoose (MongoDB adapter — every live site) reserves these path names and warns on every start.
const MONGOOSE_RESERVED = ['collection', 'db', 'emit', 'errors', 'get', 'init', 'isModified', 'isNew', 'listeners', 'modelName', 'on', 'once', 'populated', 'prototype', 'remove', 'removeListener', 'save', 'schema', 'set', 'toObject', 'validate']
test('no block uses a name Mongoose reserves', () => {
const offending = blockLibraryManifest.blocks.flatMap((b) =>
b.fields.filter((f) => f.path.split(/\[\]\.|\./).some((seg) => MONGOOSE_RESERVED.includes(seg))).map((f) => `${b.slug}.${f.path}`),
)
expect(offending).toEqual([])
})
})
describe('blockLibraryManifest', () => {
test('lists every block with its variants and fields, the primitives, builders and templates', () => {
expect(blockLibraryManifest.blocks.map((b) => b.slug)).toEqual(LIBRARY_BLOCK_SLUGS)
@@ -167,7 +178,7 @@ describe('page templates', () => {
return
}
for (const [k, x] of Object.entries(o)) {
if (['$form', '$page', 'appearance', 'blockType', 'collection', 'columns', 'limit', 'mode', 'show', 'type', 'variant'].includes(k)) {continue}
if (['$form', '$page', 'appearance', 'blockType', 'columns', 'entryCollection', 'limit', 'mode', 'show', 'type', 'variant'].includes(k)) {continue}
if (typeof x === 'string') {problems.push(`${where}.${k} = "${x}"`)}
else {walk(x, `${where}.${k}`)}
}
@@ -176,6 +187,14 @@ describe('page templates', () => {
expect(problems).toEqual([])
})
test('post: the title is the page header (the only h1); legal pages are noindex', () => {
const page = pageTemplates.post({ title: { en: 'Hello', pl: 'Cześć' } })
expect(page.layout[0]).toMatchObject({ blockType: 'hero', header: { heading: { en: 'Hello', pl: 'Cześć' } }, variant: 'page' })
expect(pageTemplates.legal('privacyPolicy').noindex).toBe(true)
expect(pageTemplates.cookiePolicy().noindex).toBe(true)
expect(pageTemplates.home().noindex).toBeUndefined()
})
test('buttons link to pages by their slug in the default locale', () => {
const json = JSON.stringify(pageTemplates.home())
expect(json).toContain('{"$page":"kontakt"}')
+9 -1
View File
@@ -57,7 +57,7 @@ const header = { eyebrow: 'Eyebrow', heading: 'Section heading', intro: 'Intro t
const SAMPLES: Record<string, Record<string, unknown>> = {
contact: { content: null, form: { id: 'f1', confirmationType: 'message', fields: [{ name: 'name', blockType: 'text', label: 'Name', required: true }], submitButtonLabel: 'Send', title: 'Contact form' }, variant: 'formOnly' },
cta: { links, media: image(), variant: 'band' },
entryList: { collection: 'posts', limit: 3, links, mode: 'latest', variant: 'cards' },
entryList: { entryCollection: 'posts', limit: 3, links, mode: 'latest', variant: 'cards' },
faq: { items: [{ id: 'q1', answer: 'Yes, we do.', question: 'Do you ship?' }], links, variant: 'single' },
featureGrid: { columns: 'three', items: [{ id: 'i1', heading: 'Fast', link: { type: 'internal', page: { slug: 'fast' } }, media: image(), text: 'Quick delivery' }], links, variant: 'cards' },
gallery: { columns: 'three', items: [{ id: 'g1', caption: 'Kitchen', media: image('Kitchen') }, { id: 'g2', media: image('Hall') }], variant: 'grid' },
@@ -180,6 +180,14 @@ describe('block details', () => {
expect(await render(block('logos'))).toContain('alt="Acme"')
})
test('a link that wraps a logo but leads nowhere keeps the logo (an empty link group is stored as { type })', async () => {
const html = await render(block('logos', { items: [{ id: 'o1', heading: 'Acme', link: { type: 'internal' }, media: image('') }] }))
expect(html).toContain('alt="Acme"')
expect(html).not.toContain('<a')
const linked = await render(block('logos', { items: [{ id: 'o1', heading: 'Acme', link: { type: 'internal', page: { slug: 'acme' } }, media: image('') }] }))
expect(linked).toMatch(/<a[^>]*href="\/pl\/acme"[^>]*><img[^>]*alt="Acme"/)
})
test('testimonials: figure/blockquote/figcaption; the rating has a text equivalent per language', async () => {
const en = await render(block('testimonials'))
expect(en).toMatch(/<figure[^>]*>[\s\S]*<blockquote[^>]*>Great work\.<\/blockquote>[\s\S]*<figcaption/)