style: finish CHRNX editorial sections
This commit is contained in:
3 files changed
+316
-16
No files matched your search
@@ -52,6 +52,158 @@ test( 'home remains coherent at all approved review viewports', async ( { page }
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'lower home sections form compact, contained editorial panels in both themes', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
const expectedOrder = [
|
||||
'chrnx-home-projects',
|
||||
'chrnx-home-music',
|
||||
'wp-block-chrnx-latest-podcast',
|
||||
'chrnx-home-about-preview',
|
||||
'wp-block-chrnx-subscribe-cta',
|
||||
];
|
||||
|
||||
for ( const theme of [ 'Dark', 'Light' ] ) {
|
||||
for ( const viewport of viewports ) {
|
||||
await page.setViewportSize( viewport );
|
||||
await page.goto( '/' );
|
||||
await page.evaluate(
|
||||
( value ) => window.localStorage.setItem( 'chrnx-theme', value ),
|
||||
theme.toLowerCase(),
|
||||
);
|
||||
await page.reload();
|
||||
await expect( page.locator( 'html' ) ).toHaveAttribute( 'data-theme', theme.toLowerCase() );
|
||||
|
||||
const result = await page.locator( '.chrnx-home' ).evaluate( ( home, order ) => {
|
||||
const selectors = [
|
||||
'.chrnx-home-projects',
|
||||
'.chrnx-home-music .wp-block-columns',
|
||||
'.chrnx-latest-podcast',
|
||||
'.chrnx-home-about-preview',
|
||||
'.chrnx-subscribe-cta',
|
||||
];
|
||||
const panels = selectors.map( ( selector ) => home.querySelector( selector ) );
|
||||
const bodyStyle = window.getComputedStyle( document.body );
|
||||
const canvas = `${ bodyStyle.backgroundColor }|${ bodyStyle.backgroundImage }`;
|
||||
const spacingProbe = document.createElement( 'div' );
|
||||
spacingProbe.style.cssText =
|
||||
'position:absolute;visibility:hidden;width:var(--wp--preset--spacing--70);height:1px';
|
||||
document.body.append( spacingProbe );
|
||||
const xl = spacingProbe.getBoundingClientRect().width;
|
||||
spacingProbe.remove();
|
||||
const signature = ( element ) => {
|
||||
const style = window.getComputedStyle( element );
|
||||
return `${ style.backgroundColor }|${ style.backgroundImage }|${ style.borderTopColor }|${ style.boxShadow }`;
|
||||
};
|
||||
const hasOpaqueSurface = ( element ) => {
|
||||
const style = window.getComputedStyle( element );
|
||||
return (
|
||||
style.backgroundColor !== 'rgba(0, 0, 0, 0)' && style.backgroundColor !== 'transparent'
|
||||
);
|
||||
};
|
||||
const isTreated = ( element ) => {
|
||||
const style = window.getComputedStyle( element );
|
||||
return (
|
||||
style.filter !== 'none' ||
|
||||
style.boxShadow !== 'none' ||
|
||||
style.maskImage !== 'none' ||
|
||||
style.webkitMaskImage !== 'none'
|
||||
);
|
||||
};
|
||||
const isContained = ( child, frame ) => {
|
||||
const childRect = child.getBoundingClientRect();
|
||||
const frameRect = frame.getBoundingClientRect();
|
||||
return (
|
||||
childRect.left >= frameRect.left - 1 &&
|
||||
childRect.right <= frameRect.right + 1 &&
|
||||
childRect.top >= frameRect.top - 1 &&
|
||||
childRect.bottom <= frameRect.bottom + 1
|
||||
);
|
||||
};
|
||||
const panelRects = panels.map( ( panel ) => panel.getBoundingClientRect() );
|
||||
const journalRect = home.querySelector( '.chrnx-journal-stream' ).getBoundingClientRect();
|
||||
const musicFrame = panels[ 1 ];
|
||||
const collage = window.getComputedStyle( musicFrame, '::before' );
|
||||
const musician = musicFrame.querySelector( '.chrnx-home-music__art' );
|
||||
const projectPortraits = [
|
||||
...panels[ 0 ].querySelectorAll( '.chrnx-section-portrait' ),
|
||||
].filter( ( portrait ) => portrait.getClientRects().length > 0 );
|
||||
|
||||
return {
|
||||
directOrder: [ ...home.children ]
|
||||
.filter( ( child ) =>
|
||||
order.some( ( className ) => child.classList.contains( className ) ),
|
||||
)
|
||||
.map( ( child ) =>
|
||||
order.find( ( className ) => child.classList.contains( className ) ),
|
||||
),
|
||||
signatures: panels.map( signature ),
|
||||
opaqueSurfaces: panels.map( hasOpaqueSurface ),
|
||||
canvas,
|
||||
xl,
|
||||
gaps: [
|
||||
panelRects[ 0 ].top - journalRect.bottom,
|
||||
...panelRects
|
||||
.slice( 1 )
|
||||
.map( ( rect, index ) => rect.top - panelRects[ index ].bottom ),
|
||||
],
|
||||
projectsContained: projectPortraits.every( ( portrait ) =>
|
||||
isContained( portrait, panels[ 0 ] ),
|
||||
),
|
||||
projectsTreated: projectPortraits.every( isTreated ),
|
||||
collageBackground: collage.backgroundImage,
|
||||
collageContent: collage.content,
|
||||
collageContained:
|
||||
collage.position === 'absolute' &&
|
||||
[ collage.inset, collage.top, collage.right, collage.bottom, collage.left ]
|
||||
.join( ' ' )
|
||||
.includes( '0px' ),
|
||||
musicianContained: isContained( musician, musicFrame ),
|
||||
musicianTreated: isTreated( musician ),
|
||||
};
|
||||
}, expectedOrder );
|
||||
|
||||
expect( result.directOrder ).toEqual( expectedOrder );
|
||||
expect( result.xl ).toBeGreaterThan( 0 );
|
||||
expect(
|
||||
result.gaps.every( ( gap ) => gap >= -1 && gap <= result.xl + 1 ),
|
||||
`gaps ${ result.gaps.join( ', ' ) }; XL ${ result.xl } at ${ viewport.width }px ${ theme }`,
|
||||
).toBeTruthy();
|
||||
expect( new Set( result.signatures ).size ).toBe( result.signatures.length );
|
||||
expect( result.opaqueSurfaces.every( Boolean ) ).toBeTruthy();
|
||||
expect(
|
||||
result.signatures.every( ( signature ) => signature !== result.canvas ),
|
||||
).toBeTruthy();
|
||||
expect( result.projectsContained ).toBeTruthy();
|
||||
expect( result.projectsTreated ).toBeTruthy();
|
||||
expect( result.collageBackground ).toContain( 'the-no-names-collage.jpeg' );
|
||||
expect( result.collageContent ).not.toBe( 'none' );
|
||||
expect( result.collageContained ).toBeTruthy();
|
||||
expect( result.musicianContained ).toBeTruthy();
|
||||
expect( result.musicianTreated ).toBeTruthy();
|
||||
await expectNoHorizontalOverflow( page );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'lower home panels survive missing media and reduced motion', async ( { page } ) => {
|
||||
await page.emulateMedia( { reducedMotion: 'reduce' } );
|
||||
await page.route( /\/assets\/images\//, ( route ) => route.abort() );
|
||||
await page.setViewportSize( { width: 375, height: 812 } );
|
||||
await page.goto( '/' );
|
||||
|
||||
for ( const selector of [
|
||||
'.chrnx-home-projects',
|
||||
'.chrnx-home-music .wp-block-columns',
|
||||
'.chrnx-latest-podcast',
|
||||
'.chrnx-home-about-preview',
|
||||
'.chrnx-subscribe-cta',
|
||||
] ) {
|
||||
await expect( page.locator( selector ) ).toBeVisible();
|
||||
}
|
||||
await expectNoHorizontalOverflow( page );
|
||||
} );
|
||||
|
||||
test( 'explicit themes use an atmospheric canvas and a compact home introduction', async ( {
|
||||
page,
|
||||
} ) => {
|
||||
|
||||
@@ -89,6 +89,47 @@ test( 'the page canvas is atmospheric rather than a repeating grid', () => {
|
||||
);
|
||||
} );
|
||||
|
||||
test( 'lower home sections preserve editorial order and define layered panel treatments', () => {
|
||||
const front = read( 'templates/front-page.html' );
|
||||
const components = read( 'assets/css/components.css' );
|
||||
const orderedSections = [
|
||||
'chrnx/home-projects',
|
||||
'chrnx/home-music',
|
||||
'chrnx/latest-podcast',
|
||||
'chrnx-home-about-preview',
|
||||
'chrnx/subscribe-cta',
|
||||
];
|
||||
let previousIndex = -1;
|
||||
|
||||
for ( const section of orderedSections ) {
|
||||
const currentIndex = front.indexOf( section );
|
||||
assert.ok( currentIndex > previousIndex, `${ section } must keep its semantic position` );
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
assert.match(
|
||||
components,
|
||||
/\.chrnx-home-music \.wp-block-columns::before\s*\{[\s\S]*?the-no-names-collage\.jpeg/,
|
||||
);
|
||||
assert.match(
|
||||
components,
|
||||
/\.chrnx-home-music \.chrnx-responsive-portrait\s*\{[\s\S]*?(?:filter|box-shadow|mask(?:-image)?):/,
|
||||
);
|
||||
for ( const selector of [
|
||||
'.chrnx-home-projects',
|
||||
'.chrnx-latest-podcast',
|
||||
'.chrnx-home-about-preview',
|
||||
'.chrnx-subscribe-cta',
|
||||
] ) {
|
||||
const escapedSelector = selector.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
||||
assert.match(
|
||||
components,
|
||||
new RegExp( `${ escapedSelector }[^,{]*\\{[\\s\\S]*?background(?:-color|-image)?:` ),
|
||||
`${ selector } needs an authored surface`,
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
||||
test( 'all approved portraits rebuild byte-identically within payload bounds', () => {
|
||||
const readme = read( 'README.md' );
|
||||
const documentedCommand = 'mktemp -d "${TMPDIR:-/tmp}/chrnx-responsive.XXXXXX"';
|
||||
|
||||
Reference in new issue
Block a user