32 lines
7.3 KiB
JavaScript
32 lines
7.3 KiB
JavaScript
// Official captures: actual installed Development application with isolated, fictional persisted data.
|
|
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',masters='/home/nick/.codex/artifacts/writing-solver-screenshots-20261102';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.AssetID&&id.ScenarioID);
|
|
const profile=fs.mkdtempSync(path.join(os.tmpdir(),'pd-capture-'));const ctx=await chromium.launchPersistentContext(profile,{headless:false,viewport:{width:1280,height:944}});const cdp=await ctx.browser().newBrowserCDPSession();let installed=false;const manifestId=base+'/Projects';
|
|
try{const web=ctx.pages()[0];await web.goto(base+'/Account/Login');await web.locator('[name=Email]').fill(id.Email);await web.locator('[name=Password]').fill(id.Password);await web.locator('form button[type=submit]').click();await web.waitForURL('**/Projects');await web.waitForFunction(()=>!document.querySelector('[data-app-theme-choice]').disabled);assert.equal(await web.locator('html').getAttribute('data-app-theme'),'plotdirector');
|
|
stage='Timeline settings';await web.goto(base+'/Timeline/Settings?projectId='+id.ProjectID);await web.locator('[name=ShowMetricShape][type=checkbox]').check();await web.locator('[name=ShowSceneCards][type=checkbox]').check();await web.locator('form.timeline-settings-form button[type=submit]').click();
|
|
stage='PWA install';await web.goto(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 app.setViewportSize({width:1280,height:944});
|
|
const q=`projectId=${id.ProjectID}&bookId=${id.BookID}`;const selection=process.env.CAPTURE_ASSETS?.split(',');const captures=selection?JSON.parse(fs.readFileSync(path.join(masters,'captures.json'))).filter(c=>!selection.includes(c.asset)):[];
|
|
async function capture(asset,url,prepare){if(selection&&!selection.includes(asset))return;stage=asset;await app.setViewportSize(asset==='series-project'?{width:1440,height:1000}:{width:1280,height:944});assert.equal((await app.goto(base+url)).status(),200);assert.equal(await app.locator('html').getAttribute('data-app-theme'),'plotdirector');if(prepare)await prepare();await app.evaluate(()=>document.fonts.ready);await app.waitForTimeout(400);
|
|
const height=['object-journey','character-records'].includes(asset)?520:asset==='series-project'?760:asset==='scenario-alternatives'?420:['object-journey','character-knowledge','scenario-alternatives'].includes(asset)?660:800;const width=asset==='series-project'?1440:1280;const y=Math.ceil(await app.locator('.pd-titlebar').evaluate(e=>e.getBoundingClientRect().bottom));const clip={x:0,y,width,height};const visible=await app.evaluate(clip=>{const out=[];const w=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT);while(w.nextNode()){const n=w.currentNode;if(!n.textContent.trim()||['SCRIPT','STYLE'].includes(n.parentElement.tagName))continue;const range=document.createRange();range.selectNode(n);const r=range.getBoundingClientRect();if(r.width&&r.height&&r.bottom>clip.y&&r.top<clip.y+clip.height&&getComputedStyle(n.parentElement).visibility!=='hidden')out.push(n.textContent.trim());}return out.join(' ');},clip);
|
|
assert(!visible.includes(id.Email)&&!visible.includes('Desktop Verification')&&!visible.includes('House Theme Verification')&&!/Development preview|debug|@example.invalid/i.test(visible),'Private/development label in capture');
|
|
await app.screenshot({path:path.join(masters,asset+'.png'),clip,animations:'disabled'});captures.push({asset,route:url.replace(/\d+/g,'{id}'),width,height,cropY:y,theme:'plotdirector',presentation:'actual-installed-pwa',privacyChecked:true});console.log('CAPTURE',asset);}
|
|
const timelinePrepare=async()=>{const hint=app.locator('[data-timeline-navigation-dismiss]');if(await hint.isVisible())await hint.click();await app.locator('.timeline-shell').scrollIntoViewIfNeeded();};
|
|
await capture('plot-lines-weave','/PlotLineWorkspace?'+q+'&plotLineId='+id.LineAID+'&plotLineId='+id.LineBID,async()=>{await app.locator('.plot-map-scroll').scrollIntoViewIfNeeded();});
|
|
await capture('timeline-chronology','/Timeline?'+q,timelinePrepare);
|
|
await capture('timeline-scene-overview','/Timeline?'+q,async()=>{await timelinePrepare();await app.locator('[data-timeline-density]').selectOption('expanded',{force:true});await app.locator('[data-timeline-zoom]').selectOption('scene-overview',{force:true});});
|
|
await capture('character-records','/Characters?projectId='+id.ProjectID);
|
|
await capture('relationship-map','/RelationshipMap?projectId='+id.ProjectID+'&bookId='+id.BookID);
|
|
await capture('character-knowledge','/Dynamics/Knowledge/'+id.CharacterAID+'?projectId='+id.ProjectID);
|
|
await capture('character-arc','/Dynamics/Character/'+id.CharacterAID+'?projectId='+id.ProjectID,async()=>{await app.locator('[data-metric-shape-chart]').scrollIntoViewIfNeeded();});
|
|
await capture('location-reference','/Locations?projectId='+id.ProjectID);
|
|
await capture('object-journey',`/ContinuityExplorer?projectId=${id.ProjectID}&mode=Journey&EntityTypes=Assets&assetId=${id.AssetID}&SceneRangeMode=Book&BookID=${id.BookID}`,async()=>{const toggle=app.getByRole('button',{name:'Toggle',exact:true});if(await app.locator('#continuity-filter-panel').isVisible())await toggle.click();});
|
|
await web.goto(base+'/Timeline/Settings?projectId='+id.ProjectID);await web.locator('[name=ShowSceneCards][type=checkbox]').uncheck();await web.locator('form.timeline-settings-form button[type=submit]').click();
|
|
await capture('timeline-story-values','/Timeline?'+q,async()=>{const hint=app.locator('[data-timeline-navigation-dismiss]');if(await hint.isVisible())await hint.click();await app.locator('[data-timeline-zoom]').selectOption('book',{force:true});await app.locator('[data-metric-shape-chart]').evaluate(e=>{window.scrollTo(0,window.scrollY+e.getBoundingClientRect().top-220);});});
|
|
await capture('scenario-alternatives','/Scenarios?projectId='+id.ProjectID);
|
|
await capture('continuity-story-state',`/ContinuityExplorer?projectId=${id.ProjectID}&sceneId=${id.LastSceneID}&EntityTypes=Assets&EntityTypes=Characters`,async()=>{if(await app.locator('#continuity-filter-panel').isVisible())await app.getByRole('button',{name:'Toggle',exact:true}).click();});
|
|
await capture('series-project','/Projects/Details/'+id.ProjectID);
|
|
await capture('story-bible','/StoryBible?projectId='+id.ProjectID);
|
|
fs.writeFileSync(path.join(masters,'captures.json'),JSON.stringify(captures,null,2));console.log('PASS 14 real Development PWA captures; account strip excluded; fictional data privacy checks passed.');
|
|
}catch(e){console.error('FAILED',stage,e.message);process.exitCode=1;}finally{if(installed)await cdp.send('PWA.uninstall',{manifestId}).catch(()=>{});await ctx.close();fs.rmSync(profile,{recursive:true,force:true});}})();
|