28 lines
6.1 KiB
JavaScript
28 lines
6.1 KiB
JavaScript
// Real Development forms and persistent fixtures; no mocked reads or writes.
|
|
const assert=require('node:assert/strict'),{open}=require('./dev-acceptance.cjs');
|
|
let session,stage='login';
|
|
(async()=>{try{
|
|
session=await open();let p=session.page;const project=await session.project();
|
|
const room=await session.create('Locations','?projectId='+project,{LocationName:'Observation room'});
|
|
const yard=await session.create('Locations','?projectId='+project,{LocationName:'Courtyard'});
|
|
const book=await session.create('Books','?projectId='+project,{BookTitle:'Directional acceptance',BookNumber:1});
|
|
const chapter=await session.create('Chapters','?bookId='+book,{ChapterTitle:'Test chapter',ChapterNumber:1});
|
|
await session.goto('/Scenes/Create?chapterId='+chapter);await p.locator('#SceneTitle').fill('Sight and sound');await p.locator('#PrimaryLocationID').selectOption(String(room));await p.getByRole('button',{name:'Create scene',exact:true}).click();await p.waitForURL('**/Scenes/Edit/*');const scene=Number(new URL(p.url()).pathname.split('/').at(-1));
|
|
stage='directional relationship form';await session.goto('/Locations/Details/'+room);const form=p.locator('form[action="/Locations/AddRelationship"]');await form.getByRole('button',{name:'Choose related location',exact:true}).click();await p.locator('dialog').getByRole('button',{name:'Courtyard',exact:true}).click();await p.locator('dialog').getByRole('button',{name:'Choose location',exact:true}).click();await form.locator('[name=CanSeeMovement]').check();await form.locator('[name=CanHearLoudNoise]').check();await form.locator('[name=IsBidirectional]').check();await form.locator('[name=Notes]').fill('Directional saved evidence');await form.locator('button[type=submit]').click();await p.waitForURL('**/Locations/Details/'+room);
|
|
stage='recorded character form';const character=await session.create('Characters','?projectId='+project,{CharacterName:'Recorded observer'},async page=>{const custom=page.locator('[name=CustomSex]');if(await custom.count()&&await custom.isEnabled())await custom.fill('Unspecified');});
|
|
await session.goto('/Scenes/SceneCharactersEditor?sceneId='+scene);await session.post('/Scenes/SaveSceneCharacters',{SceneID:scene,'NewCharacter.CharacterID':character,'NewCharacter.LocationID':room});
|
|
const feature=`/Writing/Context?projectId=${project}&bookId=${book}&chapterId=${chapter}&sceneId=${scene}&pinned=true`;
|
|
async function inspect(){await session.goto(feature);await p.selectOption('[data-context-pane="0"] [data-context-tab]','locations');await p.locator('[data-spatial-details] h2').filter({hasText:'Observation room'}).waitFor();}
|
|
async function verify(){const host=p.locator('[data-spatial-details]');await host.getByRole('heading',{name:'Can see',exact:true}).waitFor();assert.match(await host.textContent(),/Recorded observer/);assert.match(await host.textContent(),/movement: enabled/);assert.match(await host.textContent(),/clear sight: unset \/ not enabled/);assert.match(await host.textContent(),/loud noise: enabled/);assert.match(await host.textContent(),/normal speech: unset \/ not enabled/);assert.equal(await host.getByText('Unknown / unset: no relationship recorded in this direction.',{exact:true}).count(),2);assert.equal(await host.getByRole('link',{name:'Courtyard',exact:true}).count(),2);}
|
|
stage='live Context direction';await inspect();await verify();
|
|
stage='main-window navigation';const main=await p.context().newPage();await main.goto('https://dev.plotdirector.com/Locations/Details/'+room);await main.waitForFunction(()=>window.PlotDirectorPresenceConnection?.state==='Connected');const held=p.url();await p.getByRole('link',{name:'Courtyard',exact:true}).first().click();await main.waitForURL('**/Locations/Details/'+yard);assert.equal(p.url(),held);await main.close();
|
|
stage='split and narrow layout';await p.selectOption('[data-context-layout]','columns');await p.selectOption('[data-context-pane="1"] [data-context-tab]','locations');await p.locator('[data-context-pane="1"] [data-spatial-details]').getByRole('heading',{name:'Can see',exact:true}).waitFor();await p.setViewportSize({width:460,height:850});assert.equal(await p.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1),true);await p.setViewportSize({width:1280,height:900});await p.selectOption('[data-context-layout]','single');
|
|
stage='fresh login persistence';await session.close();session=await open();p=session.page;await inspect();await verify();
|
|
stage='incoming direction without reciprocity';const state=await p.evaluate(async url=>{const response=await fetch(url,{cache:'no-store'});if(!response.ok)throw Error('State unavailable');return response.json();},`/SpatialContext/State?bookId=${book}&sceneId=${scene}&locationId=${yard}`);assert.equal(state.sensoryRelationships.length,1);assert.equal(state.sensoryRelationships[0].fromLocationID,room);assert.equal(state.sensoryRelationships[0].toLocationID,yard);
|
|
// Inspect the destination through the existing window-local spatial bus.
|
|
await p.evaluate(id=>{const root=document.querySelector('[data-context-workspace]');window.PlotDirectorSpatialContext.inspect(root,id,'acceptance');},yard);await p.locator('[data-spatial-details] h2').filter({hasText:'Courtyard'}).waitFor();const host=p.locator('[data-spatial-details]');assert.equal(await host.getByRole('link',{name:'Observation room',exact:true}).count(),2);assert.equal(await host.getByText('Unknown / unset: no relationship recorded in this direction.',{exact:true}).count(),2);
|
|
console.log(JSON.stringify({passed:true,project,book,scene,checks:['normal relationship and character saves','four directional groups','unset flags','no reciprocal inference despite both-ways flag','recorded presence','existing main-window navigation','split layout','narrow viewport','fresh-login persistence','incoming inspection'],featureUrl:'https://dev.plotdirector.com'+feature}));
|
|
}catch{console.error('Locations acceptance failed at '+stage+'; no credentials logged.');process.exitCode=1;}
|
|
finally{if(session){try{await session.cleanup();console.log('PASS disposable project cleanup');}catch{console.error('Cleanup incomplete; preserve journal.');process.exitCode=1;}finally{await session.close();}}}
|
|
})();
|