From c286de5aaae2f2363f6f9399c168ba3d218c08b0 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 6 Oct 2026 16:32:07 -0400 Subject: [PATCH] test(capture): await source resize fixture transitions --- src/lib/fidelity/reference.test.ts | 1 + src/lib/screenshot/fluid-capture.test.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/fidelity/reference.test.ts b/src/lib/fidelity/reference.test.ts index e516f35b..5de57752 100644 --- a/src/lib/fidelity/reference.test.ts +++ b/src/lib/fidelity/reference.test.ts @@ -446,6 +446,7 @@ describe.skipIf( Boolean( process.env.SKIP_BROWSER_TESTS ) || ! existsSync( chro const browser = await chromium.launch(); const context = await browser.newContext( { viewport: { width: 1440, height: 900 } } ); try { const page = await context.newPage(); await page.goto( url ); await page.setViewportSize( { width: 768, height: 900 } ); + await page.waitForFunction( () => document.documentElement.dataset.pose === 'resized' ); expect( await page.locator( 'h1' ).evaluate( element => getComputedStyle( element ).fontSize ) ).toBe( '29px' ); const collector = createReferenceCollector( directory, url, [ url ], { cleanupPolicy: cleanupPolicy() } ); await collector.observe( page, url, 'desktop', [], { isMobile: false, hasTouch: false } ); diff --git a/src/lib/screenshot/fluid-capture.test.ts b/src/lib/screenshot/fluid-capture.test.ts index adcd3330..fed8071f 100644 --- a/src/lib/screenshot/fluid-capture.test.ts +++ b/src/lib/screenshot/fluid-capture.test.ts @@ -538,7 +538,10 @@ describe( 'learnAndApplyFluidGeometry', () => { const heights: Record< number, number > = {}; for ( const width of [ 390, 600, 768, 1024, 1280, 1440, 1536, 1680, 1792, 1920 ] ) { await source.setViewportSize( { width, height: 900 } ); - await source.waitForTimeout( 10 ); + await source.waitForFunction( () => { + const expected = innerWidth < 768 ? innerWidth === 390 ? '208px' : '100%' : `${ innerWidth * 0.23 }px`; + return document.querySelector< HTMLElement >( '#frame' )!.style.getPropertyValue( '--image-height' ) === expected; + } ); heights[ width ] = ( await source.locator( '#image' ).boundingBox() )!.height; } await learnAndApplyFluidGeometry( source, { settleMs: 30 } );