4 lines
2.4 KiB
JavaScript
4 lines
2.4 KiB
JavaScript
const{chromium}=require('playwright'),assert=require('node:assert/strict');
|
|
(async()=>{const b=await chromium.launch();try{const p=await b.newPage({viewport:{width:1440,height:1000}});for(const destination of['Write','Explore','Plan','Review','Reflect']){const r=await p.goto(`http://127.0.0.1:5238/Writer/${destination}?projectId=7&bookId=12`);assert.equal(r.status(),200);await p.waitForFunction(()=>document.querySelector('.writer3')?.classList.contains('writer3-viewport'));await p.evaluate(async()=>{await document.fonts.ready;await new Promise(r=>setTimeout(r,50))});const normal=await p.evaluate(()=>({header:document.querySelector('.writer3-header').getBoundingClientRect().height,bottom:document.querySelector('.writer3-workspace').getBoundingClientRect().bottom,height:innerHeight}));assert(normal.header<85,'compact shared header');if(destination!=='Review')assert(normal.height-normal.bottom<12,'uses available viewport');await p.evaluate(()=>{document.documentElement.style.overflow='auto';document.documentElement.style.height='auto';document.body.style.overflow='visible';document.body.style.height='auto';document.body.style.minHeight='1800px';document.body.style.paddingTop='180px';window.scrollTo({top:150,behavior:'instant'});window.dispatchEvent(new Event('resize'));});if(destination!=='Review')await p.waitForFunction(()=>{const w=document.querySelector('.writer3-workspace');return Math.abs(innerHeight-w.getBoundingClientRect().bottom)<12});else assert(await p.evaluate(()=>getComputedStyle(document.querySelector('.writer3-main')).overflowY==='visible'),'Review flows in document');assert(await p.evaluate(()=>window.scrollY>100),'scrolled shell fixture');}
|
|
await p.goto('http://127.0.0.1:5238/Writer/Explore?projectId=7&bookId=12');const links=await p.locator('.writer3-explore-paths>a').evaluateAll(ns=>ns.map(n=>n.href));assert.equal(links.length,3);for(const href of links){const u=new URL(href);assert(!u.pathname.includes('problem-solver'));assert.equal(u.searchParams.get('projectId'),'7');assert.equal(u.searchParams.get('bookId'),'12');}assert.equal(new Set(links.map(x=>new URL(x).pathname)).size,3);assert.equal(await p.locator('iframe').count(),0);console.log('PASS five destinations compact viewport use and controlled scrolled-shell geometry; Explore has three distinct authenticated scoped tool routes and no public solver/iframe.');}finally{await b.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1});
|