Keep investigation recovery links scoped to in-page book changes
This commit is contained in:
parent
aad91b2c7f
commit
5ebb9f82e8
@ -28,8 +28,10 @@ const base=live?'https://dev.plotdirector.com':'http://127.0.0.1:5238',out=proce
|
||||
await expandRibbon();await p.getByRole('tab',{name:'Writer',exact:true}).click();await p.waitForURL(u=>/\/Writer(?:\/Index)?$/.test(u.pathname));await root.locator('#guidance-finding').waitFor();await expandRibbon();await p.locator('[data-app-back]').click();await p.waitForURL(live?/\/Timeline/:/\/Writer\/Review/);await root.locator('#guidance-finding').waitFor();assert(await first.locator('select').inputValue()==='Done');await snap('Ribbon-Back-retains-guidance');
|
||||
await p.setViewportSize({width:800,height:1000});assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));assert((await root.locator('.pd-investigation-panel').boundingBox()).height<=551);await snap('Narrow-in-flow');await p.setViewportSize({width:1440,height:1000});
|
||||
state=await c.storageState();await c.close();const reopened=await b.newContext({storageState:state,viewport:{width:1440,height:1000}});await reopened.addInitScript(()=>Object.defineProperty(navigator,'standalone',{value:true}));const q=await reopened.newPage();await q.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.book}`);await q.locator('#guidance-finding').waitFor();assert.equal(await q.locator('.pd-guidance-tool[data-capability=threads] select').inputValue(),'Done');
|
||||
await q.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.otherBook}`);await q.waitForFunction(()=>document.querySelector('[data-guidance-content]')?.textContent.includes('No active investigation'));assert.equal(await q.locator('#guidance-finding').count(),0);assert.equal(await q.locator('[data-investigation-companion]').getAttribute('data-collapsed'),'true');
|
||||
await q.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.book}`);await q.locator('#guidance-finding').waitFor();
|
||||
await q.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.otherBook}`);await q.waitForFunction(()=>document.querySelector('[data-guidance-content]')?.textContent.includes('No active investigation'));assert.equal(await q.locator('#guidance-finding').count(),0);assert.equal(await q.locator('[data-investigation-companion]').getAttribute('data-collapsed'),'true');await q.locator('[data-guidance-expand]').click();const resume=await q.getByRole('link',{name:'Open saved investigations',exact:true}).getAttribute('href');assert.equal(new URL(resume).searchParams.get('bookId'),String(w.otherBook));
|
||||
// In-page book context changes use the same event as Calendar/At This Point and recheck server scope.
|
||||
await q.evaluate(()=>document.dispatchEvent(new CustomEvent('plotdirector:book-context-changed',{detail:{bookId:0}})));await q.waitForFunction(()=>document.querySelector('[data-guidance-content]')?.textContent.includes('Choose a book'));await q.locator('[data-guidance-expand]').click();assert(!(new URL(await q.getByRole('link',{name:'Choose a book in Writer to resume an investigation'}).getAttribute('href'))).searchParams.has('bookId'));
|
||||
await q.evaluate(book=>document.dispatchEvent(new CustomEvent('plotdirector:book-context-changed',{detail:{bookId:book}})),w.book);await q.locator('#guidance-finding').waitFor();
|
||||
// Server-side failure paths retain the active guidance; forged IDs never expose it.
|
||||
const token=await q.locator('[data-guidance-token] [name=__RequestVerificationToken]').inputValue();const response=await q.request.post(base+'/InvestigationCompanion/Open',{form:{__RequestVerificationToken:token,bookId:w.book,id:w.investigation,finding:'disconnected',capability:'invented'}});assert.equal(response.status(),400);
|
||||
const wrong=await q.request.get(base+`/InvestigationCompanion/Evidence?bookId=${w.otherBook}&id=${w.investigation}&finding=disconnected`);assert.equal(wrong.status(),404);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
@model ApplicationNavigationViewModel
|
||||
<aside class="pd-investigation" data-investigation-companion data-collapsed="true" data-user="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value" data-project="@Model.Project?.ProjectID" data-book="@Model.Book?.BookID"
|
||||
data-summary-url="@Url.Action("Summary","InvestigationCompanion")" data-update-url="@Url.Action("Update","InvestigationCompanion")" data-open-url="@Url.Action("Open","InvestigationCompanion")" data-evidence-url="@Url.Action("Evidence","InvestigationCompanion")" data-start-url="@(Model.Book is not null ? Url.Action("Index","WriterInvestigations",new{bookId=Model.Book.BookID}) : Url.Action("Index","Writer",new{projectId=Model.Project?.ProjectID}))" aria-label="Investigation companion">
|
||||
data-summary-url="@Url.Action("Summary","InvestigationCompanion")" data-update-url="@Url.Action("Update","InvestigationCompanion")" data-open-url="@Url.Action("Open","InvestigationCompanion")" data-evidence-url="@Url.Action("Evidence","InvestigationCompanion")" data-start-url="@Url.Action("Index","WriterInvestigations")" data-choose-url="@Url.Action("Index","Writer",new{projectId=Model.Project?.ProjectID})" aria-label="Investigation companion">
|
||||
<button type="button" class="pd-investigation-tab" data-guidance-expand aria-label="Expand investigation companion" title="Expand investigation companion" aria-expanded="false" aria-controls="investigation-panel">Investigation</button>
|
||||
<div class="plotline-help-drawer-panel pd-investigation-panel" id="investigation-panel">
|
||||
<header class="plotline-help-drawer-header"><div><p class="eyebrow mb-0">Investigation</p><strong data-guidance-title>Your story concern</strong></div>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
function setWidth(value,persist=true){const width=Math.max(280,Math.min(440,Number(value)||320));layout.style.setProperty('--investigation-width',width+'px');splitter.setAttribute('aria-valuenow',String(width));if(persist){preference.width=width;save();}}
|
||||
function measure(){const h=document.querySelector('.pd-application-header'),top=h&&getComputedStyle(h).position==='sticky'?h.getBoundingClientRect().height:0;layout.style.setProperty('--context-sticky-top',Math.ceil(top)+8+'px');}
|
||||
function failure(text){message.textContent=text;}
|
||||
function startLink(){const a=element('a',root.dataset.book?'Open saved investigations':'Choose a book in Writer to resume an investigation');a.href=root.dataset.startUrl;return a;}
|
||||
function startLink(){const book=Number(root.dataset.book),a=element('a',book>0?'Open saved investigations':'Choose a book in Writer to resume an investigation');const url=new URL(book>0?root.dataset.startUrl:root.dataset.chooseUrl,location.origin);if(book>0)url.searchParams.set('bookId',String(book));a.href=url.href;return a;}
|
||||
function render(){
|
||||
content.replaceChildren();message.textContent='';root.querySelector('[data-guidance-title]').textContent=current?.bookTitle||'Your story concern';
|
||||
if(!current){content.append(element('p','No active investigation for this context.'),startLink());return;}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user