diff --git a/PlotLine.Tests/Browser/scene-creation-acceptance.cjs b/PlotLine.Tests/Browser/scene-creation-acceptance.cjs index 97844d47..ef60e720 100644 --- a/PlotLine.Tests/Browser/scene-creation-acceptance.cjs +++ b/PlotLine.Tests/Browser/scene-creation-acceptance.cjs @@ -13,18 +13,66 @@ let stage = 'login'; const rows = () => page.locator('tr[data-pd-context="scene"]'); stage = 'cancel'; await session.goto(chapterUrl); - const before = await rows().count(); + let before = await rows().count(); await page.getByRole('link',{name:'Add scene',exact:true}).click(); await page.locator('#scene-create-form').waitFor(); stage = 'creation form context'; assert.equal(await page.locator('#ChapterID').inputValue(),String(chapter)); assert.equal(Number(await page.locator('#SceneNumber').inputValue()),1); + stage = 'responsive layout and ribbon'; + const fs = require('node:fs'); + const evidence = '/tmp/cyj-task58-layout'; + fs.mkdirSync(evidence,{recursive:true,mode:0o700}); + for (const standalone of [false,true]) for (const theme of ['light','dark']) for (const width of [1920,2560,390]) { + await page.setViewportSize({width,height:1080}); + await page.evaluate(({standalone,theme})=>{ + Object.defineProperty(navigator,'standalone',{configurable:true,value:standalone}); + window.dispatchEvent(new Event('pageshow')); + document.documentElement.dataset.theme=theme; + document.documentElement.dataset.bsTheme=theme; + },{standalone,theme}); + await page.waitForTimeout(150); + const details=await page.locator('.scene-create-details').boundingBox(); + const timing=await page.locator('.scene-create-timing').boundingBox(); + assert(details && timing); + assert(width>=900 ? Math.abs(details.y-timing.y)<2 : timing.y>details.y+details.height-2); + assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1),'No horizontal overflow'); + const visibleCreate=page.getByRole('button',{name:'Create scene',exact:true}); + if(standalone){ + // Expand the established ribbon if the ordinary writer preference collapsed it. + const collapse=page.locator('[data-ribbon-collapse]'); + if(await collapse.getAttribute('aria-expanded')==='false') await collapse.click(); + const tab=page.locator('[data-ribbon-tab][aria-selected=true]'); + if(await tab.count()) await tab.click(); + } + // Narrow ribbon groups can use the established command disclosure. + const disclosure=page.locator('.pd-context-menu[data-compact=true]').filter({has:page.getByRole('button',{name:'Create scene',exact:true})}); + if(standalone && await disclosure.count()) await disclosure.locator('summary').click(); + assert.equal(await visibleCreate.filter({visible:true}).count(),1); + await page.screenshot({path:`${evidence}/${standalone?'standalone-emulated':'browser'}-${theme}-${width}.png`,fullPage:true}); + } + await page.evaluate(()=>{Object.defineProperty(navigator,'standalone',{configurable:true,value:false});window.dispatchEvent(new Event('pageshow'));}); + await page.setViewportSize({width:1920,height:1080}); stage = 'cancel navigation'; + page.once('dialog', dialog => dialog.accept()); await page.locator('#SceneTitle').fill('Cancelled scene'); await page.getByRole('link',{name:'Cancel',exact:true}).click(); await page.reload(); stage = 'cancel mutation check'; assert.equal(await rows().count(),before); + stage = 'title only creation'; + await page.getByRole('link',{name:'Add scene',exact:true}).click(); + await page.evaluate(()=>{Object.defineProperty(navigator,'standalone',{configurable:true,value:true});window.dispatchEvent(new Event('pageshow'));}); + await page.locator('[data-ribbon-tab][aria-selected=true]').click(); + await page.locator('#SceneTitle').fill('Title only acceptance scene'); + await page.getByRole('button',{name:'Create scene',exact:true}).click(); + await page.waitForURL('**/Scenes/Edit/*'); + await page.reload(); + await page.locator('[data-scene-workspace]').waitFor(); + assert.match(await page.locator('main').innerText(),/Title only acceptance scene/); + await session.goto(chapterUrl); + before++; + assert.equal(await rows().count(),before); stage = 'validation'; await page.getByRole('link',{name:'Add scene',exact:true}).click(); await page.locator('#scene-create-form').waitFor(); @@ -32,10 +80,27 @@ let stage = 'login'; assert.equal(await page.locator('#scene-create-form').count(),1); // Bypass only client validation to exercise the server's invalid-model path. await page.locator('#Summary').fill('Preserved after invalid submission'); + page.once('dialog', dialog => dialog.accept()); await page.locator('#scene-create-form').evaluate(form=>HTMLFormElement.prototype.submit.call(form)); await page.waitForURL('**/Scenes/Save'); assert.equal(await page.locator('#Summary').inputValue(),'Preserved after invalid submission'); assert.match(await page.locator('[data-valmsg-for="SceneTitle"]').innerText(),/required/i); + stage = 'optional fields'; + const purpose=page.locator('input[name=SelectedPurposeTypeIds]').first(); + await purpose.check(); + const purposeId=await purpose.inputValue(); + await page.locator('#ScenePurposeNotes').fill('Acceptance purpose notes'); + await page.locator('#SceneOutcomeNotes').fill('Acceptance outcome notes'); + await page.locator('#RelativeTimeText').fill('The next morning'); + await page.locator('#DurationAmount').fill('2'); + const unit=await page.locator('#DurationUnitID option').evaluateAll(options=>options.find(o=>o.value)?.value); + await page.locator('#DurationUnitID').selectOption(unit); + await page.locator('#TimeModeID').selectOption({label:'Relative'}); + assert(await page.locator('#StartDateTime').isHidden()); + await page.getByRole('button',{name:'Show date/time fields',exact:true}).click(); + await page.locator('#StartDateTime').fill('2026-11-01T09:00'); + await page.locator('#TimeModeID').selectOption({label:'Unknown'}); + assert.equal(await page.locator('#StartDateTime').inputValue(),'2026-11-01T09:00'); stage = 'create'; await page.locator('#SceneTitle').fill('Persisted acceptance scene'); await page.getByRole('button',{name:'Create scene',exact:true}).click(); @@ -51,7 +116,7 @@ let stage = 'login'; await session.goto(chapterUrl); assert.equal(await rows().count(),before+1); const row = page.locator('tr').filter({hasText:'Persisted acceptance scene'}); - assert.equal(Number(await row.locator('td').first().innerText()),1); + assert.equal(Number(await row.locator('td').first().innerText()),2); stage = 'existing edit'; await row.getByRole('link',{name:'Persisted acceptance scene',exact:true}).click(); await page.waitForURL('**/Scenes/Edit/*'); @@ -66,7 +131,7 @@ let stage = 'login'; assert.match(await page.locator('main').innerText(),/Edited acceptance scene/); stage = 'sequence'; await session.goto('/Scenes/Create?chapterId='+chapter); - assert.equal(Number(await page.locator('#SceneNumber').inputValue()),2); + assert.equal(Number(await page.locator('#SceneNumber').inputValue()),3); await page.getByRole('link',{name:'Cancel',exact:true}).click(); await session.close(); session = await open(); @@ -79,13 +144,17 @@ let stage = 'login'; assert.match(await session.page.locator('main').innerText(),/Edited acceptance scene/); await session.page.getByRole('button',{name:'Edit scene details',exact:true}).click(); assert.equal(await session.page.locator('form[data-scene-editor-form] [name=Summary]').inputValue(),'Preserved after invalid submission'); - console.log(JSON.stringify({status:'passed',checks:['cancel without mutation','required title client and server validation','field preservation','chapter context and sequence','creation workspace redirect','existing workspace editing','reload and fresh login persistence'],featureUrl:'https://dev.plotdirector.com'+sceneUrl,chapterUrl:'https://dev.plotdirector.com'+chapterUrl})); + const persisted=session.page.locator('form[data-scene-editor-form]'); + assert.equal(await persisted.locator('[name=RelativeTimeText]').inputValue(),'The next morning'); + assert.equal(await persisted.locator('[name=ScenePurposeNotes]').inputValue(),'Acceptance purpose notes'); + assert.equal(await persisted.locator('[name=SelectedPurposeTypeIds][value="'+purposeId+'"]').isChecked(),true); + console.log(JSON.stringify({layoutEvidence:evidence,standalone:'navigator.standalone emulation; no OS-installed PWA launch',status:'passed',checks:['cancel without mutation','required title client and server validation','field preservation','chapter context and sequence','creation workspace redirect','existing workspace editing','reload and fresh login persistence'],featureUrl:'https://dev.plotdirector.com'+sceneUrl,chapterUrl:'https://dev.plotdirector.com'+chapterUrl})); } catch(error) { if(session && stage !== 'login') { console.log(JSON.stringify({stage,errorType:error.name,path:new URL(session.page.url()).pathname,cancelLinks:await session.page.getByRole('link',{name:'Cancel',exact:true}).count()})); } throw error; } finally { - if(session) {try {await session.cleanup();console.log('PASS disposable project cleanup');} finally {await session.close();}} + if(session) {session.page.on('dialog', dialog=>dialog.accept());try {await session.cleanup();console.log('PASS disposable project cleanup');} finally {await session.close();}} } })().catch(()=>{console.error('Scene creation acceptance failed at stage: '+stage+'; no credentials logged.');process.exitCode=1;}); diff --git a/PlotLine/Help/Articles/Scenes/Edit.md b/PlotLine/Help/Articles/Scenes/Edit.md index de22eba2..818742db 100644 --- a/PlotLine/Help/Articles/Scenes/Edit.md +++ b/PlotLine/Help/Articles/Scenes/Edit.md @@ -24,6 +24,10 @@ Use this page when creating a new story beat, adjusting an existing scene, or ch From Chapter Details, choose **Add scene** to open the New Scene form for that chapter. Enter a scene title and review the suggested scene number and revision status. **Create scene** saves it and opens the persisted Scene Workspace. **Cancel** returns to Chapter Details without creating a scene. Validation messages keep your entered values in the form so you can correct them. +Scene details and Timing sit side by side on desktop and stack in a narrow window. Purpose chips support multiple selections; purpose and outcome notes are optional. Relative, Unknown and Timeless modes tuck away empty date fields: choose **Show date/time fields** to add dates. Switching modes keeps entered values. The Word connection and manuscript section starts collapsed. + +In the installed app, **Create scene** and **Cancel** appear in the contextual ribbon. Expand the ribbon or its Scene command group when collapsed. In a browser tab, use the page buttons. Leaving a changed form prompts you before discarding your work. + Start with the scene title, summary and revision status. Add time, location and point-of-view details when they matter. Record enough continuity information that later scenes can rely on it. # Example diff --git a/PlotLine/Views/Scenes/Create.cshtml b/PlotLine/Views/Scenes/Create.cshtml index 55d8c1db..dd46149f 100644 --- a/PlotLine/Views/Scenes/Create.cshtml +++ b/PlotLine/Views/Scenes/Create.cshtml @@ -5,7 +5,9 @@ ViewData["ShellClass"] = "plotline-shell-wide"; } -