// Real controls, normal pointer input and isolated application/model chain at every viewport/theme. const {chromium}=require(process.env.PLAYWRIGHT_MODULE_PATH||'playwright'); const fs=require('node:fs'),assert=require('node:assert/strict'); const out='e2e/shots/hel732',WEB='http://127.0.0.1:5173',API='http://127.0.0.1:8247'; (async()=>{ const browser=await chromium.launch({args:['--no-sandbox','--disable-dev-shm-usage']}); const rows=[],errors=[],checks=[]; const board=JSON.parse(fs.readFileSync(out+'/fixture-state.json')).board; const measure=async(page,selector)=>page.locator(selector).first().evaluate(e=>{const r=e.getBoundingClientRect();return {selector:e.getAttribute('aria-label')||e.className,x:r.x,y:r.y,width:r.width,height:r.height,right:r.right,bottom:r.bottom,visible:r.x>=0&&r.y>=0&&r.right<=innerWidth&&r.bottom<=innerHeight,hit:e.contains(document.elementFromPoint(r.x+r.width/2,r.y+r.height/2))}}); try{ for(const [width,height]of [[1440,900],[1366,768],[1280,720]])for(const theme of ['night','day','grade','bluehour']){ const context=await browser.newContext({viewport:{width,height}}),p=await context.newPage(); p.on('pageerror',e=>errors.push(e.message)); await p.goto(WEB+'/agents');await p.locator('.roster .acard').first().waitFor(); await p.evaluate(theme=>{document.documentElement.dataset.theme=theme;localStorage.setItem('aigc-theme',theme)},theme); const home={hero:await measure(p,'.ahero'),input:await measure(p,'[aria-label="任务想法"]'),start:await measure(p,'.big-input .primary')}; assert(home.input.visible&&home.input.hit&&home.start.visible&&home.start.hit,JSON.stringify(home)); assert(home.start.bottom<=home.hero.bottom); assert(await p.locator('.agent-home').evaluate(e=>e.scrollWidth<=e.clientWidth)); await p.getByLabel('任务想法').fill(`小窗口真实启动 ${theme} ${width},请调用工具读取工作区并写一段海岸故事。`); await p.getByLabel('任务想法').click();assert(await p.getByLabel('任务想法').evaluate(e=>e===document.activeElement)); await p.screenshot({path:`${out}/layout-input-${theme}-${width}.png`,animations:'disabled'}); await p.locator('.mini-row').scrollIntoViewIfNeeded(); await p.waitForFunction(()=>{const r=document.querySelector('.mini-row').getBoundingClientRect();return r.bottom<=innerHeight+1&&r.top>=0}); await p.screenshot({path:`${out}/layout-scrolled-${theme}-${width}.png`,animations:'disabled'}); await p.getByRole('button',{name:'开始任务',exact:true}).click(); await p.waitForURL(/session=\d+/);const session=Number(new URL(p.url()).searchParams.get('session')); await p.waitForFunction(async({API,session})=>(await(await fetch(API+'/api/results/deliverables?session_id='+session)).json()).length>0,{API,session}); checks.push(`输入、焦点、自然滚动和正常点击启动真实会话 ${theme} ${width}`); await p.goto(WEB+'/agents?session='+board);await p.locator('.shot-copy textarea').first().waitFor(); const controls={};for(const selector of ['.art-f','[aria-label="成果项目"]','[aria-label="成果阶段"]','.art-f .secondary','.art-f .primary']){ controls[selector]=await measure(p,selector);assert(controls[selector].visible&&controls[selector].hit,JSON.stringify(controls[selector])); } for(const label of ['成果项目','成果阶段']){await p.getByLabel(label).focus();assert(await p.getByLabel(label).evaluate(e=>e===document.activeElement));} for(const selector of ['.art-f .secondary','.art-f .primary']){await p.locator(selector).focus();assert(await p.locator(selector).evaluate(e=>e===document.activeElement));} assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth)); await p.screenshot({path:`${out}/layout-footer-${theme}-${width}.png`,animations:'disabled'}); rows.push({theme,width,height,home,controls});await context.close(); } assert.deepEqual(errors,[]);fs.writeFileSync(out+'/layout-checks.json',JSON.stringify({rows,checks,errors},null,2));console.log('PASS 12 theme/viewport input/start/scroll/real selector/focus/overflow checks'); }finally{await browser.close()} })().catch(e=>{console.error(e);process.exit(1)});