Merge branch 'main' into claude/reference-site-build

This commit is contained in:
Radosław Smoliński
2026-10-29 15:17:24 +01:00
27 changed files with 258 additions and 103 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/)
+29 -3
View File
@@ -48,8 +48,9 @@ describe('shipped CSS files', () => {
test('the preset maps every colour role and keeps the dark variant on data-theme', () => {
const preset = read('src/styles/tailwind.css')
// link-inverse / focus-inverse are read through the inverse scope, not by a utility
for (const role of Object.keys(COLOR_DEFAULTS).filter((r) => r !== 'link-inverse' && r !== 'focus-inverse')) {
// *-inverse roles are read through the inverse scope, not by a utility
const scoped = ['link-inverse', 'focus-inverse', 'primary-inverse', 'primary-inverse-text']
for (const role of Object.keys(COLOR_DEFAULTS).filter((r) => !scoped.includes(r))) {
expect(preset, role).toContain(`var(--ipal-${role})`)
}
expect(preset).toContain('@custom-variant dark (&:where([data-theme=dark], [data-theme=dark] *));')
@@ -127,10 +128,35 @@ describe('defineTokens / tokensToCss', () => {
expect(light).toEqual(dark)
const css = tokensToCss(tokens)
expect(css).toContain('color-scheme: dark;')
expect(css.match(/--ipal-bg: #070707;/g)).toHaveLength(2)
expect(css.match(/--ipal-bg: #070707;/g)).toHaveLength(1)
expect(css).toContain(':root, [data-theme="light"], :root[data-theme="dark"], [data-theme="dark"] {')
expect(contrastReport(tokens).every((r) => r.theme === 'dark')).toBe(true)
})
test('themes switch on any element, not only <html>', () => {
const defaults = defaultTokensCss()
expect(defaults).toContain(':root, [data-theme="light"] {')
expect(defaults).toContain(':root[data-theme="dark"], [data-theme="dark"] {')
const css = tokensToCss({ color: { dark: { bg: '#111' }, light: { bg: '#fefefe' } } })
expect(css).toMatch(/:root, \[data-theme="light"\] \{\n {2}--ipal-bg: #fefefe;/)
expect(css).toMatch(/:root\[data-theme="dark"\], \[data-theme="dark"\] \{\n {2}--ipal-bg: #111;/)
})
test('primary is re-mapped inside an inverted section and checked there', () => {
expect(defaultTokensCss()).toMatch(/\[data-surface="inverse"\] \{[^}]*--ipal-primary: var\(--ipal-primary-inverse\);/)
const darkBrand = { color: { light: { primary: 'oklch(0.3 0.08 150)' } } }
const warn = contrastReport(darkBrand).find((r) => r.scope === 'inverse' && r.fg === 'primary' && r.theme === 'light')
expect(warn).toMatchObject({ level: 'warn', pass: false })
// the dark theme's inverse surface is light: there the dark brand colour works again
const fixed = contrastReport({
color: {
dark: { 'primary-inverse': 'oklch(0.3 0.08 150)', 'primary-inverse-text': 'oklch(0.98 0 0)' },
light: { ...darkBrand.color.light, 'primary-inverse': 'oklch(0.85 0.1 150)', 'primary-inverse-text': 'oklch(0.2 0.05 150)' },
},
})
expect(fixed.filter((r) => r.scope === 'inverse' && !r.pass)).toEqual([])
})
test('the contrast report fails a low-contrast brand', () => {
const rows = contrastReport({ color: { light: { primary: '#ffeb3b', 'primary-text': '#ffffff' } } })
expect(rows.find((r) => r.theme === 'light' && r.fg === 'primary-text' && r.bg === 'primary')).toMatchObject({ pass: false })