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

+5 -5
View File
@@ -1,9 +1,9 @@
import { execFileSync } from 'node:child_process';
export default function globalSetup() {
execFileSync(
'npm',
[ 'exec', '--', 'wp-env', 'run', 'cli', 'wp', 'eval', 'chrnx_seed_editorial_terms();' ],
{ cwd: process.cwd(), env: process.env, stdio: 'inherit' },
);
execFileSync( './scripts/seed-test-content.sh', [], {
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
} );
}
+140
View File
@@ -0,0 +1,140 @@
import { expect, test } from '@playwright/test';
import { injectAxe } from 'axe-playwright';
const viewports = [
{ width: 375, height: 812 },
{ width: 768, height: 1024 },
{ width: 1440, height: 900 },
{ width: 2560, height: 1440 },
];
async function expectNoHorizontalOverflow( page ) {
const overflow = await page.evaluate( () => ( {
document: document.documentElement.scrollWidth - window.innerWidth,
body: document.body.scrollWidth - window.innerWidth,
} ) );
expect( overflow.document ).toBeLessThanOrEqual( 1 );
expect( overflow.body ).toBeLessThanOrEqual( 1 );
}
test( 'home remains coherent at all approved review viewports', async ( { page } ) => {
for ( const viewport of viewports ) {
await page.setViewportSize( viewport );
await page.goto( '/' );
await expect( page.getByRole( 'banner' ) ).toBeVisible();
await expect( page.locator( 'main#chrnx-main' ) ).toBeVisible();
await expect( page.getByRole( 'contentinfo' ) ).toBeVisible();
await expect( page.getByRole( 'heading', { level: 1 } ) ).toHaveCount( 1 );
await expect( page.getByText( 'Selected work', { exact: true } ) ).toBeVisible();
await expect( page.getByText( 'The No Names', { exact: true } ).first() ).toBeVisible();
await expect( page.locator( 'picture source[type="image/avif"]' ).first() ).toHaveAttribute(
'srcset',
/384\.avif 384w/,
);
await expectNoHorizontalOverflow( page );
}
} );
test( 'topic, music, podcast, and about surfaces use real content and approved art', async ( {
page,
} ) => {
for ( const [ path, heading, asset ] of [
[ '/topic/code/', 'Code', 'alter-ego-code' ],
[ '/topic/research/', 'Research', 'alter-ego-research' ],
[ '/topic/gaming/', 'Gaming', 'alter-ego-gaming' ],
] ) {
await page.goto( path );
await expect( page.getByRole( 'heading', { level: 1, name: heading } ) ).toBeVisible();
await expect( page.locator( `.chrnx-topic-hero img[src*="${ asset }.png"]` ) ).toBeVisible();
await expectNoHorizontalOverflow( page );
}
await page.goto( '/music/' );
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"]' ),
).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( 'iframe, audio' ) ).toHaveCount( 0 );
await page.goto( '/about/' );
await expect( page.getByRole( 'heading', { level: 1, name: 'About' } ) ).toBeVisible();
await expect( page.getByRole( 'link', { name: 'arXiv:2603.05352' } ) ).toHaveAttribute(
'href',
'https://arxiv.org/abs/2603.05352',
);
await expect( page.locator( '.chrnx-about__portraits picture' ) ).toHaveCount( 3 );
} );
test( 'long, incomplete, empty, and missing states stay usable', async ( { page } ) => {
await page.goto( '/?s=fixture-that-cannot-exist' );
await expect( page.getByText( 'No journal entries match these filters yet.' ) ).toBeVisible();
await expect( page.getByRole( 'link', { name: 'Browse the full Journal' } ) ).toBeVisible();
await page.goto( '/conversacion-pendiente-de-datos-editoriales/' );
await expect(
page.getByRole( 'heading', { level: 1, name: 'Conversación pendiente de datos editoriales' } ),
).toBeVisible();
await expect( page.locator( '.chrnx-podcast-meta' ) ).toHaveCount( 0 );
await page.goto( '/emotion-is-not-a-slider-designing-expressive-systems-that-can-hesitate/' );
await expect( page.locator( 'pre code' ) ).toContainText( 'const state' );
await expectNoHorizontalOverflow( page );
await page.goto( '/this-route-does-not-exist/' );
await expect( page ).toHaveTitle( /Page not found/i );
await expect( page.getByRole( 'heading', { level: 1, name: 'Page not found' } ) ).toBeVisible();
} );
test( 'reduced motion removes card transitions while theme preference remains user-controlled', async ( {
page,
} ) => {
await page.emulateMedia( { reducedMotion: 'reduce', colorScheme: 'light' } );
await page.goto( '/' );
const card = page.locator( '.chrnx-featured-story' ).first();
const duration = await card.evaluate( ( element ) =>
Number.parseFloat( window.getComputedStyle( element ).transitionDuration ),
);
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 expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', 'dark' );
} );
test( 'key public surfaces pass automated WCAG 2.2 AA checks', async ( { page }, testInfo ) => {
test.skip(
testInfo.project.name !== 'chromium',
'One engine is sufficient for deterministic axe rules.',
);
const tags = [ 'wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa' ];
for ( const viewport of [ viewports[ 0 ], viewports[ 2 ] ] ) {
await page.setViewportSize( viewport );
for ( const path of [
'/',
'/music/',
'/podcasts/',
'/about/',
'/topic/code/',
'/?s=fixture-that-cannot-exist',
'/this-route-does-not-exist/',
] ) {
await page.goto( path );
await injectAxe( page );
const violations = await page.evaluate( async ( runOnly ) => {
const result = await globalThis.axe.run( document, {
runOnly: { type: 'tag', values: runOnly },
} );
return result.violations.map( ( violation ) => ( {
id: violation.id,
impact: violation.impact,
nodes: violation.nodes.map( ( node ) => node.target ),
} ) );
}, tags );
expect( violations, `${ path } at ${ viewport.width }px` ).toEqual( [] );
}
}
} );