import assert from 'node:assert/strict'; import {writeFile} from 'node:fs/promises'; // 本次任务已有的空间;新的验收任务请改成已创建的空间 ID。 const task=await taskSpace(4),page=task.page('p1'); const dir='/Users/wukaibing/Grok/number-swipe/modes/02-connect-1234/docs/qa-v2'; await page.keyboard.press('Escape'); assert(await page.evaluate(()=>document.querySelector('#modal').hidden)); await page.click('#records'); await page.screenshot({path:dir+'/records.png'}); await page.keyboard.press('Escape'); const layouts=[]; for(const [width,height] of [[320,568],[360,740],[390,844],[430,932],[844,390],[1280,900]]){ await page.cdp('Emulation.setDeviceMetricsOverride',{width,height,deviceScaleFactor:2,mobile:width<600}); await page.waitForFunction(w=>innerWidth===w,width,{timeout:3000}); const layout=await page.evaluate(()=>({width:innerWidth,height:innerHeight,scrollWidth:document.documentElement.scrollWidth,scrollHeight:document.documentElement.scrollHeight, buttons:[...document.querySelectorAll('#app button')].map(b=>{const r=b.getBoundingClientRect();return {id:b.id,w:r.width,h:r.height,bottom:r.bottom}}),stageHeight:document.querySelector('#stage').getBoundingClientRect().height})); assert.equal(layout.scrollWidth,width); assert(layout.buttons.every(b=>b.w>=44&&b.h>=44)); layouts.push(layout); if(width===320)await page.screenshot({path:dir+'/small-phone.png'}); if(width===1280)await page.screenshot({path:dir+'/desktop.png'}); } await page.cdp('Emulation.setDeviceMetricsOverride',{width:390,height:844,deviceScaleFactor:2,mobile:true}); await page.cdp('Emulation.setEmulatedMedia',{features:[{name:'prefers-reduced-motion',value:'reduce'}]}); await page.click('#restart'); await page.click('button[data-action="new"]'); assert.equal(await page.evaluate(()=>window.__balloons.snapshot().stats.turns),0); const points=await page.evaluate(()=>{const api=window.__balloons,s=api.snapshot(),t=api.transform(),r=document.querySelector('#board').getBoundingClientRect();return api.hint().map(id=>{const b=s.balls.find(b=>b.id===id);return{x:r.left+t.x+b.x*t.scale,y:r.top+t.y+b.y*t.scale,id:0}})}); for(let i=0;iwindow.__balloons.snapshot().stats.turns),1);assert(!await page.evaluate(()=>window.__balloons.animating())); // 减少动态效果下的横幅仍可显示(不依赖 CSS keyframes)。 const bannerStyle=await page.evaluate(()=>{const el=document.querySelector('#combo-banner');el.classList.add('show');const style=getComputedStyle(el);return{opacity:style.opacity,animation:style.animationName};}); assert.equal(bannerStyle.opacity,'1');assert.equal(bannerStyle.animation,'none'); await page.cdp('Emulation.setEmulatedMedia',{features:[]}); await writeFile(dir+'/layout.json',JSON.stringify({layouts,reducedMotion:true,keyboardModal:true},null,2)+'\n'); console.log(JSON.stringify({layouts:layouts.map(l=>({width:l.width,height:l.height,scrollHeight:l.scrollHeight,stageHeight:l.stageHeight})),reducedMotion:true}));