32 lines
3.5 KiB
JavaScript
32 lines
3.5 KiB
JavaScript
const {chromium}=require('playwright');
|
|
const assert=require('node:assert/strict');
|
|
const fs=require('node:fs');
|
|
(async()=>{const browser=await chromium.launch();try{
|
|
for(const pwa of [false,true]){
|
|
const context=await browser.newContext();if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));
|
|
await context.route('**/signalr.min.js',route=>route.fulfill({contentType:'application/javascript',body:fs.readFileSync(require.resolve('@microsoft/signalr/dist/browser/signalr.min.js'),'utf8')}));
|
|
const page=await context.newPage();const errors=[];page.on('pageerror',e=>errors.push(e.message));
|
|
for(const populated of [false,true])for(const theme of ['modern-light','modern-dark','warm-light','warm-dark'])for(const width of [390,1024,1440]){
|
|
await page.setViewportSize({width,height:1000});await page.addInitScript(theme=>localStorage.setItem('plotdirector.applicationTheme',theme),theme);
|
|
await page.goto(`http://127.0.0.1:5238/writer2-fixture?populated=${populated}`);
|
|
assert.equal(await page.locator('h1').textContent(),'A Distant Shore');
|
|
assert.equal(await page.locator('.pd-ribbon-navigation').filter({hasText:/^Writer$/}).count(),1);
|
|
assert.equal(await page.locator('#ribbon-panel-writer').isVisible(),true);
|
|
assert.equal(await page.locator('.writer-tabs a').count(),5);
|
|
assert.equal(await page.locator('.writer-heading select').count(),0,'Book/project selection belongs to common shell');
|
|
const choices=await page.locator('[data-app-book-choice]').evaluateAll(nodes=>nodes.map(n=>n.getAttribute('href')));assert(choices.length>0);assert(choices.every(href=>new URL(href,'http://127.0.0.1:5238').pathname==='/Writer'),'Common book selection stays in Writer');
|
|
assert.equal(await page.locator('[data-start-writing-workspace]').isVisible(),false,'No linked document exposes no workspace reapply action');
|
|
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth>innerWidth+2),false,`${theme} ${width} overflow`);
|
|
assert.equal(await page.locator('[data-writer-queue="WriteNext"]').isVisible(),true);
|
|
assert.equal(await page.locator('[data-writer-queue="Revision"]').isVisible(),false);
|
|
if(populated){assert.equal(await page.locator('.writer-day').count(),28);assert.equal(await page.locator('.writer-day-observed').count(),2);assert.equal(await page.locator('.writer-indicators strong').nth(0).textContent(),'120');assert((await page.locator('.writer-day-observed').first().getAttribute('href')).includes('day='));}
|
|
else{assert((await page.locator('.writer-empty').textContent()).includes('Earlier writing'));assert.equal(await page.locator('.writer-indicators strong').first().textContent(),'—');}
|
|
await page.getByRole('link',{name:'Connection & Display Setup'}).click();await page.waitForFunction(()=>document.getElementById('display-setup').open);assert.equal(await page.locator('#display-setup').getAttribute('open'),'');
|
|
if(theme==='warm-light'&&width===1440&&populated&&!pwa)await page.screenshot({path:'/home/nick/writer2-sprint/writer2-desktop.png',fullPage:true});
|
|
if(theme==='warm-light'&&width===390&&populated&&!pwa)await page.screenshot({path:'/home/nick/writer2-sprint/writer2-small.png',fullPage:true});
|
|
}
|
|
assert.deepEqual(errors,[]);await context.close();
|
|
}
|
|
console.log('PASS Writer 2 overview: real Razor, 48 theme/viewport/history/PWA combinations, single navigation, book scope, honest empty states, chart links and contextual controls.');
|
|
}finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;});
|