const{chromium}=require('playwright'); const assert=require('node:assert/strict'); const fs=require('node:fs'); const base='https://dev.plotdirector.com'; (async()=>{const browser=await chromium.launch();try{ for(const width of [390,768,1440,1920]){ const page=await browser.newPage({viewport:{width,height:1100}}); if(process.env.SOLVER_LOCAL_CSS==='true')await page.route('**/css/writing-solver.css*',route=>route.fulfill({contentType:'text/css',body:fs.readFileSync('PlotLine/wwwroot/css/writing-solver.css','utf8')})); for(const slug of ['comparing-different-story-versions','too-many-storylines-to-manage','']){ const path='/problem-solver'+(slug?'/'+slug:'');await page.goto(base+path); const dimensions=await page.locator('.solver-space').evaluate(e=>{const r=e.getBoundingClientRect(),c=e.querySelector('.solver-content').getBoundingClientRect();return{left:r.left,right:r.right,width:r.width,content:c.width,overflow:document.documentElement.scrollWidth>innerWidth,bg:getComputedStyle(e).backgroundImage}}); assert.equal(dimensions.left,0);assert.equal(dimensions.width,width);assert(!dimensions.overflow); assert(dimensions.content<= (slug?930:1000));assert(dimensions.bg.includes('writing-solver-desk.png')); if(slug)assert.equal(new URL(page.url()).pathname,path); if(slug==='comparing-different-story-versions')await page.screenshot({path:`/tmp/solver-canvas-${process.env.SOLVER_LOCAL_CSS?'candidate':'live'}-${width}.png`}); console.log('PASS',width,path,JSON.stringify(dimensions)); } // Third diagnosis and an interactive question use the same full-width canvas. await page.goto(base+'/problem-solver');await page.locator('input[name=choices]').first().check();await page.locator('button[type=submit]').click(); assert.equal(await page.locator('.solver-space').evaluate(e=>e.getBoundingClientRect().width),width); assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth),false); await page.close(); } const page=await browser.newPage({viewport:{width:1920,height:1100}}); if(process.env.SOLVER_LOCAL_CSS==='true')await page.route('**/css/writing-solver.css*',r=>r.fulfill({contentType:'text/css',body:fs.readFileSync('PlotLine/wwwroot/css/writing-solver.css','utf8')})); const graph=JSON.parse(fs.readFileSync('PlotLine/Content/WritingSolver/Candidates/curated-v2-stage1-repair/writing-solver-curated-v2-stage1-repair.json')); const third=graph.solutions.find(s=>s.id==='d02').slug;await page.goto(base+'/problem-solver/'+third);assert.equal(await page.locator('.solver-space').evaluate(e=>e.getBoundingClientRect().width),1920); console.log('PASS third diagnosis',third); }finally{await browser.close();}})().catch(e=>{console.error(e);process.exit(1)});