diff --git a/PlotLine.Tests/Browser/writer3-focus.cjs b/PlotLine.Tests/Browser/writer3-focus.cjs index 3c8ed48b..ec3891e1 100644 --- a/PlotLine.Tests/Browser/writer3-focus.cjs +++ b/PlotLine.Tests/Browser/writer3-focus.cjs @@ -5,14 +5,14 @@ let session=null,starts=[],saves=[],blockStart=null;await c.route('**/Writer/Wor await c.route('**/Writer/SaveObjective',async r=>{saves.push(Object.fromEntries(new URLSearchParams(r.request().postData())));assert(saves.at(-1).__RequestVerificationToken);await r.fulfill({status:200,contentType:'text/html',body:'
Working focus saved by fixture
'});}); const p=await c.newPage(),errors=[];p.on('pageerror',e=>errors.push(e.message));const url='http://127.0.0.1:5238/Writer/Write?projectId=7&bookId=12'; await p.goto(url);await p.locator('[data-record-focus]:enabled').waitFor();for(const theme of ['modern-dark','modern-light','warm-dark','plotdirector']){await p.evaluate(t=>window.PlotDirectorApplyApplicationTheme(t),theme);await p.locator('[data-save-focus]').screenshot({animations:'disabled'});const contrast=await p.locator('[data-save-focus]').evaluate(n=>{const lum=s=>s.match(/[\d.]+/g).slice(0,3).map(Number).map(x=>{x/=255;return x<=.04045?x/12.92:((x+.055)/1.055)**2.4}).reduce((v,x,i)=>v+x*[.2126,.7152,.0722][i],0),c=getComputedStyle(n),a=lum(c.color),b=lum(c.backgroundColor);return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)});assert(contrast>=4.5,'Save focus label contrast '+theme);} -assert.equal(await p.locator('select[name=ChapterID]').count(),1);assert.equal(await p.locator('[data-work-start] select').count(),0,'one chapter/activity selection');assert.equal(await p.locator('[data-focus-activity]').count(),1); +assert.equal(await p.locator('select[name=ChapterID]').count(),1);assert.equal(await p.locator('[data-work-start] select').count(),2,'recording choices are separate from working focus');assert.equal(await p.locator('[data-focus-activity]').count(),1); await p.locator('[data-objective-chapter]').selectOption('21');await p.locator('[data-objective-scene]').selectOption('31');await p.locator('[data-objective-chapter]').selectOption('22');assert.equal(await p.locator('[data-objective-scene]').inputValue(),'');assert(await p.locator('[data-objective-scene] option[value="31"]').evaluate(n=>n.disabled));await p.locator('[data-objective-scene]').selectOption('32'); await Promise.all([p.waitForURL('**/Writer/SaveObjective'),p.locator('[data-focus-form]').evaluate(n=>{n.requestSubmit();n.requestSubmit();})]);assert.equal(saves.length,1,'repeated submit saves only once');assert.equal(saves[0].ChapterID,'22');assert.equal(saves[0].SceneID,'32');assert.equal(starts.length,0,'saving never starts recording'); await p.goto(url+'&objective=true');assert.equal(await p.locator('[data-focus-form]').count(),0,'saved focus is read-only by default');assert(await p.getByRole('link',{name:'Change working focus'}).isVisible());await p.locator('[data-record-focus]:enabled').waitFor();let release;blockStart=new Promise(r=>release=r);await p.locator('[data-record-focus]').click();await p.locator('[data-record-focus]').dispatchEvent('click');release();blockStart=null;await p.locator('[data-work-current]:visible').waitFor();assert.equal(starts.length,1);assert.equal(starts[0].chapterId,'21');assert.equal(starts[0].kind,'Editing');assert.equal(saves.length,1,'recording never saves objective');assert(await p.locator('[data-record-focus]').isHidden()); const activeId=session.sessionID;await p.goto(url+'&objective=true&setup=true');await p.locator('[data-work-current]:visible').waitFor();await p.locator('[data-objective-chapter]').selectOption('22');assert.equal(session.sessionID,activeId);assert.equal(session.chapterID,21);assert(await p.locator('[data-record-focus]').isHidden()); session={...session,chapterID:22,chapterTitle:'The harbour',kind:'Writing'};await p.reload();await p.locator('[data-focus-session-difference]:visible').waitFor();assert((await p.locator('[data-focus-session-difference]').textContent()).includes('differs'));assert((await p.locator('[data-work-bound]').textContent()).includes('The harbour')); session=null;await p.goto(url+'&setup=true');await p.locator('[data-record-focus]:enabled').waitFor();await p.locator('[data-focus-activity]').selectOption('Proofreading');await p.locator('[data-record-focus]').click();assert.equal(starts.length,1);assert(await p.locator('[data-record-kind-choice]').isVisible());await p.locator('[data-record-kind]').selectOption('Reading');await p.locator('[data-record-focus]').click();await p.locator('[data-work-current]:visible').waitFor();assert.equal(starts.at(-1).kind,'Reading'); -session=null;await p.goto(url+'&setup=true');await p.locator('[data-record-focus]:enabled').waitFor();await p.locator('[data-focus-activity]').selectOption('AudioReview');assert(await p.locator('[data-save-focus]').isDisabled());await p.locator('[data-record-focus]').click();assert.equal(starts.length,2,'Audio Review requires chapter');await p.locator('[data-objective-chapter]').selectOption('21');await p.locator('[data-record-focus]').click();await p.locator('[data-work-audio]:visible').waitFor();assert.equal(starts.at(-1).kind,'AudioReview'); +session=null;await p.goto(url+'&setup=true');await p.locator('[data-record-focus]:enabled').waitFor();assert.equal(await p.locator('[data-focus-activity] option[value=AudioReview]').count(),0);assert(await p.locator('[data-save-focus]').isEnabled());const recording=p.locator('[data-work-start]');await recording.locator('[name=kind]').selectOption('AudioReview');await recording.locator('[name=chapterId]').selectOption('');await recording.locator('button[type=submit]').click();assert.equal(starts.length,2,'Audio Review requires chapter');await recording.locator('[name=chapterId]').selectOption('21');await recording.locator('button[type=submit]').click();await p.locator('[data-work-audio]:visible').waitFor();assert.equal(starts.at(-1).kind,'AudioReview'); session=null;await p.goto(url+'&setup=true');await p.locator('[data-focus-activity]').selectOption('Editing');await p.locator('[data-plan-focus]').click();await p.waitForURL('**/Writer/ScheduleSetup?*');assert.equal(new URL(p.url()).searchParams.get('bookId'),'12');assert.equal(new URL(p.url()).searchParams.get('focusActivity'),'Editing');assert.equal(saves.length,1);assert.equal(starts.length,3); await p.goto(url+'&setup=true');await p.locator('#appBookMenu').click();await p.locator('[data-app-book-choice="13"]').click();await p.waitForURL('**bookId=13*');assert.equal(await p.locator('[data-objective-chapter] option[value="21"]').count(),0);assert.equal(await p.locator('[data-objective-scene]').inputValue(),'');assert.deepEqual(errors,[]);await c.close();} console.log('PASS unified current work: one selector set, save-only, explicit recording/idempotent repeat, saved display/change, active/mismatched targets, explicit proofreading choice, AudioReview chapter rule, dependent scenes, optional scoped scheduling and book-switch clearing in browser/simulated PWA.');}finally{await b.close()}})().catch(e=>{console.error(e.stack);process.exitCode=1}); diff --git a/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml b/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml index 2d556823..ce4d8781 100644 --- a/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml +++ b/PlotLine/Views/Shared/_WriterWorkToolbar.cshtml @@ -1,15 +1,13 @@ @model PlotLine.Models.WriterWorkToolbar