fix: harden CHRNX shell accessibility
This commit is contained in:
14 files changed
+520
-54
No files matched your search
@@ -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();
|
||||
} );
|
||||
}
|
||||
} );
|
||||
Reference in new issue
Block a user