// Explain content-driven height differences without altering the frozen sample or product. // Original sample screenshots remain in the evidence pack. This second pass changes only // the two descriptive strings to the isolated fixture strings and measures their reflow. import fs from 'node:fs/promises'; import path from 'node:path'; import {pathToFileURL} from 'node:url'; const {chromium}=await import(process.env.PLAYWRIGHT_MODULE || 'playwright'); const out='e2e/shots/hel731'; const measurements=JSON.parse(await fs.readFile(out+'/measurements.json','utf8')); const browser=await chromium.launch({args:['--no-sandbox']}); const results=[]; try{ for(const [width,height] of [[1440,900],[1366,768],[1280,720]])for(const theme of ['night','day','grade','bluehour']){ const page=await browser.newPage({viewport:{width,height}}); await page.goto(pathToFileURL(path.resolve('../attachments/夜片场-多主题交互样本.html')).href); await page.evaluate(t=>{document.documentElement.dataset.theme=t;document.documentElement.classList.add('reduce');document.querySelector('.hero .copy p').textContent='纸船带回一片树叶';document.querySelectorAll('#projShots .scard .bd p').forEach(e=>e.textContent='女孩沿着海岸走向灯塔,纸船随海风起伏。');},theme); for(const [name,ref,actual] of [['studio','.hero','.studio-hero'],['project','.scard','.storyboard-card']]){ await page.evaluate(name=>document.querySelectorAll('.page').forEach(e=>e.classList.toggle('on',e.id==='p-'+name)),name);await page.waitForTimeout(350); const box=await page.locator(ref).first().boundingBox();const a=measurements.find(x=>x.width===width&&x.theme===theme&&x.selector===actual).actual; results.push({theme,width,page:name,sampleWithFixtureDescription:box,actual:a,deltaHeight:a.height-box.height}); await page.screenshot({path:`${out}/${name}-${theme}-${width}-sample-description-normalized.png`}); }await page.close(); } await fs.writeFile(out+'/description-reflow.json',JSON.stringify(results,null,2)); console.log('normalized reflow comparisons',results.length,'maximum height delta',Math.max(...results.map(r=>Math.abs(r.deltaHeight)))); }finally{await browser.close()}