← back to Dw Photo Capture
selfcheck-ui.cjs
41 lines
const { chromium } = require('/Users/macstudio3/.npm-global/lib/node_modules/playwright/index.js');
const BASE='http://127.0.0.1:9890';
(async()=>{
const fails=[], errs=[], notes=[];
const b=await chromium.launch();
const ctx=await b.newContext({ httpCredentials:{username:'admin',password:'DW2024!'}, viewport:{width:430,height:932} });
const pg=await ctx.newPage();
pg.on('console',m=>{ if(m.type()==='error') errs.push(m.text().slice(0,160)); });
pg.on('requestfailed',r=>fails.push(`${r.method()} ${r.url()} — ${(r.failure()||{}).errorText}`));
pg.on('response',r=>{ if(r.status()>=400) fails.push(`HTTP ${r.status()} ${r.url().replace(BASE,'')}`); });
const log=(m)=>notes.push(m);
await pg.goto(BASE+'/?fresh',{waitUntil:'networkidle',timeout:30000});
log('version pill = '+await pg.$eval('.ver',e=>e.textContent).catch(()=>'(none)'));
const chips=await pg.$$eval('.chip',els=>els.map(e=>e.dataset.f));
log('chips present: '+chips.join(', '));
for(const c of ['need','live','done','new','all']){
const chip=await pg.$(`.chip[data-f="${c}"]`); if(!chip){ log(`MISSING chip ${c}`); continue; }
await chip.click(); await pg.waitForTimeout(900);
log(`chip ${c}: count="${await pg.$eval('#count',e=>e.textContent).catch(()=>'?')}" cards=${await pg.$$eval('.card',e=>e.length)}`);
}
await pg.click('.chip[data-f="any"]'); await pg.waitForTimeout(400);
await pg.fill('#q','maranello'); await pg.waitForTimeout(1300);
log('any/maranello cards='+await pg.$$eval('.card',e=>e.length));
await pg.click('.chip[data-f="shop"]'); await pg.waitForTimeout(400);
await pg.fill('#q','natural cork'); await pg.waitForTimeout(3500);
log('shop/"natural cork" cards='+await pg.$$eval('.card',e=>e.length));
const galBtn=await pg.$('.gal');
if(galBtn){ await galBtn.click(); await pg.waitForTimeout(1800);
log(`gallery opened=${await pg.$eval('#gallery',e=>!e.hidden).catch(()=>false)} tiles=${await pg.$$eval('.gtile',e=>e.length).catch(()=>0)}`);
const cl=await pg.$('#galClose'); if(cl){await cl.click();log('gallery close OK');} else log('MISSING galClose');
} else log('no .gal button in current view');
await pg.click('.chip[data-f="need"]'); await pg.waitForTimeout(500);
await pg.$eval('#dens',e=>{e.value=3;e.dispatchEvent(new Event('input'));e.dispatchEvent(new Event('change'));}); await pg.waitForTimeout(400);
log('density=3 -> columns='+await pg.$eval('main',e=>getComputedStyle(e).gridTemplateColumns.split(' ').length));
await b.close();
console.log('=== NOTES ==='); notes.forEach(n=>console.log(' •',n));
const uf=[...new Set(fails)];
console.log('\n=== FAILED REQUESTS / DEAD LINKS ('+uf.length+') ==='); uf.forEach(f=>console.log(' x',f));
console.log('\n=== CONSOLE ERRORS ('+[...new Set(errs)].length+') ==='); [...new Set(errs)].slice(0,15).forEach(e=>console.log(' !',e));
})();