From aac32d5d19dcf03f91c5abdd653c1fb2b93a1c44 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Wed, 18 Nov 2026 22:25:25 +0000 Subject: [PATCH] Qualify deployed Review and keep chapter selection usable in the browser --- PlotLine.Tests/Browser/review-layout-checks.cjs | 2 +- PlotLine.Tests/Browser/ribbon-compact-live.cjs | 8 +++++++- PlotLine.Tests/Browser/writer-review-amendment-live.cjs | 8 ++++++++ PlotLine/wwwroot/css/writer-review-layout.css | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 PlotLine.Tests/Browser/writer-review-amendment-live.cjs diff --git a/PlotLine.Tests/Browser/review-layout-checks.cjs b/PlotLine.Tests/Browser/review-layout-checks.cjs index 15d90c96..7a60acc9 100644 --- a/PlotLine.Tests/Browser/review-layout-checks.cjs +++ b/PlotLine.Tests/Browser/review-layout-checks.cjs @@ -8,7 +8,7 @@ module.exports=async function reviewLayout(page,pwa,shot=async()=>{}){ for(const [which,offset] of [['left',35],['right',-25]]){const divider=page.locator('[data-review-divider='+which+']'),b=await divider.boundingBox();await page.mouse.move(b.x+b.width/2,b.y+25);await page.mouse.down();await page.mouse.move(b.x+b.width/2+offset,b.y+25,{steps:8});await page.mouse.up();} boxes=await measure();const saved=[boxes[0].width,boxes[4].width];assert(saved[0]>width*.25+20&&saved[1]>width*.25+10,'both pointer dividers resize '+JSON.stringify({saved,width}));await page.reload();await page.locator('[data-review-panel]').waitFor();await page.waitForTimeout(100);boxes=await measure();assert(Math.abs(boxes[0].width-saved[0])<3&&Math.abs(boxes[4].width-saved[1])<3,'widths persist after refresh'); const divider=page.locator('[data-review-divider=left]');await divider.focus();await divider.press('ArrowLeft');assert(Number(await divider.getAttribute('aria-valuenow'))scrollTo(0,0));await shot('Review-top'); - for(const position of await page.locator('#reader-content').evaluate(n=>n.offsetHeight>innerHeight*2)?['middle','bottom']:[]){await page.evaluate(position=>{const a=document.querySelector('#reader-content');scrollTo(0,position==='middle'?a.offsetTop+a.offsetHeight/2:document.documentElement.scrollHeight-innerHeight-8);},position);await page.waitForTimeout(160);boxes=await measure();const header=await page.locator('.pd-application-header').boundingBox();for(const index of [0,4])assert(boxes[index].top>=Math.min(8,header?.bottom||8)-2&&boxes[index].top<400,'notes remain visible '+position);assert(await left.isVisible()&&await right.isVisible());await shot('Review-'+position,false);} + for(const position of await page.locator('#reader-content').evaluate(n=>n.offsetHeight>innerHeight*2)?['middle','bottom']:[]){await page.evaluate(position=>{const a=document.querySelector('#reader-content');if(position==='middle')scrollTo(0,a.getBoundingClientRect().top+scrollY+a.offsetHeight/2);else a.querySelector('[data-paragraph-id]:last-child')?.scrollIntoView({block:'end'});},position);await page.waitForTimeout(160);boxes=await measure();const header=await page.locator('.pd-application-header').boundingBox();for(const index of [0,4])assert(boxes[index].top>=Math.min(8,header?.bottom||8)-2&&boxes[index].top<400,'notes remain visible '+position);assert(await left.isVisible()&&await right.isVisible());await shot('Review-'+position,false);} for(const note of [left,right]){const overflow=await note.evaluate(n=>n.scrollHeight>n.clientHeight);if(overflow){const moved=await note.evaluate(n=>{const before=scrollY;n.scrollTop=80;return {before,after:scrollY,notes:n.scrollTop};});assert(moved.notes>0);assert.equal(moved.after,moved.before,'notes scroll independently');}} await page.evaluate(()=>scrollTo(0,0));await page.locator('[data-review-diagnostics-open]').click();assert.equal(await page.locator('[data-review-diagnostics]').evaluate(n=>n.open),true);assert(await page.locator('[data-writer-word]').isVisible());await page.locator('[data-review-diagnostics] summary').first().click(); if(pwa){for(const id of ['reader-focus','reader-audio','reader-pause-toggle']){assert.equal(await page.locator('.pd-context-command[data-command-identity="handler:'+id+'"]').count(),1);assert.equal(await page.locator('#'+id).isVisible(),false,'native command suppressed only after ribbon composition');}await page.locator('.pd-context-command[data-command-identity="handler:reader-pause-toggle"]').click();assert.equal(await page.locator('#reader-pause').isChecked(),true);assert.equal(await page.locator('.pd-context-command[data-command-identity="handler:reader-pause-toggle"]').getAttribute('aria-pressed'),'true');await page.locator('.pd-context-command[data-command-identity="handler:reader-pause-toggle"]').click();} diff --git a/PlotLine.Tests/Browser/ribbon-compact-live.cjs b/PlotLine.Tests/Browser/ribbon-compact-live.cjs index 31f3c143..f8a458af 100644 --- a/PlotLine.Tests/Browser/ribbon-compact-live.cjs +++ b/PlotLine.Tests/Browser/ribbon-compact-live.cjs @@ -2,6 +2,12 @@ const{chromium}=require('playwright'),fs=require('node:fs'),assert=require('node const who=JSON.parse(fs.readFileSync(process.env.PD_PHASE21_IDENTITY)),s=JSON.parse(fs.readFileSync(process.env.PD_PHASE21_SCOPE)),out=process.env.PD_PHASE21_RIBBON; assert(who.Database==='PlotDirector_Development'&&/^pwa-browser-.*@example\.invalid$/.test(who.Email)); (async()=>{const b=await chromium.launch();try{for(const pwa of[false,true]){const c=await b.newContext({viewport:{width:1666,height:1050}});await c.addInitScript(({user,pwa})=>{localStorage.setItem('plotdirector.desktop.v1.'+user,JSON.stringify({dismissedAt:Date.now()}));if(pwa)Object.defineProperty(navigator,'standalone',{value:true});},{user:who.UserID,pwa});const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));await p.goto('https://dev.plotdirector.com/Account/Login');await p.locator('[name=Email]').fill(who.Email);await p.locator('[name=Password]').fill(who.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);await p.goto('https://dev.plotdirector.com/Maps?projectId='+s.project+'&bookId='+s.book);const toggle=p.locator('[data-ribbon-collapse]');if(await toggle.getAttribute('aria-expanded')==='false')await toggle.click();if(pwa)await p.locator('[data-pwa-context-controls] .pd-context-command').first().waitFor();if(out)fs.mkdirSync(out,{recursive:true}); -for(const theme of['modern-light','modern-dark','warm-light','warm-dark']){await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);if(out)await p.screenshot({path:out+'/Maps-1666-'+theme+'-'+(pwa?'PWA':'browser')+'.png'});} +for(const theme of['modern-light','modern-dark','warm-light','warm-dark']){await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);if(out)await p.screenshot({path:out+'/Maps-1666-'+theme+'-'+(pwa?'PWA':'browser')+'.png'}); +const style=async tab=>await p.locator('#ribbon-tab-'+tab).evaluate(n=>{const s=getComputedStyle(n);return [s.color,s.backgroundColor,s.fontWeight];}); +await p.locator('#ribbon-tab-project').click();await p.mouse.move(1,1);assert.deepEqual(await style('writer'),await style('book'),'same inactive tab style '+theme);const active=await style('project'); +await p.locator('#ribbon-tab-writer').hover();const hover=await style('writer');await p.locator('#ribbon-tab-book').hover();assert.deepEqual(await style('book'),hover,'same hover tab style '+theme); +await p.mouse.move(1,1);await p.locator('#ribbon-tab-writer').focus();const focused=await style('writer');await p.locator('#ribbon-tab-book').focus();assert.deepEqual(await style('book'),focused,'same focus tab style '+theme); +await p.locator('#ribbon-tab-writer').click();await p.waitForURL('**/Writer**');await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);await p.mouse.move(1,1);assert.deepEqual(await style('writer'),active,'same active tab style '+theme);await p.goto('https://dev.plotdirector.com/Maps?projectId='+s.project+'&bookId='+s.book);} + for(const width of[1666,1366,1024,800]){await p.setViewportSize({width,height:1050});for(const category of['project','book','writer','story','characters','world','tools']){await p.locator('#ribbon-tab-'+category).click();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),category+width);const rows=await p.locator('#ribbon-panel-'+category+' .pd-ribbon-command:visible').evaluateAll(ns=>ns.filter(n=>!n.closest('.pd-context-menu-content')).map(n=>{const span=n.querySelector(':scope>span');return{height:Math.round(n.getBoundingClientRect().height),label:n.textContent.trim(),lines:span?Math.round(span.scrollHeight/parseFloat(getComputedStyle(span).lineHeight)):0};}));for(const row of rows){assert.equal(row.height,68,category+' '+row.label);assert(row.lines<=2,category+' '+row.label+' wrapping');}if(out&&pwa&&(width===1666||width===800))await p.screenshot({path:out+'/'+category+'-'+width+'-deployed.png'});await p.keyboard.press('Tab');assert(await p.evaluate(()=>document.activeElement!==document.body),'keyboard focus retained');}} assert.deepEqual(errors,[]);console.log('PASS deployed authenticated ribbons '+(pwa?'simulated PWA':'browser')+': all seven primary categories, four widths, four Maps themes, two-line labels, uniform heights, keyboard focus and no page overflow; no map command invoked');await c.close();}}finally{await b.close();}})().catch(e=>{console.error(String(e.stack).replaceAll(who.Password,'[redacted]'));process.exitCode=1}); diff --git a/PlotLine.Tests/Browser/writer-review-amendment-live.cjs b/PlotLine.Tests/Browser/writer-review-amendment-live.cjs new file mode 100644 index 00000000..03a9e76d --- /dev/null +++ b/PlotLine.Tests/Browser/writer-review-amendment-live.cjs @@ -0,0 +1,8 @@ +const {chromium}=require('playwright'),fs=require('node:fs'),assert=require('node:assert/strict'); +const who=JSON.parse(fs.readFileSync(process.env.PD_PHASE21_IDENTITY)),s=JSON.parse(fs.readFileSync(process.env.PD_PHASE21_SCOPE)),base='https://dev.plotdirector.com',out=process.env.PD_PHASE21_SCREENSHOTS; +assert(who.Database==='PlotDirector_Development'&&/^pwa-browser-.*@example\.invalid$/.test(who.Email)); +(async()=>{const browser=await chromium.launch();try{for(const pwa of [false,true]){const c=await browser.newContext({viewport:{width:1920,height:1100}});await c.addInitScript(({user,pwa})=>{localStorage.setItem('plotdirector.desktop.v1.'+user,JSON.stringify({dismissedAt:Date.now()}));if(pwa)Object.defineProperty(navigator,'standalone',{value:true});},{user:who.UserID,pwa});const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(who.Email);await p.locator('[name=Password]').fill(who.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);await p.goto(`${base}/Writer/Review?bookId=${s.book}&projectId=${s.project}&chapterId=${s.chapter}`);await p.locator('[data-review-panel]').waitFor();if(await p.locator('[data-ribbon-collapse]').getAttribute('aria-expanded')==='false')await p.locator('[data-ribbon-collapse]').click();assert(await p.locator('#reader-content').evaluate(n=>n.offsetHeight>innerHeight*2),'real long accepted chapter'); +const shot=async(name,reset=true)=>{if(!out)return;fs.mkdirSync(out,{recursive:true});if(reset)await p.evaluate(()=>scrollTo(0,0));await p.waitForTimeout(100);if(!reset){await p.waitForTimeout(500);console.log('viewport',name,await p.evaluate(()=>({scroll:scrollY,height:document.documentElement.scrollHeight,hit:document.elementFromPoint(950,500)?.outerHTML.slice(0,180),header:document.querySelector('.pd-application-header').getBoundingClientRect().toJSON()})));}const session=await c.newCDPSession(p);const capture=await session.send('Page.captureScreenshot',{format:'png',captureBeyondViewport:false});fs.writeFileSync(out+'/'+name+'-'+(pwa?'PWA':'browser')+'.png',Buffer.from(capture.data,'base64'));await session.detach();}; +await require('./review-layout-checks.cjs')(p,pwa,shot); +const form=p.locator('[data-review-form]');await p.locator('[data-review-new]').click();assert.equal(await form.locator('[name=Scope]').inputValue(),'','ambiguous scope is explicit');await form.locator('[data-review-cancel]').click();await p.locator('[data-review-scope-new=Chapter]').click();assert.equal(await form.evaluate(n=>n.closest('.writer21-notes').id),'review-chapter-notes');await form.locator('[data-review-cancel]').click(); +assert.deepEqual(errors,[]);console.log('PASS deployed Review amendment '+(pwa?'simulated PWA':'browser')+': long chapter top/middle/bottom, permanent columns, both pointer and keyboard dividers, saved widths, independent notes scrolling, Focus restore, audio controls, diagnostics, explicit scope, four themes and responsive layouts');await c.close();}}finally{await browser.close();}})().catch(e=>{console.error(String(e.stack).replaceAll(who.Password,'[redacted]'));process.exitCode=1;}); diff --git a/PlotLine/wwwroot/css/writer-review-layout.css b/PlotLine/wwwroot/css/writer-review-layout.css index edf2cc9f..7d8a8812 100644 --- a/PlotLine/wwwroot/css/writer-review-layout.css +++ b/PlotLine/wwwroot/css/writer-review-layout.css @@ -41,3 +41,6 @@ body .manuscript-reader[data-focus=true] #reader-focus,body .manuscript-reader[d .manuscript-reader[data-focus=true]>#reader-audio,.manuscript-reader[data-focus=true] #reader-pause-toggle{display:none!important} .writer21-editorial>.writer21-notes,.review-column-divider{overflow-anchor:none} +.writer21-manuscript .reader-controls form{flex-basis:100%;order:-1} +.writer21-notes [data-observation] h4{font-size:1rem;line-height:1.4;margin-bottom:.3rem} +.writer21-notes [data-observation]{font-size:.9rem}