26 lines
6.8 KiB
JavaScript
26 lines
6.8 KiB
JavaScript
// Real Development account only. No login screenshots, traces, credentials or author data output.
|
|
const{chromium}=require('playwright'),fs=require('node:fs'),os=require('node:os'),path=require('node:path'),assert=require('node:assert/strict');
|
|
const base='https://dev.plotdirector.com';let stage='setup';
|
|
(async()=>{const file=process.argv[2];assert(file?.startsWith('/tmp/pd-dev-browser-'));const id=JSON.parse(fs.readFileSync(file));assert.equal(id.Database,'PlotDirector_Development');assert(id.Email.startsWith('pwa-browser-'));assert(id.SceneID&&id.LineAID);
|
|
const profile=fs.mkdtempSync(path.join(os.tmpdir(),'pd-house-theme-'));const ctx=await chromium.launchPersistentContext(profile,{headless:false,viewport:{width:1440,height:1000}});const cdp=await ctx.browser().newBrowserCDPSession();let installed=false;
|
|
try{const page=ctx.pages()[0];stage='login';await page.goto(base+'/Account/Login');await page.locator('[name=Email]').fill(id.Email);await page.locator('[name=Password]').fill(id.Password);await page.locator('form button[type=submit]').click();await page.waitForURL(base+'/Projects');
|
|
assert.equal(await page.locator('html').getAttribute('data-app-theme'),'plotdirector','New account with no preference should use house theme');await page.waitForFunction(()=>!document.querySelector('[data-app-theme-choice]').disabled);
|
|
const q=`projectId=${id.ProjectID}&bookId=${id.BookID}`;
|
|
const routes=[['home','/Projects'],['dashboard','/Projects/Details/'+id.ProjectID],['chapters','/Books/Details/'+id.BookID],['scene','/Scenes/Edit/'+id.SceneID],['timeline','/Timeline?'+q],['plot-focus','/PlotLineWorkspace?'+q+'&plotLineId='+id.LineAID],['plot-weave','/PlotLineWorkspace?'+q+'&plotLineId='+id.LineAID+'&plotLineId='+id.LineBID],['relationships','/RelationshipMap?projectId='+id.ProjectID],['story-flow','/Analytics?'+q],['form','/Projects/Edit/'+id.ProjectID]];
|
|
async function inspect(p,mode,width){await p.setViewportSize({width,height:1000});for(const[label,url]of routes){stage=mode+'/'+width+'/'+label;const response=await p.goto(base+url);assert.equal(response.status(),200,stage);assert.equal(await p.locator('html').getAttribute('data-app-theme'),'plotdirector');assert(!p.url().includes('/Account/'));
|
|
if(label==='scene')assert.equal(await p.locator('[data-scene-area-command]').count(),6);
|
|
if(label==='story-flow')assert.equal(await p.locator('canvas[data-metric-canvas], [data-metric-shape-chart] canvas').count(),1);
|
|
await p.screenshot({path:`/tmp/house-theme-live-${mode}-${label}-${width}.png`});}
|
|
}
|
|
await inspect(page,'web',1440);await inspect(page,'web',390);
|
|
stage='theme persistence';await page.goto(base+'/Projects');await page.locator('#accountMenuButton').click();assert.equal(await page.locator('[data-app-theme-choice]').count(),7);await page.locator('[data-app-theme-choice=modern-dark]').click();await page.waitForFunction(()=>!document.querySelector('[data-app-theme-choice]').disabled);await page.reload();assert.equal(await page.locator('html').getAttribute('data-app-theme'),'modern-dark');await page.locator('#accountMenuButton').click();await page.locator('[data-app-theme-choice=plotdirector]').click();await page.waitForFunction(()=>!document.querySelector('[data-app-theme-choice]').disabled);
|
|
stage='install';await page.goto(base+'/Projects');const manifestId=base+'/Projects';await cdp.send('PWA.install',{manifestId,installUrlOrBundleUrl:base+'/Projects'});installed=true;await cdp.send('PWA.changeAppUserSettings',{manifestId,displayMode:'standalone'});const opened=ctx.waitForEvent('page');await cdp.send('PWA.launch',{manifestId,url:base+'/Projects'});const app=await opened;await app.waitForLoadState();assert(await app.evaluate(()=>matchMedia('(display-mode: standalone)').matches));await inspect(app,'pwa',1440);await inspect(app,'pwa',390);
|
|
stage='scene areas';await app.setViewportSize({width:1440,height:1000});await app.goto(base+'/Scenes/Edit/'+id.SceneID);for(const area of ['overview','story','people','world','writer','continuity']){if(await app.locator('#ribbon-surface').isHidden())await app.locator('[data-ribbon-tab][aria-selected=true]').click();const g=app.locator('.pd-context-group[aria-label="Edit Scene"]');const compact=g.locator('details[data-compact=true]');if(await compact.count()&&!await compact.getAttribute('open'))await compact.locator('summary').click();await g.locator('button.pd-context-command').filter({hasText:new RegExp('^'+area+'$','i')}).click();assert.equal(await app.locator('[data-scene-workspace]').getAttribute('data-scene-area'),area);}
|
|
stage='context menu';await app.goto(base+'/Books/Details/'+id.BookID);const target=app.locator('[data-pd-context]').first();assert(await target.count());await target.click({button:'right'});assert(await app.locator('body > .pd-context-popup').isVisible());await app.screenshot({path:'/tmp/house-theme-live-context-menu.png'});await app.keyboard.press('Escape');
|
|
stage='modal';await app.locator('#customiseToolbar').evaluate(e=>bootstrap.Modal.getOrCreateInstance(e).show());await app.locator('#customiseToolbar.show').waitFor();await app.waitForFunction(()=>getComputedStyle(document.getElementById('customiseToolbar')).opacity==='1'&&getComputedStyle(document.querySelector('#customiseToolbar .modal-dialog')).transform==='none');await app.screenshot({path:'/tmp/house-theme-live-modal.png'});await app.locator('#customiseToolbar').evaluate(e=>bootstrap.Modal.getInstance(e).hide());
|
|
stage='public isolation';for(const theme of ['plotdirector','modern-dark','baby-blue']){await page.evaluate(t=>localStorage.setItem('plotdirector.applicationTheme',t),theme);for(const url of ['/','/features','/writing-problems','/writing-problems/comparing-different-story-versions','/Account/Login']){await page.goto(base+url);assert.equal(await page.locator('html').getAttribute('data-site-theme'),'public');assert.equal(await page.locator('html').getAttribute('data-app-theme'),null);}}
|
|
stage='PWA login';await app.evaluate(()=>localStorage.setItem('plotdirector.applicationTheme','plotdirector'));await app.goto(base+'/Account/Login');assert.equal(await app.locator('html').getAttribute('data-app-theme'),'plotdirector');await app.screenshot({path:'/tmp/house-theme-live-pwa-login.png'});
|
|
for(const url of ['/','/writing-problems']){await app.goto(base+url);assert.equal(await app.locator('html').getAttribute('data-site-theme'),'public');assert.equal(await app.locator('html').getAttribute('data-app-theme'),null);}
|
|
console.log('PASS real Development: new-user default; explicit alternate persistence; 10 pages at 390/1440 in web and actual installed PWA; Focus/Weave; six Scene areas; modal/context menu; public and web-login isolation across three cached themes; PWA login.');
|
|
}catch(e){console.error('FAILED',stage,e.message);process.exitCode=1;}finally{if(installed)await cdp.send('PWA.uninstall',{manifestId:base+'/Projects'}).catch(()=>{});await ctx.close();fs.rmSync(profile,{recursive:true,force:true});}})();
|