Remove redundant page-level narrative focus readouts
This commit is contained in:
parent
6bfdf8ce3a
commit
ba322b1e54
@ -26,7 +26,7 @@ const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238';
|
||||
await p.locator('[data-focus-toggle]').click();await p.locator('[data-focus-position]').selectOption('22/32');await p.waitForURL(/Chapters\/Details\/22/);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus?.state.sceneID===32);assert.equal(await p.locator('[data-focus-chapter]').getAttribute('data-chapter'),'22');
|
||||
await command('previous');await p.waitForURL(/Chapters\/Details\/21/);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus?.state.sceneID===101);assert.equal(await p.locator('[data-pd-context=scene][aria-current=location]').getAttribute('data-pd-context-id'),'101');
|
||||
const form=p.locator('[data-focus-chapter] form:has(input[name=overwriteAuthor])');await form.locator('input[type=checkbox]').check();await set({chapterID:22,sceneID:32});assert.equal(await p.locator('[data-focus-chapter]').getAttribute('data-chapter'),'21');await go();assert.match(await p.locator('[data-focus-workspace-status]').textContent(),/Save or cancel/);await form.evaluate(n=>n.reset());await go();await p.waitForURL(/Chapters\/Details\/22/);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus?.state.sceneID===32);
|
||||
const version=(await state()).version;await go();assert.equal((await state()).version,version,'aligned Chapter Go retains scene and version');
|
||||
const version=(await state()).version;await go();assert.equal((await state()).version,version,'aligned Chapter Go retains scene and version');assert.equal(await p.locator('[data-focus-workspace-status]').count(),0,'aligned chapter has no status strip or empty wrapper');
|
||||
await p.goto(base+'/Writer/Review?projectId=7&bookId=12');await positioned(32);let baseline=await position();assert(baseline.id,'initial Review load positions verified scene');await clear();await go();await positioned(32);assert.deepEqual(await position(),baseline,'initial load and Go use identical accepted target and offset');
|
||||
for(const scene of [31,101,32]){const chapter=scene===32?22:21;await choose(chapter+'/'+scene);baseline=await position();assert.equal((await p.evaluate(()=>window.__focusEvents.length)),1,'one authoritative event per successful selection');assert.equal(baseline.id,await p.locator(`[data-paragraph-id][data-scene-id="${scene}"]`).first().getAttribute('data-paragraph-id'));await clear();await go();await positioned(scene);assert.deepEqual(await position(),baseline,'Go leaves identical scene position unchanged');}
|
||||
// Return to the same scene through canonical ribbon stepping and recent history.
|
||||
@ -45,6 +45,15 @@ const base=process.env.PD_NARRATIVE_TEST_URL||'http://127.0.0.1:5238';
|
||||
if(installed){const divider=await p.locator(active+' .pd-ribbon-focus').evaluate(n=>{const s=getComputedStyle(n);return {width:s.borderRightWidth,style:s.borderRightStyle,color:s.borderRightColor};});assert.equal(divider.width,'1px');assert.equal(divider.style,'solid');}
|
||||
await p.route('**/StoryPoint?*',r=>r.fulfill({status:503,body:'Synthetic unavailable snapshot'}));await p.route('**/StoryPoint/Index?*',r=>r.fulfill({status:503,body:'Synthetic unavailable snapshot'}));await go();assert.match(await p.locator('[data-focus-workspace-status]').textContent(),/could not be loaded/);
|
||||
await p.goto(base+'/fixture?desktop=Characters');await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus);assert(await p.locator(active+' [data-global-focus=go]').isDisabled());assert.match(await p.locator(active+' [data-global-focus=go]').getAttribute('title'),/does not support/);
|
||||
// Success locations belong in the header, not duplicate page-level status strips.
|
||||
for(const path of ['/Chapters/Details/21','/Writer/Chapter/21','/fixture?record=Chapters','/Scenes/Edit/31','/Writer/Index?projectId=7&bookId=12','/Writer/Write?projectId=7&bookId=12&objective=true','/fixture?desktop=Books','/fixture?desktop=StoryPoint','/fixture?record=Characters','/fixture?page=maps']){
|
||||
await p.goto(base+path);await p.waitForFunction(()=>window.PlotDirectorNarrativeFocus);
|
||||
assert.equal(await p.locator('[data-focus-workspace-status]').count(),0,path+' has no redundant strip');
|
||||
assert.doesNotMatch(await p.locator('main').first().innerText(),/Displaying current focus|Current narrative location:|Current Focus:/i,path);
|
||||
assert.equal(await p.locator('[data-writer-global-location]').count(),0);
|
||||
assert(await p.locator('[data-focus-label]').count());assert(await p.locator('[data-narrative-status][role=status]').count(),'header accessibility status retained');
|
||||
if(path==='/Chapters/Details/21')for(const width of [1666,950]){await p.setViewportSize({width,height:1050});await p.screenshot({path:`/tmp/pd-focus-text-${installed?'pwa':'browser'}-${width}.png`});}
|
||||
}
|
||||
console.log(`PASS ${installed?'installed Chromium PWA':'Chromium'} focus synchronisation: stable-ID chapter follow/dirty guard/Go, identical initial/header/recent/ribbon/Go/refresh accepted positions, canonical boundaries, stale anchor/response rejection, missing-map fallback, repeatable sticky/narrow offsets, disabled explanations and Focus/Help divider.`);
|
||||
}finally{await c.close();await b?.close();fs.rmSync(profile,{recursive:true,force:true});}
|
||||
})().catch(e=>{console.error(e.stack);process.exitCode=1;});
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
ViewData["Title"] = "Writer Home";
|
||||
ViewData["ProjectSection"] = "Writer";
|
||||
ViewData["ShellClass"] = "pd-writer writer3-shell";
|
||||
var focus = Model.NarrativeFocus?.Label;
|
||||
}
|
||||
<link rel="stylesheet" href="~/css/writer3.css" asp-append-version="true" />
|
||||
<div class="writer3 writer3-home" data-writer-destination="Home" data-writer-queues-url="@Url.Action("Workspaces",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writer-legacy-url="@Url.Action("Overview",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writer-write-url="@Url.Action("Write",new{projectId=Model.ProjectID,bookId=Model.BookID})" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID">
|
||||
@ -13,7 +12,7 @@
|
||||
<a class="writer3-choice" asp-action="Write" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">
|
||||
<svg class="writer3-choice-icon" viewBox="0 0 24 24" aria-hidden="true"><path d="@ApplicationRibbon.Icon("writer").IconPath" /></svg>
|
||||
<h2>Continue Writing</h2><p>Work on your chapters, scenes<br class="writer3-desktop-break" /> and manuscript.</p>
|
||||
<small>@(focus != null ? $"Current Focus: {focus}" : "Choose your narrative location in Current Focus.")</small>
|
||||
@if(Model.NarrativeFocus?.ChapterID == null){<small>Choose your narrative location in Current Focus.</small>}
|
||||
<span class="writer3-cta">Go to Write <span aria-hidden="true">→</span></span>
|
||||
</a>
|
||||
<a class="writer3-choice" asp-action="Explore" asp-route-projectId="@Model.ProjectID" asp-route-bookId="@Model.BookID">
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
<div class="writer3-workspace" aria-label="Writing workspace">
|
||||
<section class="writer3-panel writer3-main" tabindex="0" id="working-focus" aria-label="Saved Writer objective" data-writer-focus data-focus-url="@Url.Action("Focus","Writer",new{bookId=Model.BookID})" data-saved-activity="@focus?.Activity" data-saved-session-kind="@PlotLine.Services.Writer.WriterFocusActivities.SessionKind(focus?.Activity)" data-saved-chapter="@focus?.ChapterID" data-book-id="@Model.BookID" data-plan-url="@Url.Action("ScheduleSetup", "Writer", new { bookId = Model.BookID, projectId = Model.ProjectID })">
|
||||
<p class="eyebrow">Saved Writer objective</p>
|
||||
<p data-writer-global-location>Current narrative location: @(Model.NarrativeFocus?.Label ?? "Choose in Current Focus")</p>
|
||||
<p class="writer3-caption" data-objective-location data-chapter="@focus?.ChapterID" data-scene="@focus?.SceneID">Objective target: @(focus?.SceneTitle ?? focus?.ChapterTitle ?? "Across the book"). This target changes only when you edit the objective.</p>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-go-objective data-chapter="@focus?.ChapterID" data-scene="@focus?.SceneID" hidden="@(focus?.ChapterID==null)">Go to objective</button>
|
||||
<div data-focus-summary>
|
||||
|
||||
@ -58,7 +58,7 @@
|
||||
chapterPage.querySelectorAll('[aria-current=location]').forEach(n=>n.removeAttribute('aria-current'));
|
||||
const scene=focus.sceneID?chapterPage.querySelector(`[data-pd-context="scene"][data-pd-context-id="${focus.sceneID}"]`):null;
|
||||
if(focus.sceneID&&!scene){offer('The focused scene is not present in this chapter view.','Refresh chapter',()=>{const url=new URL(location.href);url.searchParams.set('retainNarrativeFocus','true');location.assign(url);});return;}
|
||||
offer('Displaying Current Focus: '+focus.label);
|
||||
document.querySelector('[data-focus-workspace-status]')?.remove();
|
||||
const target=scene||chapterPage.querySelector('h1');if(scene)scene.setAttribute('aria-current','location');target?.scrollIntoView({block:'center',behavior:'instant'});
|
||||
}
|
||||
registry.register({canGo:scope,unavailable:'Choose a chapter in this chapter page’s book',go:align});
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
}
|
||||
function publish(){document.querySelector('[data-focus-workspace-status]')?.remove();render();try{if(state.bookID)localStorage.setItem(scopeKey,String(state.bookID));}catch{}
|
||||
for(const card of document.querySelectorAll('.timeline-scene-card[data-scene-id]')){const current=Number(card.dataset.sceneId)===state.sceneID;card.classList.toggle('pd-current-narrative-focus',current);if(current)card.setAttribute('aria-current','location');else if(card.getAttribute('aria-current')==='location')card.removeAttribute('aria-current');}
|
||||
const locationLabel=document.querySelector('[data-writer-global-location]');if(locationLabel)locationLabel.textContent='Current narrative location: '+currentLabel();
|
||||
for(const link of document.querySelectorAll('[data-focus-reference-link]')){const url=new URL(link.href);url.searchParams.delete('chapterId');url.searchParams.delete('sceneId');if(state.chapterID)url.searchParams.set('chapterId',state.chapterID);if(state.sceneID)url.searchParams.set('sceneId',state.sceneID);link.href=url;}
|
||||
window.dispatchEvent(new CustomEvent('plotdirector:narrative-focus-changed',{detail:state}));}
|
||||
async function refresh(){if(!state.bookID)return;if(busy){refreshQueued=true;return;}refreshQueued=false;const mine=++epoch;try{const response=await fetch(`/NarrativeFocus/Read?projectId=${state.projectID}&bookId=${state.bookID}`,{cache:'no-store'});if(!response.ok||response.redirected)throw Error();const fresh=await response.json();if(mine!==epoch||busy)return;if(fresh.version!==state.version){state=fresh;publish();}else{state=fresh;render();}}catch{if(mine===epoch&&!busy)status.textContent='Current focus could not be refreshed. Your edits are retained.';}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user