← back to Marketing Command Center
scripts/verify-fix2.js
29 lines
// Deterministic race test via location.hash. Fire calendar->board with a tiny gap so
// board's route() starts while calendar's is mid-fetch. Poll board up to 10s.
// Blank after 10s = race left it dead. Compare unfixed-live vs fixed-proxy.
const { chromium } = require('playwright');
const BASE = process.env.MCC_BASE || 'https://marketing.designerwallcoverings.com';
async function boardCards(page){return await page.evaluate(()=>{const t=(document.querySelector('#paneltitle')?.innerText||'').trim();let n=0;document.querySelectorAll('.bd-card').forEach(e=>{const r=e.getBoundingClientRect();if(r.width>40&&r.height>20)n++;});return {t,n};});}
(async()=>{
let blank=0;const TRIALS=6;
for(let i=1;i<=TRIALS;i++){
const b=await chromium.launch();
const ctx=await b.newContext({viewport:{width:1600,height:900},httpCredentials:{username:'admin',password:'DW2024!'}});
const page=await ctx.newPage();
await page.goto(BASE+'/',{waitUntil:'domcontentloaded'}); await page.waitForTimeout(2500);
// vary the mid-flight gap across trials to hit the interleave window
const gap=[20,40,60,90,130,200][i-1];
await page.evaluate(()=>{location.hash='calendar';});
await page.waitForTimeout(gap);
await page.evaluate(()=>{location.hash='board';});
// poll board specifically
let r={t:'',n:0},t0=Date.now();
while(Date.now()-t0<10000){ r=await boardCards(page); if(r.t==='Streams Board'&&r.n>0)break; await page.waitForTimeout(400); }
const isBlank=(r.t==='Streams Board'&&r.n===0);
if(isBlank)blank++;
console.log(`trial${i} gap=${gap}ms: title="${r.t}" boardCards=${r.n} in=${Date.now()-t0}ms ${isBlank?' <-- BLANK after 10s':''}`);
await ctx.close(); await b.close();
}
console.log(`\n${BASE}\n=> board BLANK ${blank}/${TRIALS}`);
})().catch(e=>{console.error('FATAL',e);process.exit(1);});