feat: complete CHRNX responsive content states

This commit is contained in:
chrnx committed 2026-08-12 08:42:20 -05:00
1 parent 9385c1b9fb
commit 5073178492
60 files changed
+1699 -22

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { test } from 'node:test';
const read = ( path ) => readFileSync( new URL( `../../${ path }`, import.meta.url ), 'utf8' );
test( 'local visual fixtures define stable pages and representative editorial states', () => {
const pages = JSON.parse( read( 'tests/fixtures/pages.json' ) );
const posts = JSON.parse( read( 'tests/fixtures/posts.json' ) );
assert.deepEqual(
pages.map( ( page ) => page.slug ),
[ 'home', 'journal', 'projects', 'music', 'podcasts', 'about', 'subscribe' ],
);
assert.ok( pages.every( ( page ) => page.fixtureKey && page.status === 'publish' ) );
assert.ok( posts.length >= 10 );
assert.ok( posts.some( ( post ) => post.title.length > 100 ) );
assert.ok( posts.some( ( post ) => post.content.includes( 'wp:code' ) ) );
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-media' ) );
assert.ok( posts.some( ( post ) => post.fixtureState === 'missing-podcast-meta' ) );
for ( const topic of [ 'code', 'research', 'gaming', 'literature', 'music', 'podcasts', 'life' ] ) {
assert.ok( posts.some( ( post ) => post.topic === topic ), `missing ${ topic } fixture` );
}
} );
test( 'the seed entrypoint is explicitly local-only and uses a stable fixture key', () => {
const shell = read( 'scripts/seed-test-content.sh' );
const php = read( 'scripts/seed-test-content.php' );
assert.match( shell, /localhost|127\.0\.0\.1/ );
assert.match( shell, /wp eval-file/ );
assert.match( php, /_chrnx_fixture_key/ );
assert.match( php, /show_on_front/ );
assert.match( php, /page_on_front/ );
assert.match( php, /page_for_posts/ );
} );
test( 'the visual layer is separately enqueued and covers responsive accessible states', () => {
const assets = read( 'inc/assets.php' );
const components = read( 'assets/css/components.css' );
assert.match( assets, /chrnx-components/ );
assert.match( components, /\.chrnx-section-portrait/ );
assert.match( components, /prefers-reduced-motion/ );
assert.match( components, /@media \(max-width: 599px\)/ );
assert.match( components, /html\[data-theme="light"\]/ );
} );
test( 'all approved portraits expose reproducible WebP and AVIF derivatives', () => {
for ( const topic of [ 'code', 'gaming', 'life', 'literature', 'podcasts', 'research' ] ) {
const manifest = JSON.parse( read( `assets/images/generated/alter-ego-${ topic }.json` ) );
assert.equal( manifest.source, `alter-ego-${ topic }.png` );
assert.deepEqual( manifest.formats, [ 'avif', 'webp' ] );
assert.deepEqual( manifest.widths, [ 384, 768 ] );
}
} );
test( 'front page and section pages connect the real editorial patterns', () => {
const front = read( 'templates/front-page.html' );
assert.match( front, /chrnx\/home-intro/ );
assert.match( front, /chrnx\/featured-stories/ );
assert.match( front, /chrnx\/journal-stream/ );
assert.match( front, /chrnx\/latest-podcast/ );
const fixtures = read( 'tests/fixtures/pages.json' );
for ( const slug of [ 'chrnx/about', 'chrnx/music-landing', 'chrnx/podcast-landing' ] ) {
assert.match( fixtures, new RegExp( slug.replace( '/', '\\/' ) ) );
}
} );