PlotDirector/PlotLine.Tests/Browser/timeline-plot-retirement.cjs
Nick Beckley e48889ac05 Complete desktop workspaces, context menus and plot health
Commit the pending application, help and browser regression work. Pin the patched PKCS dependency for the production release.
2026-10-31 09:27:04 +00:00

44 lines
3.6 KiB
JavaScript

const { chromium } = require('playwright');
const assert = require('node:assert/strict');
(async () => {
const browser = await chromium.launch({ headless: true, executablePath: process.env.CHROMIUM_PATH });
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
const errors = [];
page.on('pageerror', e => errors.push(e.message));
if (process.env.PLOT_ASSET_ORIGIN) {
await page.route(/\/(?:css\/(?:site|plotline-theme|application-shell)\.css|js\/site\.js)(?:\?.*)?$/, async route => {
await route.fulfill({ response: await route.fetch({ url: process.env.PLOT_ASSET_ORIGIN + new URL(route.request().url()).pathname }) });
});
}
await page.addInitScript(() => {
localStorage.setItem('plotline.timeline.visibility', JSON.stringify({ 'plot-lines': false, 'scene-cards': true }));
localStorage.setItem('plotline.timeline.collapsed', JSON.stringify(['plot-lines', 'plot-group-legacy']));
});
await page.goto('http://127.0.0.1:5238/fixture?page=timeline-render');
assert.equal(await page.locator('.timeline-scene-card').count(), 2);
assert.ok(await page.locator('.timeline-book-title').count());
assert.ok(await page.locator('.timeline-chapter-title').count());
assert.equal(await page.locator('.plot-lane-board,.plot-lane-row,.thread-marker,[data-plot-line-svg],[data-plot-line-health-svg],.character-lane-board').count(), 0);
assert.equal(await page.locator('[name="ShowPlotLines"],[data-timeline-toggle="plot-lines"],[data-collapse-toggle="plot-lines"]').count(), 0);
assert.equal(await page.locator('[data-timeline-entity-jump] option').filter({ hasText: 'Plot line:' }).count(), 0);
assert.equal(await page.locator('select[name="PlotLineID"]').count(), 1);
assert.equal(await page.locator('select[name="PlotThreadID"]').count(), 1);
assert.equal(await page.locator('.timeline-scene-card[data-scene-id="101"]').evaluate(el => el.classList.contains('filter-match') && el.classList.contains('focus-match')), true);
assert.equal(await page.locator('.timeline-scene-card[data-scene-id="102"]').evaluate(el => el.classList.contains('filter-dim') && el.classList.contains('focus-dim')), true);
await page.locator('[data-timeline-search]').evaluate(el => el.closest('details').open = true);
await page.locator('[data-timeline-search]').fill('First clues');
assert.ok(await page.locator('.timeline-scene-card[data-scene-id="101"]').isVisible());
assert.equal(await page.locator('.timeline-scene-card[data-scene-id="102"]').evaluate(el => el.classList.contains('search-dim')), true);
await page.locator('[data-timeline-search]').fill('');
assert.ok(await page.locator('.timeline-scene-card[data-scene-id="102"]').isVisible());
const href = await page.locator('.timeline-scene-card[data-scene-id="101"]').getAttribute('href');
assert.match(href, /SelectedSceneID=101/i);
await page.goto('http://127.0.0.1:5238/fixture?page=timeline-render&scenario=true');
assert.deepEqual(await page.locator('.timeline-scene-card').evaluateAll(items => items.map(el => el.dataset.sceneId)), ['102', '101']);
assert.equal(await page.locator('.plot-lane-board').count(), 0);
assert.deepEqual(errors, []);
await page.screenshot({ path: '/tmp/timeline-plot-retirement.png', fullPage: true });
await browser.close();
console.log('PASS: real Timeline Razor renders scenes/books/chapters, membership focus/search and supplied scenario order; no plot lanes/health/controls/jumps; legacy preferences ignored');
})().catch(e => { console.error(e); process.exit(1); });