33 lines
5.0 KiB
JavaScript
33 lines
5.0 KiB
JavaScript
// Development only, normal login, dedicated disposable owner with one saved focus and a second empty book.
|
|
const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict');
|
|
(async()=>{
|
|
const w=JSON.parse(fs.readFileSync(process.env.PD_WRITER3_IDENTITY));assert(w.Database==='PlotDirector_Development'&&/^pwa-browser-.*@example\.invalid$/.test(w.Email));
|
|
for(const key of ['project','book','chapter','scene','other'])assert(Number.isSafeInteger(w[key])&&w[key]>0);
|
|
const b=await chromium.launch(),base='https://dev.plotdirector.com',checks=[];
|
|
try{for(const pwa of[false,true]){
|
|
const c=await b.newContext({viewport:{width:1440,height:1000}});if(pwa)await c.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));
|
|
const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));p.setDefaultTimeout(20000);
|
|
await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);
|
|
for(const book of[w.book,w.other])for(const action of['Index','Write','Explore','Plan','Review','Reflect','Dashboard']){
|
|
const response=await p.goto(`${base}/Writer/${action}?projectId=${w.project}&bookId=${book}`);assert.equal(response.status(),200);
|
|
assert.equal(await p.locator('[data-writer-destination]').getAttribute('data-writer-destination'),action==='Index'?'Home':action);
|
|
if(action==='Write'&&book===w.book)assert((await p.getByRole('link',{name:'Open current scene',exact:true}).getAttribute('href')).includes('/'+w.scene));
|
|
if(action==='Write'&&book===w.other)assert.equal(await p.getByRole('heading',{name:'Where would you like to begin?',exact:true}).isVisible(),true);
|
|
if(action==='Review'&&book===w.other)assert.equal(await p.getByRole('heading',{name:'No chapters yet',exact:true}).isVisible(),true);
|
|
if(!pwa&&book===w.book&&process.env.PD_WRITER3_SCREENSHOTS){await p.evaluate(()=>window.PlotDirectorApplyApplicationTheme('modern-dark'));fs.mkdirSync(process.env.PD_WRITER3_SCREENSHOTS,{recursive:true});await p.screenshot({path:`${process.env.PD_WRITER3_SCREENSHOTS}/${action==='Index'?'Home':action}-Development.png`,fullPage:true});}
|
|
}
|
|
for(const [index,action]of[[0,'Write'],[1,'Explore'],[2,'Dashboard']]){await p.goto(`${base}/Writer?projectId=${w.project}&bookId=${w.book}`);await p.locator('.writer3-home-choices>a').nth(index).click();await p.waitForURL(`**/Writer/${action}?*`);assert.equal(new URL(p.url()).searchParams.get('bookId'),String(w.book));}
|
|
await p.goto(`${base}/Writer/Write?projectId=${w.project}&bookId=${w.book}`);await p.locator('#appBookMenu').click();await p.locator(`[data-app-book-choice="${w.other}"]`).click();await p.waitForURL(`**/Writer/Write?*bookId=${w.other}*`);assert.equal(await p.getByRole('link',{name:'Open current scene',exact:true}).count(),0);
|
|
await p.goBack();assert((await p.getByRole('link',{name:'Open current scene',exact:true}).getAttribute('href')).includes('/'+w.scene));await p.goForward();await p.reload();assert.equal(await p.getByRole('link',{name:'Open current scene',exact:true}).count(),0);
|
|
for(const action of['Overview','Journey','Workspaces','WritingPlans','SchedulePreview'])assert.equal((await p.request.get(`${base}/Writer/${action}?projectId=${w.project}&bookId=${w.book}`)).status(),200);
|
|
const setup=await p.request.get(`${base}/Writer/DisplaySetup?projectId=${w.project}&bookId=${w.book}`);assert.equal(setup.status(),200);assert(new URL(setup.url()).pathname==='/Writer/Overview');
|
|
for(const action of['Write','Explore','Plan','Review','Reflect'])assert.equal((await p.request.get(`${base}/Writer/${action}?bookId=2147483647`)).status(),404);
|
|
await p.goto(`${base}/Writer/Review?projectId=${w.project}&bookId=${w.book}`);
|
|
if(pwa){if(await p.locator('[data-ribbon-shell]').getAttribute('data-collapsed')==='true'){await p.locator('[data-ribbon-collapse]').click();await p.waitForFunction(()=>!document.querySelector('[data-ribbon-collapse]').disabled);}await p.locator('[data-help-open="writer3.review"]:visible').click();await p.waitForFunction(()=>document.querySelector('[data-help-drawer]')?.innerText.includes('Review Your Writing'));}
|
|
else{await p.locator('[data-help-key="writer3.review"] button').click();await p.locator('.plotline-help-popover').waitFor();}
|
|
for(const key of['home','write','explore','plan','review','reflect','dashboard'])assert.equal((await p.request.get(`${base}/Help/Article/writer3.${key}`)).status(),200);
|
|
assert.deepEqual(errors,[]);checks.push(`${pwa?'Simulated PWA':'Browser'}: existing/new book7surfaces,3Home actions, five destinations, contextual scope/back/forward/reload, saved focus isolation,5legacy pages,DisplaySetup,unavailable-book404 and7Help articles pass; no author-data forms submitted.`);await c.close();
|
|
}}finally{await b.close();}
|
|
console.log(JSON.stringify({checks,physicalWindows:false,installedPWA:false},null,2));
|
|
})().catch(e=>{console.error(e.message);process.exitCode=1});
|