create-pmos 0.322.0 → 0.324.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.322.0",
3
+ "version": "0.324.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@de4bfa4
1
+ kernel-source: pmos@ec2aa8c
2
2
  assembled: 2026-10-19
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T22:26:41Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T22:26:41Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T22:26:41Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -119,6 +119,8 @@ Above the list, with today picked, a ring shows how many of the meetings still a
119
119
 
120
120
  With another day picked, the card lists that day's meetings from the calendar PMOS holds, and the items due that day. It reads the week once when the page opens. If the calendar cannot be read, the card says "Calendar not read" and gives the reason, and does not guess. A meeting in the past is shown dimmer. Picking a day changes only what the card shows and records nothing.
121
121
 
122
+ **The full calendar.** The button beside the filter in the card's title row opens the calendar in a dialog. **Day**, **Week** and **Month** each read the calendar PMOS holds for that range; the arrows move one day, week or month, and **Today** comes back. Week is a timeline from Monday to Friday, with Saturday and Sunday only when they hold something; meetings at the same time sit side by side, and the all-day row shows the dated marks the Calendar reads (a promised date, a plan item, a release, a report, your own due items). In a narrow dialog, such as on a phone, Day and Week are a list of days. In Month, press a day to open it. Press a meeting to open its meeting dialog; the calendar stays as a **Calendar** tab beside it, at the same view. An empty range says "No meetings in this week" (or day, or month), and a calendar that cannot be read says "Calendar not read" with the reason.
123
+
122
124
  Press a meeting, from today or from another day, to open the meeting dialog. It shows the time, the people, and what the meeting is about. It also shows the notes (decisions, next steps and open questions), the material, and, when a recording was kept, its length and the key points. Each part appears only when a record holds it.
123
125
 
124
126
  When the meeting is not linked, the dialog has a **Link it** press. You choose the portfolio, a board, an initiative or none. The press writes one calendar link, through a check that only a real press from this page can pass, so an agent session is refused. After the write, the page reads the week again. The **Material** part has **Add material** and a **Remove** on each row. Add material opens a sheet in the dialog with three ways to pick: **Suggested** (the documents of the meeting's initiative and the newest report cycles), **Find in PMOS** (type two letters or more) and **Paste a link** (an https address). A **For** choice says whether the material belongs to this meeting or to every meeting in the series. Before you press Add, the sheet says what it records: one line in PMOS's own record of the meeting. The calendar invite is never changed. After a write, the list is read again from the record. Remove names its scope and says the document itself is not changed. A few seconds of **Undo** put a removed item back.
@@ -307,6 +309,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
307
309
  - **Found in your work.** Up to three reports PMOS found in your calendar, mail or documents, each with why and what it saw. **Set it up** records the report and drafts its first cycle as a file. **Not a report** hides it and records it after 5 seconds, unless you press **Undo**. If the finding changed while the window was open, the window says what happened. It was already set up, it was marked not a report, or a new scan replaced it. The list is read again. Close the window and open the report from the list. If PMOS does not hear back, the window says nothing was recorded. Press the button to try again.
308
310
  - **Set up.** Your recurring reports, with their schedule and next draft. A report opens with **Draft it now** (for a report drawn from your work) and **Pause** or **Resume**.
309
311
  - **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens it on the page at the normal dialog size, with a status line (Draft or Issued, the saved design version, the file). The **slide deck / Document** menu picks the view: a deck is a title slide, then one slide for each section, with the arrow keys and a strip of slides; a document is a page. The **Read** menu holds **Present**, which shows the slide on the whole screen (the arrow keys move and Escape stops), and **Print or save as PDF**, which prints one slide to a page. **Download** gives PowerPoint, Word, Excel, CSV or the Markdown file; the files carry the words, not the look. **Open in the console** is where a document is edited or issued. Nothing is sent from this page.
312
+ - **Edit the slides.** In the **Read** menu of a draft, **Edit the slides** opens the same file as a **Slides** tab beside the report. The rail on the left lists the slides. Drag a slide to move it, or use the up and down buttons on it; the buttons also duplicate and delete a slide, and **+ Slide** adds one from a layout. On the slide, click an item to select it, drag it to move it (a line shows when it is centred), and drag a corner to resize it. Double-click text to type. The toolbar adds text, an image, a chart, a table or a shape, and changes the layout of the slide or the theme of the deck. The bar under it changes the selected item: text style, alignment and colour; bars or a line and **Edit data** for a chart; rows and columns for a table. An image is a file that is already in the workspace: type its path, such as `planning/design/screen.png`. Speaker notes go in the box under the slide. **Undo** and **Redo** cover every change. **Present** opens the presenter view: the slide, the next slide, your speaker notes (you can type in them) and a timer. The arrow keys move, and Escape stops. **Slides only** hides the notes. **Audience window** opens a second window with the slide alone, for the screen you share; it follows your slide and closes when you stop. **Save** asks why the slides change, then writes the file; the reason goes in the Edit log. The file stays markdown: each slide is a heading with its text under it, and a hidden comment keeps the layout and the notes. If someone changed the text of a slide in the file, the editor shows the file's text and says so. If the file changed while the slides were open, Save stops and tells you to open the slides again. An issued report opens its slides read-only, with **Open the slides**.
310
313
  - **Shape a report's look.** On a draft, **Add a sample** takes a PDF, PowerPoint, Word, PNG or JPG file to follow. Say how it should look in the conversation; PMOS draws the next design version (D1, D2, …) and says what it changed. Press a version to go back to it. **This is it** saves the version shown as the report's design, and PMOS draws the cycle to match. An issued cycle is frozen with its look.
311
314
 
312
315
  Not built: a second measure next to a chart, bar highlights, speaker notes and notes on a slide, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.322.0",
3
+ "version": "0.324.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.322.0",
9
+ "version": "0.324.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.322.0",
3
+ "version": "0.324.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -104,7 +104,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
104
104
  await page.click('.vcf [data-a="1"]');
105
105
  ok('R1 vwConfirm resolves true on the yes button and removes the card', (await yes) === true && !(await page.$('.vcf')));
106
106
  await page.evaluate(() => window.__premiumViewer.vwStyle('none-such'));
107
- ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x'); return document.querySelectorAll('link[data-vw-css]').length === 1 && document.querySelector('link[data-vw-css]').getAttribute('href') === '/pm/premium-vw-none-such.css'; }));
107
+ ok('R1 vwStyle adds the view\'s stylesheet link once', await page.evaluate(() => { window.__premiumViewer.vwStyle('none-such'); window.__premiumViewer.vwStyle('../x'); const l = document.querySelectorAll('link[data-vw-css="none-such"]'); return l.length === 1 && l[0].getAttribute('href') === '/pm/premium-vw-none-such.css' && !document.querySelector('link[href*="/x.css"]'); }));
108
108
  await page.keyboard.press('Escape');
109
109
  await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
110
110
  await openDialog(page);
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-cal-test.js — the calendar grid in the premium viewer: Day, Week and Month (initiative premium-viewer, R8; planning/prd/premium-viewer-prd.md R6, R7).
4
+ * Serves the real Briefing page from the real server. The Briefing model and GET /api/calendar-views are answered by stand-ins; the stand-in
5
+ * buckets its meetings with the repo's own calendar model (scripts/calendar-model.js), so each view gets the cells the real route would send.
6
+ * R8 the card's button opens the grid · Day, Week, Month · previous, next, Today · a month day opens that day · a meeting opens its detail with the
7
+ * calendar as a tab · R6 an empty range and a failed answer say so · R7 390px day list, 44px targets, no sideways scroll, dark theme
8
+ * Every wait polls the page; no fixed sleep stands in for a state. */
9
+ const path = require('path');
10
+ const { spawn } = require('child_process');
11
+ const { findBrowser } = require('./lib/find-browser');
12
+ const T = require('./test-run').configure({ name: 'premium-vw-cal' });
13
+ const B = require('./lib/briefing-premium.js');
14
+ const F = require('./fixtures/briefing-premium-facts.js');
15
+ const model = require('../scripts/calendar-model.js');
16
+
17
+ const BASE = T.BASE;
18
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
20
+ const results = [];
21
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
22
+ let srv = null; let browser = null;
23
+ const finish = async (code) => {
24
+ if (browser) await browser.close().catch(() => {});
25
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
26
+ T.killTmux();
27
+ const bad = results.filter((x) => !x.cond).length;
28
+ console.log(`\n${results.length - bad}/${results.length} premium-vw-cal assertions passed`);
29
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
30
+ };
31
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
32
+
33
+ const pad = (n) => String(n).padStart(2, '0');
34
+ const key = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
35
+ const TODAY = key(new Date());
36
+ const plus = (k, n) => { const [y, m, d] = k.split('-').map(Number); return key(new Date(y, m - 1, d + n)); };
37
+ /* today's meetings: two that overlap and one later; one more in five days, so it falls in a later week of the same or the next month */
38
+ const EVENTS = [
39
+ { id: 'ev-sync', title: 'Onboarding weekly sync', at: `${TODAY}T10:00:00`, end: `${TODAY}T11:00:00`, attendees: ['Sam', 'Lee'] },
40
+ { id: 'ev-over', title: 'Billing meter review', at: `${TODAY}T10:30:00`, end: `${TODAY}T11:30:00`, attendees: ['Ana'] },
41
+ { id: 'ev-late', title: 'Customer call', at: `${TODAY}T15:00:00`, end: `${TODAY}T15:45:00` },
42
+ { id: 'ev-next', title: 'Sprint planning', at: `${plus(TODAY, 8)}T13:00:00`, end: `${plus(TODAY, 8)}T14:30:00` },
43
+ ];
44
+ const answer = (url, mode) => {
45
+ const q = new URL(url).searchParams, view = q.get('view') || 'week', date = q.get('date') || TODAY;
46
+ if (mode === 'fail') return { status: 500, body: { ok: false, error: 'the calendar reader stopped' } };
47
+ const b = model.bucketEvents(mode === 'empty' ? [] : EVENTS, view, date);
48
+ return { status: 200, body: { ok: true, view, range: b.range, unit: b.unit, cells: b.cells, gantt: [], events_source: 'calendar-memory', today: TODAY,
49
+ layers: mode === 'empty' ? [] : [{ id: 'ini:x', date: TODAY, kind: 'initiative', layer: 'initiatives', title: 'Self-serve v2 promised', tone: 'warn' }], context: {}, link_boards: [] } };
50
+ };
51
+
52
+ (async () => {
53
+ const exe = findBrowser();
54
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
55
+ let chromium;
56
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
57
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
58
+ await T.waitForServer(BASE);
59
+ browser = await chromium.launch({ executablePath: exe });
60
+
61
+ const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
62
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
63
+ const page = await ctx.newPage();
64
+ const S = { errors: [], mode: 'full', asks: [] };
65
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
66
+ await page.route('**/api/briefing-premium*', (r) => r.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }) }));
67
+ await page.route('**/api/calendar-views*', (r) => { S.asks.push(r.request().url()); const a = answer(r.request().url(), S.mode); r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
68
+ await page.goto(BASE + '/premium.html?theme=' + theme);
69
+ S.up = await until(() => page.evaluate(() => !!document.querySelector('#todayCard .vc-open') && !!window.__premiumViewer), 20000);
70
+ return { page, ctx, S };
71
+ };
72
+ const vis = (page, sel) => page.evaluate((s) => [...document.querySelectorAll(s)].filter((e) => e.getClientRects().length && getComputedStyle(e).visibility !== 'hidden').length, sel);
73
+ const ready = (page) => until(() => page.evaluate(() => !!document.querySelector('#vcMain .vc-w .vc-h') || !!document.querySelector('.obody.vw[data-vw="cal"] .vc-w .vc-h')));
74
+ const pressed = (page) => page.evaluate(() => { const b = document.querySelector('#dOut .vc-seg [aria-pressed="true"]:not([hidden])'); return b && b.dataset.cv; });
75
+ const title = (page) => page.evaluate(() => { const t = [...document.querySelectorAll('#dOut .vc-t')].find((x) => x.getClientRects().length); return t ? t.textContent : ''; });
76
+
77
+ /* R8 desktop */
78
+ {
79
+ const { page, ctx, S } = await open();
80
+ ok('R8 the Briefing\'s Calendar card has a button that opens the calendar', S.up);
81
+ await page.click('#todayCard .vc-open');
82
+ ok('R8 the button opens a dialog with the calendar as its detail', await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dTitle').textContent === 'Calendar')) && await ready(page));
83
+ await until(() => vis(page, '#vcMain .vc-ev'));
84
+ ok('R8 it opens on this week, read from GET /api/calendar-views?view=week', (await pressed(page)) === 'week' && S.asks.some((u) => /view=week&date=/.test(u)), S.asks.join(' '));
85
+ ok('R8 the week draws today\'s three meetings as blocks', (await vis(page, '#vcMain .vc-ev')) === 3, String(await vis(page, '#vcMain .vc-ev')));
86
+ const lanes = await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].filter((b) => /sync|meter/.test(b.textContent)).map((b) => b.getBoundingClientRect()));
87
+ ok('R8 two meetings that overlap sit side by side', lanes.length === 2 && Math.abs(lanes[0].left - lanes[1].left) > 20 && lanes[0].width < 200, JSON.stringify(lanes.map((r) => [r.left, r.width])));
88
+ ok('R8 the all-day row carries the dated layer as a mark', await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-adc .vc-ad')].some((x) => /promised/.test(x.textContent) && x.tagName === 'SPAN')));
89
+ ok('R8 the now line is drawn on today', (await vis(page, '#vcMain .vc-now')) <= 1);
90
+ const wk = await title(page);
91
+ await page.click('#vcMain [data-cn="1"]');
92
+ await until(async () => (await title(page)) !== wk);
93
+ ok('R8 Next moves a week on', (await title(page)) !== wk && S.asks.some((u) => u.includes('date=' + plus(TODAY, 7))), S.asks.slice(-1)[0]);
94
+ await page.click('#vcMain [data-cn="0"]');
95
+ await until(async () => (await title(page)) === wk);
96
+ ok('R8 Today comes back to this week', (await title(page)) === wk);
97
+ await page.click('#vcMain [data-cv="month"]');
98
+ await until(async () => (await pressed(page)) === 'month' && (await vis(page, '#vcMain .vc-md')) >= 28);
99
+ ok('R8 Month draws whole weeks of days', (await vis(page, '#vcMain .vc-md')) % 7 === 0 && (await vis(page, '#vcMain .vc-md')) >= 28 && /\d{4}$/.test(await title(page)), await title(page));
100
+ ok('R8 today\'s cell lists its meetings', await page.evaluate(() => { const c = document.querySelector('#vcMain .vc-md.now'); return !!c && c.querySelectorAll('.vc-me').length === 3; }));
101
+ await page.click('#vcMain .vc-md.now .vc-dn');
102
+ await until(async () => (await pressed(page)) === 'day');
103
+ await until(() => vis(page, '#vcMain .vc-ev'));
104
+ ok('R8 a month day opens that day', (await pressed(page)) === 'day' && S.asks.some((u) => u.includes('view=day&date=' + TODAY)) && (await vis(page, '#vcMain .vc-dh')) === 1);
105
+ await page.click('#vcMain [data-cv="week"]');
106
+ await until(() => vis(page, '#vcMain .vc-ev'));
107
+ await page.evaluate(() => [...document.querySelectorAll('#vcMain .vc-ev')].find((b) => /weekly sync/.test(b.textContent)).click());
108
+ ok('R8 a meeting opens its detail, the meeting dialog', await until(() => page.evaluate(() => document.querySelector('#dTitle').textContent === 'Onboarding weekly sync')));
109
+ const tabs = await page.evaluate(() => ({ ...window.__premiumViewer.vwState(), main: !document.querySelector('#oMain').hidden }));
110
+ ok('R8 the calendar stays as a tab beside the meeting, the meeting shown', JSON.stringify(tabs.ids) === '["cal"]' && tabs.on === 'main' && tabs.main, JSON.stringify(tabs));
111
+ await page.click('#vTabs .vtab[data-vw="cal"]');
112
+ await until(() => vis(page, '.obody.vw[data-vw="cal"] .vc-ev'));
113
+ ok('R8 the Calendar tab shows the grid at the same view', (await vis(page, '.obody.vw[data-vw="cal"] .vc-ev')) === 3 && (await pressed(page)) === 'week');
114
+ await page.evaluate(() => [...document.querySelectorAll('.obody.vw[data-vw="cal"] .vc-ev')].find((b) => /Customer call/.test(b.textContent)).click());
115
+ ok('R8 a meeting from the tab opens that meeting, with the tab again', await until(() => page.evaluate(() => document.querySelector('#dTitle').textContent === 'Customer call' && JSON.stringify(window.__premiumViewer.vwState().ids) === '["cal"]')));
116
+
117
+ /* R6 honesty */
118
+ await page.keyboard.press('Escape');
119
+ await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')), 3000);
120
+ S.mode = 'empty';
121
+ await page.click('#todayCard .vc-open');
122
+ await until(() => page.evaluate(() => /No meetings in this week/.test((document.querySelector('#vcMain') || {}).textContent || '')));
123
+ ok('R6 a week with no meetings says so', await page.evaluate(() => /No meetings in this week\./.test(document.querySelector('#vcMain').textContent) && !document.querySelector('#vcMain .vc-ev')));
124
+ S.mode = 'fail';
125
+ await page.click('#vcMain [data-cv="month"]');
126
+ await until(() => page.evaluate(() => /Calendar not read/.test(document.querySelector('#vcMain').textContent)));
127
+ ok('R6 a calendar that did not answer says it was not read, and why', await page.evaluate(() => /Calendar not read\. the calendar reader stopped/.test(document.querySelector('#vcMain').textContent)));
128
+ ok('R8 no page error', S.errors.length === 0, S.errors.join(' | '));
129
+ await ctx.close();
130
+ }
131
+
132
+ /* R7 phone and dark theme */
133
+ {
134
+ const { page, ctx, S } = await open({ w: 390, h: 844, theme: 'dark' });
135
+ await page.click('#todayCard .vc-open');
136
+ await until(() => vis(page, '#vcMain .vc-ar'));
137
+ ok('R7 at 390px the week is a day list, not the timeline', (await vis(page, '#vcMain .vc-ar')) === 3 && (await vis(page, '#vcMain .vc-g')) === 0, String(await vis(page, '#vcMain .vc-ar')));
138
+ const m = async () => page.evaluate(() => {
139
+ const bs = [...document.querySelectorAll('#vcMain button')].filter((b) => b.getClientRects().length).map((b) => b.getBoundingClientRect());
140
+ return { minH: Math.min(...bs.map((r) => r.height)), minW: Math.min(...bs.map((r) => r.width)), over: document.documentElement.scrollWidth > window.innerWidth,
141
+ right: Math.max(...bs.map((r) => r.right)) <= window.innerWidth + 1, bg: getComputedStyle(document.querySelector('#vcMain .vc-w')).backgroundColor };
142
+ });
143
+ let x = await m();
144
+ ok('R7 every control of the week is at least 44px', x.minH >= 44 && x.minW >= 44, JSON.stringify(x));
145
+ ok('R7 the week fits the width, no sideways scroll', x.right && !x.over, JSON.stringify(x));
146
+ ok('R7 in the dark theme the calendar is not a light card', (() => { const c = (x.bg.match(/\d+/g) || []).slice(0, 3).map(Number); return c.length === 3 && c[0] + c[1] + c[2] < 3 * 160; })(), x.bg);
147
+ await page.click('#vcMain [data-cv="month"]');
148
+ await until(() => vis(page, '#vcMain .vc-md'));
149
+ x = await m();
150
+ ok('R7 the month at 390px: day buttons of 44px, no sideways scroll', x.minH >= 44 && x.minW >= 40 && x.right && !x.over && (await vis(page, '#vcMain .vc-me')) === 0, JSON.stringify(x));
151
+ ok('R7 no page error', S.errors.length === 0, S.errors.join(' | '));
152
+ await ctx.close();
153
+ }
154
+ finish();
155
+ })();
@@ -0,0 +1,269 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-slides-test.js — the slide editor in the premium viewer (initiative premium-viewer, R-SL1, R6, R7; planning/prd/premium-viewer-prd.md).
4
+ * A real server on a scratch git repository with two cycles of one report (one issued). The real Insights page opens a report, and Read >
5
+ * Edit the slides opens the editor as a tab of the viewer. Every save goes through the real POST /api/doc-sheet/edit and is read back from disk.
6
+ * O opening · E editing · S save and read back · H a hand edit wins · C a stale file · N Present · I issued · F floors
7
+ * Set SLIDES_SHOTS=<dir> to save screenshots at 1280 and 390 wide. Every wait polls the page; no fixed sleep stands in for a state. */
8
+ const fs = require('fs');
9
+ const os = require('os');
10
+ const path = require('path');
11
+ const { spawn, execFileSync } = require('child_process');
12
+ const { findBrowser } = require('./lib/find-browser');
13
+ const T = require('./test-run').configure({ name: 'premium-vw-slides' });
14
+ const issues = require('./lib/issues.js');
15
+ const RDraft = require('./lib/report-draft.js');
16
+
17
+ const BASE = T.BASE;
18
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
+ const until = async (fn, ms = 15000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
20
+ const results = [];
21
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
22
+ let srv = null, browser = null;
23
+ const base = fs.mkdtempSync(path.join(os.tmpdir(), 'vw-slides-'));
24
+ const finish = async (code) => {
25
+ if (browser) await browser.close().catch(() => {});
26
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
27
+ T.killTmux();
28
+ try { fs.rmSync(base, { recursive: true, force: true }); } catch { /* left for the OS */ }
29
+ const bad = results.filter((x) => !x.cond).length;
30
+ console.log(`\n${results.length - bad}/${results.length} premium-vw-slides assertions passed`);
31
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
32
+ };
33
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
34
+
35
+ /* the scratch repository: one measure, so the Insights page draws; two cycles of one report, the older one issued */
36
+ const dir = path.join(base, 'repo'), stateDir = path.join(base, 'state'), fakeHome = path.join(base, 'home');
37
+ for (const d of [path.join(dir, 'planning', 'records'), path.join(dir, 'planning', 'design'), stateDir, path.join(fakeHome, '.claude')]) fs.mkdirSync(d, { recursive: true });
38
+ const rd = (id, rid, at, value) => ({ id, kind: 'reading', rid, fields: { at, value } });
39
+ fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), [
40
+ { id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
41
+ rd('2', 'krm-a', '2026-08-01', 24), rd('3', 'krm-a', '2026-09-01', 30),
42
+ ].map((x) => JSON.stringify(x)).join('\n') + '\n');
43
+ const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==', 'base64');
44
+ fs.writeFileSync(path.join(dir, 'planning', 'design', 'screen.png'), PNG);
45
+ const CAD = 'partner-review';
46
+ const DOC = '---\ntype: Report\ntitle: "Partner review, 12 Oct"\n---\n\n# Partner review, 12 Oct\n\n## Headline\nPartner activation is **33%**, short of its line.\n\n## Initiatives\n- Partner activation: in build\n- Onboarding emails: shipped\n\n## Partner note\n<!-- pmos:note partner-activation -->\nThe PM\'s words.\n<!-- /pmos:note -->\n\n## Sources\n- KR metric record krm-a\n';
47
+ const OLD = '---\ntype: Report\ntitle: "Partner review, 5 Oct"\n---\n\n# Partner review, 5 Oct\n\n## Headline\nPartner activation is 30%.\n';
48
+ const pNew = RDraft.draftPath(dir, CAD, '2026-10-12'), pOld = RDraft.draftPath(dir, CAD, '2026-10-05');
49
+ fs.mkdirSync(path.join(dir, path.dirname(pNew)), { recursive: true });
50
+ fs.writeFileSync(path.join(dir, pNew), DOC); fs.writeFileSync(path.join(dir, pOld), OLD);
51
+ const git = (...a) => execFileSync('git', a, { cwd: dir, stdio: 'ignore' });
52
+ git('init', '-q'); git('-c', 'user.name=t', '-c', 'user.email=t@t', 'add', '-A'); git('-c', 'user.name=t', '-c', 'user.email=t@t', 'commit', '-q', '-m', 'records');
53
+ const iss = issues.appendFromCli(dir, [{ ev: 'issued', cadence: CAD, slot: '2026-10-05', path: pOld, sha: issues.blobSha(fs.readFileSync(path.join(dir, pOld))) }], { actor: { by: 'pm:wawan', via: 'cli' } });
54
+ const disk = () => fs.readFileSync(path.join(dir, pNew), 'utf8');
55
+
56
+ (async () => {
57
+ ok('setup: the older cycle is issued', iss && iss.ok === true, JSON.stringify(iss));
58
+ const exe = findBrowser();
59
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
60
+ let chromium;
61
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
62
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore',
63
+ env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: stateDir, PMOS_NO_OPEN: '1', PMOS_REPORT_FIND: 'off', PMOS_CORE_DOCS: 'off', HOME: fakeHome }) });
64
+ await T.waitForServer(BASE);
65
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
66
+
67
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
68
+ p.on('pageerror', (e) => errs.push(String(e)));
69
+ p.on('console', (m) => { if (m.type() === 'error') console.log(' page console: ' + m.text() + ' ' + JSON.stringify(m.location())); });
70
+ p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
71
+ const shot = async (n) => { if (process.env.SLIDES_SHOTS) await p.screenshot({ path: path.join(process.env.SLIDES_SHOTS, n + '.png') }); };
72
+ const tap = (sel) => p.$eval(sel, (b) => b.click());
73
+ const V = '#dOut .obody.vw:not([hidden])';
74
+ const st = () => p.evaluate((pth) => { const S = window.__premiumSlides && window.__premiumSlides.state(pth); return S ? { i: S.i, n: S.deck.slides.length, theme: S.deck.theme, dirty: S.dirty, ro: S.ro, sel: S.sel, msg: S.msg, slides: JSON.parse(JSON.stringify(S.deck.slides)) } : null; }, pNew);
75
+ const openReader = async (slot) => {
76
+ await p.goto(BASE + '/premium-insights.html');
77
+ await until(() => p.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
78
+ await tap(`#repDocs [data-rep="rep:${CAD}:${slot}"]`);
79
+ return until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
80
+ };
81
+ const openEditor = async () => {
82
+ await tap('#oMain [data-rr="rm"]');
83
+ await tap('#oMain [data-rr="slides"]');
84
+ return until(() => p.evaluate(() => !!document.querySelector('#dOut .obody.vw:not([hidden]) .sl .sl-stage .sl-cv')));
85
+ };
86
+
87
+ /* O: opening */
88
+ ok('O1 a draft report opens in the reader', await openReader('2026-10-12'));
89
+ ok('O2 the Read menu offers Edit the slides', /Edit the slides/.test(await p.evaluate(() => { document.querySelector('#oMain [data-rr="rm"]').click(); return (document.querySelector('#oMain [data-rr="slides"]') || {}).textContent || ''; })));
90
+ await tap('#oMain [data-rr="rm"]');
91
+ ok('O3 Edit the slides opens the editor as a tab beside the report', await openEditor() && await p.evaluate((pth) => { const s = window.__premiumViewer.vwState(); return s.on === 'slides:' + pth && s.ids.length === 1 && document.querySelector('#oMain').hidden; }, pNew));
92
+ let s = await st();
93
+ ok('O4 the report reads as a title slide and one slide per section', s && s.n === 5 && s.slides[0].l === 'title' && s.slides.map((x) => x.els[0].html).join('|') === 'Partner review, 12 Oct|Headline|Initiatives|Partner note|Sources', s && s.slides.map((x) => x.els[0].html).join('|'));
94
+ ok('O5 the view says the document has no slide layout yet', /no slide layout yet/.test(await p.textContent(V + ' .sl-msg')));
95
+ ok('O6 the rail shows five slides, the first current', await p.evaluate((v) => [...document.querySelectorAll(v + ' .sl-th')].length === 5 && document.querySelector(v + ' .sl-th[aria-current="true"]').dataset.k === '0', V));
96
+ ok('O7 the note of a report is not slide text', !(await p.evaluate((v) => document.querySelector(v + ' .sl-rail').textContent, V)).includes('pmos:note'));
97
+ await shot('slides-open-1280');
98
+
99
+ /* E: editing */
100
+ await tap(V + ' [data-go="1"]');
101
+ const box = async (k) => p.evaluate(([v, k2]) => { const n = document.querySelectorAll(v + ' .sl-stage .sl-it')[k2]; const r = n.getBoundingClientRect(); return { x: r.x, y: r.y, w: r.width, h: r.height, g: n.dataset.g }; }, [V, k]);
102
+ let b = await box(1);
103
+ await p.mouse.move(b.x + b.w / 2, b.y + 10); await p.mouse.down(); await p.mouse.move(b.x + b.w / 2 + 60, b.y + 40, { steps: 6 }); await p.mouse.up();
104
+ s = await st();
105
+ ok('E1 dragging an item moves it on the canvas', s.slides[1].els[1].x > 72 && s.slides[1].els[1].y > 150 && s.dirty, JSON.stringify(s.slides[1].els[1]));
106
+ await p.$eval(V + ' .sl-stage', (e) => e.scrollIntoView({ block: 'center' }));
107
+ b = await box(1);
108
+ const se = await p.evaluate((v) => { const h = document.querySelector(v + ' .sl-stage .sl-it.sel .h-sw').getBoundingClientRect(); return { x: h.x + h.width / 2, y: h.y + h.height / 2 }; }, V);
109
+ const w0 = s.slides[1].els[1].w;
110
+ await p.mouse.move(se.x, se.y); await p.mouse.down(); await p.mouse.move(se.x + 80, se.y - 30, { steps: 6 }); await p.mouse.up();
111
+ s = await st();
112
+ ok('E2 a corner handle resizes the item', s.slides[1].els[1].w < w0, s.slides[1].els[1].w + ' vs ' + w0);
113
+ b = await box(0);
114
+ await p.mouse.dblclick(b.x + 20, b.y + b.h / 2);
115
+ await until(() => p.evaluate(() => document.activeElement && document.activeElement.isContentEditable));
116
+ await p.keyboard.press('End'); await p.keyboard.type(' this week');
117
+ await p.click(V + ' .sl-notes textarea'); await p.keyboard.type('Say the number first.');
118
+ s = await st();
119
+ ok('E3 double-click types into a text item', s.slides[1].els[0].html === 'Headline this week', s.slides[1].els[0].html);
120
+ ok('E4 speaker notes are typed into the slide', s.slides[1].notes === 'Say the number first.');
121
+ ok('E5 the rail shows the edit on the slide\'s thumbnail', /Headline this week/.test(await p.evaluate((v) => document.querySelectorAll(v + ' .sl-mini')[1].textContent, V)));
122
+ await tap(V + ' [data-c="chart"]');
123
+ await until(() => p.$(V + ' .sl-pop .sl-grid'));
124
+ await p.fill(V + ' .sl-pop input[data-r="0"][data-i="0"]', 'Aug'); await p.fill(V + ' .sl-pop input[data-r="0"][data-i="1"]', '24');
125
+ await tap(V + ' .sl-pop [data-addrow]');
126
+ await p.fill(V + ' .sl-pop input[data-r="1"][data-i="0"]', 'Sep'); await p.fill(V + ' .sl-pop input[data-r="1"][data-i="1"]', '30');
127
+ await p.keyboard.press('Escape');
128
+ s = await st();
129
+ const chart = s.slides[1].els.find((e) => e.t === 'chart');
130
+ ok('E6 Chart adds a chart and its data is edited in a grid', chart && JSON.stringify(chart.data) === '[["Aug",24],["Sep",30]]' && await p.evaluate((v) => document.querySelectorAll(v + ' .sl-stage .sl-bar').length === 2, V), JSON.stringify(chart));
131
+ await tap(V + ' [data-c="shape"]');
132
+ await tap(V + ' .sl-ctx [data-c="fill"][data-v="soft"]'); await tap(V + ' .sl-ctx [data-c="round"]');
133
+ s = await st();
134
+ ok('E7 Shape adds a shape and its fill and corners change', s.slides[1].els.some((e) => e.t === 'shape' && e.fill === 'soft' && e.round));
135
+ await tap(V + ' [data-c="img"]');
136
+ await until(() => p.$(V + ' .sl-pop form'));
137
+ await p.fill(V + ' .sl-pop input[name="src"]', 'https://evil.example/x.png');
138
+ await tap(V + ' .sl-pop [type="submit"]');
139
+ ok('E8 an image on the web is refused with a reason', /inside the workspace/.test(await p.textContent(V + ' .sl-pop .sl-err')));
140
+ await p.fill(V + ' .sl-pop input[name="src"]', 'planning/design/screen.png');
141
+ await p.fill(V + ' .sl-pop input[name="alt"]', 'The setup screen'); await tap(V + ' .sl-pop [type="submit"]');
142
+ ok('E9 an image from the workspace shows through /api/asset', await until(() => p.evaluate((v) => { const i = document.querySelector(v + ' .sl-stage img'); return i && i.complete && i.naturalWidth > 0 && i.getAttribute('src').startsWith('/api/asset?'); }, V)));
143
+ await tap(V + ' [data-c="theme"]'); await tap(V + ' .sl-pop [data-pick="sky"]');
144
+ await tap(V + ' [data-c="layout"]'); await tap(V + ' .sl-pop [data-pick="two"]');
145
+ s = await st();
146
+ ok('E10 Theme and Layout change the deck and the slide, keeping the title', s.theme === 'sky' && s.slides[1].l === 'two' && s.slides[1].els.filter((e) => e.k === 'body' || e.k === 'body2').length === 2 && s.slides[1].els.find((e) => e.k === 'title').html === 'Headline this week');
147
+ await tap(V + ' [data-dn="1"]');
148
+ s = await st();
149
+ ok('E11 Move down reorders the slides', s.slides[2].els.find((e) => e.k === 'title').html === 'Headline this week' && s.i === 2);
150
+ await tap(V + ' [data-del="4"]');
151
+ ok('E12 Delete removes a slide', (await st()).n === 4);
152
+ await tap(V + ' [data-c="undo"]');
153
+ ok('E13 Undo puts the slide back, and Redo takes it away again', (await st()).n === 5 && await (async () => { await tap(V + ' [data-c="redo"]'); const n = (await st()).n; await tap(V + ' [data-c="undo"]'); return n === 4 && (await st()).n === 5; })());
154
+ await tap(V + ' [data-add]'); await tap(V + ' .sl-pop [data-pick="big"]');
155
+ s = await st();
156
+ ok('E14 Add slide adds one from a layout after the current one', s.n === 6 && s.slides[3].l === 'big' && s.i === 3);
157
+ await shot('slides-edit-1280');
158
+
159
+ /* S: save, and read back from disk */
160
+ posts.length = 0;
161
+ await tap(V + ' [data-c="save"]');
162
+ await until(() => p.$(V + ' .sl-savef'));
163
+ await p.fill(V + ' .sl-savef input[name="why"]', 'Slides for Thursday'); await tap(V + ' .sl-savef [type="submit"]');
164
+ await until(() => p.evaluate((pth) => !window.__premiumSlides.state(pth).dirty, pNew));
165
+ const md = disk();
166
+ ok('S1 Save writes once through the document sheet\'s edit route', JSON.stringify(posts) === '["/api/doc-sheet/edit"]', JSON.stringify(posts));
167
+ ok('S2 the file is markdown with a slide block under each heading', (md.match(/^<!-- pmos:slide \{/gm) || []).length === 6 && /^# Partner review, 12 Oct\n<!-- pmos:slide/m.test(md) && /\ndeck_theme: sky\n/.test(md), md.slice(0, 300));
168
+ ok('S3 the slide\'s text, its chart data and its image are written as markdown', md.includes('## Headline this week\n') && md.includes('| Sep | 30 |') && md.includes('![The setup screen](planning/design/screen.png)'));
169
+ ok('S4 the speaker notes and the report note are in the file', md.includes('"notes":"Say the number first."') && md.includes('<!-- pmos:note partner-activation -->\nThe PM\'s words.\n<!-- /pmos:note -->'));
170
+ ok('S5 the reason is kept in the document\'s revision log', await p.evaluate(async ([pth]) => { const S = window.__premiumSlides.state(pth); const r = await fetch('/api/doc-sheet/log?' + new URLSearchParams({ ...(S.ws ? { ws: S.ws } : {}), path: pth })).then((x) => x.json()); return JSON.stringify(r).includes('Slides for Thursday'); }, [pNew]));
171
+ await tap('#vTabs .vtab[data-vw="main"]');
172
+ ok('S6 the report reader shows the saved words, without the slide blocks', await until(() => p.evaluate(() => { const t = document.querySelector('#oMain').textContent; return t.includes('Headline this week') && !t.includes('pmos:slide'); })));
173
+ await openReader('2026-10-12'); await openEditor();
174
+ s = await st();
175
+ ok('S7 opened again, the deck is as it was saved, with no "no layout" note', s.n === 6 && s.theme === 'sky' && s.slides[2].l === 'two' && s.slides[2].notes === 'Say the number first.' && JSON.stringify(s.slides[2].els.find((e) => e.t === 'chart').data) === '[["Aug",24],["Sep",30]]' && !s.msg, JSON.stringify({ n: s.n, msg: s.msg }));
176
+
177
+ /* H: a hand edit of a slide's text wins on the next open */
178
+ fs.writeFileSync(path.join(dir, pNew), disk().replace('\n- Onboarding emails: shipped', '\n- Onboarding emails: shipped to all partners'));
179
+ await openReader('2026-10-12'); await openEditor();
180
+ s = await st();
181
+ const ini = s.slides.find((x) => (x.els.find((e) => e.k === 'title') || {}).html === 'Initiatives');
182
+ ok('H1 a slide edited in the file shows the file\'s text and says so', ini && ini.changed && /shipped to all partners/.test(JSON.stringify(ini.els)) && /changed in the file outside the editor/.test(await p.textContent(V + ' .sl-msg')), s.msg);
183
+
184
+ /* C: the file changes while the editor is open */
185
+ await tap(V + ' [data-c="text"]'); await p.keyboard.type('New words');
186
+ fs.writeFileSync(path.join(dir, pNew), disk() + '\n');
187
+ posts.length = 0;
188
+ await tap(V + ' [data-c="save"]'); await until(() => p.$(V + ' .sl-savef')); await tap(V + ' .sl-savef [type="submit"]');
189
+ ok('C1 a save over a file that changed is refused with a reason, and nothing is written', await until(() => p.evaluate((v) => /changed since the slides were opened/.test((document.querySelector(v + ' .sl-savef .sl-err') || {}).textContent || ''), V)) && posts.length === 0, JSON.stringify(posts));
190
+ await p.keyboard.press('Escape');
191
+
192
+ /* N: Present */
193
+ await tap(V + ' [data-go="0"]');
194
+ await tap(V + ' [data-c="present"]');
195
+ ok('N1 Present shows the slide over the whole page', await until(() => p.evaluate(() => { const o = document.querySelector('.sl-pres'); if (!o) return false; const r = o.getBoundingClientRect(); return r.width >= innerWidth - 1 && r.height >= innerHeight - 1 && !!o.querySelector('.sl-cv'); })));
196
+ await p.keyboard.press('ArrowRight');
197
+ ok('N2 the arrow keys move while presenting', /^2 \//.test(await p.textContent('.sl-pres .sl-pn')));
198
+ await p.keyboard.press('Escape');
199
+ ok('N3 Escape stops presenting and leaves the dialog open', await until(() => p.evaluate(() => !document.querySelector('.sl-pres') && document.querySelector('#dlg').classList.contains('on'))));
200
+
201
+ /* N: the presenter view (R-SL2) */
202
+ await tap(V + ' [data-go="0"]');
203
+ await tap(V + ' [data-c="present"]');
204
+ await until(() => p.$('.sl-pres .sl-pside'));
205
+ const pv = await p.evaluate(() => { const o = document.querySelector('.sl-pres'); return { k: o.dataset.k, cur: !!o.querySelector('.sl-pslot .sl-cv'), next: !!o.querySelector('.sl-pnx .sl-cv'), notes: !!o.querySelector('.sl-pside textarea'), t: (o.querySelector('[data-pt]') || {}).textContent || '' }; });
206
+ ok('N4 Present opens the presenter view: the slide, the next one, the notes and a timer', pv.k === 'pres' && pv.cur && pv.next && pv.notes && /^\d\d:\d\d$/.test(pv.t), JSON.stringify(pv));
207
+ if (process.env.SLIDES_SHOTS) await p.screenshot({ path: path.join(process.env.SLIDES_SHOTS, 'presenter.png') });
208
+ const s0 = await st(), j = s0.slides.findIndex((x) => x.notes === 'Say the number first.');
209
+ for (let k = 0; k < j; k++) await p.keyboard.press('ArrowRight');
210
+ ok('N5 the notes of the slide on screen are shown', (await p.inputValue('.sl-pres .sl-pside textarea')) === 'Say the number first.', String(j));
211
+ await p.click('.sl-pres .sl-pside textarea'); await p.keyboard.press('End'); await p.keyboard.type(' Then the beta date.');
212
+ await p.keyboard.press('Escape');
213
+ ok('N6 notes typed in the presenter view are the slide\'s notes, and Escape in the notes keeps presenting', !!(await p.$('.sl-pres')) && (await st()).slides[j].notes === 'Say the number first. Then the beta date.');
214
+ const [aw] = await Promise.all([p.context().waitForEvent('page'), p.click('.sl-pres [data-c="win"]')]);
215
+ await until(() => aw.evaluate(() => !!document.querySelector('.sl-pres[data-k="win"] .sl-cv')));
216
+ const aud = await aw.evaluate(() => ({ cv: document.querySelectorAll('.sl-cv').length, ta: document.querySelectorAll('textarea').length, b: document.querySelectorAll('button').length, i: document.querySelector('.sl-pslot').dataset.i }));
217
+ ok('N7 the audience window shows the slide only: no notes, no buttons', aud.cv === 1 && aud.ta === 0 && aud.b === 0 && aud.i === String(j), JSON.stringify(aud));
218
+ await p.click('.sl-pres [data-c="next"]');
219
+ ok('N8 the audience window follows the presenter\'s slide', await until(() => aw.evaluate((k) => (document.querySelector('.sl-pslot') || {}).dataset.i === String(k), j + 1)));
220
+ await p.click('.sl-pres [data-c="kind"]');
221
+ ok('N9 Slides only shows the slide without the notes and offers the presenter view back', await p.evaluate(() => { const o = document.querySelector('.sl-pres'); return o.dataset.k === 'aud' && !o.querySelector('textarea') && /Presenter view/.test(o.querySelector('[data-c="kind"]').textContent); }));
222
+ await p.keyboard.press('Escape');
223
+ ok('N10 stopping closes the audience window and the editor shows the last slide presented', await until(() => aw.isClosed()) && (await st()).i === j + 1 && await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
224
+ await tap(V + ' [data-c="undo"]');
225
+ ok('N11 Undo takes back the notes typed while presenting', (await st()).slides[j].notes === 'Say the number first.');
226
+
227
+ /* I: an issued report */
228
+ await openReader('2026-10-05');
229
+ ok('I1 an issued report offers Open the slides', /Open the slides/.test(await p.evaluate(() => { document.querySelector('#oMain [data-rr="rm"]').click(); return (document.querySelector('#oMain [data-rr="slides"]') || {}).textContent || ''; })));
230
+ await tap('#oMain [data-rr="rm"]'); await openEditor();
231
+ ok('I2 its slides are read-only: no Save, no editing tools, and it says why', await p.evaluate((v) => !document.querySelector(v + ' [data-c="save"]') && !document.querySelector(v + ' [data-c="text"]') && !document.querySelector(v + ' .sl-cv.ed') && /issued, so its slides are read-only/.test(document.querySelector(v + ' .sl-msg').textContent), V));
232
+ ok('I3 the issued file is not changed', fs.readFileSync(path.join(dir, pOld), 'utf8') === OLD);
233
+ ok('X no page error', errs.length === 0, errs.join(' | '));
234
+ await ctx.close();
235
+
236
+ /* F: floors at 390 px, dark, touch */
237
+ {
238
+ const c2 = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true, colorScheme: 'dark' }), q = await c2.newPage(), e2 = [];
239
+ q.on('pageerror', (e) => e2.push(String(e)));
240
+ await q.goto(BASE + '/premium-insights.html?theme=dark');
241
+ await until(() => q.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
242
+ await q.$eval(`#repDocs [data-rep="rep:${CAD}:2026-10-12"]`, (x) => x.click());
243
+ await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
244
+ await q.$eval('#oMain [data-rr="rm"]', (x) => x.click()); await q.$eval('#oMain [data-rr="slides"]', (x) => x.click());
245
+ await until(() => q.evaluate(() => !!document.querySelector('#dOut .obody.vw:not([hidden]) .sl .sl-stage .sl-cv')));
246
+ await sleep(300);
247
+ const m = await q.evaluate((v) => {
248
+ const r = (e) => e.getBoundingClientRect(), vis = (e) => e.offsetParent !== null && r(e).width > 0;
249
+ const bs = [...document.querySelectorAll(v + ' .sl-tb .sl-b, ' + v + ' .sl-tha .sl-b')].filter(vis);
250
+ const rail = document.querySelector(v + ' .sl-rail'), stage = document.querySelector(v + ' .sl-stage');
251
+ return { minH: Math.min(...bs.map((b) => r(b).height)), minW: Math.min(...bs.map((b) => r(b).width)), over: document.documentElement.scrollWidth > innerWidth + 1,
252
+ railBelow: r(rail).top >= r(stage).bottom - 1, stageFits: r(stage).right <= innerWidth + 1, bg: getComputedStyle(document.querySelector(v + ' .sl-notes textarea')).backgroundColor };
253
+ }, V);
254
+ ok('F1 buttons are at least 44px on a phone', m.minH >= 44 && m.minW >= 44, JSON.stringify(m));
255
+ ok('F2 no sideways scroll at 390 px; the slide fits and the rail sits below it', !m.over && m.stageFits && m.railBelow, JSON.stringify(m));
256
+ ok('F3 in the dark theme the notes box is not a light card', (() => { const c = (m.bg.match(/\d+/g) || []).slice(0, 3).map(Number); return c.length === 3 && c[0] + c[1] + c[2] < 3 * 160; })(), m.bg);
257
+ if (process.env.SLIDES_SHOTS) await q.screenshot({ path: path.join(process.env.SLIDES_SHOTS, 'slides-390-dark.png') });
258
+ await q.$eval(V + ' [data-c="present"]', (x) => x.click());
259
+ await until(() => q.$('.sl-pres .sl-pside'));
260
+ const pm = await q.evaluate(() => { const o = document.querySelector('.sl-pres'), r = (e) => e.getBoundingClientRect(), bs = [...o.querySelectorAll('.sl-b')].filter((b) => r(b).width > 0), cur = o.querySelector('.sl-pslot .sl-pbox');
261
+ return { minH: Math.min(...bs.map((b) => r(b).height)), wide: o.scrollWidth > o.clientWidth + 1, curFits: r(cur).right <= innerWidth + 1 && r(cur).width > 300, notesBelow: r(o.querySelector('.sl-pside')).top >= r(cur).bottom - 1 }; });
262
+ if (process.env.SLIDES_SHOTS) await q.screenshot({ path: path.join(process.env.SLIDES_SHOTS, 'presenter-390-dark.png') });
263
+ ok('F5 the presenter view at 390 px: the slide fills the width, the notes sit below, 44 px buttons, no sideways scroll', pm.minH >= 44 && !pm.wide && pm.curFits && pm.notesBelow, JSON.stringify(pm));
264
+ await q.keyboard.press('Escape');
265
+ ok('F4 no page error at 390 px', e2.length === 0, e2.join(' | '));
266
+ await c2.close();
267
+ }
268
+ finish();
269
+ })();