style: refine CHRNX canvas and hero
This commit is contained in:
3 files changed
+111
-19
No files matched your search
@@ -35,6 +35,60 @@ test( 'home remains coherent at all approved review viewports', async ( { page }
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'explicit themes use an atmospheric canvas and a compact home introduction', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
const canvases = new Map();
|
||||
|
||||
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 expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', theme.toLowerCase() );
|
||||
|
||||
const desktop = await page.evaluate( () => {
|
||||
const hero = document.querySelector( '.chrnx-home-intro' );
|
||||
const bodyStyle = window.getComputedStyle( document.body );
|
||||
const heroRect = hero.getBoundingClientRect();
|
||||
return {
|
||||
backgroundColor: bodyStyle.backgroundColor,
|
||||
backgroundImage: bodyStyle.backgroundImage,
|
||||
backgroundRepeat: bodyStyle.backgroundRepeat,
|
||||
backgroundSize: bodyStyle.backgroundSize,
|
||||
heroHeight: heroRect.height,
|
||||
};
|
||||
} );
|
||||
|
||||
expect( desktop.backgroundImage ).toMatch( /(?:radial|linear)-gradient/ );
|
||||
expect( desktop.backgroundImage ).not.toBe( 'none' );
|
||||
expect(
|
||||
desktop.backgroundRepeat.split( ', ' ).every( ( value ) => value === 'no-repeat' ),
|
||||
).toBeTruthy();
|
||||
expect( desktop.backgroundSize ).not.toMatch( /(?:32|48)px\s+(?:32|48)px/ );
|
||||
expect( desktop.heroHeight ).toBeGreaterThanOrEqual( 900 * 0.6 - 1 );
|
||||
expect( desktop.heroHeight ).toBeLessThanOrEqual( 900 * 0.68 + 1 );
|
||||
expect( desktop.heroHeight ).toBeLessThanOrEqual( 42 * 16 + 1 );
|
||||
canvases.set( theme, `${ desktop.backgroundColor } ${ desktop.backgroundImage }` );
|
||||
|
||||
await page.setViewportSize( { width: 375, height: 812 } );
|
||||
const mobile = await page.locator( '.chrnx-home-intro' ).evaluate( ( hero ) => {
|
||||
const heroRect = hero.getBoundingClientRect();
|
||||
const paragraphRect = hero.querySelector( 'p' ).getBoundingClientRect();
|
||||
const style = window.getComputedStyle( hero );
|
||||
return {
|
||||
height: heroRect.height,
|
||||
trailingSpace: heroRect.bottom - paragraphRect.bottom,
|
||||
sectionSpacing: Number.parseFloat( style.paddingBottom ),
|
||||
};
|
||||
} );
|
||||
|
||||
expect( mobile.height ).toBeLessThanOrEqual( 34 * 16 + 1 );
|
||||
expect( mobile.trailingSpace ).toBeLessThanOrEqual( mobile.sectionSpacing + 1 );
|
||||
}
|
||||
|
||||
expect( canvases.get( 'Dark' ) ).not.toBe( canvases.get( 'Light' ) );
|
||||
} );
|
||||
|
||||
test( 'seeded post permalink resolves its single template', async ( { page } ) => {
|
||||
const title = 'The save file remembers what the hero pretends to forget';
|
||||
const expectedPath = '/the-save-file-remembers-what-the-hero-pretends-to-forget/';
|
||||
|
||||
Reference in new issue
Block a user