diff --git a/PlotLine.Tests/Browser/writer-navigation-themes.cjs b/PlotLine.Tests/Browser/writer-navigation-themes.cjs new file mode 100644 index 00000000..78a6bd32 --- /dev/null +++ b/PlotLine.Tests/Browser/writer-navigation-themes.cjs @@ -0,0 +1,52 @@ +// Production Razor layouts and shared theme tokens; isolated fixture repositories. +const {chromium}=require('playwright'); +const assert=require('node:assert/strict'); +const base='http://127.0.0.1:5238'; +(async()=>{const browser=await chromium.launch();try{ + for(const pwa of [false,true]){ + const context=await browser.newContext(); + 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$/}); + 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 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)); + 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. + const fragment=await (await page.request.get(base+`/writing-desk-fixture/${role.toLowerCase()}?fragment=true`)).text(); + await page.locator(`[data-writing-${role.toLowerCase()}-content]`).evaluate((el,html)=>el.innerHTML=html,fragment); + if(role==='Intent')await page.locator('.writing-workspace-role-indicator span').evaluate(el=>el.textContent='Saved PlotDirector snapshot · manual navigation · no automatic save'); + const sender=await context.newPage();await sender.goto(base+'/fixture'); + for(const theme of ['modern-light','modern-dark','warm-light','warm-dark']){ + await sender.evaluate(theme=>localStorage.setItem('plotdirector.applicationTheme',theme),theme); + await page.waitForFunction(theme=>document.documentElement.dataset.appTheme===theme,theme); + for(const width of [390,1440]){ + await page.setViewportSize({width,height:1000}); + const result=await page.evaluate(()=>{ + const main=document.querySelector('.writing-context-page'),card=main.querySelector('.writing-context-card'); + const probe=document.createElement('span');main.append(probe); + const resolve=token=>{probe.style.color=`var(${token})`;return getComputedStyle(probe).color;}; + const result={body:getComputedStyle(document.body).backgroundColor,workspace:resolve('--pd-workspace'),text:getComputedStyle(main).color,expectedText:resolve('--pd-text'),card:getComputedStyle(card).backgroundColor,surface:resolve('--pd-surface'),overflow:document.documentElement.scrollWidth>innerWidth+2};probe.remove();return result; + }); + assert.equal(result.body,result.workspace,`${role} ${theme} background`); + assert.equal(result.text,result.expectedText,`${role} ${theme} text`); + assert.equal(result.card,result.surface,`${role} ${theme} card`); + assert.equal(result.overflow,false,`${role} ${theme} ${width} overflow`); + const active=page.locator('.writing-context-tabs button.active'); + if(await active.count())assert(await active.evaluate(el=>{ + const probe=document.createElement('span');el.append(probe);probe.style.color='var(--pd-on-accent)';const expected=getComputedStyle(probe).color;probe.remove();return getComputedStyle(el).color===expected; + }),`${role} ${theme} selected text`); + } + } + await sender.close(); + } + 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.'); +}finally{await browser.close();}})().catch(e=>{console.error(e);process.exitCode=1;}); diff --git a/PlotLine/Services/ApplicationRibbon.cs b/PlotLine/Services/ApplicationRibbon.cs index d28b9074..8f7e5735 100644 --- a/PlotLine/Services/ApplicationRibbon.cs +++ b/PlotLine/Services/ApplicationRibbon.cs @@ -31,7 +31,7 @@ public static class ApplicationRibbon new("book", "Book", new("Selected book", new("Book overview", "bible", "Books", "Details", "book"), new("Edit book", "writer", "Books", "Edit", "book"), new("Add chapter", "threads", "Chapters", "Create", "chapter")), new("Manuscript review", S("review")), new("Library", S("overview"), new("Add book", "bible", "Books", "Create"))), - new("story", "Story", new("Story structure", S("timeline"), S("plotlines"), S("threads"), S("calendar"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity")), new("Writing", S("writer"))), + new("story", "Story", new("Story structure", S("timeline"), S("plotlines"), S("threads"), S("calendar"), S("point")), new("Analysis & planning", S("review"), S("scenarios"), S("continuity"))), new("characters", "Characters", new("Cast", S("characters"), S("names")), new("Connections", S("relationships"))), new("world", "World", new("Setting", S("locations"), S("maps"), S("floorplans")), new("Story world", S("assets"))), new("tools", "Tools", new("Reference", S("bible")), new("Insights", S("metrics"), S("health"), S("warnings")), new("Organisation", S("archive"))), @@ -46,6 +46,7 @@ public static class ApplicationRibbon "Timeline" or "Calendar" or "At This Point" or "Plot Lines" or "Threads" or "Scenarios" or "Continuity Explorer" => "story", "Characters" or "Names" or "Relationships" => "characters", "Locations" or "Assets" or "Maps" or "Floor Plans" => "world", + "Writer" => "writer", "Story Bible" or "Metrics" or "Health" or "Warnings" or "Archive" => "tools", _ => "project" } }; diff --git a/PlotLine/Views/Shared/_ApplicationNavigation.cshtml b/PlotLine/Views/Shared/_ApplicationNavigation.cshtml index cf9be4ae..561fb419 100644 --- a/PlotLine/Views/Shared/_ApplicationNavigation.cshtml +++ b/PlotLine/Views/Shared/_ApplicationNavigation.cshtml @@ -74,6 +74,10 @@ } + else + { + + }