Validate retained chapter links against current book structure
This commit is contained in:
parent
9e75970ceb
commit
ec34ac8013
@ -8,8 +8,9 @@ const shot=async n=>{if(!out)return;fs.mkdirSync(out,{recursive:true});await p.m
|
||||
for(const [label,book,project] of [['Populated',w.book,w.project],['Minimal',w.otherBook,w.project],['Structured',w.structuredBook,w.project],['No-book',null,w.emptyProject]])for(const d of ['Write','Explore','Plan','Review','Reflect']){const r=await p.goto(route(d,book,project));assert.equal(r.status(),200,label+d);if(!before&&book&&d==='Reflect')await p.locator('.writer-month-grid').waitFor();if(!before&&book&&d==='Explore')await p.locator('[data-investigation-opening] input[name=concern]').first().waitFor();assert(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+2),label+d+' overflow');await shot(label+'-'+d);}
|
||||
if(before){console.log('PASS baseline authenticated four-fixture captures');return;}
|
||||
await p.goto(route('Write'));const exportSessions=async()=>await(await p.request.get(base+`/Writer/Work/Export?bookId=${w.book}`)).json();const sessionsBefore=await exportSessions();const form=p.locator('[data-focus-wizard]');if(!await form.isVisible())await p.locator('[data-change-focus]').click();await form.locator('[name=Activity]').selectOption('Revising');await form.locator('[data-focus-next]').click();await form.locator('[name=ChapterID]').selectOption(String(w.chapter));await form.locator('[name=SceneID]').selectOption(String(w.scene));await form.locator('[data-focus-next]').click();await form.locator('[name=Intention]').fill('Clarify the turning point');await form.locator('[data-focus-back]').click();assert.equal(await form.locator('[name=ChapterID]').inputValue(),String(w.chapter));await form.locator('[data-focus-next]').click();assert.equal(await form.locator('[name=Intention]').inputValue(),'Clarify the turning point');let saves=0;p.on('request',r=>{if(r.method()==='POST'&&new URL(r.url()).pathname==='/Writer/SaveObjective')saves++;});await form.evaluate(n=>{n.requestSubmit();n.requestSubmit();});await p.locator('[data-focus-summary]').filter({hasText:'Clarify the turning point'}).waitFor();assert.equal(saves,1);assert.deepEqual(await exportSessions(),sessionsBefore,'focus must not create sessions');await shot('Write-established');await p.goto(route('Plan'));assert((await p.locator('.writer3-main').textContent()).includes('Clarify the turning point'));await p.goto(route('Write'));assert((await p.locator('[data-focus-summary]').textContent()).includes('Clarify the turning point'));await p.locator('[data-change-focus]').click();await form.locator('[data-focus-next]').click();await form.locator('[name=ChapterID]').selectOption('');await form.locator('[data-focus-next]').click();await form.locator('[data-save-focus]').click();await p.locator('[data-focus-summary]').filter({hasText:'Across the book'}).waitFor();assert.deepEqual(await exportSessions(),sessionsBefore);
|
||||
await p.goto(route('Plan',w.otherBook));await p.locator('[data-change-focus]').click();const next=p.locator('[data-focus-wizard]');await next.locator('[name=Activity]').selectOption('Researching');await next.locator('[data-focus-next]').click();await next.locator('[data-focus-next]').click();await next.locator('[name=Intention]').fill('Consider the next scene without a schedule');await next.locator('[data-save-focus]').click();await p.locator('[data-focus-summary]').filter({hasText:'Consider the next scene without a schedule'}).waitFor();assert(p.url().includes('/Writer/Plan'));
|
||||
await p.goto(route('Explore'));await p.locator('[data-discovery-tiles] [data-tile]:visible').first().waitFor();const tile=p.locator('[data-discovery-tiles] [data-tile]:visible').first(),id=await tile.getAttribute('data-tile');await tile.locator('[data-dismiss]').click();assert(await p.locator(`[data-tile="${id}"]`).isHidden());await p.reload();assert(await p.locator(`[data-tile="${id}"]`).isHidden());await p.locator('[data-reconsider]').click();assert(await p.locator(`[data-tile="${id}"]`).isVisible());await p.locator(`[data-tile="${id}"] [data-defer]`).click();assert(await p.locator(`[data-tile="${id}"]`).isHidden());await p.locator('[data-reconsider]').click();await p.locator('[data-investigation-opening] input[name=concern]').first().check();await p.locator('[data-investigation-opening] button[type=submit]').click();await p.waitForURL(/Investigate\?bookId=.*id=/);assert(await p.locator('[data-investigation-answer]').isVisible());await p.goto(route('Explore'));await p.locator('[data-my-investigations] article').first().waitFor();const completed=p.locator('[data-my-investigations] article').filter({hasText:'Original results'}).first();await completed.getByRole('button',{name:'Continue',exact:true}).click();await p.locator('.investigation form[data-guidance-navigation]').first().locator('button').click();await p.locator('[data-investigation-companion] #guidance-finding').waitFor();assert.equal(context.pages().length,1);await p.locator('[data-guidance-pin]').click();await p.goto(route('Explore'));await p.locator('[data-discovery-active] form').first().waitFor();await p.evaluate(()=>PlotLineHelpDrawer.open('writer3.explore'));await p.locator('.help-drawer-article').waitFor();await shot('Explore-both-panels');
|
||||
await p.goto(route('Review')+'&chapterId='+w.chapter);await p.locator('[data-review-intentions-slot] [data-review-intentions]').waitFor();assert(await p.locator('.reader-page').isVisible());const paragraph=p.locator('[data-paragraph-id][data-scene-id]').filter({hasText:'recorded first paragraph'}).first();await paragraph.click();await p.locator('[data-review-record]').click();await p.locator('[data-review-form] [name=Observation]').fill('The transition could show a clearer consequence.');await p.locator('[data-review-form] [name=Decision]').fill('Consider this transition when revising in Word.');await p.locator('[data-review-save]').click();await p.locator('[data-review-message]').filter({hasText:'Observation saved.'}).waitFor();await p.locator('[data-review-intentions-slot]').getByText('Disposable review scene',{exact:true}).waitFor();await shot('Review-context');await p.locator('#reader-focus').click();await p.locator('.reader-controls a[rel=next]').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await p.locator('#reader-focus').click();await p.goto(route('Review')+'&reading=true&chapterId='+w.chapter);assert.equal(await p.locator('.manuscript-reader').getAttribute('data-reading'),'true');await shot('Reading-mode');
|
||||
await p.goto(route('Review')+'&chapterId='+w.chapter);await p.locator('[data-review-intentions-slot] [data-review-intentions]').waitFor();assert(await p.locator('.reader-page').isVisible());const paragraph=p.locator('[data-paragraph-id][data-scene-id]').filter({hasText:'recorded first paragraph'}).first();await paragraph.click();await p.locator('[data-review-record]').click();await p.locator('[data-review-form] [name=Observation]').fill('The transition could show a clearer consequence.');await p.locator('[data-review-form] [name=Decision]').fill('Consider this transition when revising in Word.');await p.locator('[data-review-save]').click();await p.locator('[data-review-message]').filter({hasText:'Observation saved.'}).waitFor();await p.locator('[data-review-intentions-slot]').getByText('Disposable review scene',{exact:true}).waitFor();await shot('Review-context');await p.locator('#reader-focus').click();await p.locator('.reader-controls a[rel=next]').click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-focus'),'true');await p.locator('#reader-focus').click();await p.goto(route('Plan'));await p.locator('a[href*="/Writer/Review?"]').first().click();assert.equal(await p.locator('.manuscript-reader').getAttribute('data-chapter-id'),String(w.chapter2));await p.goto(route('Review')+'&reading=true&chapterId='+w.chapter);assert.equal(await p.locator('.manuscript-reader').getAttribute('data-reading'),'true');await shot('Reading-mode');
|
||||
// An explicit session is a separate action, never a side effect of choosing focus.
|
||||
await p.goto(route('Write'));const token=await p.locator('input[name=__RequestVerificationToken]').first().inputValue();const session=require('crypto').randomUUID();assert.equal((await p.request.post(base+'/Writer/Work/Start',{form:{bookId:w.book,kind:'Planning',requestId:session,__RequestVerificationToken:token}})).status(),200);assert.equal((await p.request.post(base+'/Writer/Work/End',{form:{bookId:w.book,sessionId:session,note:'Considered the next writing step',__RequestVerificationToken:token}})).status(),200);
|
||||
if(w.planId){await p.goto(`${base}/Writer/PlanActivities?writingPlanId=${w.planId}`);}else{await p.goto(`${base}/Writer/ScheduleSetup?projectId=${w.project}&bookId=${w.book}`);await p.locator('[name=PlanName]').fill('Disposable Phase 2 writing plan');const today=new Date(),end=new Date(Date.now()+28*86400000);await p.locator('[name=StartDate]').fill(today.toISOString().slice(0,10));await p.locator('[name=DeadlineDate]').fill(end.toISOString().slice(0,10));for(const box of await p.locator('input[type=checkbox][name$=".IsAvailable"]').all())await box.check();await p.getByRole('button',{name:'Review activities',exact:true}).click();await p.waitForURL(/PlanActivities|SchedulePreview/);}if(p.url().includes('PlanActivities')){await p.locator('input[type=checkbox][name=Confirm]').check();await p.getByRole('button',{name:'Commit reviewed schedule'}).click();await p.waitForURL(/SchedulePreview/);}const planId=new URL(p.url()).searchParams.get('writingPlanId');assert(planId);await p.goto(route('Plan'));assert((await p.locator('.writer3-main').textContent()).includes('Scheduled writing activities'));await p.goto(`${base}/Writer/EditWritingPlan?writingPlanId=${planId}`);assert(await p.locator('[name=PlanName]').isVisible());await p.goto(route('Reflect'));await p.locator('.writer-month-grid').waitFor();const month=await p.locator('.writer-section-heading h2').first().textContent();await p.getByRole('link',{name:'Previous month',exact:true}).click();assert(p.url().includes('/Writer/Reflect'));assert.notEqual(await p.locator('.writer-section-heading h2').first().textContent(),month);await p.locator('.writer-month-grid a').first().click();assert(p.url().includes('day='));await shot('Reflect-day');
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
}
|
||||
<link rel="stylesheet" href="~/css/writer-work.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/css/writer3.css" asp-append-version="true" />
|
||||
<div class="writer3 writer3-destination" data-writer-destination="@Model.Destination" data-layout-owner="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID">
|
||||
<div class="writer3 writer3-destination" data-writer-destination="@Model.Destination" data-review-chapters="@string.Join(",",Model.ObjectiveChoices.Select(x=>x.ChapterID).Distinct())" data-layout-owner="@User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value" data-writing-workspace-launcher data-compact-writer="true" data-project-id="@Model.ProjectID" data-book-id="@Model.BookID">
|
||||
<partial name="_Writer3Header" model="Model" />
|
||||
@if(!Model.BookID.HasValue && Model.Destination != "Explore"){
|
||||
<section class="writer3-panel writer3-empty"><h2>Begin with a book</h2><p>Select a project and book in the application bar. Your chapters, writing focus and recorded work will stay with that book.</p><a class="btn btn-primary writer3-cta" asp-controller="Projects" asp-action="Index">Open your projects <span aria-hidden="true">→</span></a></section>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
const workspace=document.querySelector('[data-writer-destination]');
|
||||
if(workspace?.dataset.bookId){const key=`plotdirector.writerReview.v1.${workspace.dataset.layoutOwner}.${workspace.dataset.bookId}`;let remembered=null;try{remembered=JSON.parse(localStorage.getItem(key));}catch{}
|
||||
const reader=workspace.querySelector('.manuscript-reader');if(reader){remembered={chapter:reader.dataset.chapterId,reading:reader.dataset.reading==='true'};try{localStorage.setItem(key,JSON.stringify(remembered));}catch{}}
|
||||
if(remembered?.chapter)for(const a of document.querySelectorAll('a[href]')){const url=new URL(a.href,location.href);if(url.origin===location.origin&&url.pathname.toLowerCase()==='/writer/review'&&url.searchParams.get('bookId')===workspace.dataset.bookId&&!url.searchParams.has('chapterId')){url.searchParams.set('chapterId',remembered.chapter);url.searchParams.set('reading',String(remembered.reading));a.href=url.href;}}
|
||||
if(remembered?.chapter&&workspace.dataset.reviewChapters.split(',').includes(String(remembered.chapter)))for(const a of document.querySelectorAll('a[href]')){const url=new URL(a.href,location.href);if(url.origin===location.origin&&url.pathname.toLowerCase()==='/writer/review'&&url.searchParams.get('bookId')===workspace.dataset.bookId&&!url.searchParams.has('chapterId')){url.searchParams.set('chapterId',remembered.chapter);url.searchParams.set('reading',String(remembered.reading));a.href=url.href;}}
|
||||
}
|
||||
|
||||
const opening=document.querySelector('[data-investigation-opening]');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user