From 72a77ebb0ca302cfb42d726138fd3e86d5c8b27c Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Tue, 17 Nov 2026 14:53:31 +0000 Subject: [PATCH] Keep guided investigations in the Explore ribbon context --- PlotLine.Tests/Browser/writer3-investigations.cjs | 2 +- PlotLine/Models/Investigations/Contracts.cs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/PlotLine.Tests/Browser/writer3-investigations.cjs b/PlotLine.Tests/Browser/writer3-investigations.cjs index 3ee4539b..48cf8614 100644 --- a/PlotLine.Tests/Browser/writer3-investigations.cjs +++ b/PlotLine.Tests/Browser/writer3-investigations.cjs @@ -2,7 +2,7 @@ const {chromium}=require('playwright'),assert=require('node:assert/strict'),fs=r const base=process.env.PD_INV_BASE||'http://127.0.0.1:5238',identity=process.env.PD_INV_IDENTITY?JSON.parse(fs.readFileSync(process.env.PD_INV_IDENTITY)):null,w=identity||{UserID:4,book:12,other:13,project:7}; const report=JSON.parse(fs.readFileSync(process.env.PD_INV_COVERAGE||'Docs/Writer/Writer3/Evidence/Phase3D1/simulation.json'));const path=report.RepresentativePaths.find(p=>p.concern==='story'&&p.target==='motivation'&&p.recommendations.includes('motivation'));assert(path,'unexpected destination witness'); (async()=>{const browser=await chromium.launch();try{for(const pwa of[false,true]){const c=await browser.newContext({viewport:{width:1440,height:1000}});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:w.UserID,pwa});const p=await c.newPage(),errors=[],external=[];p.on('pageerror',e=>errors.push(e.message));p.on('request',r=>{if(/openai|anthropic|generativelanguage|inference/i.test(r.url()))external.push(r.url());});if(identity){await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email);await p.locator('[name=Password]').fill(w.Password);await Promise.all([p.waitForURL('**/Projects'),p.locator('button[type=submit]').click()]);} -await p.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.book}`);await p.getByRole('link',{name:'Explore a concern',exact:true}).click();assert((await p.locator('#investigation-question').textContent()).includes("What's troubling"));assert.equal(await p.locator('iframe').count(),0);if(process.env.PD_INV_SCREENSHOTS&&!pwa){fs.mkdirSync(process.env.PD_INV_SCREENSHOTS,{recursive:true});await p.screenshot({path:process.env.PD_INV_SCREENSHOTS+'/Explore-investigation-start.png'});} +await p.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.book}`);await p.getByRole('link',{name:'Explore a concern',exact:true}).click();assert((await p.locator('#investigation-question').textContent()).includes("What's troubling"));assert.equal(await p.locator('iframe').count(),0);assert((await p.locator('[data-ribbon-shell]').textContent()).includes('Explore'));if(process.env.PD_INV_SCREENSHOTS&&!pwa){fs.mkdirSync(process.env.PD_INV_SCREENSHOTS,{recursive:true});await p.screenshot({path:process.env.PD_INV_SCREENSHOTS+'/Explore-investigation-start.png'});} await p.locator('[name=concern][value=story]').check();await p.getByRole('button',{name:'Begin',exact:true}).click();await p.locator('[data-investigation-answer]').waitFor();const id=new URL(p.url()).searchParams.get('id'),url=p.url();const explanation=p.locator('#investigation-explanation');await explanation.fill('Unfinished explanation retained for later');await p.getByRole('button',{name:'Save for later',exact:true}).click();assert.equal(await p.locator('#investigation-explanation').inputValue(),'Unfinished explanation retained for later'); let firstQuestion;for(const entry of path.answers){const form=p.locator('[data-investigation-answer]');if(!await form.count())break;const current=await form.locator('[name=question]').inputValue();firstQuestion??=current;const expected=path.answers.find(x=>x.startsWith(current+'='));assert(expected,'dynamic current question is in deterministic witness');await form.locator(`[name=option][value="${expected.split('=')[1]}"]`).check();await form.locator('[name=explanation]').fill('Synthetic browser answer ');await form.locator('button[value=answer]').click();} assert.equal(await p.locator('[data-investigation-answer]').count(),0);assert((await p.locator('#investigation-question').textContent()).includes('possible next step'));assert((await p.locator('body').textContent()).includes('Character'));assert.equal(external.length,0);const open=p.locator('form[action$="/Open"]').first();const formData=await open.evaluate(f=>Object.fromEntries(new FormData(f)));formData.capability=await open.locator('[name=capability]').getAttribute('value');const destination=await p.request.post(base+'/Writer/Explore/Investigate/Open',{form:formData,maxRedirects:0});assert.equal(destination.status(),302);assert(!destination.headers().location.toLowerCase().includes('solver'));assert(destination.headers().location.includes('projectId='+w.project));assert(destination.headers().location.includes('bookId='+w.book));await p.reload(); diff --git a/PlotLine/Models/Investigations/Contracts.cs b/PlotLine/Models/Investigations/Contracts.cs index c2d79670..5b410088 100644 --- a/PlotLine/Models/Investigations/Contracts.cs +++ b/PlotLine/Models/Investigations/Contracts.cs @@ -75,4 +75,8 @@ public sealed class Investigation public int Version {get;set;}public DateTime CreatedUtc {get;set;}public DateTime UpdatedUtc {get;set;} } public sealed record RecommendationRecord(int AnswerCount,string Outcome,List Hypotheses,DateTime Utc); -public sealed record InvestigationPage(Investigation? Investigation,Catalogue Catalogue,Evaluation? Evaluation,IReadOnlyList Saved,int ProjectID,int BookID,string? Error=null); +public sealed record InvestigationPage(Investigation? Investigation,Catalogue Catalogue,Evaluation? Evaluation,IReadOnlyList Saved,int ProjectID,int BookID,string? Error=null) +{ + // The existing application ribbon reads the destination from page models. + public string Destination => "Explore"; +}