26 lines
6.4 KiB
JavaScript
26 lines
6.4 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/public-marketing-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-'));fs.mkdirSync(masters,{recursive:true});
|
|
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);if(await web.locator('html').getAttribute('data-app-theme')!=='plotdirector'){await web.locator('#accountMenuButton').click();await web.locator('[data-app-theme-choice=plotdirector]').click();await web.waitForFunction(()=>document.documentElement.dataset.appTheme==='plotdirector');await web.locator('#accountMenuButton').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)):[];let theme='plotdirector';
|
|
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'),theme);if(prepare)await prepare();await app.evaluate(()=>document.fonts.ready);await app.waitForTimeout(400);
|
|
const height=800;const width=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.evaluate(()=>document.activeElement?.blur());await app.mouse.move(1278,940);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,presentation:'actual-installed-pwa',privacyChecked:true});console.log('CAPTURE',asset);}
|
|
async function sceneArea(area){const command=app.locator(`[data-scene-area-command="${area}"]:visible`);if(await command.count())await command.click();else{const group=app.locator('.pd-context-group[aria-label="Edit Scene"]');const details=group.locator('details[data-compact="true"]');if(await details.count()&&await details.getAttribute('open')===null)await details.locator('summary').click();await group.locator('button.pd-context-command').filter({hasText:new RegExp('^'+area+'$','i')}).click();}}
|
|
await capture('scene','/Scenes/Edit/'+id.SceneID);
|
|
await capture('writing','/Scenes/Edit/'+id.SceneID,async()=>{await sceneArea('writer');await app.locator('[data-scene-editor="notes"]:visible').first().click();await app.locator('[data-scene-editor-body] textarea').first().waitFor();});
|
|
await capture('calendar','/StoryCalendar?'+q+'&month=1926-05&date=1926-05-14',async()=>{await app.locator('.story-calendar-grid-wrap').evaluate(e=>e.scrollTop=260);});
|
|
await capture('characters','/Characters/Details/'+id.CharacterID+'?projectId='+id.ProjectID);
|
|
await capture('import','/onboarding',async()=>{if((await app.locator('h1').innerText()).includes('Scan'))await app.getByRole('button',{name:'Back',exact:true}).click();});
|
|
// One explicitly labelled alternative-theme cluster, selected only in this disposable account.
|
|
await app.locator('#accountMenuButton').click();await app.locator('[data-app-theme-choice="modern-dark"]').click();await app.locator('#accountMenuButton').click();await app.waitForFunction(()=>document.documentElement.dataset.appTheme==='modern-dark');theme='modern-dark';
|
|
await capture('dark-overview','/Timeline?'+q,async()=>{const hint=app.locator('[data-timeline-navigation-dismiss]');if(await hint.isVisible())await hint.click();});
|
|
await capture('dark-knowledge','/Dynamics/Knowledge/'+id.CharacterID+'?projectId='+id.ProjectID);
|
|
await capture('dark-plot-lines','/PlotLineWorkspace?'+q+'&plotLineId='+id.LineAID+'&plotLineId='+id.LineBID);
|
|
fs.writeFileSync(path.join(masters,'captures.json'),JSON.stringify(captures,null,2));console.log('PASS public marketing 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});}})();
|