Exclude read-only focus validation from Calendar navigation assertions
This commit is contained in:
parent
64cee1374c
commit
6b02f7fb9a
@ -9,7 +9,7 @@ let session,stage='login';
|
||||
stage='saved chronology';const first=await scene(chapter,'First dated scene','1983-11-19'),second=await scene(chapter,'Second dated scene','1983-11-19'),other=await scene(otherChapter,'Other book collision','1983-11-19'),undated=await scene(chapter,'Undated with chapter fallback'),empty=await scene(undatedChapter,'Undated without fallback');
|
||||
const feature=`/Writing/Context?projectId=${project}&bookId=${book}&chapterId=${chapter}&sceneId=${first}&pinned=true`,ctx=await p.context().newPage();await ctx.setViewportSize({width:1280,height:800});await ctx.goto('https://dev.plotdirector.com'+feature);await ctx.selectOption('[data-context-pane="0"] [data-context-tab]','calendar');const pane=ctx.locator('[data-context-pane="0"]'),day=d=>pane.locator(`[data-calendar-date="${d}"]`);
|
||||
stage='follow, deduplication and collision';await day('1983-11-19').waitFor();assert.equal(await day('1983-11-19').getAttribute('aria-current'),'date');assert.equal(await day('1983-11-19').locator('.context-calendar-chapter').textContent(),'Ch 1');assert.equal(await day('1983-11-19').locator('small').count(),0);await pane.locator('[data-calendar-books]').selectOption('all');assert.equal(await day('1983-11-19').locator('small').textContent(),' +1');await pane.locator('[data-calendar-details]>details').first().locator('summary').first().click();await pane.getByText('Scene 1 · First dated scene',{exact:true}).click();assert.equal(await pane.getByRole('link',{name:'Open scene in main window'}).count(),1);
|
||||
await ctx.waitForFunction(()=>document.querySelector('[data-context-workspace]').contextController.connection?.state==='Connected');const posts=[];ctx.on('request',r=>{if(r.method()==='POST'&&/NarrativeFocus|NativeCompanion.*Navigate/.test(r.url()))posts.push(new URL(r.url()).pathname);});const focus=await ctx.evaluate(()=>({...document.querySelector('[data-context-workspace]').contextController.position}));const shared=()=>ctx.evaluate(async({project,book})=>(await(await fetch(`/NarrativeFocus/Shared?projectID=${project}&bookID=${book}`)).json()),{project,book});const before=await shared();
|
||||
await ctx.waitForFunction(()=>document.querySelector('[data-context-workspace]').contextController.connection?.state==='Connected');const posts=[];ctx.on('request',r=>{if(r.method()==='POST'&&/NarrativeFocus|NativeCompanion.*Navigate/.test(r.url())&&!r.url().endsWith('/NarrativeFocus/Shared/Validate'))posts.push(new URL(r.url()).pathname);});const focus=await ctx.evaluate(()=>({...document.querySelector('[data-context-workspace]').contextController.position}));const shared=()=>ctx.evaluate(async({project,book})=>(await(await fetch(`/NarrativeFocus/Shared?projectID=${project}&bookID=${book}`)).json()),{project,book});const before=await shared();
|
||||
stage='browse empty dates and six-row viewport';await day('1983-11-20').click();await pane.locator('[data-calendar-month]').fill('2020-08');await pane.locator('[data-calendar-month]').dispatchEvent('change');assert.equal(await pane.locator('[data-calendar-grid] button').count(),42);const geometry=await pane.locator('[data-calendar-grid]').evaluate(n=>({bottom:n.getBoundingClientRect().bottom,scroll:n.scrollHeight,height:n.clientHeight,viewport:innerHeight}));assert(geometry.bottom<=geometry.viewport);assert(geometry.scroll<=geometry.height+1);await day('2020-08-15').click();assert.match(await pane.locator('[data-calendar-details]').textContent(),/No dated/);await pane.locator('[data-calendar-from]').fill('2020-08-01');await pane.locator('[data-calendar-from]').dispatchEvent('change');assert.equal(await pane.locator('[data-calendar-elapsed]').textContent(),'14 days to selected date');
|
||||
stage='real saved date refresh while held';await session.goto('/Scenes/SceneDetailsEditor?sceneId='+first);const exact=await p.locator('[name=TimeModeID] option').evaluateAll(ns=>ns.find(n=>/exact/i.test(n.textContent))?.value);await p.locator('[name=TimeModeID]').selectOption(exact);await p.locator('[name=StartDateTime]').fill('1984-02-29T10:00');await Promise.all([p.waitForResponse(r=>r.url().includes('/Scenes/SaveSceneDetails')&&r.status()===200),p.getByRole('button',{name:'Save details',exact:true}).click()]);await ctx.waitForFunction(()=>document.querySelector('[data-calendar-status]').textContent.includes('29 February 1984'));assert.equal(await pane.locator('[data-calendar-month]').inputValue(),'2020-08');assert.equal(await day('2020-08-15').getAttribute('aria-pressed'),'true');assert.deepEqual(await ctx.evaluate(()=>({...document.querySelector('[data-context-workspace]').contextController.position})),focus);assert.deepEqual(posts,[]);const after=await shared();assert.equal(after.version,before.version);assert.equal(after.sceneID,before.sceneID);
|
||||
stage='sibling-book date save refresh';await session.goto('/Scenes/SceneDetailsEditor?sceneId='+other);const otherExact=await p.locator('[name=TimeModeID] option').evaluateAll(ns=>ns.find(n=>/exact/i.test(n.textContent))?.value);await p.locator('[name=TimeModeID]').selectOption(otherExact);await p.locator('[name=StartDateTime]').fill('1984-03-01T10:00');await Promise.all([ctx.waitForResponse(r=>r.url().includes('/Calendar/State')&&r.status()===200),p.getByRole('button',{name:'Save details',exact:true}).click()]);await pane.locator('[data-calendar-month]').fill('1984-03');await pane.locator('[data-calendar-month]').dispatchEvent('change');assert.match(await day('1984-03-01').textContent(),/Book 2/);assert.equal((await shared()).version,before.version);assert.deepEqual(posts,[]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user