fix: harden CHRNX shell accessibility

This commit is contained in:
chrnx committed 2026-08-11 17:12:18 -05:00
1 parent f371db4cb5
commit e1579657d6
14 files changed
+520 -54

No files matched your search

+29
View File
@@ -136,6 +136,7 @@ test.describe( 'real theme preference shell', () => {
const page = await context.newPage();
await page.goto( '/' );
await expect( page.locator( '[data-chrnx-theme-toggle]' ) ).toBeHidden();
await expect( page.locator( '[data-chrnx-menu-toggle]' ) ).toBeHidden();
await expect( page.locator( '.chrnx-theme-noscript' ) ).toHaveText(
'Enable JavaScript to choose a color theme.',
);
@@ -144,4 +145,32 @@ test.describe( 'real theme preference shell', () => {
).toBeVisible();
await context.close();
} );
for ( const [ scheme, background, colorScheme ] of [
[ 'light', 'rgb(246, 242, 233)', 'light' ],
[ 'dark', 'rgb(13, 17, 23)', 'dark' ],
] ) {
test( `without JavaScript follows ${ scheme } system colors`, async ( {
browser,
baseURL,
} ) => {
const context = await browser.newContext( {
baseURL,
colorScheme: scheme,
javaScriptEnabled: false,
} );
const page = await context.newPage();
await page.goto( '/' );
await expect( page.locator( 'html' ) ).not.toHaveAttribute( 'data-theme' );
const actual = await page.evaluate( () => ( {
background: window.getComputedStyle( document.body ).backgroundColor,
colorScheme: window.getComputedStyle( document.documentElement ).colorScheme,
} ) );
expect( actual ).toEqual( { background, colorScheme } );
await expect(
page.getByRole( 'banner' ).getByRole( 'link', { name: 'Journal', exact: true } ),
).toBeVisible();
await context.close();
} );
}
} );