fix: correct entry layout, light mode and editor parity

The single/page/404 templates set contentSize to 70ch, which resolves
against each child's own font size: the display-size h1 asked for
~2660px and broke full bleed while the body stayed narrow. They now
inherit the 720px from theme.json.

Also drops the About facets that duplicated the portrait, adds the
missing prefers-color-scheme branch for the character stage copy
surface (dark text on a dark panel in System light), loads
components.css in the editor, and replaces the unstyled index
fallback with the journal stream.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-13 19:41:09 -05:00
1 parent b0e44423a1
commit a3ba692669
13 files changed
+221 -92

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
node_modules/
vendor/
.phpunit.result.cache
.pytest_cache/
dist/
.wp-env.override.json
test-results/
+1
View File
@@ -18,6 +18,7 @@ body {
margin: 0;
background: var(--wp--preset--color--night);
color: var(--wp--preset--color--text);
overflow-wrap: break-word;
}
img,
+61 -1
View File
@@ -13,9 +13,69 @@ function chrnx_setup() {
add_theme_support( 'post-thumbnails' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'editor-styles' );
add_editor_style( array( 'assets/css/base.css', 'assets/css/layout.css' ) );
add_editor_style( array( 'assets/css/base.css', 'assets/css/layout.css', 'assets/css/components.css' ) );
remove_action( 'wp_footer', 'the_block_template_skip_link' );
add_image_size( 'chrnx-card', 720, 480, true );
register_nav_menus(
array(
'chrnx-primary' => __( 'Primary navigation', 'chrnx' ),
'chrnx-footer' => __( 'Footer navigation', 'chrnx' ),
)
);
// No template renders a comment thread, so nothing is collected silently.
remove_post_type_support( 'post', 'comments' );
remove_post_type_support( 'page', 'comments' );
}
add_action( 'after_setup_theme', 'chrnx_setup' );
add_filter( 'comments_open', '__return_false' );
/**
* Print Open Graph and Twitter card tags for the current request.
*
* ponytail: hand-rolled because the theme needs four tags, not an SEO plugin.
*/
function chrnx_print_social_meta() {
if ( is_singular() ) {
$title = get_the_title();
$url = get_permalink();
$description = wp_strip_all_tags( get_the_excerpt() );
$type = 'article';
$image_id = get_post_thumbnail_id();
} else {
$title = get_bloginfo( 'name' );
$url = home_url( '/' );
$description = get_bloginfo( 'description' );
$type = 'website';
$image_id = 0;
}
// Generated derivative, not the design master: masters are not shipped.
$image = $image_id
? wp_get_attachment_image_url( $image_id, 'full' )
: get_theme_file_uri( 'assets/images/generated/about-grunge-1536.webp' );
$tags = array(
'og:site_name' => get_bloginfo( 'name' ),
'og:type' => $type,
'og:title' => $title,
'og:description' => $description,
'og:url' => $url,
'og:image' => $image,
);
foreach ( $tags as $property => $content ) {
if ( '' === $content ) {
continue;
}
printf(
'<meta property="%1$s" content="%2$s" />' . "\n",
esc_attr( $property ),
esc_attr( $content )
);
}
echo '<meta name="twitter:card" content="summary_large_image" />' . "\n";
}
add_action( 'wp_head', 'chrnx_print_social_meta' );
+2 -8
View File
@@ -10,11 +10,11 @@
*/
$chrnx_research_url = esc_url( 'https://arxiv.org/abs/2603.05352' );
?>
<!-- wp:group {"tagName":"section","className":"chrnx-about","layout":{"type":"constrained","contentSize":"70ch"}} -->
<!-- wp:group {"tagName":"section","className":"chrnx-about","layout":{"type":"constrained"}} -->
<section class="wp-block-group chrnx-about">
<!-- wp:group {"className":"chrnx-character-stage","layout":{"type":"constrained"}} -->
<div class="wp-block-group chrnx-character-stage">
<!-- wp:html --><div class="chrnx-character-stage__atmosphere" aria-hidden="true"></div><!-- /wp:html -->
<!-- wp:html --><div class="chrnx-character-stage__atmosphere" aria-hidden="true"><?php echo chrnx_get_atmosphere_markup( 'about-grunge', 'chrnx-character-stage__backdrop' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?></div><!-- /wp:html -->
<!-- wp:group {"className":"chrnx-character-stage__content","layout":{"type":"constrained"}} -->
<div class="wp-block-group chrnx-character-stage__content">
<!-- wp:heading {"level":2} --><h2 class="wp-block-heading"><?php echo esc_html__( 'About', 'chrnx' ); ?></h2><!-- /wp:heading -->
@@ -28,11 +28,5 @@ $chrnx_research_url = esc_url( 'https://arxiv.org/abs/2603.05352' );
<!-- wp:html --><div class="chrnx-character-stage__art"><?php echo chrnx_get_topic_portrait_markup( 'life', '', 'chrnx-section-portrait' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?></div><!-- /wp:html -->
</div>
<!-- /wp:group -->
<!-- wp:group {"className":"chrnx-character-facets chrnx-about__portraits","layout":{"type":"flex","flexWrap":"wrap"}} -->
<div class="wp-block-group chrnx-character-facets chrnx-about__portraits">
<!-- wp:html --><?php echo chrnx_get_topic_portrait_markup( 'literature', '', 'chrnx-section-portrait' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?><!-- /wp:html -->
<!-- wp:html --><?php echo chrnx_get_topic_portrait_markup( 'gaming', '', 'chrnx-section-portrait' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Helper returns escaped, allowlisted markup. ?><!-- /wp:html -->
</div>
<!-- /wp:group -->
</section>
<!-- /wp:group -->
+1 -1
View File
@@ -1,6 +1,6 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-not-found","layout":{"type":"constrained","contentSize":"70ch"}} -->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-not-found","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group chrnx-not-found" tabindex="-1">
<!-- wp:heading {"level":1} --><h1 class="wp-block-heading">Page not found</h1><!-- /wp:heading -->
<!-- wp:paragraph --><p>This address does not lead to a published page. Search the site or return to a known starting point.</p><!-- /wp:paragraph -->
+4 -20
View File
@@ -1,25 +1,9 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group" tabindex="-1">
<!-- wp:query {"queryId":0,"query":{"inherit":true},"layout":{"type":"default"}} -->
<div class="wp-block-query">
<!-- wp:post-template -->
<!-- wp:group {"tagName":"article","layout":{"type":"constrained"}} -->
<article class="wp-block-group">
<!-- wp:post-title {"isLink":true} /-->
<!-- wp:post-excerpt /-->
</article>
<!-- /wp:group -->
<!-- /wp:post-template -->
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"space-between"}} -->
<!-- wp:query-pagination-previous /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->
</div>
<!-- /wp:query -->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-archive","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group chrnx-archive" tabindex="-1">
<!-- wp:query-title {"type":"archive","level":1,"showPrefix":false} /-->
<!-- wp:chrnx/journal-stream /-->
</main>
<!-- /wp:group -->
+1 -1
View File
@@ -1,6 +1,6 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-entry chrnx-entry--page","layout":{"type":"constrained","contentSize":"70ch"}} -->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-entry chrnx-entry--page","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group chrnx-entry chrnx-entry--page" tabindex="-1">
<!-- wp:post-title {"level":1} /-->
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
+2 -1
View File
@@ -1,6 +1,6 @@
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-entry chrnx-entry--single","layout":{"type":"constrained","contentSize":"70ch"}} -->
<!-- wp:group {"tagName":"main","anchor":"chrnx-main","className":"chrnx-entry chrnx-entry--single","layout":{"type":"constrained"}} -->
<main id="chrnx-main" class="wp-block-group chrnx-entry chrnx-entry--single" tabindex="-1">
<!-- wp:post-title {"level":1} /-->
<!-- wp:group {"className":"chrnx-entry__meta","layout":{"type":"flex","flexWrap":"wrap"}} -->
@@ -14,6 +14,7 @@
<!-- wp:post-featured-image {"aspectRatio":"3/2"} /-->
<!-- wp:post-content {"layout":{"type":"constrained"}} /-->
<!-- wp:chrnx/podcast-meta /-->
<!-- wp:chrnx/track-meta /-->
<!-- wp:chrnx/related-posts /-->
<!-- wp:chrnx/subscribe-cta {"className":"is-style-quiet"} /-->
</main>
+20 -21
View File
@@ -237,7 +237,7 @@ test( 'lower home sections keep the layered Music stage contained in both themes
const result = await page.locator( '.chrnx-home' ).evaluate( ( home, order ) => {
const selectors = [
'.chrnx-home-projects',
'.chrnx-home-projects > .chrnx-character-stage',
'.chrnx-home-music > .chrnx-character-stage',
'.chrnx-latest-podcast',
'.chrnx-home-about-preview',
@@ -372,7 +372,7 @@ test( 'lower home sections keep the layered Music stage contained in both themes
} ),
] );
expect( result.collageLazy ).toBe( 'lazy' );
expect( result.collageFallback ).toContain( 'the-no-names-collage.jpeg' );
expect( result.collageFallback ).toContain( 'the-no-names-collage-768.webp' );
expect( result.collageContained ).toBeTruthy();
expect( result.collageTreated ).toBeTruthy();
expect( result.copyPosition ).not.toBe( 'static' );
@@ -540,7 +540,7 @@ test( 'explicit themes use an atmospheric canvas and a compact home introduction
for ( const theme of [ 'Dark', 'Light' ] ) {
await page.setViewportSize( { width: 1440, height: 900 } );
await page.goto( '/' );
await page.getByRole( 'radio', { name: theme, exact: true } ).check();
await page.getByRole( 'button', { name: theme, exact: true } ).click();
await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', theme.toLowerCase() );
const desktop = await page.evaluate( () => {
@@ -649,9 +649,9 @@ test( 'topic, music, podcast, and about surfaces use real content and approved a
page,
} ) => {
for ( const [ path, heading, asset ] of [
[ '/topic/code/', 'Code', 'alter-ego-code.png' ],
[ '/topic/research/', 'Research', 'alter-ego-research.png' ],
[ '/topic/gaming/', 'Gaming', 'alter-ego-gaming-half-body.png' ],
[ '/topic/code/', 'Code', 'alter-ego-code-768.webp' ],
[ '/topic/research/', 'Research', 'alter-ego-research-768.webp' ],
[ '/topic/gaming/', 'Gaming', 'alter-ego-gaming-half-body-768.webp' ],
] ) {
await page.goto( path );
await expect( page.getByRole( 'heading', { level: 1, name: heading } ) ).toBeVisible();
@@ -705,12 +705,12 @@ test( 'topic, music, podcast, and about surfaces use real content and approved a
await expect( page.getByRole( 'heading', { level: 1, name: 'Music' } ) ).toBeVisible();
await expect( page.getByText( 'Grunge mexicano para cerebros que no se callan.' ) ).toBeVisible();
await expect(
page.locator( 'picture img[src*="the-no-names-musician-cutout.png"]' ),
page.locator( 'picture img[src*="the-no-names-musician-cutout-768.webp"]' ),
).toBeVisible();
await page.goto( '/podcasts/' );
await expect( page.getByRole( 'heading', { level: 1, name: 'Podcasts' } ) ).toBeVisible();
await expect( page.locator( 'picture img[src*="alter-ego-podcasts.png"]' ) ).toBeVisible();
await expect( page.locator( 'picture img[src*="alter-ego-podcasts-768.webp"]' ) ).toBeVisible();
await expect( page.locator( 'iframe, audio' ) ).toHaveCount( 0 );
await page.goto( '/about/' );
@@ -722,8 +722,8 @@ test( 'topic, music, podcast, and about surfaces use real content and approved a
await expect( page.locator( '.chrnx-about .chrnx-character-stage__art > picture' ) ).toHaveCount(
1,
);
await expect( page.locator( '.chrnx-about__portraits > picture' ) ).toHaveCount( 2 );
await expect( page.locator( '.chrnx-about picture' ) ).toHaveCount( 3 );
// One backdrop in the atmosphere layer plus the portrait in the art layer.
await expect( page.locator( '.chrnx-about picture' ) ).toHaveCount( 2 );
} );
test( 'long, incomplete, empty, and missing states stay usable', async ( { page } ) => {
@@ -888,7 +888,7 @@ test( 'reduced motion removes card transitions while theme preference remains us
);
expect( duration ).toBeLessThanOrEqual( 0.001 );
await expect( page.locator( '.chrnx-home-music h2' ) ).toHaveCSS( 'color', 'rgb(230, 237, 243)' );
await page.getByRole( 'radio', { name: 'Dark', exact: true } ).check();
await page.getByRole( 'button', { name: 'Dark', exact: true } ).click();
await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', 'dark' );
} );
@@ -970,8 +970,10 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt
}
expect( geometry.contentArtIntersect ).toBeFalsy();
expect( geometry.followingIntersections ).toBe( 0 );
// 'about' is absent: its stage is now the last thing on the page, so
// there is no following surface left to check for overlap.
if (
[ 'home-projects', 'home-music', 'projects', 'music', 'podcasts', 'about' ].includes(
[ 'home-projects', 'home-music', 'projects', 'music', 'podcasts' ].includes(
surface.name,
)
) {
@@ -991,7 +993,8 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt
const sourceName = new URL( image.src ).pathname
.split( '/' )
.pop()
.replace( /\.png$/, '' );
// The src is a generated derivative now: strip -<width>.<ext>.
.replace( /-\d+\.(?:png|jpe?g|webp|avif)$/, '' );
const [ naturalWidth, naturalHeight, x0, y0, x1, y1 ] = boundsByAsset[ sourceName ];
const imageRect = image.getBoundingClientRect();
const stageRect = element.getBoundingClientRect();
@@ -1057,10 +1060,6 @@ test( 'character stage geometry, layering, effects, loading, and inspection capt
expect( collageContract.hiddenAncestor ).toBeFalsy();
expect( collageContract.alt ).toBe( 'The No Names collage' );
}
if ( surface.name === 'about' ) {
expect( geometry.facetsOpacity ).toBeLessThan( 1 );
expect( geometry.facetsZ ).toBeLessThan( geometry.pictureZ );
}
await expectNoHorizontalOverflow( page );
if ( initial.top >= viewport.height ) {
@@ -1310,8 +1309,8 @@ const musicPodcastLandingCases = [
path: '/music/',
root: '.chrnx-music-landing',
copy: 'The No Names es una banda activa',
atmosphere: 'img[src*="the-no-names-collage.jpeg"]',
art: 'img[src*="the-no-names-musician-cutout.png"]',
atmosphere: 'img[src*="the-no-names-collage-768.webp"]',
art: 'img[src*="the-no-names-musician-cutout-768.webp"]',
latestMedia: null,
supporting: 'text=El proceso usa generative AI',
},
@@ -1320,8 +1319,8 @@ const musicPodcastLandingCases = [
path: '/podcasts/',
root: '.chrnx-podcast-landing',
copy: 'Conversations about the work behind software, research, music, and games.',
atmosphere: 'img[src*="podcast-frequency-grunge.png"]',
art: 'img[src*="alter-ego-podcasts.png"]',
atmosphere: 'img[src*="podcast-frequency-grunge-1536.webp"]',
art: 'img[src*="alter-ego-podcasts-768.webp"]',
latestMedia:
'.chrnx-latest-podcast .chrnx-podcast-card__image, .chrnx-latest-podcast .chrnx-podcast-card__fallback',
supporting: '.chrnx-latest-podcast',
+30 -24
View File
@@ -68,12 +68,12 @@ class PatternsTest extends WP_UnitTestCase {
$this->assertMatchesRegularExpression( '/<img\b[^>]*\bloading="lazy"[^>]*\bdecoding="async"/i', $content, $name );
}
$music = $this->render_pattern( get_theme_file_path( 'patterns/music-landing.php' ) );
$this->assertStringContainsString( 'the-no-names-collage.jpeg', $music );
$this->assertStringContainsString( 'the-no-names-musician-cutout.png', $music );
$this->assertStringContainsString( 'the-no-names-collage-768.webp', $music );
$this->assertStringContainsString( 'the-no-names-musician-cutout-768.webp', $music );
$this->assertSame( 2, substr_count( $music, '<img' ) );
$show = $this->render_pattern( get_theme_file_path( 'patterns/podcast-show.php' ) );
$this->assertStringContainsString( 'alter-ego-podcasts.png', $show );
$this->assertStringContainsString( 'alter-ego-podcasts-768.webp', $show );
$this->assertStringContainsString( 'alt=""', $show );
$this->assertStringContainsString( 'aria-hidden="true"', $show );
}
@@ -89,9 +89,9 @@ class PatternsTest extends WP_UnitTestCase {
$this->assertStringContainsString( 'the-no-names-collage-768.webp 768w', $content );
$this->assertStringContainsString( 'sizes="(max-width: 599px) 100vw, 720px"', $content );
$this->assertMatchesRegularExpression( '/class="chrnx-character-stage__collage"[^>]*loading="lazy"[^>]*alt=""/', $content );
$this->assertStringContainsString( 'the-no-names-musician-cutout.png', $content );
$this->assertStringContainsString( 'the-no-names-musician-cutout-768.webp', $content );
$this->assertLessThan(
strpos( $content, 'the-no-names-musician-cutout.png' ),
strpos( $content, 'the-no-names-musician-cutout-768.webp' ),
strpos( $content, 'the-no-names-collage-384.avif' )
);
}
@@ -103,18 +103,22 @@ class PatternsTest extends WP_UnitTestCase {
'Grunge mexicano para cerebros que no se callan.',
'grunge en español mexicano desde Sinaloa',
'estudio crudo, cero live',
'El Hermoso Caos que habita en mi cabeza',
'13-track debut album',
'Ando Bien Arriba',
'six-track bright mirrored EP',
'Aquí se Rompió una Jerga',
'six-track dark mirrored EP',
'draft/in production',
'generative AI',
'Chrnx',
) as $copy ) {
$this->assertStringContainsString( $copy, wp_strip_all_tags( $content ), $copy );
}
// Release names moved out of the pattern into the chrnx_release vocabulary.
$releases = chrnx_get_editorial_taxonomies()['chrnx_release']['terms'];
foreach ( array(
'El Hermoso Caos que habita en mi cabeza',
'Ando Bien Arriba',
'Aquí se Rompió una Jerga',
) as $release ) {
$this->assertContains( $release, $releases, $release );
}
$this->assertStringContainsString( 'chrnx/release-list', file_get_contents( get_theme_file_path( 'patterns/music-landing.php' ) ) ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Local test fixture.
$this->assertDoesNotMatchRegularExpression( '/concert|rehearsal|coming live|tour/i', $content );
}
@@ -202,22 +206,23 @@ class PatternsTest extends WP_UnitTestCase {
$contracts = array(
'home-projects' => array(
'heading' => 'Selected work',
'order' => array( 'Selected work', 'Expressive Tea', 'Ailed', 'Published research' ),
'art' => 'alter-ego-code.png',
// The project names come from chrnx/selected-work now, not the pattern.
'order' => array( 'Selected work' ),
'art' => 'alter-ego-code-768.webp',
'art_alt' => '',
'atmosphere' => 'chrnx-character-stage__secondary-art',
),
'home-music' => array(
'heading' => 'The No Names',
'order' => array( 'The No Names', 'Grunge mexicano para cerebros que no se callan.', 'Un proyecto de banda activo hecho en Sinaloa: estudio crudo, cero live.' ),
'art' => 'the-no-names-musician-cutout.png',
'art' => 'the-no-names-musician-cutout-768.webp',
'art_alt' => 'The No Names musician portrait',
'atmosphere' => 'chrnx-character-stage__collage',
),
'music-landing' => array(
'heading' => 'The No Names',
'order' => array( 'The No Names', 'Grunge mexicano para cerebros que no se callan.', 'The No Names es una banda activa' ),
'art' => 'the-no-names-musician-cutout.png',
'art' => 'the-no-names-musician-cutout-768.webp',
'art_alt' => 'The No Names musician portrait',
'atmosphere' => 'chrnx-character-stage__collage',
'atmos_alt' => 'The No Names collage',
@@ -226,16 +231,15 @@ class PatternsTest extends WP_UnitTestCase {
'podcast-landing' => array(
'heading' => 'Podcasts',
'order' => array( 'Podcasts', 'Conversations about the work behind software, research, music, and games.' ),
'art' => 'alter-ego-podcasts.png',
'art' => 'alter-ego-podcasts-768.webp',
'art_alt' => '',
'atmosphere' => 'chrnx-character-stage__frequency',
),
'about' => array(
'heading' => 'About',
'order' => array( 'About', 'I work as Lead Developer @Expressive Tea', 'I am a published researcher.', 'I am an autistic Level 1 software developer and researcher.', 'Beyond the work', 'I am the father of three wonderful children' ),
'art' => 'alter-ego-life.png',
'art' => 'alter-ego-life-768.webp',
'art_alt' => '',
'facets' => array( 'alter-ego-literature.png', 'alter-ego-gaming-half-body.png' ),
),
);
@@ -343,8 +347,9 @@ class PatternsTest extends WP_UnitTestCase {
$music_root = $music_xpath->query( '//*[@id="chrnx-test-root"]/*[1]' )->item( 0 );
$this->assertInstanceOf( DOMElement::class, $music_stage );
$this->assertSame( 1, substr_count( $music, 'the-no-names-collage.jpeg' ) );
$this->assertSame( 1, substr_count( $music, 'the-no-names-musician-cutout.png' ) );
// Twice: once in the WebP srcset, once as the <img> fallback src.
$this->assertSame( 2, substr_count( $music, 'the-no-names-collage-768.webp' ) );
$this->assertSame( 2, substr_count( $music, 'the-no-names-musician-cutout-768.webp' ) );
$this->assertSame( 1, $music_xpath->query( './*[1]//img[@alt="The No Names collage"]', $music_stage )->length );
$this->assertSame( 0, $music_xpath->query( './*[2]//img[contains(@class,"chrnx-character-stage__collage")]', $music_stage )->length );
$this->assertSame( 1, $music_xpath->query( './*[3]//img[@alt="The No Names musician portrait"]', $music_stage )->length );
@@ -355,20 +360,21 @@ class PatternsTest extends WP_UnitTestCase {
$this->assertInstanceOf( DOMElement::class, $releases );
$this->assertSame( $music_stage, $process->previousElementSibling ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property.
$this->assertSame( $process, $releases->previousElementSibling ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- DOM API property.
$this->assertSame( array( 2, 3, 4, 4, 4 ), $this->heading_levels( $music_dom ) );
// The h4 release headings are rendered by chrnx/release-list now.
$this->assertSame( array( 2, 3 ), $this->heading_levels( $music_dom ) );
$podcast = $this->render_pattern( get_theme_file_path( 'patterns/podcast-landing.php' ) );
$podcast_dom = $this->load_html_fragment( $podcast );
$podcast_xpath = new DOMXPath( $podcast_dom );
$podcast_stage = $podcast_xpath->query( '//*[contains(concat(" ", normalize-space(@class), " "), " chrnx-character-stage ")]' )->item( 0 );
$this->assertInstanceOf( DOMElement::class, $podcast_stage );
$this->assertSame( 1, substr_count( $podcast, 'podcast-frequency-grunge.png' ) );
$this->assertSame( 2, substr_count( $podcast, 'podcast-frequency-grunge-1536.webp' ) );
$podcast_atmosphere = $podcast_dom->saveHTML( $podcast_xpath->query( './*[1]', $podcast_stage )->item( 0 ) );
$this->assertStringContainsString( '<picture class="chrnx-responsive-atmosphere" aria-hidden="true">', $podcast_atmosphere );
$this->assertStringContainsString( 'alt=""', $podcast_atmosphere );
$podcast_art = $podcast_dom->saveHTML( $podcast_xpath->query( './*[3]', $podcast_stage )->item( 0 ) );
$this->assertStringContainsString( '<picture class="chrnx-responsive-portrait" aria-hidden="true">', $podcast_art );
$this->assertStringContainsString( 'alter-ego-podcasts.png', $podcast_art );
$this->assertStringContainsString( 'alter-ego-podcasts-768.webp', $podcast_art );
$this->assertStringContainsString( 'alt=""', $podcast_art );
$this->assertSame( 1, substr_count( $podcast, '<!-- wp:chrnx/latest-podcast /-->' ) );
$this->assertSame( 1, substr_count( $podcast, '"metadata":{"name":"chrnx/podcast-show-discovery"}' ) );
+1
View File
@@ -34,6 +34,7 @@ class ThemeSetupTest extends WP_UnitTestCase {
$this->assertContains( 'assets/css/base.css', $editor_styles );
$this->assertContains( 'assets/css/layout.css', $editor_styles );
$this->assertContains( 'assets/css/components.css', $editor_styles );
}
/**
+55 -4
View File
@@ -1,5 +1,5 @@
import assert from 'node:assert/strict';
import { access, readFile } from 'node:fs/promises';
import { access, readFile, readdir } from 'node:fs/promises';
import test from 'node:test';
const readProjectFile = (path) => readFile(new URL(`../../${path}`, import.meta.url), 'utf8');
@@ -43,6 +43,56 @@ test('the stylesheet and PHP asset versions remain synchronized', async () => {
assert.equal(phpVersion, stylesheetVersion);
});
test('every block.json version matches CHRNX_VERSION so cached block assets bust', async () => {
// Block viewScript/style URLs are versioned from block.json, not
// CHRNX_VERSION. Letting them drift served stale JS from browser cache.
const functions = await readProjectFile('functions.php');
const phpVersion = functions.match(/define\( 'CHRNX_VERSION', '([^']+)' \);/)?.[1];
assert.ok(phpVersion, 'functions.php must define the literal CHRNX_VERSION constant');
const blocksDir = new URL('../../blocks/', import.meta.url);
const names = (await readdir(blocksDir, { withFileTypes: true }))
.filter((entry) => entry.isDirectory())
.map((entry) => entry.name)
.sort();
assert.ok(names.length > 0, 'blocks/ must contain block directories');
for (const name of names) {
const block = JSON.parse(await readProjectFile(`blocks/${name}/block.json`));
assert.equal(block.version, phpVersion, `blocks/${name}/block.json version`);
}
});
test('no shipped runtime file points at an unshipped design master', async () => {
// The package excludes assets/images/*.png|jpeg because every image is served
// from assets/images/generated. A direct reference would 404 once installed.
const roots = ['inc', 'blocks', 'patterns', 'parts', 'templates', 'assets/css'];
const offenders = [];
const walk = async (dir) => {
for (const entry of await readdir(new URL(`../../${dir}/`, import.meta.url), { withFileTypes: true })) {
const path = `${dir}/${entry.name}`;
if (entry.isDirectory()) {
await walk(path);
continue;
}
if (!/\.(php|css|html|json)$/.test(entry.name)) {
continue;
}
const source = await readProjectFile(path);
// Anything under generated/ is shipped; a bare master path is not.
const matches = source.match(/assets\/images\/(?!generated\/)[A-Za-z0-9._-]+\.(?:png|jpe?g)/g);
if (matches) {
offenders.push(`${path}: ${[...new Set(matches)].join(', ')}`);
}
}
};
for (const root of roots) {
await walk(root);
}
assert.deepEqual(offenders, [], `runtime files reference unshipped masters:\n${offenders.join('\n')}`);
});
test('theme.json declares the v3 schema and layout widths', async () => {
const theme = JSON.parse(await readProjectFile('theme.json'));
@@ -89,8 +139,9 @@ test('the index template has header, semantic query content, and footer regions'
assert.match(template, /<!-- wp:template-part \{"slug":"header","tagName":"header"\} \/-->/);
assert.match(template, /<!-- wp:group \{"tagName":"main"[^>]*-->/);
assert.match(template, /<!-- wp:query\b/);
assert.match(template, /<!-- wp:post-template -->/);
assert.match(template, /<!-- wp:post-(?:content|excerpt)\b/);
// index is the last-resort fallback; it lists posts through the same
// stream every other archive uses, not an unstyled core query loop.
assert.match(template, /<!-- wp:query-title\b/);
assert.match(template, /<!-- wp:chrnx\/journal-stream \/-->/);
assert.match(template, /<!-- wp:template-part \{"slug":"footer","tagName":"footer"\} \/-->/);
});
+42 -11
View File
@@ -53,7 +53,7 @@ test( 'local visual fixtures define stable pages and representative editorial st
[ 'home', 'journal', 'projects', 'music', 'podcasts', 'about', 'subscribe' ],
);
assert.ok( pages.every( ( page ) => page.fixtureKey && page.status === 'publish' ) );
assert.equal( posts.length, 12 );
assert.equal( posts.length, 18 );
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' ) );
@@ -73,7 +73,16 @@ test( 'local visual fixtures define stable pages and representative editorial st
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 === 'projects' && post.projectFeatured === true ) );
assert.ok( posts.some( ( post ) => post.topic === 'projects' && ! ( 'projectFeatured' in post ) ) );
// Tracks must carry a release and an order for the album tracklist to mean anything.
const tracks = posts.filter( ( post ) => 'release' in post );
assert.ok( tracks.length >= 3 );
assert.ok( tracks.every( ( post ) => post.topic === 'music' && Number.isInteger( post.trackNumber ) ) );
assert.ok( new Set( tracks.map( ( post ) => post.release ) ).size >= 2 );
// No invented listening data: fixtures never ship platform URLs or audio.
assert.ok( ! posts.some( ( post ) => Object.keys( post ).some( ( key ) => key.startsWith( 'trackUrl' ) ) ) );
for ( const topic of [ 'code', 'research', 'gaming', 'literature', 'music', 'podcasts', 'life', 'projects' ] ) {
assert.ok( posts.some( ( post ) => post.topic === topic ), `missing ${ topic } fixture` );
}
} );
@@ -131,10 +140,10 @@ test( 'media and review documentation matches the current inventory and cleanup
const readme = read( 'README.md' );
const plan = read( 'docs/superpowers/plans/2026-08-13-music-podcast-grunge-stages.md' );
assert.match( readme, /52 generated files: 42 binary derivatives and 10 manifests/ );
assert.match( readme, /nine portrait families at 384 px and 768 px/ );
assert.match( readme, /Podcast\s+background family at 384 px, 768 px, and 1536 px/ );
for ( const budget of [ '160 KiB', '260 KiB', '400 KiB', '340 KiB', '620 KiB', '2.75 MiB' ] ) {
assert.match( readme, /76 generated files: 62 binary derivatives and 14 manifests/ );
assert.match( readme, /eleven portrait families at 384 px and 768 px/ );
assert.match( readme, /three\s+landscape background families \(Podcast, About, and Projects\) at 384 px, 768 px,\s+and 1536 px/ );
for ( const budget of [ '160 KiB', '260 KiB', '400 KiB', '340 KiB', '620 KiB', '3 MiB' ] ) {
assert.ok( readme.includes( budget ), `README missing ${ budget } budget` );
}
assert.doesNotMatch( readme, /all 40 outputs|2\.1 MiB/ );
@@ -460,7 +469,7 @@ test( 'all approved responsive media rebuild byte-identically within payload bou
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 );
assert.equal( names.length, 76 );
for ( const name of [
'alter-ego-gaming-half-body-384.avif',
'alter-ego-gaming-half-body-384.webp',
@@ -479,6 +488,18 @@ test( 'all approved responsive media rebuild byte-identically within payload bou
'podcast-frequency-grunge-1536.avif',
'podcast-frequency-grunge-1536.webp',
'podcast-frequency-grunge.json',
'about-grunge-1536.avif',
'about-grunge-1536.webp',
'about-grunge.json',
'projects-grunge-1536.avif',
'projects-grunge-1536.webp',
'projects-grunge.json',
'placeholder-post-384.avif',
'placeholder-post-768.webp',
'placeholder-post.json',
'placeholder-release-384.avif',
'placeholder-release-768.webp',
'placeholder-release.json',
] ) {
assert.ok( names.includes( name ), `missing ${ name }` );
}
@@ -490,6 +511,16 @@ test( 'all approved responsive media rebuild byte-identically within payload bou
widths: [ 384, 768, 1536 ],
},
);
for ( const backdrop of [ 'about-grunge', 'projects-grunge' ] ) {
assert.deepEqual(
JSON.parse( readFileSync( join( output, `${ backdrop }.json` ), 'utf8' ) ),
{
source: `${ backdrop }.png`,
formats: [ 'avif', 'webp' ],
widths: [ 384, 768, 1536 ],
},
);
}
let total = 0;
let collageTotal = 0;
let gamingHalfBodyTotal = 0;
@@ -533,7 +564,7 @@ test( 'all approved responsive media rebuild byte-identically within payload bou
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` );
assert.ok( total <= 3 * 1024 * 1024, `generated binary payload exceeds 3 MiB: ${ total } total bytes` );
} finally {
rmSync( output, { recursive: true, force: true } );
rmSync( external, { recursive: true, force: true } );
@@ -653,7 +684,7 @@ printf 'partial-build-%s\n' "$count" > "$output"
}
} );
test( 'responsive promotion failure restores all 52 prior files', () => {
test( 'responsive promotion failure restores all 76 prior files', () => {
const output = mkdtempSync( join( tmpdir(), 'chrnx-promotion-output-' ) );
const fakeBin = mkdtempSync( join( tmpdir(), 'chrnx-promotion-bin-' ) );
const external = mkdtempSync( join( tmpdir(), 'chrnx-promotion-external-' ) );
@@ -666,7 +697,7 @@ test( 'responsive promotion failure restores all 52 prior files', () => {
try {
execFileSync( './scripts/build-responsive-images.sh', [ output ], { cwd: projectRoot } );
const published = new Map( readdirSync( output ).map( ( name ) => [ name, sha256( join( output, name ) ) ] ) );
assert.equal( published.size, 52 );
assert.equal( published.size, 76 );
writeFileSync( sentinel, 'external-sentinel' );
const sentinelHash = sha256( sentinel );
const realMv = execFileSync( '/bin/sh', [ '-c', 'command -v mv' ], { encoding: 'utf8' } ).trim();
@@ -794,7 +825,7 @@ test( 'character-led openings share the exact stage class contract', () => {
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.doesNotMatch( read( 'patterns/about.php' ), /chrnx-character-facets/ );
assert.match( read( 'blocks/topic-hero/render.php' ), /chrnx-topic-hero__fallback/ );
} );