8 lines
3.2 KiB
JavaScript
8 lines
3.2 KiB
JavaScript
// Explicit Development-only read/navigation acceptance on disposable scope; no Word commands or edits.
|
|
const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict');
|
|
(async()=>{assert(process.env.PD_CONTEXT_IDENTITY&&process.env.PD_CONTEXT_SCOPE);const who=JSON.parse(fs.readFileSync(process.env.PD_CONTEXT_IDENTITY)),s=JSON.parse(fs.readFileSync(process.env.PD_CONTEXT_SCOPE));assert.equal(who.Database,'PlotDirector_Development');assert.equal(who.UserID,s.user);assert(who.Email.startsWith('pwa-browser-'));const b=await chromium.launch();let step='login';try{const c=await b.newContext({viewport:{width:1366,height:900}}),main=await c.newPage();await main.goto('https://dev.plotdirector.com/Account/Login');await main.locator('[name=Email]').fill(who.Email);await main.locator('[name=Password]').fill(who.Password);await Promise.all([main.waitForURL(u=>u.pathname!='/Account/Login'),main.locator('button[type=submit]').click()]);await main.goto('https://dev.plotdirector.com/Projects/Details/'+s.project);let word=0;c.on('request',r=>{if(/\/(Writing\/Context|WriterWord)\/Navigate/.test(new URL(r.url()).pathname))word++;});const p=await c.newPage();await p.goto(`https://dev.plotdirector.com/Writing/Context?projectId=${s.project}&bookId=${s.book}&sceneId=${s.scene}`);await p.waitForSelector('[data-context-tab-fragment]');await p.waitForFunction(book=>document.querySelector('[data-context-workspace]').contextController.connection?.state==='Connected'&&document.querySelector('[data-context-workspace]').contextController.connection.invoke('MyContextWindows',book).then(rows=>rows.some(r=>r.kind==='main'&&r.environmentID===window.PlotDirectorContextEnvironment)),s.book);
|
|
const count=c.pages().length;step='scene editor in existing main';await p.click('[data-context-editor]');await main.waitForURL(u=>u.pathname==='/Scenes/Edit/'+s.scene);assert.equal(c.pages().length,count);
|
|
for(const [tool,button,path] of [['characters',`[data-context-workspace-target="characters"][data-context-entity="${s.characters[0]}"]`,'/Characters/Details/'+s.characters[0]],['names','[data-context-workspace-target="names"]','/Names'],['relationships','[data-context-workspace-target="relationships"]','/RelationshipMap']]){step=tool+' existing-main reuse';await p.selectOption('[data-context-tab]',tool);await p.waitForSelector('[data-context-tab-fragment]');if(tool==='characters'){const row=p.locator(`[data-context-character="${s.characters[0]}"]`);if(!await row.evaluate(n=>n.open))await row.locator('summary').click();}await p.waitForTimeout(600);for(const toast of await p.locator('.pd-toast button[aria-label^="Dismiss"]').all())await toast.click();await p.locator(button).last().click();await main.waitForURL(u=>u.pathname===path);assert.equal(c.pages().length,count);}
|
|
assert.equal(word,0);assert.equal(await p.locator('[data-context-scene]').inputValue(),String(s.scene));console.log('PASS Development main-window navigation: actual scene, character, Names and Relationships editors reused one existing main window; Context scene and Word position unchanged. Browser focus remains discretionary.');
|
|
} catch(e){console.error('FAILED '+step+': '+e.message);process.exitCode=1;}finally{await b.close();}})();
|