feat: complete CHRNX responsive content states
This commit is contained in:
60 files changed
+1699
-22
No files matched your search
@@ -2,13 +2,15 @@ import assert from 'node:assert/strict';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import test from 'node:test';
|
||||
|
||||
test( 'Playwright seeds editorial prerequisites once outside browser workers', async () => {
|
||||
test( 'Playwright seeds deterministic local fixtures once outside browser workers', async () => {
|
||||
const config = await readFile( 'playwright.config.mjs', 'utf8' );
|
||||
const setup = await readFile( 'tests/e2e/global-setup.mjs', 'utf8' );
|
||||
const seed = await readFile( 'scripts/seed-test-content.php', 'utf8' );
|
||||
const spec = await readFile( 'tests/e2e/editorial-editor.spec.mjs', 'utf8' );
|
||||
|
||||
assert.match( config, /globalSetup:\s*['"]\.\/tests\/e2e\/global-setup\.mjs['"]/ );
|
||||
assert.match( setup, /wp-env.*chrnx_seed_editorial_terms\(\);/s );
|
||||
assert.equal( setup.match( /chrnx_seed_editorial_terms/g )?.length, 1 );
|
||||
assert.match( setup, /execFileSync\(\s*['"]\.\/scripts\/seed-test-content\.sh['"]/s );
|
||||
assert.equal( setup.match( /seed-test-content\.sh/g )?.length, 1 );
|
||||
assert.equal( seed.match( /chrnx_seed_editorial_terms\(\);/g )?.length, 1 );
|
||||
assert.doesNotMatch( spec, /wp-env|execFileSync|beforeAll/ );
|
||||
} );
|
||||
@@ -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( '/', '\\/' ) ) );
|
||||
}
|
||||
} );
|
||||
Reference in new issue
Block a user