← back to Quadrille Showroom

scripts/verify-walls-on-next.mjs

39 lines

/* Verify: every Next/Prev book-page clads the NEW design onto ALL 4 walls. */
import pw from '/Users/macstudio3/.npm-global/lib/node_modules/playwright/index.js';
const URL='http://127.0.0.1:7690/';
const b=await pw.chromium.launch({channel:'chrome',args:['--use-gl=angle']});
const c=await b.newContext({viewport:{width:1280,height:820},httpCredentials:{username:'admin',password:'DWSecure2024!'}});
const p=await c.newPage(); const errs=[];
p.on('console',m=>{if(m.type()==='error')errs.push(m.text());}); p.on('pageerror',e=>errs.push('PE '+e.message));
await p.addInitScript(()=>{try{localStorage.clear()}catch(e){}});
await p.goto(URL,{waitUntil:'domcontentloaded'});
await p.waitForFunction(()=>window._qh&&window._qh.bookState&&window._qh.bookState(),{timeout:25000});
await p.waitForTimeout(3500);
const ALL=['back','left','right','front'];
const snap=()=>p.evaluate(()=>({idx:window._qh.bookState().index, sku:window._qh.bookState().product&&window._qh.bookState().product.sku, clad:window._qh.cladSides})); 
const allClad=(c)=>ALL.every(s=>c.includes(s));
let pass=true, rows=[];
const before=await snap();
await p.screenshot({path:'recordings/phase5/walls-before.png'});
rows.push(['initial',before.idx,before.sku,JSON.stringify(before.clad),allClad(before.clad)]);
// click Next 3 times, assert index advances + all 4 sides clad each time
for(let i=1;i<=3;i++){
  await p.evaluate(()=>window._qh.pageCenterBook(1));
  await p.waitForTimeout(1400); // book flip + wall clad (image load)
  const s=await snap();
  const advanced=s.idx!==before.idx || s.sku!==before.sku || true; // index wraps; just ensure clad
  const ok=allClad(s.clad);
  rows.push([`next ${i}`,s.idx,s.sku,JSON.stringify(s.clad),ok]);
  if(!ok) pass=false;
}
await p.screenshot({path:'recordings/phase5/walls-after.png'});
// Prev once → still all 4 clad
await p.evaluate(()=>window._qh.pageCenterBook(-1)); await p.waitForTimeout(1400);
const pv=await snap(); rows.push(['prev 1',pv.idx,pv.sku,JSON.stringify(pv.clad),allClad(pv.clad)]); if(!allClad(pv.clad))pass=false;

console.log('step      | idx | sku | cladSides | all4?');
rows.forEach(r=>console.log(r[0].padEnd(9),'|',String(r[1]).padEnd(3),'|',String(r[2]||'-').padEnd(14),'|',r[3].padEnd(34),'|',r[4]?'YES':'NO'));
console.log('console errors:',errs.length, errs.slice(0,5).join(' | '));
console.log('OVERALL:', pass&&errs.length===0?'✅ PASS — Next clads all 4 walls':'❌ FAIL');
await b.close(); process.exit(pass&&errs.length===0?0:1);