(async()=>{constbrowser=awaitchromium.launch({headless:true,executablePath:'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'});constpage=awaitbrowser.newPage();letunintended=0;page.on('request',r=>{if(r.method()==='POST'&&/\/(jobs|playlists|display)$/.test(r.url()))unintended++;});constbase=process.env.FRAME_FLOW_URL||'http://127.0.0.1:6005';awaitpage.goto(base);awaitpage.locator('#username').fill(process.env.FRAME_FLOW_TEST_USERNAME);awaitpage.locator('#password').fill(process.env.FRAME_FLOW_TEST_PASSWORD);awaitpage.locator('#login-form button').click();awaitpage.locator('.hero').waitFor();assert(awaitpage.evaluate(()=>state.settings.mock));letchecks=0;for(constlangof['zh','en'])for(constwritableof[false,true]){constclean=awaitpage.evaluate(({lang,writable})=>{constprevious={lang:state.lang,settings:state.settings};state.lang=lang;state.settings={...state.settings,mock:false,write_enabled:writable};shell();constclean=notice()===''&&!document.querySelector('#connection')&&!document.querySelector('.sidebar-bottom .live-dot');state.lang=previous.lang;state.settings=previous.settings;shell();returnclean;},{lang,writable});assert(clean,'Live-device status must not appear in either language');checks++;}for(constwidthof[1440,390])for(constthemeof['light','dark']){awaitpage.setViewportSize({width,height:1000});awaitpage.evaluate(theme=>{localStorage.setItem('ff-theme',theme);document.documentElement.dataset.theme=theme;},theme);for(constnameof['dashboard','gallery','photo-sources','upload','templates','automation','playlists','history','settings']){awaitpage.locator(`[data-page="${name}"]`).click();awaitpage.waitForTimeout(350);if(name==='settings')awaitpage.locator('#image-host-form').waitFor();constresult=awaitpage.evaluate(()=>{constchildren=[...document.querySelector('#main').children].filter(x=>x.getBoundingClientRect().height>0);return{overflow:document.documentElement.scrollWidth>innerWidth,buttonGaps:[...document.querySelectorAll('#main button')].flatMap(b=>{constnext=b.nextElementSibling;if(next?.tagName!=='BUTTON')return[];consta=b.getBoundingClientRect(),c=next.getBoundingClientRect();if(!a.width||!c.width)return[];return[Math.abs(a.top-c.top)<4?c.left-a.right:c.top-a.bottom];}),gaps:children.slice(1).map((x,i)=>x.getBoundingClientRect().top-children[i].getBoundingClientRect().bottom)};});constcontrols=awaitpage.evaluate(()=>{constnodes=[...document.querySelectorAll('#main input:not([type="checkbox"]):not([type="radio"]),#main select,#main textarea,#main button')].filter(x=>{constr=x.getBoundingClientRect();returnr.width&&r.height&&getComputedStyle(x).visibility!=='hidden';});constissues=[];for(leti=0;i<nodes.length;i++)for(letj=i+1;j<nodes.length;j++){consta=nodes[i].getBoundingClientRect(),b=nodes[j].getBoundingClientRect();constox=Math.min(a.right,b.right)-Math.max(a.left,b.left),oy=Math.min(a.bottom,b.bottom)-Math.max(a.top,b.top);constdy=Math.max(a.top,b.top)-Math.min(a.bottom,b.bottom),dx=Math.max(a.left,b.left)-Math.min(a.right,b.right);if((ox>Math.min(a.width,b.width)/2&&dy>=0&&dy<8)||(oy>Math.min(a.height,b.height)/2&&dx>=0&&dx<8))issues.push({a:nodes[i].id,b:nodes[j].id,gap:ox>0?dy:dx});}returnissues;});assert(controls.length===0,`${name}${width}${theme} controls ${JSON.stringify(controls)}`);checks++;