diff --git a/PlotLine.Tests/Browser/ribbon-compact-live.cjs b/PlotLine.Tests/Browser/ribbon-compact-live.cjs index f8a458af..d7eb31dc 100644 --- a/PlotLine.Tests/Browser/ribbon-compact-live.cjs +++ b/PlotLine.Tests/Browser/ribbon-compact-live.cjs @@ -7,7 +7,7 @@ const style=async tab=>await p.locator('#ribbon-tab-'+tab).evaluate(n=>{const s= 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);} +const currentURL=p.url();await p.locator('#ribbon-tab-writer').click();assert.equal(p.url(),currentURL,'Writer selects its ribbon without leaving Maps');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-navigation-themes.cjs b/PlotLine.Tests/Browser/writer-navigation-themes.cjs index 78a6bd32..2886a921 100644 --- a/PlotLine.Tests/Browser/writer-navigation-themes.cjs +++ b/PlotLine.Tests/Browser/writer-navigation-themes.cjs @@ -8,14 +8,16 @@ const base='http://127.0.0.1:5238'; if(pwa)await context.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true})); const page=await context.newPage(); await page.goto(base+'/fixture?page=writer&layout=full&bookId=12'); - const nav=page.locator('.pd-ribbon-navigation').filter({hasText:/^Writer$/}); + const nav=page.locator('#ribbon-tab-writer'); assert.equal(await nav.count(),1); - assert.equal(await nav.getAttribute('aria-current'),'page'); - assert.equal(new URL(await nav.getAttribute('href'),base).searchParams.get('projectId'),'7'); - assert.equal(new URL(await nav.getAttribute('href'),base).searchParams.get('bookId'),'12'); + assert.equal(await nav.getAttribute('aria-selected'),'true'); + assert.equal(await nav.getAttribute('data-ribbon-tab'),'writer'); + const home=page.locator('#ribbon-panel-writer a[data-command-operation="writer.index"]'); + assert.equal(new URL(await home.getAttribute('href'),base).searchParams.get('projectId'),'7'); + assert.equal(new URL(await home.getAttribute('href'),base).searchParams.get('bookId'),'12'); assert.equal(await page.locator('#ribbon-panel-story a').filter({hasText:/^Writer$/}).count(),0); assert.equal(await page.locator('#appStoryMenu + ul a').filter({hasText:/Writer/}).count(),0); - assert(await nav.evaluate(a=>a.matches('.pd-ribbon-navigation')?a.nextElementSibling?.dataset.ribbonTab==='story':a.parentElement.nextElementSibling?.querySelector('#appStoryMenu')!==null)); + assert(await nav.evaluate(a=>a.nextElementSibling?.dataset.ribbonTab==='story')); for(const embedded of [false,true])for(const role of ['Context','Intent']){ await page.goto(base+`/Writing/${role}?bookId=12${embedded?'&embedded=true':''}`); // Exercise real populated cards and controls without a database or native session. @@ -48,5 +50,5 @@ const base='http://127.0.0.1:5238'; } await context.close(); } - console.log('PASS Writer direct navigation/order/context/active state, Story removal; Context and Intent shared palettes and live cross-window changes in all four themes, browser/PWA, full/embedded and 390/1440 layouts.'); + console.log('PASS Writer shared section selection/order/context/active state, Story removal; Context and Intent shared palettes and live cross-window changes in all four themes, browser/PWA, full/embedded and 390/1440 layouts.'); }finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;}); diff --git a/PlotLine.Tests/Browser/writer-ribbon-style.cjs b/PlotLine.Tests/Browser/writer-ribbon-style.cjs index f2ef20b6..604972d2 100644 --- a/PlotLine.Tests/Browser/writer-ribbon-style.cjs +++ b/PlotLine.Tests/Browser/writer-ribbon-style.cjs @@ -13,7 +13,7 @@ const assert=require('node:assert/strict'); await page.evaluate(theme=>window.PlotDirectorApplyApplicationTheme(theme),theme); await page.waitForFunction(theme=>document.documentElement.dataset.appTheme===theme,theme); const writer=page.locator('#ribbon-tab-writer'),project=page.locator('#ribbon-tab-project'),book=page.locator('#ribbon-tab-book'); - const href=await writer.getAttribute('href'); + assert.equal(await writer.getAttribute('data-ribbon-tab'),'writer'); await page.mouse.move(0,0);const activeWriter=await style(writer); await project.click();await page.mouse.move(0,0);await project.evaluate(el=>el.blur()); assert.equal(await writer.getAttribute('aria-selected'),'false'); @@ -25,7 +25,7 @@ const assert=require('node:assert/strict'); assert(await writer.evaluate(el=>el.matches(':focus-visible'))); const focusWriter=await style(writer);await book.focus(); assert.deepEqual(focusWriter,await style(book),`${theme} focus`); - assert.equal(await writer.getAttribute('href'),href,'Writer navigation remains unchanged'); + assert.equal(await writer.evaluate(n=>n.tagName),'BUTTON','Writer shares the section selector control'); } await context.close(); } diff --git a/PlotLine.Tests/Browser/writer-tab-collapse.cjs b/PlotLine.Tests/Browser/writer-tab-collapse.cjs new file mode 100644 index 00000000..27a202d2 --- /dev/null +++ b/PlotLine.Tests/Browser/writer-tab-collapse.cjs @@ -0,0 +1,42 @@ +const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=require('node:fs'); +const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238'; +(async()=>{ + const installed=process.argv.includes('--installed'),profile=fs.mkdtempSync('/tmp/pd-narrative-pwa-'); + const c=installed?await chromium.launchPersistentContext(profile,{headless:false,viewport:{width:1666,height:1050}}):await(await chromium.launch()).newContext({viewport:{width:1666,height:1050}}),b=c.browser(); + try{ + await c.route('**/Writer/Work/State?*',r=>r.fulfill({json:{session:null,defaultPauseOnEdit:true}})); + await c.route('**/native-companion/connection-state',r=>r.fulfill({json:{known:false,state:'Disconnected',wordConnected:false}})); + await c.route('**/native-companion/status*',r=>r.fulfill({json:{leases:[]}})); + await c.route('**/signalr.min.js',r=>r.fulfill({contentType:'application/javascript',body:fs.readFileSync(require.resolve('@microsoft/signalr/dist/browser/signalr.min.js'),'utf8')})); + await c.route('**/hubs/**',r=>r.abort()); + await c.addInitScript(()=>localStorage.setItem('plotdirector.desktop.v1.4',JSON.stringify({dismissedAt:Date.now()}))); + let p; + if(installed){const tab=c.pages()[0];await tab.goto(base+'/fixture');const d=await b.newBrowserCDPSession(),manifestId=base+'/Projects';await d.send('PWA.install',{manifestId,installUrlOrBundleUrl:base+'/fixture'});await d.send('PWA.changeAppUserSettings',{manifestId,displayMode:'standalone'});const opened=c.waitForEvent('page');await d.send('PWA.launch',{manifestId,url:base+'/fixture'});p=await opened;await p.waitForLoadState();assert(await p.evaluate(()=>matchMedia('(display-mode: standalone)').matches));}else p=await c.newPage(); + + + + await c.route('**/WriterActivities/**',r=>r.fulfill({contentType:'text/html',body:'