Files
chrnx-dev-wp/tests/smoke/visual-integration.test.mjs
T

569 lines
25 KiB
JavaScript

import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import {
chmodSync,
existsSync,
linkSync,
lstatSync,
mkdtempSync,
readFileSync,
readdirSync,
rmSync,
statSync,
symlinkSync,
unlinkSync,
writeFileSync,
} from 'node:fs';
import { execFileSync } from 'node:child_process';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
const read = ( path ) => readFileSync( new URL( `../../${ path }`, import.meta.url ), 'utf8' );
const PODCAST_BACKGROUND_SOURCE = 'assets/images/podcast-frequency-grunge.png';
const sha256 = ( path ) => createHash( 'sha256' ).update( readFileSync( path ) ).digest( 'hex' );
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.equal( posts.length, 12 );
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' ) );
const hasState = ( post, state ) => post.fixtureState === state || post.fixtureStates?.includes( state );
assert.ok( posts.some( ( post ) => hasState( post, 'missing-podcast-meta' ) ) );
assert.ok( posts.some( ( post ) => hasState( post, 'missing-excerpt' ) && !( 'excerpt' in post ) ) );
assert.ok( posts.some( ( post ) => hasState( post, 'missing-topic' ) && !( 'topic' in post ) ) );
assert.ok( posts.some( ( post ) => hasState( post, 'missing-language' ) && !( 'language' in post ) ) );
assert.ok( posts.some( ( post ) => post.fixtureState === 'unbroken-code' && /[A-Z0-9]{256}/.test( post.content ) ) );
assert.ok( posts.some( ( post ) => /^https:\/\//.test( post.canonicalEpisodeUrl ?? '' ) ) );
assert.ok( posts.some( ( post ) => hasState( post, 'missing-podcast-meta' ) && !( 'canonicalEpisodeUrl' in post ) ) );
assert.equal( new Set( posts.map( ( post ) => post.fixtureKey ) ).size, posts.length );
const incompletePodcast = posts.find( ( post ) => post.fixtureKey === 'post-podcast-missing-meta' );
assert.equal( incompletePodcast?.topic, 'podcasts' );
assert.equal( incompletePodcast?.language, 'es' );
assert.ok( !( 'show' in incompletePodcast ) && !( 'canonicalEpisodeUrl' in incompletePodcast ) );
assert.ok( hasState( incompletePodcast, 'missing-excerpt' ) );
assert.ok( posts.some( ( post ) => post.fixtureKey !== incompletePodcast.fixtureKey && hasState( post, 'missing-topic' ) && !( 'topic' in post ) ) );
assert.ok( posts.some( ( post ) => post.fixtureKey !== incompletePodcast.fixtureKey && hasState( post, 'missing-language' ) && !( 'language' in post ) ) );
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( shell, /featured-1/ );
assert.match( shell, /subscribe-unavailable/ );
assert.match( php, /_chrnx_fixture_key/ );
assert.match( php, /wp_delete_post/ );
assert.match( php, /canonical_episode_url/ );
assert.match( php, /show_on_front/ );
assert.match( php, /page_on_front/ );
assert.match( php, /page_for_posts/ );
} );
test( 'search and not-found recovery landmarks declare distinct accessible names', () => {
const search = read( 'templates/search.html' );
const missing = read( 'templates/404.html' );
assert.match( search, /"ariaLabel":"Search recovery navigation"/ );
assert.match( missing, /"ariaLabel":"Page not found recovery navigation"/ );
assert.notEqual( search.match( /"ariaLabel":"([^"]+)"/ )?.[ 1 ], missing.match( /"ariaLabel":"([^"]+)"/ )?.[ 1 ] );
} );
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( 'editorial review capture stays bounded to approved pages, variants, and filenames', () => {
const capture = read( 'scripts/capture-visual-review.mjs' );
for ( const target of [ 'home', 'music', 'post', 'footer' ] ) {
assert.match( capture, new RegExp( `name: '${ target }'` ) );
}
assert.match( capture, /path: '\/'/ );
assert.match( capture, /path: '\/music\/'/ );
assert.match( capture, /path: '\/una-cuerda-rota-tambien-puede-decidir-el-arreglo\/'/ );
assert.match( capture, /selector: 'footer\.wp-block-template-part'/ );
for ( const variant of [ 'desktop-dark', 'desktop-light', 'mobile-dark', 'mobile-light' ] ) {
assert.match( capture, new RegExp( `name: '${ variant }'` ) );
}
assert.match(
capture,
/`editorial-polish-\$\{\s*target\.name\s*\}-\$\{\s*variant\.name\s*\}\.png`/,
);
assert.doesNotMatch( capture, /name: 'topic-|name: 'podcasts'|name: 'about'/ );
} );
test( 'editorial review capture isolates browser compositing between theme variants', () => {
const capture = read( 'scripts/capture-visual-review.mjs' );
assert.ok(
capture.indexOf( 'const browser = await chromium.launch()' ) >
capture.indexOf( 'async function capture' ),
'Chromium must launch inside capture so a dark render cannot corrupt the next light screenshot',
);
assert.match(
capture,
/const browser = await chromium\.launch\(\);[\s\S]*?try \{[\s\S]*?finally \{\s*await browser\.close\(\);\s*\}/,
'Every isolated browser must close even when navigation or capture fails',
);
} );
test( 'the page canvas is atmospheric rather than a repeating grid', () => {
const components = read( 'assets/css/components.css' );
assert.doesNotMatch(
components,
/linear-gradient\([^)]*1px,\s*transparent\s+1px\)[\s\S]*linear-gradient\(90deg,[^)]*1px,\s*transparent\s+1px\)/,
);
assert.doesNotMatch(
components,
/background-size:\s*[^;]*(?:2|3)rem\s+(?:2|3)rem(?:\s*,\s*(?:2|3)rem\s+(?:2|3)rem)?/,
);
} );
test( 'lower home sections preserve editorial order and define layered panel treatments', () => {
const front = read( 'templates/front-page.html' );
const homeMusic = read( 'patterns/home-music.php' );
const components = read( 'assets/css/components.css' );
const orderedSections = [
'chrnx/home-projects',
'chrnx/home-music',
'chrnx/latest-podcast',
'chrnx-home-about-preview',
'chrnx/subscribe-cta',
];
let previousIndex = -1;
for ( const section of orderedSections ) {
const currentIndex = front.indexOf( section );
assert.ok( currentIndex > previousIndex, `${ section } must keep its semantic position` );
previousIndex = currentIndex;
}
assert.match( homeMusic, /chrnx_get_topic_portrait_markup\( 'music-collage'/ );
assert.match( homeMusic, /chrnx-character-stage__atmosphere/ );
assert.doesNotMatch( components, /url\([^)]*the-no-names-collage\.jpeg/ );
assert.match(
components,
/\.chrnx-home-music \.wp-block-column:last-child \.chrnx-responsive-portrait\s*\{[\s\S]*?(?:filter|box-shadow|mask(?:-image)?):/,
);
for ( const selector of [
'.chrnx-home-projects',
'.chrnx-latest-podcast',
'.chrnx-home-about-preview',
'.chrnx-subscribe-cta',
] ) {
const escapedSelector = selector.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
assert.match(
components,
new RegExp( `${ escapedSelector }[^,{]*\\{[\\s\\S]*?background(?:-color|-image)?:` ),
`${ selector } needs an authored surface`,
);
}
} );
test( 'all approved responsive media rebuild byte-identically within payload bounds', () => {
const readme = read( 'README.md' );
const documentedCommand = 'mktemp -d "${TMPDIR:-/tmp}/chrnx-responsive.XXXXXX"';
assert.ok( readme.includes( documentedCommand ) );
const output = execFileSync( 'sh', [ '-c', documentedCommand ], { encoding: 'utf8' } ).trim();
const unsafeOutput = join( output, 'unsafe-output' );
const external = mkdtempSync( join( tmpdir(), 'chrnx-external-' ) );
const symlink = join( tmpdir(), `chrnx-symlink-${ process.pid }` );
try {
assert.throws( () => execFileSync( './scripts/build-responsive-images.sh', [ unsafeOutput ], { cwd: new URL( '../..', import.meta.url ) } ) );
writeFileSync( join( external, 'sentinel' ), 'unchanged' );
symlinkSync( external, symlink );
assert.throws( () => execFileSync( './scripts/build-responsive-images.sh', [ symlink ], { cwd: new URL( '../..', import.meta.url ) } ) );
assert.deepEqual( readdirSync( external ), [ 'sentinel' ] );
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: new URL( '../..', import.meta.url ) } );
const names = readdirSync( output ).sort();
assert.equal( names.length, 52 );
for ( const name of [
'alter-ego-gaming-half-body-384.avif',
'alter-ego-gaming-half-body-384.webp',
'alter-ego-gaming-half-body-768.avif',
'alter-ego-gaming-half-body-768.webp',
'alter-ego-gaming-half-body.json',
'the-no-names-collage-384.avif',
'the-no-names-collage-384.webp',
'the-no-names-collage-768.avif',
'the-no-names-collage-768.webp',
'the-no-names-collage.json',
'podcast-frequency-grunge-384.avif',
'podcast-frequency-grunge-384.webp',
'podcast-frequency-grunge-768.avif',
'podcast-frequency-grunge-768.webp',
'podcast-frequency-grunge-1536.avif',
'podcast-frequency-grunge-1536.webp',
'podcast-frequency-grunge.json',
] ) {
assert.ok( names.includes( name ), `missing ${ name }` );
}
assert.deepEqual(
JSON.parse( readFileSync( join( output, 'podcast-frequency-grunge.json' ), 'utf8' ) ),
{
source: 'podcast-frequency-grunge.png',
formats: [ 'avif', 'webp' ],
widths: [ 384, 768, 1536 ],
},
);
let total = 0;
let collageTotal = 0;
let gamingHalfBodyTotal = 0;
let podcastTotal = 0;
for ( const name of names ) {
const generated = readFileSync( join( output, name ) );
const committed = readFileSync( new URL( `../../assets/images/generated/${ name }`, import.meta.url ) );
assert.deepEqual( generated, committed, `${ name } must rebuild byte-identically` );
if ( /\.(?:avif|webp)$/.test( name ) ) {
const binarySize = statSync( join( output, name ) ).size;
const expectedWidth = Number( name.match( /-(384|768|1536)\.(?:avif|webp)$/ )[ 1 ] );
const binaryLimit = expectedWidth === 1536 ? 260 * 1024 : 160 * 1024;
assert.ok( binarySize <= binaryLimit, `${ name } exceeds ${ binaryLimit } bytes: ${ binarySize } bytes` );
const dimensions = execFileSync( 'sips', [ '-g', 'pixelWidth', '-g', 'pixelHeight', join( output, name ) ], { encoding: 'utf8' } );
assert.match( dimensions, new RegExp( `pixelWidth: ${ expectedWidth }` ) );
assert.match( dimensions, /pixelHeight: [1-9][0-9]*/ );
if ( name.endsWith( '.webp' ) ) {
assert.equal( generated.subarray( 0, 4 ).toString(), 'RIFF' );
assert.equal( generated.subarray( 8, 12 ).toString(), 'WEBP' );
} else {
assert.equal( generated.subarray( 4, 12 ).toString(), 'ftypavif' );
}
total += generated.length;
if ( name.startsWith( 'the-no-names-collage-' ) ) {
collageTotal += generated.length;
}
if ( name.startsWith( 'alter-ego-gaming-half-body-' ) ) {
gamingHalfBodyTotal += generated.length;
}
if ( name.startsWith( 'podcast-frequency-grunge-' ) ) {
podcastTotal += generated.length;
}
}
}
assert.ok( collageTotal <= 400 * 1024, `collage family exceeds 400 KiB: ${ collageTotal } total bytes` );
assert.ok(
gamingHalfBodyTotal <= 340 * 1024,
`gaming half-body family exceeds 340 KiB: ${ gamingHalfBodyTotal } total bytes`,
);
assert.ok(
podcastTotal <= 620 * 1024,
`podcast-frequency-grunge family exceeds 620 KiB: ${ podcastTotal } total bytes`,
);
assert.ok( total <= 2.75 * 1024 * 1024, `generated binary payload exceeds 2.75 MiB: ${ total } total bytes` );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( external, { recursive: true, force: true } );
rmSync( symlink, { force: true } );
}
} );
test( 'responsive rebuild replaces output aliases without mutating external files or the master', () => {
const output = mkdtempSync( join( tmpdir(), 'chrnx-alias-output-' ) );
const external = mkdtempSync( join( tmpdir(), 'chrnx-alias-external-' ) );
const projectRoot = new URL( '../..', import.meta.url );
const master = new URL( `../../${ PODCAST_BACKGROUND_SOURCE }`, import.meta.url );
const symlinkSentinel = join( external, 'symlink-sentinel.webp' );
const hardlinkSentinel = join( external, 'hardlink-sentinel.webp' );
const symlinkOutput = join( output, 'podcast-frequency-grunge-384.webp' );
const hardlinkOutput = join( output, 'podcast-frequency-grunge-768.webp' );
const symlinkBytes = Buffer.from( 'external-symlink-sentinel' );
const hardlinkBytes = Buffer.from( 'external-hardlink-sentinel' );
const masterHash = sha256( master );
let hardlinkSupported = false;
try {
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: projectRoot } );
writeFileSync( symlinkSentinel, symlinkBytes );
writeFileSync( hardlinkSentinel, hardlinkBytes );
const symlinkHash = sha256( symlinkSentinel );
const hardlinkHash = sha256( hardlinkSentinel );
unlinkSync( symlinkOutput );
symlinkSync( symlinkSentinel, symlinkOutput );
unlinkSync( hardlinkOutput );
try {
linkSync( hardlinkSentinel, hardlinkOutput );
hardlinkSupported = true;
} catch ( error ) {
if ( ! [ 'ENOTSUP', 'EOPNOTSUPP', 'EXDEV' ].includes( error.code ) ) {
throw error;
}
}
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: projectRoot } );
assert.equal( sha256( symlinkSentinel ), symlinkHash );
assert.equal( lstatSync( symlinkOutput ).isSymbolicLink(), false );
assert.equal( lstatSync( symlinkOutput ).isFile(), true );
assert.notEqual( statSync( symlinkOutput ).ino, statSync( symlinkSentinel ).ino );
if ( hardlinkSupported ) {
assert.equal( sha256( hardlinkSentinel ), hardlinkHash );
assert.equal( lstatSync( hardlinkOutput ).isSymbolicLink(), false );
assert.equal( lstatSync( hardlinkOutput ).isFile(), true );
assert.notEqual( statSync( hardlinkOutput ).ino, statSync( hardlinkSentinel ).ino );
}
assert.equal( sha256( master ), masterHash );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( external, { recursive: true, force: true } );
}
} );
test( 'encoder failure cannot partially replace an existing responsive inventory', () => {
const output = mkdtempSync( join( tmpdir(), 'chrnx-failure-output-' ) );
const fakeBin = mkdtempSync( join( tmpdir(), 'chrnx-fake-bin-' ) );
const projectRoot = new URL( '../..', import.meta.url );
const master = new URL( `../../${ PODCAST_BACKGROUND_SOURCE }`, import.meta.url );
const masterHash = sha256( master );
const fakeCwebp = join( fakeBin, 'cwebp' );
const counter = join( fakeBin, 'counter' );
try {
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: projectRoot } );
const published = new Map( readdirSync( output ).map( ( name ) => [ name, sha256( join( output, name ) ) ] ) );
writeFileSync(
fakeCwebp,
`#!/bin/sh
set -eu
count=0
if [ -f "$CHRNX_TEST_CWEBP_COUNTER" ]; then
count=$(cat "$CHRNX_TEST_CWEBP_COUNTER")
fi
count=$((count + 1))
printf '%s\n' "$count" > "$CHRNX_TEST_CWEBP_COUNTER"
if [ "$count" -eq 3 ]; then
exit 73
fi
output=
while [ "$#" -gt 0 ]; do
if [ "$1" = "-o" ]; then
shift
output=$1
fi
shift
done
printf 'partial-build-%s\n' "$count" > "$output"
`,
);
chmodSync( fakeCwebp, 0o755 );
assert.throws( () =>
execFileSync( './scripts/build-responsive-images.sh', [ output ], {
cwd: projectRoot,
env: {
...process.env,
PATH: `${ fakeBin }:${ process.env.PATH }`,
CHRNX_TEST_CWEBP_COUNTER: counter,
},
} ),
);
assert.deepEqual( readdirSync( output ).sort(), [ ...published.keys() ].sort() );
assert.equal( readFileSync( counter, 'utf8' ).trim(), '3' );
for ( const [ name, hash ] of published ) {
assert.equal( sha256( join( output, name ) ), hash, `${ name } changed after encoder failure` );
}
assert.equal( sha256( master ), masterHash );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( fakeBin, { recursive: true, force: true } );
}
} );
test( 'post-card CSS fallbacks never reuse approved section portraits', () => {
const components = read( 'assets/css/components.css' );
assert.doesNotMatch( components, /url\([^)]*(?:alter-ego-|the-no-names-musician-cutout)/ );
} );
test( 'podcast background source uses fixed art and stays separate from card fallbacks', () => {
assert.ok(
existsSync( new URL( `../../${ PODCAST_BACKGROUND_SOURCE }`, import.meta.url ) ),
`missing ${ PODCAST_BACKGROUND_SOURCE }`,
);
const artAllowlist = read( 'inc/queries.php' );
assert.match( artAllowlist, /'podcast-frequency'\s*=>\s*'podcast-frequency-grunge\.png'/ );
for ( const path of [
'assets/css/components.css',
'blocks/featured-stories/style.css',
'blocks/journal-stream/style.css',
'blocks/latest-podcast/style.css',
'blocks/related-posts/style.css',
] ) {
assert.doesNotMatch(
read( path ),
/podcast-frequency-grunge\.png/,
`${ PODCAST_BACKGROUND_SOURCE } must not become a card fallback in ${ path }`,
);
}
} );
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( '/', '\\/' ) ) );
}
} );
test( 'character-led openings share the exact stage class contract', () => {
for ( const path of [
'patterns/home-projects.php',
'patterns/home-music.php',
'patterns/music-landing.php',
'patterns/podcast-landing.php',
'patterns/about.php',
'blocks/topic-hero/render.php',
] ) {
const source = read( path );
const stageDeclaration = path.startsWith( 'patterns/' )
? /className":"chrnx-character-stage"/g
: /class="chrnx-character-stage"/g;
assert.equal( ( source.match( stageDeclaration ) || [] ).length, 1, path );
for ( const className of [
'chrnx-character-stage__atmosphere',
'chrnx-character-stage__content',
'chrnx-character-stage__art',
] ) {
assert.match( source, new RegExp( className ), `${ path } missing ${ className }` );
}
}
const musicLanding = read( 'patterns/music-landing.php' );
assert.match( musicLanding, /chrnx_get_topic_portrait_markup\( 'music-collage', __\( 'The No Names collage', 'chrnx' \), 'chrnx-character-stage__collage' \)/ );
assert.doesNotMatch( musicLanding, /<img\s+src=/ );
assert.match( read( 'patterns/about.php' ), /chrnx-character-facets/ );
assert.match( read( 'blocks/topic-hero/render.php' ), /chrnx-topic-hero__fallback/ );
} );
test( 'Music and Podcast patterns own one ordered three-layer landing composition', () => {
const music = read( 'patterns/music-landing.php' );
const podcast = read( 'patterns/podcast-landing.php' );
const pages = JSON.parse( read( 'tests/fixtures/pages.json' ) );
const assertLayerOrder = ( source, label ) => {
const stage = source.indexOf( 'className":"chrnx-character-stage"' );
const atmosphere = source.indexOf( 'chrnx-character-stage__atmosphere', stage );
const content = source.indexOf( 'chrnx-character-stage__content', atmosphere );
const art = source.indexOf( 'chrnx-character-stage__art', content );
assert.ok( stage >= 0 && atmosphere > stage && content > atmosphere && art > content, label );
};
assertLayerOrder( music, 'Music layer order' );
assert.equal( ( music.match( /chrnx_get_topic_portrait_markup\( 'music-collage'/g ) || [] ).length, 1 );
assert.equal( ( music.match( /chrnx_get_topic_portrait_markup\( 'music',/g ) || [] ).length, 1 );
assert.doesNotMatch(
music.match( /chrnx-character-stage__atmosphere[\s\S]*?chrnx-character-stage__content/ )?.[ 0 ] ?? '',
/aria-hidden="true"/,
);
assert.ok(
music.indexOf( 'chrnx_get_topic_portrait_markup( \'music-collage\'' ) <
music.indexOf( 'chrnx-character-stage__content' ),
);
assert.ok(
music.indexOf( 'El proceso usa generative AI' ) > music.indexOf( '<!-- /wp:group -->', music.indexOf( 'chrnx-character-stage__art' ) ) &&
music.indexOf( 'El proceso usa generative AI' ) < music.indexOf( 'Releases in progress' ),
);
assertLayerOrder( podcast, 'Podcast layer order' );
assert.equal( ( podcast.match( /chrnx_get_atmosphere_markup\( 'podcast-frequency'/g ) || [] ).length, 1 );
assert.equal( ( podcast.match( /chrnx_get_topic_portrait_markup\( 'podcasts'/g ) || [] ).length, 1 );
assert.equal( ( podcast.match( /<!-- wp:chrnx\/latest-podcast \/-->/g ) || [] ).length, 1 );
assert.match( podcast, /chrnx-character-stage__atmosphere" aria-hidden="true"/ );
assert.match( podcast, /chrnx\/podcast-show-discovery/ );
assert.match( podcast, /chrnx\/podcast-archive/ );
assert.doesNotMatch( podcast, /chrnx\/podcast-latest/ );
assert.equal( pages.length, 7 );
const podcastPage = pages.find( ( page ) => page.slug === 'podcasts' );
assert.equal(
podcastPage?.content,
'<!-- wp:pattern {"slug":"chrnx/podcast-landing"} /-->',
);
} );
test( 'editor pattern validity is derived only from the live block-editor store', () => {
const editorValidity = read( 'tests/e2e/pattern-editor-validity.spec.mjs' );
assert.doesNotMatch( editorValidity, /resolvePatternReferences|shouldResolvePatterns/ );
assert.doesNotMatch(
editorValidity,
/editorSnapshot[\s\S]*?wp\.apiFetch\(\s*\{\s*path:\s*'\/wp\/v2\/block-patterns\/patterns'/,
);
assert.match( editorValidity, /const roots = store\.getBlocks\(\)/ );
assert.doesNotMatch( editorValidity, /__experimentalGetParsedPattern/ );
assert.doesNotMatch( editorValidity, /\.resetBlocks\s*\(/ );
assert.doesNotMatch( editorValidity, /\.insertBlocks\s*\(/ );
assert.match( editorValidity, /getByRole\( 'button', \{ name: 'Block Inserter' \} \)/ );
assert.match( editorValidity, /getByRole\( 'tab', \{ name: 'Blocks'/ );
assert.match(
editorValidity,
/getByRole\( 'option', \{[\s\S]*?name: pattern\.patternTitle/,
);
assert.match( editorValidity, /\[ 'POST', 'PUT', 'PATCH', 'DELETE' \]/ );
assert.match( editorValidity, /expect\( templateAfter \)\.toEqual\( templateBefore \)/ );
} );
test( 'Music and Podcast visual states decode every relevant image before measuring', () => {
const visualStates = read( 'tests/e2e/visual-states.spec.mjs' );
assert.match( visualStates, /async function waitForDecodedLandingImages/ );
assert.match( visualStates, /image\.complete/ );
assert.match( visualStates, /image\.naturalWidth > 0/ );
assert.match( visualStates, /image\.naturalHeight > 0/ );
assert.match( visualStates, /typeof image\.decode === 'function'/ );
assert.match( visualStates, /awaitDecode: false/ );
assert.match( visualStates, /latestMedia/ );
} );
test( 'character stages define the shared mockup effect and responsive geometry', () => {
const components = read( 'assets/css/components.css' );
const visualStates = read( 'tests/e2e/visual-states.spec.mjs' );
for ( const token of [
'--chrnx-character-accent',
'--chrnx-character-halo',
'--chrnx-character-wash',
'--chrnx-character-shadow',
] ) {
assert.match( components, new RegExp( token ), `${ token } must be shared` );
}
assert.match( components, /\.chrnx-character-stage\s*\{[\s\S]*?grid-template-columns:\s*minmax\(0,\s*55fr\)\s+minmax\(0,\s*45fr\)/ );
assert.match( components, /\.chrnx-character-stage__atmosphere::before/ );
assert.match( components, /\.chrnx-character-stage__atmosphere::after/ );
assert.match( components, /\.chrnx-character-stage__art\s*>\s*\.chrnx-responsive-portrait/ );
assert.match( components, /@media \(max-width:\s*780px\)[\s\S]*?\.chrnx-character-stage\s*\{[\s\S]*?grid-template-columns:\s*1fr/ );
assert.match( components, /@media \(prefers-reduced-motion:\s*reduce\)[\s\S]*?\.chrnx-character-stage/ );
assert.match( components, /--chrnx-character-copy-surface/ );
assert.match( components, /\.chrnx-music-landing \.chrnx-character-stage__content\s*>\s*\.chrnx-responsive-portrait:has\(\.chrnx-character-stage__collage\)[\s\S]*?inset:\s*0/ );
for ( const timeout of [ '180_000', '120_000', '60_000' ] ) {
assert.match( visualStates, new RegExp( `test\\.setTimeout\\( ${ timeout } \\)` ) );
}
assert.match( visualStates, /character stage below-fold derivatives wait for approach/ );
} );