diff --git a/PlotLine.Tests/Browser/investigation-ux-correction.cjs b/PlotLine.Tests/Browser/investigation-ux-correction.cjs index 527a3277..cac0cafe 100644 --- a/PlotLine.Tests/Browser/investigation-ux-correction.cjs +++ b/PlotLine.Tests/Browser/investigation-ux-correction.cjs @@ -4,8 +4,8 @@ await p.goto(base+'/Account/Login');await p.locator('[name=Email]').fill(w.Email // Starting from saved results does not activate guidance. Continue is explicit. assert(await root.isHidden());assert(await root.locator('[data-guidance-expand]').isHidden()); const older=p.locator('[data-my-investigations] article').filter({has:p.locator(`input[name=id][value="${w.oldInvestigation}"]`)});await older.getByRole('button',{name:'Continue',exact:true}).click();await p.waitForFunction(()=>document.querySelector('[data-guidance-content]')?.textContent.includes('older investigation'));assert.equal(await root.locator('.pd-guidance-tool').count(),0);await shot('Older-investigation');await p.goto(explore);await p.locator('[data-my-investigations] article').first().waitFor();const card=p.locator('[data-my-investigations] article').filter({has:p.locator(`input[name=id][value="${w.investigation}"]`)});await card.getByRole('button',{name:'Continue',exact:true}).click();await p.locator('[data-conclusion]').waitFor();await root.waitFor();const count=c.pages().length; -for(let n=0;n<3;n++){if(n)await p.goto(`${base}/Writer/Explore/Investigate?bookId=${w.book}&id=${w.investigation}`);const network=[];const capture=r=>{if(r.request().isNavigationRequest()||r.url().includes('/InvestigationCompanion/Summary'))network.push({url:new URL(r.url()).pathname,status:r.status(),timing:r.request().timing(),serverTiming:r.headers()['server-timing']});};p.on('response',capture);const start=Date.now();await p.locator('form[data-guidance-navigation]').first().getByRole('button').click();await p.waitForURL(/PlotLineWorkspace/);const documentMs=Date.now()-start;await root.locator('#guidance-finding').waitFor();timings.push({documentMs,restoredMs:Date.now()-start,network});p.removeListener('response',capture);} -assert.equal(c.pages().length,count);const panelContent=root.locator('.plotline-help-drawer-panel');assert.equal(await root.getAttribute('data-state'),'open');await p.evaluate(()=>PlotLineHelpDrawer.open('plotLines.workspace'));await help.locator('.help-drawer-article').waitFor();await shot('Both-open'); +for(let n=0;n<3;n++){if(n)await p.goto(`${base}/Writer/Explore/Investigate?bookId=${w.book}&id=${w.investigation}`);const network=[];const capture=r=>{if(r.request().isNavigationRequest()||r.url().includes('/InvestigationCompanion/Summary'))network.push({url:new URL(r.url()).pathname,status:r.status(),timing:r.request().timing(),serverTiming:r.headers()['server-timing']});};p.on('response',capture);const start=Date.now();await p.locator('.investigation form[data-guidance-navigation]').first().getByRole('button').click();await p.waitForURL(/PlotLineWorkspace/);const documentMs=Date.now()-start;await root.locator('#guidance-finding').waitFor();timings.push({documentMs,restoredMs:Date.now()-start,network});p.removeListener('response',capture);} +assert.equal(c.pages().length,count);const panelContent=root.locator('.plotline-help-drawer-panel');assert.equal(await root.getAttribute('data-state'),'open');await p.evaluate(()=>PlotLineHelpDrawer.open('plotLines.workspace'));await help.locator('.help-drawer-article').waitFor();assert(await p.locator('.plot-workspace-controls').evaluate(n=>{const r=n.closest('.plotline-help-main').getBoundingClientRect();return [...n.querySelectorAll('input:not([type=hidden]),select,button')].every(c=>c.getBoundingClientRect().right<=r.right);}));await shot('Both-open'); for(const left of['open','collapsed','closed'])for(const right of['open','collapsed','closed']){ if(await root.getAttribute('data-state')!=='open')await p.locator('[data-guidance-open]').click();if(left==='collapsed')await root.locator('[data-guidance-collapse]').click();if(left==='closed')await root.locator('[data-guidance-close]').click(); await p.evaluate(()=>PlotLineHelpDrawer.open('plotLines.workspace'));await help.locator('.help-drawer-article').waitFor();if(right==='collapsed')await help.locator('[data-help-collapse]').click();if(right==='closed')await help.locator('[data-help-close]').click(); @@ -13,8 +13,8 @@ for(const left of['open','collapsed','closed'])for(const right of['open','collap await p.locator('[data-guidance-open]').click();await p.evaluate(()=>PlotLineHelpDrawer.open('plotLines.workspace'));await help.locator('.help-drawer-article').waitFor();await root.locator('[data-guidance-close]').click();await shot('Help-only');assert(await help.isVisible());await p.locator('[data-guidance-open]').click();await help.locator('[data-help-close]').click();await shot('Investigation-only'); // A close is presentation only, and a saved selector changes only authorised guidance. const before=await (await p.request.get(base+`/InvestigationCompanion/Summary?projectId=${w.project}&bookId=${w.book}`)).json();await root.locator('[data-guidance-close]').click();const after=await (await p.request.get(base+`/InvestigationCompanion/Summary?projectId=${w.project}&bookId=${w.book}`)).json();assert.equal(after.summary.version,before.summary.version);await p.reload();assert(await root.isHidden());await p.locator('[data-guidance-open]').click(); -const picker=root.getByLabel('Switch saved investigation');await picker.focus();await picker.locator(`option[value="${w.secondInvestigation}"]`).waitFor({state:'attached'});await picker.selectOption(w.secondInvestigation);await p.waitForFunction(()=>document.querySelector('[data-guidance-content] a')?.href.includes(window.location.origin)&&document.querySelector('[data-guidance-content] a')?.href.includes('id='));await p.waitForFunction(id=>document.querySelector('[data-guidance-content] a')?.href.includes(id),w.secondInvestigation);assert((await root.getByRole('link',{name:'Full investigation results'}).getAttribute('href')).includes(w.secondInvestigation)); +const picker=root.getByLabel('Switch saved investigation');await picker.focus();await picker.locator(`option[value="${w.secondInvestigation}"]`).waitFor({state:'attached'});await picker.selectOption(w.secondInvestigation);await p.waitForFunction(()=>document.querySelector('[data-guidance-picker] a')?.href.includes(window.location.origin)&&document.querySelector('[data-guidance-picker] a')?.href.includes('id='));await p.waitForFunction(id=>document.querySelector('[data-guidance-picker] a')?.href.includes(id),w.secondInvestigation);assert((await root.getByRole('link',{name:'Full investigation results'}).getAttribute('href')).includes(w.secondInvestigation)); await root.locator('[data-guidance-pin]').click(); // pin (Close unpinned it) await root.locator('.pd-guidance-tool[data-capability=timeline] form button').click();await p.waitForURL(/Timeline/);await root.locator('#guidance-finding').waitFor();await shot('Timeline');await p.reload();await root.locator('#guidance-finding').waitFor();assert.equal(await root.getAttribute('data-state'),'open'); await root.locator('[data-guidance-pin]').click();await root.locator('.pd-guidance-tool select').first().selectOption('Done');await p.waitForFunction(()=>document.querySelector('[data-guidance-message]')?.textContent==='');assert.equal(await root.getAttribute('data-state'),'open');await p.reload();assert(await root.isHidden());await p.locator('[data-guidance-open]').click();await p.setViewportSize({width:800,height:1000});await p.evaluate(()=>PlotLineHelpDrawer.open('timeline.overview'));await help.locator('.help-drawer-article').waitFor();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2));await shot('Narrow-both');await root.locator('[data-guidance-close]').click();assert(await help.isVisible()); -await p.setViewportSize({width:1440,height:1000});await p.goto(explore);await p.locator('[data-my-investigations] article').first().waitFor();assert(await root.isHidden());await p.locator('[data-guidance-open]').click();await root.getByRole('button',{name:'Finish this journey'}).click();await p.waitForFunction(()=>document.querySelector('[data-investigation-companion]')?.dataset.state==='closed');assert.equal((await (await p.request.get(base+`/InvestigationCompanion/Summary?bookId=${w.book}`)).json()).active,false);await p.goto(explore);await p.locator('[data-my-investigations] article').first().waitFor();const original=p.locator('[data-my-investigations] article').filter({has:p.locator(`input[name=id][value="${w.investigation}"]`)});await original.getByRole('link',{name:'Original results'}).click();assert.equal((await (await p.request.get(base+`/InvestigationCompanion/Summary?bookId=${w.book}`)).json()).active,false);await p.goto(explore);await p.locator('[data-my-investigations] article').filter({has:p.locator(`input[name=id][value="${w.investigation}"]`)}).getByRole('button',{name:'Continue',exact:true}).click();await root.locator('#guidance-finding').waitFor();if(await root.locator('[data-guidance-pin]').textContent()==='Pin')await root.locator('[data-guidance-pin]').click();await p.goto(`${base}/Writer/Review?projectId=${w.project}&bookId=${w.book}`);await root.locator('#guidance-finding').waitFor();await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.reviewing'));const prior=[await root.getAttribute('data-state'),await help.getAttribute('data-state')];await p.locator('#reader-focus').click();assert(await root.evaluate(n=>n.inert));assert(await help.evaluate(n=>n.inert));await p.locator('#reader-focus').click();assert.deepEqual([await root.getAttribute('data-state'),await help.getAttribute('data-state')],prior);await shot('Writer-review');assert.deepEqual(errors,[]);fs.writeFileSync(process.env.PD_UX_TIMINGS||'/tmp/ux-timings.json',JSON.stringify(timings,null,2));console.log('PASS authenticated UX correction: saved discovery, nine independent lifecycle pairs, close preserves guidance, explicit reopen, switching, pin/unpin navigation/refresh, no duplicate windows, progress, narrow layout');await c.close();}finally{await b.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1}); +await p.setViewportSize({width:1440,height:1000});await p.goto(explore);await p.locator('[data-my-investigations] article').first().waitFor();assert(await root.isHidden());await p.locator('[data-guidance-open]').click();await root.getByRole('button',{name:'Finish this journey'}).click();await p.waitForFunction(()=>document.querySelector('[data-investigation-companion]')?.dataset.state==='closed');assert.equal((await (await p.request.get(base+`/InvestigationCompanion/Summary?bookId=${w.book}`)).json()).active,false);await p.goto(explore);await p.locator('[data-my-investigations] article').first().waitFor();const original=p.locator('[data-my-investigations] article').filter({has:p.locator(`input[name=id][value="${w.investigation}"]`)});await original.getByRole('link',{name:'Original results'}).click();assert.equal((await (await p.request.get(base+`/InvestigationCompanion/Summary?bookId=${w.book}`)).json()).active,false);await p.goto(explore);await p.locator('[data-my-investigations] article').filter({has:p.locator(`input[name=id][value="${w.investigation}"]`)}).getByRole('button',{name:'Continue',exact:true}).click();await root.locator('#guidance-finding').waitFor();if(await root.locator('[data-guidance-pin]').textContent()==='Pin')await root.locator('[data-guidance-pin]').click();await p.goto(`${base}/Writer/Review?projectId=${w.project}&bookId=${w.book}`);await root.locator('#guidance-finding').waitFor();await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.reviewing'));const prior=[await root.getAttribute('data-state'),await help.getAttribute('data-state')];await p.locator('#reader-focus').click();assert(await root.evaluate(n=>n.inert));assert(await help.evaluate(n=>n.inert));await p.locator('#reader-focus').click();assert.deepEqual([await root.getAttribute('data-state'),await help.getAttribute('data-state')],prior);await shot('Writer-review');await p.goto(`${base}/Writer/Explore?projectId=${w.project}&bookId=${w.otherBook}`);await p.waitForFunction(()=>document.querySelector('[data-saved-investigations]')?.textContent.includes('No saved investigations'));assert(await root.isHidden());assert(await p.locator('[data-guidance-open]').isHidden());await p.goto(explore);await root.locator('#guidance-finding').waitFor();assert.equal(await root.getAttribute('data-state'),'open');assert.deepEqual(errors,[]);fs.writeFileSync(process.env.PD_UX_TIMINGS||'/tmp/ux-timings.json',JSON.stringify(timings,null,2));console.log('PASS authenticated UX correction: saved discovery, nine independent lifecycle pairs, close preserves guidance, explicit reopen, switching, pin/unpin navigation/refresh, no duplicate windows, progress, narrow layout');await c.close();}finally{await b.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1}); diff --git a/PlotLine/Views/Shared/_InvestigationCompanion.cshtml b/PlotLine/Views/Shared/_InvestigationCompanion.cshtml index 9645af9a..b9ba2562 100644 --- a/PlotLine/Views/Shared/_InvestigationCompanion.cshtml +++ b/PlotLine/Views/Shared/_InvestigationCompanion.cshtml @@ -5,6 +5,7 @@
Investigation
Your story concernLoading saved guidance…