fix: complete CHRNX responsive edge states

This commit is contained in:
chrnx committed 2026-08-12 09:02:34 -05:00
1 parent 5073178492
commit 1e9386ac13
15 files changed
+384 -35

No files matched your search

+148 -3
View File
@@ -1,5 +1,18 @@
import { expect, test } from '@playwright/test';
import { injectAxe } from 'axe-playwright';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const projectRoot = fileURLToPath( new URL( '../..', import.meta.url ) );
const seedScenario = ( scenario ) =>
execFileSync( './scripts/seed-test-content.sh', [ scenario ], {
cwd: projectRoot,
env: {
...process.env,
PATH: `/opt/homebrew/opt/docker/bin:${ process.env.PATH ?? '' }`,
},
stdio: 'pipe',
} );
const viewports = [
{ width: 375, height: 812 },
@@ -77,7 +90,10 @@ test( 'long, incomplete, empty, and missing states stay usable', async ( { page
await page.goto( '/conversacion-pendiente-de-datos-editoriales/' );
await expect(
page.getByRole( 'heading', { level: 1, name: 'Conversación pendiente de datos editoriales' } ),
page.getByRole( 'heading', {
level: 1,
name: 'Conversación pendiente de datos editoriales',
} ),
).toBeVisible();
await expect( page.locator( '.chrnx-podcast-meta' ) ).toHaveCount( 0 );
@@ -85,15 +101,144 @@ test( 'long, incomplete, empty, and missing states stay usable', async ( { page
await expect( page.locator( 'pre code' ) ).toContainText( 'const state' );
await expectNoHorizontalOverflow( page );
for ( const [ path, title ] of [
[
'/long-title-night-writing-fixture/',
'Escribir cuando la casa por fin se queda en silencio',
],
[
'/una-cuerda-rota-tambien-puede-decidir-el-arreglo/',
'Una cuerda rota también puede decidir el arreglo',
],
[ '/nota-local-sin-extracto/', 'Nota local sin extracto' ],
[ '/note-without-topic/', 'Note without a topic' ],
[ '/nota-sin-idioma-asignado/', 'Nota sin idioma asignado' ],
] ) {
await page.goto( path );
await expect( page.getByRole( 'heading', { level: 1 } ) ).toContainText( title );
await expectNoHorizontalOverflow( page );
}
await expect( page.locator( '.chrnx-entry__meta a', { hasText: 'English' } ) ).toHaveCount( 0 );
await page.goto( '/unbroken-token-overflow-test/' );
await expect( page.locator( 'pre code' ) ).toContainText(
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
);
await expectNoHorizontalOverflow( page );
await page.goto( '/journal/?chrnx_topic=..%2F..%2Fcode&chrnx_language%5B%5D=en&s%5B%5D=x' );
await expect( page.locator( 'select[name="chrnx_topic"]' ) ).toHaveValue( '' );
await expect( page.locator( 'select[name="chrnx_language"]' ) ).toHaveValue( '' );
await expect( page.locator( '.chrnx-journal-stream__filters input[name="s"]' ) ).toHaveValue(
'',
);
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( 'cards without featured media use CSS-only topic treatments', async ( { page } ) => {
await page.goto( '/' );
const fallbacks = page.locator(
'.chrnx-featured-story__fallback, .chrnx-journal-card__fallback, .chrnx-podcast-card__fallback',
);
await expect( fallbacks.first() ).toBeVisible();
expect( await fallbacks.locator( 'img' ).count() ).toBe( 0 );
for ( const fallback of await fallbacks.all() ) {
const background = await fallback.evaluate(
( element ) => window.getComputedStyle( element ).backgroundImage,
);
expect( background ).not.toMatch( /alter-ego-|the-no-names-musician-cutout/ );
}
} );
test( 'local featured and subscribe scenarios restore the default dataset', async ( {
page,
}, testInfo ) => {
test.skip( testInfo.project.name !== 'chromium', 'Database scenarios run once in Chromium.' );
try {
for ( const count of [ 1, 2 ] ) {
seedScenario( `featured-${ count }` );
await page.goto( `/?fixtureScenario=featured-${ count }` );
await expect( page.locator( '.chrnx-featured-stories article' ) ).toHaveCount( count );
const hrefs = await page
.locator( '.chrnx-featured-stories article a' )
.evaluateAll( ( links ) => links.map( ( link ) => link.href ) );
expect( new Set( hrefs ).size ).toBe( hrefs.length );
}
for ( const scenario of [ 'subscribe-unpublished', 'subscribe-unavailable' ] ) {
seedScenario( scenario );
await page.goto( `/?fixtureScenario=${ scenario }` );
await expect( page.locator( '.chrnx-subscribe-cta' ) ).toHaveCount( 0 );
}
} finally {
seedScenario( 'default' );
}
await page.goto( '/' );
await expect( page.locator( '.chrnx-featured-stories article' ) ).toHaveCount( 3 );
await expect(
page.getByRole( 'link', { name: 'Subscribe', exact: true } ).first(),
).toBeVisible();
} );
test( 'podcast canonical metadata is safe and missing metadata never invents a player or link', async ( {
page,
} ) => {
await page.goto( '/silicon-ranch-conversaciones-sin-diapositivas/' );
await expect( page.getByRole( 'link', { name: 'Open canonical episode page' } ) ).toHaveAttribute(
'href',
'https://example.test/local-podcast-episode',
);
await expect( page.locator( 'iframe, audio' ) ).toHaveCount( 0 );
await page.goto( '/conversacion-pendiente-de-datos-editoriales/' );
await expect( page.locator( '.chrnx-podcast-meta, iframe, audio' ) ).toHaveCount( 0 );
await expect( page.getByRole( 'link', { name: 'Open canonical episode page' } ) ).toHaveCount(
0,
);
} );
test( 'site routes preserve heading order, named landmarks, and skip-link keyboard flow', async ( {
page,
}, testInfo ) => {
for ( const path of [ '/', '/music/', '/podcasts/', '/about/', '/topic/code/', '/journal/' ] ) {
await page.goto( path );
const headings = await page
.locator( 'h1, h2, h3, h4, h5, h6' )
.evaluateAll( ( nodes ) => nodes.map( ( node ) => Number( node.tagName.slice( 1 ) ) ) );
expect( headings.filter( ( level ) => level === 1 ) ).toHaveLength( 1 );
for ( let index = 1; index < headings.length; index += 1 ) {
expect(
headings[ index ] - headings[ index - 1 ],
`${ path } heading sequence`,
).toBeLessThanOrEqual( 1 );
}
await expect( page.getByRole( 'banner' ) ).toHaveCount( 1 );
await expect( page.getByRole( 'main' ) ).toHaveCount( 1 );
await expect( page.getByRole( 'contentinfo' ) ).toHaveCount( 1 );
const landmarkNames = await page
.locator( 'nav' )
.evaluateAll( ( nodes ) => nodes.map( ( node ) => node.getAttribute( 'aria-label' ) ) );
expect( landmarkNames.every( Boolean ) ).toBeTruthy();
expect( new Set( landmarkNames ).size ).toBe( landmarkNames.length );
if ( testInfo.project.name === 'chromium' ) {
await page.keyboard.press( 'Tab' );
const skip = page.getByRole( 'link', { name: 'Skip to content' } );
await expect( skip ).toBeFocused();
await skip.press( 'Enter' );
await expect( page.locator( 'main#chrnx-main' ) ).toBeFocused();
}
}
} );
test( 'reduced motion removes card transitions while theme preference remains user-controlled', async ( {
page,
} ) => {
await page.emulateMedia( { reducedMotion: 'reduce', colorScheme: 'light' } );
await page.emulateMedia( {
reducedMotion: 'reduce',
colorScheme: 'light',
} );
await page.goto( '/' );
const card = page.locator( '.chrnx-featured-story' ).first();
const duration = await card.evaluate( ( element ) =>
@@ -111,7 +256,7 @@ test( 'key public surfaces pass automated WCAG 2.2 AA checks', async ( { page },
'One engine is sufficient for deterministic axe rules.',
);
const tags = [ 'wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa' ];
for ( const viewport of [ viewports[ 0 ], viewports[ 2 ] ] ) {
for ( const viewport of viewports ) {
await page.setViewportSize( viewport );
for ( const path of [
'/',