From cf56a36a94fbf9945986b351036ad6487afcc677 Mon Sep 17 00:00:00 2001 From: Atlas Development Worker Date: Tue, 1 Dec 2026 12:45:05 +0000 Subject: [PATCH] Stabilize real Maps acceptance fixture creation --- PlotLine.Tests/Browser/context-maps-development.cjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PlotLine.Tests/Browser/context-maps-development.cjs b/PlotLine.Tests/Browser/context-maps-development.cjs index 52d02c46..6a408c5d 100644 --- a/PlotLine.Tests/Browser/context-maps-development.cjs +++ b/PlotLine.Tests/Browser/context-maps-development.cjs @@ -10,9 +10,9 @@ let session,stage='login'; const character=await session.create('Characters','?projectId='+project,{CharacterName:'Recorded traveller'},async page=>{const custom=page.locator('[name=CustomSex]');if(await custom.count()&&await custom.isEnabled())await custom.fill('Unspecified');}); const unknown=await session.create('Characters','?projectId='+project,{CharacterName:'Unlocated traveller'},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='+first);await session.post('/Scenes/SaveSceneCharacters',{SceneID:first,'NewCharacter.CharacterID':character,'NewCharacter.LocationID':b});await session.post('/Scenes/SaveSceneCharacters',{SceneID:first,'NewCharacter.CharacterID':unknown}); - async function map(name,extra){await session.goto('/Maps?projectId='+project);await p.locator('#mapsWelcomeNew').click();await p.locator('#mapsNewForm [name=Name]').fill(name);await p.locator('#mapsNewForm [name=Starter]').selectOption('land');await p.locator('#mapsNewForm button[type=submit]').click();await p.waitForFunction(()=>window.PlotDirectorMapWorkspace?.document.features.length>1&&!PlotDirectorMapWorkspace.busy);const id=await p.evaluate(()=>PlotDirectorMapWorkspace.document.map.mapID); + async function map(name,extra){stage='create '+name;await session.goto('/Maps?projectId='+project);stage='open map dialog '+name;await p.locator('#mapsWelcomeNew').click();await p.locator('#mapsNewForm [name=Name]').fill(name);await p.locator('#mapsNewForm [name=Starter]').selectOption('islands');stage='submit map '+name;await p.locator('#mapsNewForm button[type=submit]').click();stage='load map '+name;await p.waitForFunction(()=>window.PlotDirectorMapWorkspace?.document?.features.length>1&&!PlotDirectorMapWorkspace.busy);const id=await p.evaluate(()=>PlotDirectorMapWorkspace.document.map.mapID); const ids=await p.evaluate(()=>PlotDirectorMapWorkspace.document.features.slice(0,2).map(f=>f.featureID)); - for(const [feature,place] of [[ids[0],a],...(extra?[[ids[1],b]]:[])]){await p.locator(`[data-feature-id="${feature}"]`).click();const select=p.locator('[data-field=locationID]');await select.evaluate(e=>{for(let n=e.parentElement;n;n=n.parentElement)if(n.tagName==='DETAILS')n.open=true;});await select.selectOption(String(place));} + stage='link '+name;for(const [feature,place] of [[ids[0],a],...(extra?[[ids[1],b]]:[])]){await p.locator(`[data-feature-id="${feature}"]`).click();const select=p.locator('[data-field=locationID]');await select.evaluate(e=>{for(let n=e.parentElement;n;n=n.parentElement)if(n.tagName==='DETAILS')n.open=true;});await select.selectOption(String(place));} await p.locator('#mapsSave').click();await p.waitForFunction(()=>!PlotDirectorMapWorkspace.dirty&&!PlotDirectorMapWorkspace.busy);return {id,feature:ids[0]};} stage='map forms';const one=await map('Local chart',false),two=await map('Regional chart',true); const feature=`/Writing/Context?projectId=${project}&bookId=${book}&chapterId=${chapter}&sceneId=${first}&pinned=true`; @@ -30,6 +30,6 @@ let session,stage='login'; stage='split and narrow';await ctx.selectOption('[data-context-layout]','columns');await ctx.selectOption('[data-context-pane="1"] [data-context-tab]','maps');await ctx.locator('[data-context-pane="1"] iframe').waitFor();await ctx.setViewportSize({width:460,height:850});assert.equal(await ctx.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1),true); await session.close();session=await open();p=session.page;stage='fresh login persistence';await session.goto(`/Maps?projectId=${project}&id=${two.id}`);await p.waitForFunction(v=>window.PlotDirectorMapWorkspace?.document.features[0].width===v,value);await session.goto(feature);await p.selectOption('[data-context-pane="0"] [data-context-tab]','maps');await p.locator('[data-spatial-characters]').getByText(/Recorded traveller/).waitFor(); console.log(JSON.stringify({passed:true,checks:['two linked maps selected locally','recorded character whereabouts only','lower geography emphasis','read-only Context','local zoom and inspection preserve focus','Hold saved map refresh preserves viewport','scene changes select relevant map','split narrow layout','fresh-login persistence'],featureUrl:'https://dev.plotdirector.com'+feature})); - }catch{console.error('Maps acceptance failed at '+stage+'; no credentials logged.');process.exitCode=1;} + }catch(error){console.error('Maps acceptance failed at '+stage+' ('+error.name+'); no credentials logged.');if(/^(create|open map|submit map|load map|link )/.test(stage))console.error(error.message.split('\n')[0]);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();}}} })();