Preserve Explore selection and authenticated tools throughout investigation navigation
This commit is contained in:
parent
72a77ebb0c
commit
62fa292f81
@ -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);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.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('#ribbon-panel-writer a[aria-current=page]').allTextContents()).some(t=>t.trim()==='Explore'));assert.equal(await p.locator('#ribbon-panel-writer a[href*="writing-problems"]').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.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 <script>text only</script>');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();
|
||||
|
||||
@ -22,7 +22,7 @@ public static class WriterNavigation
|
||||
"Dashboard" => "Your plans, manuscript and recorded progress at a glance.",
|
||||
_ => "Choose where you would like to begin today."
|
||||
};
|
||||
public static IReadOnlyList<RibbonGroup> RibbonGroups(string destination)
|
||||
public static IReadOnlyList<RibbonGroup> RibbonGroups(string destination,bool investigation=false)
|
||||
{
|
||||
var groups = new List<RibbonGroup>
|
||||
{
|
||||
@ -36,7 +36,7 @@ public static class WriterNavigation
|
||||
var context = destination switch
|
||||
{
|
||||
"Write" => new RibbonGroup("Current work", new("Chapters","bible","Books","Details","book"), new("Writing desk","writer","Writer","Overview","writerBook"), new("Writing Plan","calendar","Writer","WritingPlans","writerBook")),
|
||||
"Explore" => new RibbonGroup("Story exploration", new("Problem Solver","point","WritingProblems","Index","global"), new("Story overview","timeline","Timeline","Index","writerBook")),
|
||||
"Explore" => new RibbonGroup("Story exploration", investigation ? new("Guided investigation","point","WriterInvestigations","Index","writerBook") : new("Problem Solver","point","WritingProblems","Index","global"), new("Story overview","timeline","Timeline","Index","writerBook")),
|
||||
"Plan" => new RibbonGroup("Writing plans", new("Writing Plan","calendar","Writer","WritingPlans","writerBook"), new("Schedule Preview","calendar","Writer","SchedulePreview","writerBook")),
|
||||
"Review" => new RibbonGroup("Reading & review", new("Manuscript Reader","bible","ManuscriptReader","Index","writerBook"), new("Writing desk","writer","Writer","Overview","writerBook")),
|
||||
"Reflect" => new RibbonGroup("Writing history", new("Writing Journey","calendar","Writer","Journey","writerBook"), new("Reports","metrics","WritingActivity","Index","writerBook",OwnerOnly:true)),
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
<li><hr class="dropdown-divider" /></li>
|
||||
@foreach (var choice in Model.Books)
|
||||
{
|
||||
<li><a class="dropdown-item @(choice.BookID == book?.BookID ? "active" : null)" aria-current="@(choice.BookID == book?.BookID ? "page" : null)" data-app-book-choice="@choice.BookID" data-app-book-title="@choice.BookDisplayTitle" href="@(Model.ActiveSection == "Writer" ? Url.Action(WriterNavigation.BookSwitchAction(ViewContext.RouteData.Values["action"]?.ToString()), "Writer", new { projectId = project.ProjectID, bookId = choice.BookID }) : Url.Action("Details", "Books", new { id = choice.BookID }))">Book @choice.BookNumber: @choice.BookDisplayTitle</a></li>
|
||||
<li><a class="dropdown-item @(choice.BookID == book?.BookID ? "active" : null)" aria-current="@(choice.BookID == book?.BookID ? "page" : null)" data-app-book-choice="@choice.BookID" data-app-book-title="@choice.BookDisplayTitle" href="@(Model.ActiveSection == "Writer" ? Url.Action(controller=="WriterInvestigations" ? "Explore" : WriterNavigation.BookSwitchAction(ViewContext.RouteData.Values["action"]?.ToString()), "Writer", new { projectId = project.ProjectID, bookId = choice.BookID }) : Url.Action("Details", "Books", new { id = choice.BookID }))">Book @choice.BookNumber: @choice.BookDisplayTitle</a></li>
|
||||
}
|
||||
@if (Model.Books.Count == 0)
|
||||
{
|
||||
|
||||
@ -130,7 +130,7 @@
|
||||
@foreach (var category in ApplicationRibbon.Categories)
|
||||
{
|
||||
<div class="pd-ribbon-panel" id="ribbon-panel-@category.Key" role="tabpanel" aria-labelledby="ribbon-tab-@category.Key" hidden="@(category.Key != selectedCategory)">
|
||||
@foreach (var group in category.Key == "writer" ? WriterNavigation.RibbonGroups(Model.WriterDestination) : category.Groups)
|
||||
@foreach (var group in category.Key == "writer" ? WriterNavigation.RibbonGroups(Model.WriterDestination,controller=="WriterInvestigations") : category.Groups)
|
||||
{
|
||||
<div class="pd-ribbon-group" role="group" aria-label="@group.Label">
|
||||
<div class="pd-ribbon-commands">
|
||||
@ -139,7 +139,7 @@
|
||||
var shortcut = command.ToolbarKey is null ? null : ToolbarCommands.All.Single(x => x.Key == command.ToolbarKey);
|
||||
var available = shortcut?.IsAvailable(Model) ?? command.Available(Model);
|
||||
var url = available ? Url.Action(command.Action, command.Controller, shortcut?.RouteValues(Model) ?? command.Values(Model)) : null;
|
||||
var active = available && (shortcut?.IsActive(controller, action, Model.ActiveSection) ?? (controller == command.Controller && action == command.Action));
|
||||
var active = available && (controller=="WriterInvestigations" && command.Controller=="Writer" && command.Action=="Explore" || (shortcut?.IsActive(controller, action, Model.ActiveSection) ?? (controller == command.Controller && action == command.Action)));
|
||||
var bookScoped = command.Scope is "book" or "chapter" or "writerBook";
|
||||
var presentationIcon = RibbonPresentation.IconFor(RibbonPresentation.Operation(command.Controller, command.Action)) ?? command.IconKey;
|
||||
var icon = ApplicationRibbon.Icon(presentationIcon);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user