diff --git a/PlotLine.Tests/Browser/README.md b/PlotLine.Tests/Browser/README.md index 4ae8f4b4..47697da5 100644 --- a/PlotLine.Tests/Browser/README.md +++ b/PlotLine.Tests/Browser/README.md @@ -70,3 +70,6 @@ For Dev verification, provision a private identity using the existing `--dev-bro Run the isolated fixture host with `dotnet run --project PlotLine.Tests/PlotLine.Tests.csproj -- --toolbar-browser-host`, then `npm run test:record-workspaces`. The suite renders nine real Razor forms and checks Browser preservation, Desktop composition, responsive widths, ribbon Save/icons, existing unobtrusive validation, multipart/antiforgery submission, themes and parser-paused first paint. For Dev-only verification, provision an identity with `--dev-browser-identity create /tmp/pd-dev-browser-.json`, then run `xvfb-run -a node record-workspaces-dev.cjs /tmp/pd-dev-browser-.json`. It creates isolated records via their normal forms, installs/launches a real Chromium app, verifies eight record types plus details/settings/management, saves and reloads a changed book, checks keyboard/context behaviour, and measures initial geometry. Always finish with `--dev-browser-identity cleanup` to remove the account and all owned fixture data. Production is never a test target. + + +Responsive Chapters, Timeline and Plot Lines: start the isolated Razor host from the repository root with `dotnet run --project PlotLine.Tests -- --toolbar-browser-host`, then run `npm run test:responsive-content` in this directory. Repeat with `PD_RESPONSIVE_STANDALONE=1` for simulated standalone shell mode. The test checks 360, 390, 412, 800 and 1440 CSS pixels in modern dark, warm dark and modern light themes, with short/long chapter titles, long rail/book names, visible actions, sticky rails, internal scrolling, zoom connector coordinates and page overflow. Screenshots at 390 and 1440px are written to `/tmp/responsive-*.png`. These fixtures render compiled application views without a database; standalone simulation does not replace device testing. diff --git a/PlotLine.Tests/Browser/package.json b/PlotLine.Tests/Browser/package.json index 5de53427..14438706 100644 --- a/PlotLine.Tests/Browser/package.json +++ b/PlotLine.Tests/Browser/package.json @@ -6,6 +6,7 @@ "test:characters": "node character-enrichment-detail.cjs", "test:toolbar": "node application-toolbar.cjs", "test:pwa": "node application-pwa.cjs", + "test:responsive-content": "node responsive-content.cjs", "test:plot-lines": "node plot-line-map.cjs", "test:associate-scenes": "node associate-scenes.cjs", "test:timeline-plot-retirement": "node timeline-plot-retirement.cjs", diff --git a/PlotLine.Tests/Browser/responsive-content.cjs b/PlotLine.Tests/Browser/responsive-content.cjs new file mode 100644 index 00000000..8e8d9497 --- /dev/null +++ b/PlotLine.Tests/Browser/responsive-content.cjs @@ -0,0 +1,82 @@ +const { chromium } = require('playwright'); +const assert = require('node:assert/strict'); +const widths = [360, 390, 412, 800, 1440]; +const longName = 'The unexpectedly long journey across the northern mountains and beyond the distant sea'; +(async () => { + const browser = await chromium.launch({ headless: true, executablePath: process.env.CHROMIUM_PATH }); + try { + const page = await browser.newPage(); + const standalone = process.env.PD_RESPONSIVE_STANDALONE === '1'; + await page.addInitScript(standalone => { + if (standalone) Object.defineProperty(navigator, 'standalone', { get: () => true }); + }, standalone); + for (const width of widths) { + await page.setViewportSize({ width, height: 900 }); + for (const theme of ['modern-dark', 'warm-dark', 'modern-light']) { + const mobile = width < 768; + for (const [kind, url] of [['chapters', '/fixture?desktop=Books'], ['timeline', '/fixture?page=timeline-render'], ['plot', '/plot-map-fixture']]) { + await page.goto('http://127.0.0.1:5238' + url); + await page.evaluate(theme => { + document.documentElement.dataset.appTheme = theme; + document.documentElement.dataset.theme = theme.endsWith('dark') ? 'dark' : 'light'; + }, theme); + // The isolated map host does not have a viewport meta tag; desktop Playwright + // uses CSS pixels, just as the full application with its viewport meta does. + if (kind === 'chapters') { + assert.equal(await page.locator('.chapter-table').count(), 1); + assert.equal(await page.locator('.chapter-title').count(), 2); + const titles = await page.locator('.chapter-title').evaluateAll(els => els.map(el => ({ width: el.clientWidth, scroll: el.scrollWidth, height: el.clientHeight }))); + assert.ok(titles.every(t => t.width > (mobile ? 200 : 100) && t.scroll <= t.width + 1), JSON.stringify(titles)); + assert.equal(await page.locator('.chapter-table tbody tr').first().evaluate(el => getComputedStyle(el).display), mobile ? 'grid' : 'table-row'); + for (const selector of ['.chapter-status', '.chapter-manuscript', '.chapter-summary', '.chapter-actions a', '.chapter-actions button']) { + for (const el of await page.locator(selector).all()) assert.ok(await el.isVisible(), selector); + } + if (mobile) assert.ok(await page.locator('.chapter-actions button').first().evaluate(el => el.clientHeight >= 42)); + } else { + const rail = page.locator(kind === 'timeline' ? '.timeline-project-title' : '.plot-lane-label').first(); + const name = rail.locator('.responsive-rail-text'); + if (kind === 'timeline') await page.locator('.timeline-book-title strong').first().evaluate((el, text) => { el.textContent = text; }, longName); + await name.evaluate((el, text) => { const title = el.querySelector('strong'); (title || el).textContent = text; }, longName); + const box = await rail.boundingBox(); + assert.equal(Math.round(box.width), mobile ? 52 : kind === 'timeline' ? 180 : 204); + if (mobile) { + assert.notEqual(await name.evaluate(el => getComputedStyle(el).transform), 'none'); + const bounds = await name.boundingBox(); + assert.ok(bounds.x >= box.x - 1 && bounds.x + bounds.width <= box.x + box.width + 1, JSON.stringify({box, bounds})); + await name.focus(); + await name.evaluate(el => { el.scrollLeft = 100; }); + assert.ok(await name.evaluate(el => el.scrollLeft > 0), 'Long text remains scrollable'); + } + const scroll = page.locator(kind === 'timeline' ? '.timeline-shell' : '.plot-map-scroll').first(); + const scrollable = await scroll.evaluate(el => el.scrollWidth > el.clientWidth); + if (mobile) assert.ok(scrollable, 'mobile workspace must keep horizontal scrolling'); + await scroll.evaluate(el => { el.scrollLeft = 180; }); + if (scrollable) assert.ok(await scroll.evaluate(el => el.scrollLeft > 0)); + const after = await rail.boundingBox(); + assert.ok(Math.abs(after.x - box.x) < 1, `sticky rail moved: ${JSON.stringify({ box, after })}`); + if (kind === 'plot') { + await page.locator('[data-map-mode="associate"]').click(); + for (const el of await page.locator('.plot-lane-label .plot-associate-action').all()) { + assert.ok(await el.isVisible()); + if (mobile) assert.ok((await el.boundingBox()).height >= 44); + } + // Zoom and breakpoint changes must update scene markers and SVG dependencies together. + await page.locator('#plot-map-zoom').selectOption('180'); + const coords = await page.evaluate(() => { + const map = document.querySelector('.plot-narrative-map'); + const path = map.querySelector('[data-source-column]'); + const offset = parseFloat(getComputedStyle(map).getPropertyValue('--plot-map-origin')) || 260; + return { d: path?.getAttribute('d'), expected: offset + Number(path?.dataset.sourceColumn) * 180 }; + }); + if (coords.d) assert.ok(coords.d.startsWith(`M ${coords.expected} `)); + } + } + const overflow = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth); + assert.ok(overflow <= 1, `${kind} ${width} ${theme}: page overflow ${overflow}px`); + if (theme === 'modern-dark' && [390, 1440].includes(width)) await page.screenshot({ path: `/tmp/responsive-${kind}-${width}${standalone ? "-standalone" : ""}.png`, fullPage: true }); + } + } + console.log(`PASS responsive content: ${width}px, three themes`); + } + } finally { await browser.close(); } +})().catch(error => { console.error(error); process.exitCode = 1; }); diff --git a/PlotLine.Tests/ToolbarBrowserHost.cs b/PlotLine.Tests/ToolbarBrowserHost.cs index 81ab4f6c..7a5e95bf 100644 --- a/PlotLine.Tests/ToolbarBrowserHost.cs +++ b/PlotLine.Tests/ToolbarBrowserHost.cs @@ -258,7 +258,10 @@ internal static class ToolbarBrowserHost { "ManuscriptImport" => new OnboardingWizardViewModel { CurrentStep = OnboardingSteps.NextPathPreview, WritingSoftware = WritingSoftwareValues.MicrosoftWord, SelectedProjectName = "The Glass Harbour", SelectedBookTitle = "A Distant Shore", ProjectID = 7, BookID = 12 }, "StoryBible" => new StoryBibleViewModel { Project = project, Query = context.Request.Query["q"] }, - "Books" => new BookDetailViewModel { Project = project, Book = model.Book! }, + "Books" => new BookDetailViewModel { Project = project, Book = model.Book!, Chapters = [ + new() { ChapterID = 21, ChapterNumber = 1, ChapterTitle = "Drowning in Silence", RevisionStatusName = "Planned", IsLinkedToManuscript = true, Summary = "A quiet opening." }, + new() { ChapterID = 22, ChapterNumber = 2, ChapterTitle = "A deliberately long chapter title about an unexpected journey beyond the distant northern mountains", RevisionStatusName = "Draft", ChapterPurposeName = "Turning point", Summary = "A longer summary remains available on small screens.", IsLinkedToManuscript = false } + ] }, "Characters" => new CharacterListViewModel { Project = project, Characters = context.Request.Query["context"] == "objects" ? [new Character { CharacterID = 71, CharacterName = "Context A" }, new Character { CharacterID = 72, CharacterName = "Context B" }] : [] }, "Locations" => new LocationListViewModel { Project = project }, "FloorPlans" => new FloorPlanListViewModel { Project = project }, diff --git a/PlotLine/Views/Books/Details.cshtml b/PlotLine/Views/Books/Details.cshtml index 9e74c0a2..54bff902 100644 --- a/PlotLine/Views/Books/Details.cshtml +++ b/PlotLine/Views/Books/Details.cshtml @@ -180,34 +180,34 @@ } else { -
- - - - - - - - - +
+
ChapterTitleStatusManuscriptSummary
+ + + + + + + + - + @foreach (var chapter in Model.Chapters) { - - - - + + + - - - + +
ChapterTitleStatusManuscriptSummary
@chapter.ChapterNumber@chapter.ChapterTitle +
@chapter.ChapterNumber@chapter.ChapterTitle @chapter.RevisionStatusName @if (!string.IsNullOrWhiteSpace(chapter.ChapterPurposeName)) { @chapter.ChapterPurposeName } @(chapter.IsLinkedToManuscript ? "🔗 Linked" : "📝 Planned")@chapter.Summary + @(chapter.IsLinkedToManuscript ? "🔗 Linked" : "📝 Planned")@chapter.Summary Edit
diff --git a/PlotLine/Views/PlotLineWorkspace/_NarrativeMap.cshtml b/PlotLine/Views/PlotLineWorkspace/_NarrativeMap.cshtml index 8d03c762..98fde74a 100644 --- a/PlotLine/Views/PlotLineWorkspace/_NarrativeMap.cshtml +++ b/PlotLine/Views/PlotLineWorkspace/_NarrativeMap.cshtml @@ -44,13 +44,13 @@ var laneScenes = Model.Scenes.Where(x => x.Memberships.Any(m => m.PlotLineID == lane.Line.PlotLineID)).ToList();
- @(l + 1) @lane.Line.PlotLineName + @(l + 1) @lane.Line.PlotLineName @if (Model.Health.Lines.FirstOrDefault(h => h.PlotLineID == lane.Line.PlotLineID) is { Findings.Count: > 0 } health) { } - Edit colour - + Edit colour +
@for (var n = 0; n < laneScenes.Count; n++) { @@ -88,7 +88,7 @@ } @if (health.Findings.Any(f => f.RuleID == "H002" && f.Level != PlotHealthLevel.Information && (!f.MarkerSceneID.HasValue || !sceneIndex.ContainsKey(f.MarkerSceneID.Value)))) { - + } } @for (var i = 0; i < Model.Scenes.Count; i++) diff --git a/PlotLine/Views/Timeline/Index.cshtml b/PlotLine/Views/Timeline/Index.cshtml index e2686f17..c7016b96 100644 --- a/PlotLine/Views/Timeline/Index.cshtml +++ b/PlotLine/Views/Timeline/Index.cshtml @@ -722,10 +722,10 @@ else
-
+
Project / Series @Model.Project.ProjectName -
+
@foreach (var book in Model.Books) { @@ -967,10 +967,10 @@ else
-
+
Metric Shape Scene pacing -
+

Metric chart could not load. The raw metric rows are still available below.

@@ -1042,10 +1042,10 @@ else if ((lane.Asset.Importance >= 8 ? "High importance" : "Other assets") != group.Key) { continue; } var assetFocusClass = Model.Filter.FocusType == "asset" && Model.Filter.FocusID.HasValue && Model.Filter.FocusID != lane.Asset.StoryAssetID ? "lane-dim" : "";
- +
@foreach (var column in timelineColumns) { diff --git a/PlotLine/wwwroot/css/plot-line-workspace.css b/PlotLine/wwwroot/css/plot-line-workspace.css index 69562bdd..03da3b1b 100644 --- a/PlotLine/wwwroot/css/plot-line-workspace.css +++ b/PlotLine/wwwroot/css/plot-line-workspace.css @@ -48,7 +48,7 @@ .plot-lane-label { position:sticky; left:0; width:204px; min-height:65px; padding:.65rem; border-left:5px solid var(--line-colour); background:var(--bs-body-bg); z-index:8; margin-bottom:-65px; box-shadow:8px 0 12px var(--bs-body-bg); } .plot-lane-label strong { display:block; font-size:.85rem; } .plot-lane-label strong span { display:inline-grid; place-items:center; border:1px solid var(--line-colour); border-radius:50%; width:1.4rem; height:1.4rem; } -.plot-map-marker, .plot-scene-stem, .plot-map-callout, .plot-thread-section, .plot-map-gap, .plot-chapter-guide, .plot-explicit-target { position:absolute; left:calc(260px + var(--column) * var(--step)); } +.plot-map-marker, .plot-scene-stem, .plot-map-callout, .plot-thread-section, .plot-map-gap, .plot-chapter-guide, .plot-explicit-target { position:absolute; left:calc(var(--plot-map-origin, 260px) + var(--column) * var(--step)); } .plot-map-marker { width:14px; height:14px; transform:translate(-50%,-4px); border:3px solid var(--bs-body-bg); border-radius:50%; background:var(--line-colour); box-shadow:0 0 0 2px var(--line-colour); z-index:4; } .plot-map-marker.is-accent { border-radius:2px; transform:translate(-50%,-4px) rotate(45deg); } .plot-scene-stem { width:2px; background:var(--bs-secondary-color); z-index:2; } @@ -115,7 +115,7 @@ .plot-associating #plot-association-status { margin:.25rem 0 0; } .plot-map-callout button:has(.plot-callout-preview:hover), .plot-map-callout button:focus { border-radius:.6rem .6rem 0 0; } .plot-health-summary { display:block; border:0; padding:.1rem 0; background:transparent; color:var(--bs-secondary-color); font-size:.68rem; text-align:left; text-decoration:underline dotted; } -.plot-health-position { position:absolute; left:calc(260px + var(--column) * var(--step) + 12px); z-index:1; width:20px; height:20px; line-height:16px; border:1px solid var(--bs-border-color); border-radius:50%; background:var(--bs-body-bg); color:var(--bs-secondary-color); font-size:.8rem; } +.plot-health-position { position:absolute; left:calc(var(--plot-map-origin, 260px) + var(--column) * var(--step) + 12px); z-index:1; width:20px; height:20px; line-height:16px; border:1px solid var(--bs-border-color); border-radius:50%; background:var(--bs-body-bg); color:var(--bs-secondary-color); font-size:.8rem; } .plot-associating .plot-health-position { pointer-events:none; opacity:.55; } .plot-health-thread { margin:1rem 0; padding-top:.75rem; border-top:1px solid var(--bs-border-color); } .plot-health-thread h3 { font-size:1.05rem; } @@ -128,3 +128,29 @@ .plot-lane-label:has(.plot-health-summary) { flex-wrap:wrap; gap:0 .4rem; } .plot-lane-label:has(.plot-health-summary) [data-lane-name], .plot-health-summary { flex:1 0 100%; } .plot-lane-label:has(.plot-health-summary) .plot-associate-action { max-width:100%; white-space:normal; } + +@media (max-width: 767.98px) { + .plot-narrative-map { --plot-map-origin:100px; } + .plot-workspace, .plot-map-scroll { min-width:0; max-width:100%; } + .plot-lane-label-row { transform:translateY(-70px); } + .plot-lane-label-row .plot-lane-label { + display:flex; flex-direction:column; align-items:stretch; gap:0; + width:52px; height:232px; min-height:232px; padding:96px 0 0; + } + .plot-lane-label strong.responsive-rail-text { + top:0; width:92px; height:44px; max-height:44px; margin:0; + white-space:nowrap; overflow-wrap:normal; + } + .plot-lane-label .plot-colour-edit, .plot-lane-label .plot-associate-action, + .plot-lane-label .plot-health-summary { + display:grid; place-items:center; flex:0 0 44px; min-height:44px; + width:100%; max-width:100%; padding:0; margin:0; font-size:0; + } + .plot-lane-label .plot-associate-action[hidden] { display:none; } + .plot-colour-edit::before { content:'✎'; font-size:1.1rem; } + .plot-associate-action::before { content:'+'; font-size:1.3rem; } + .plot-health-summary::before { content:'◇'; font-size:1.2rem; } + .plot-colour-edit span, .plot-associate-action span { + position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); + } +} diff --git a/PlotLine/wwwroot/css/site.css b/PlotLine/wwwroot/css/site.css index f95c7815..721b66d9 100644 --- a/PlotLine/wwwroot/css/site.css +++ b/PlotLine/wwwroot/css/site.css @@ -7591,3 +7591,48 @@ html[data-standalone="true"] .scene-workspace .scene-workspace-workbench { heigh .scene-workspace[data-scene-area="overview"] .scene-inspector-v2-grid { height: auto; grid-template-rows: none; } .scene-workspace[data-scene-area="overview"] .scene-inspector-v2-card { overflow: visible; } } + +.timeline-project-title > .responsive-rail-text, +.metric-lane-label > .responsive-rail-text, +.asset-lane-label > .responsive-rail-text { display: contents; } + +/* Content layouts follow viewport width in both browsers and installed apps. */ +@media (max-width: 767.98px) { + .chapter-list { overflow: visible; } + .chapter-table, .chapter-table tbody { display: block; width: 100%; } + .chapter-table thead { + position: absolute; width: 1px; height: 1px; padding: 0; + overflow: hidden; clip-path: inset(50%); white-space: nowrap; + } + .chapter-table tbody tr { + display: grid; grid-template-columns: auto minmax(0, 1fr); + gap: .5rem .65rem; padding: 1rem 0; border-bottom: 1px solid var(--bs-border-color); + } + .chapter-table tbody td { padding: 0; border: 0; min-width: 0; width: auto; } + .chapter-table .chapter-number, .chapter-table .chapter-title { font-weight: 700; } + .chapter-table .chapter-title { overflow-wrap: anywhere; word-break: normal; } + .chapter-table .chapter-status, .chapter-table .chapter-manuscript, + .chapter-table .chapter-summary, .chapter-table .chapter-actions { grid-column: 1 / -1; } + .chapter-table .chapter-summary { overflow-wrap: anywhere; } + .chapter-table .chapter-summary:empty { display: none; } + .chapter-table .chapter-actions { display: flex; flex-wrap: wrap; gap: .5rem; text-align: start !important; } + .chapter-table .chapter-actions .btn { min-height: 44px; display: inline-flex; align-items: center; } + .chapter-table .archive-button-form { margin: 0; } + + .timeline-filtered-root { --timeline-label-width: 52px; } + .timeline-project-title, .metric-lane-label, .asset-lane-label, .character-lane-label { + width: var(--timeline-label-width); min-width: 0; min-height: 204px; padding: 0; + } + /* Rotate ordinary text as a whole. Long names can be scrolled/focused inside the rail. */ + .timeline-project-title > .responsive-rail-text, + .metric-lane-label > .responsive-rail-text, + .asset-lane-label > .responsive-rail-text, + .responsive-rail-text { + display: block; + position: absolute; left: 100%; top: 8px; transform-origin: top left; + transform: rotate(90deg); width: 188px; max-height: 44px; + overflow: auto; padding: 2px 4px; white-space: nowrap; + } + .responsive-rail-text strong { display: block; white-space: nowrap; overflow-wrap: normal; } + .lane-group-heading { overflow-wrap: anywhere; font-size: .65rem; padding-inline: 3px; } +} diff --git a/PlotLine/wwwroot/js/plot-line-workspace.js b/PlotLine/wwwroot/js/plot-line-workspace.js index 7c3e6ab2..3dcc648d 100644 --- a/PlotLine/wwwroot/js/plot-line-workspace.js +++ b/PlotLine/wwwroot/js/plot-line-workspace.js @@ -137,19 +137,24 @@ item.classList.toggle("btn-outline-secondary", !active); }); })); - document.getElementById("plot-map-zoom")?.addEventListener("change", event => { + const layoutMap = () => { const map = document.querySelector(".plot-narrative-map"); - const step = Number(event.target.value); + if (!map) return; + const step = Number(document.getElementById("plot-map-zoom")?.value || 224); + const offset = parseFloat(getComputedStyle(map).getPropertyValue("--plot-map-origin")) || 260; map.style.setProperty("--step", `${step}px`); map.querySelectorAll("[data-source-column]").forEach(path => { - const sx = 260 + Number(path.dataset.sourceColumn) * step; - const tx = 260 + Number(path.dataset.targetColumn) * step; + const sx = offset + Number(path.dataset.sourceColumn) * step; + const tx = offset + Number(path.dataset.targetColumn) * step; const sy = Number(path.dataset.sourceY), ty = Number(path.dataset.targetY); path.setAttribute("d", `M ${sx} ${sy} Q ${(sx + tx) / 2} ${Math.min(sy, ty) - 45} ${tx} ${ty}`); }); - map.style.width = `${Math.max(900, Number(map.dataset.mapColumns) * step + 260)}px`; + map.style.width = `${Math.max(900, Number(map.dataset.mapColumns) * step + offset)}px`; drawMemberships(); - }); + }; + document.getElementById("plot-map-zoom")?.addEventListener("change", layoutMap); + window.addEventListener("resize", layoutMap); + layoutMap(); const selectScene = button => { selectedScene = button.dataset.associateScene; document.querySelectorAll("[data-associate-scene]").forEach(item => item.setAttribute("aria-pressed", String(item === button)));