test: exercise CHRNX editor workflows

This commit is contained in:
chrnx committed 2026-08-13 07:57:04 -05:00
1 parent 03aca3beff
commit 62df36ef81
3 files changed
+204 -61

No files matched your search

+58 -7
View File
@@ -1210,6 +1210,7 @@ const musicPodcastLandingCases = [
copy: 'The No Names es una banda activa',
atmosphere: 'img[src*="the-no-names-collage.jpeg"]',
art: 'img[src*="the-no-names-musician-cutout.png"]',
latestMedia: null,
supporting: 'text=El proceso usa generative AI',
},
{
@@ -1219,10 +1220,58 @@ const musicPodcastLandingCases = [
copy: 'Conversations about the work behind software, research, music, and games.',
atmosphere: 'img[src*="podcast-frequency-grunge.png"]',
art: 'img[src*="alter-ego-podcasts.png"]',
latestMedia: '.chrnx-latest-podcast img',
supporting: '.chrnx-latest-podcast',
},
];
async function waitForDecodedLandingImages( page, landing, { awaitDecode = true } = {} ) {
const selectors = [ landing.atmosphere, landing.art ];
if ( landing.latestMedia ) {
selectors.push( landing.latestMedia );
}
const images = page.locator( landing.root ).locator( selectors.join( ', ' ) );
await expect
.poll( () =>
images.evaluateAll(
( elements ) =>
elements.length >= 2 &&
elements.every(
( image ) => image.complete && image.naturalWidth > 0 && image.naturalHeight > 0,
),
),
)
.toBe( true );
if ( ! awaitDecode ) {
await images.evaluateAll( ( elements ) => {
elements.forEach( ( image ) => {
if ( typeof image.decode === 'function' ) {
image.decode().catch( () => {} );
}
if ( ! image.complete || image.naturalWidth <= 0 || image.naturalHeight <= 0 ) {
throw new Error( `Landing image failed to decode: ${ image.currentSrc || image.src }` );
}
} );
} );
return;
}
await images.evaluateAll( async ( elements ) => {
const decodePromises = elements.map( ( image ) => {
if ( typeof image.decode === 'function' ) {
return image.decode();
}
return Promise.resolve();
} );
await Promise.all( decodePromises );
elements.forEach( ( image ) => {
if ( ! image.complete || image.naturalWidth <= 0 || image.naturalHeight <= 0 ) {
throw new Error( `Landing image failed to decode: ${ image.currentSrc || image.src }` );
}
} );
} );
}
async function readMusicPodcastLandingState( page, landing ) {
return page.locator( landing.root ).evaluate( ( root ) => {
const stage = root.querySelector( '.chrnx-character-stage' );
@@ -1303,6 +1352,9 @@ test( 'Music and Podcast without JavaScript preserve the complete landing compos
await expect( root.locator( landing.atmosphere ) ).toBeVisible();
await expect( root.locator( landing.art ) ).toBeVisible();
await expect( root.locator( landing.supporting ) ).toBeVisible();
await waitForDecodedLandingImages( page, landing, {
awaitDecode: false,
} );
const state = await readMusicPodcastLandingState( page, landing );
expect( state.layerOrder ).toEqual( [ 'atmosphere', 'content', 'art' ] );
expect( state.copyVisible ).toBeTruthy();
@@ -1335,15 +1387,14 @@ test( 'Music and Podcast reduced motion match settled layout without displacemen
try {
for ( const landing of musicPodcastLandingCases ) {
await page.goto( landing.path );
await page
.locator( `${ landing.root } .chrnx-character-stage__art img` )
.evaluate( ( image ) => image.decode() );
await waitForDecodedLandingImages( page, landing );
const settled = await readMusicPodcastLandingState( page, landing );
await page.emulateMedia( { colorScheme, reducedMotion: 'reduce' } );
await page.emulateMedia( {
colorScheme,
reducedMotion: 'reduce',
} );
await page.reload();
await page
.locator( `${ landing.root } .chrnx-character-stage__art img` )
.evaluate( ( image ) => image.decode() );
await waitForDecodedLandingImages( page, landing );
const reduced = await readMusicPodcastLandingState( page, landing );
expect( reduced.layerOrder ).toEqual( [ 'atmosphere', 'content', 'art' ] );