create-pmos 0.323.0 → 0.325.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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-calendar-2-test.js +8 -6
  7. package/workspace/briefing-premium-calendar-3-test.js +7 -4
  8. package/workspace/briefing-premium-calendar-test.js +4 -2
  9. package/workspace/guide/briefing-premium.md +15 -0
  10. package/workspace/package-lock.json +2 -2
  11. package/workspace/package.json +1 -1
  12. package/workspace/premium-vw-item-test.js +128 -0
  13. package/workspace/premium-vw-meet-test.js +210 -0
  14. package/workspace/premium-vw-notes-test.js +161 -0
  15. package/workspace/premium-vw-slides-test.js +269 -0
  16. package/workspace/public/pm/premium-board.js +3 -1
  17. package/workspace/public/pm/premium-deck.js +218 -0
  18. package/workspace/public/pm/premium-initiative.js +7 -2
  19. package/workspace/public/pm/premium-meeting.js +84 -31
  20. package/workspace/public/pm/premium-report-read.js +11 -3
  21. package/workspace/public/pm/premium-shell.js +1 -0
  22. package/workspace/public/pm/premium-vw-item-model.js +58 -0
  23. package/workspace/public/pm/premium-vw-item.css +25 -0
  24. package/workspace/public/pm/premium-vw-item.js +66 -0
  25. package/workspace/public/pm/premium-vw-meet.css +87 -0
  26. package/workspace/public/pm/premium-vw-meet.js +322 -0
  27. package/workspace/public/pm/premium-vw-notes.css +43 -0
  28. package/workspace/public/pm/premium-vw-notes.js +188 -0
  29. package/workspace/public/pm/premium-vw-slides.css +163 -0
  30. package/workspace/public/pm/premium-vw-slides.js +472 -0
  31. package/workspace/public/pm/premium.js +2 -0
  32. package/workspace/test-lists/premium-viewer.json +9 -3
  33. package/workspace/test-lists/premium-vw-item.json +13 -0
  34. package/workspace/test-lists/premium-vw-meet.json +13 -0
  35. package/workspace/test-lists/premium-vw-notes.json +13 -0
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-notes-test.js — the Notes list and a note opened beside it (initiative premium-viewer, R9; planning/prd/premium-viewer-prd.md).
4
+ * Serves the real Briefing from the real server. The Briefing model, the calendar, the notes, the boards, the search and the note are answered by stand-ins,
5
+ * so each press can be read off the request the page sent. The routes' own behaviour is in their own suites; the pure half is in premium-vw-notes.test.js.
6
+ * N1 open · N2 groups · N3 series · N4 search · N5 the note tab · N6 Change what it is about · N7 writes · N8 floors
7
+ * Every wait polls the page; no fixed sleep stands in for a state. */
8
+ const path = require('path');
9
+ const { spawn } = require('child_process');
10
+ const { findBrowser } = require('./lib/find-browser');
11
+ const T = require('./test-run').configure({ name: 'premium-vw-notes' });
12
+ const B = require('./lib/briefing-premium.js');
13
+ const F = require('./fixtures/briefing-premium-facts.js');
14
+
15
+ const BASE = T.BASE;
16
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
17
+ 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); } };
18
+ const results = [];
19
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
20
+ let srv = null; let browser = null;
21
+ const finish = async (code) => {
22
+ if (browser) await browser.close().catch(() => {});
23
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
24
+ T.killTmux();
25
+ const bad = results.filter((x) => !x.cond).length;
26
+ console.log(`\n${results.length - bad}/${results.length} premium-vw-notes assertions passed`);
27
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
28
+ };
29
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
30
+
31
+ const NOW = new Date();
32
+ const ROWS = [
33
+ { id: 'n1', title: 'Weekly sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', title: 'Weekly sync', start: '2026-10-19T10:00:00+07:00' }, board: { id: 'b1', ws: 'w1', title: 'Growth' }, initiative: { id: 'ux', ws: 'w1', title: 'Premium UX' }, series: { key: 'wk', by: 'calendar' }, meeting_ms: 32 * 60000, summary_lines: ['The copy test was agreed.'] },
34
+ { id: 'n0', title: 'Weekly sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', title: 'Weekly sync', start: '2026-10-12T10:00:00+07:00' }, board: { id: 'b1', ws: 'w1', title: 'Growth' }, series: { key: 'wk', by: 'calendar' }, summary_lines: ['The runbook was asked for.'] },
35
+ { id: 'n2', title: 'Exec sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', title: 'Exec sync', start: '2026-10-16T10:00:00+07:00' }, portfolio: true, meeting_ms: 28 * 60000 },
36
+ { id: 'n3', title: 'Call with a partner', state: 'ended', updated_at: NOW.toISOString(), created_at: '2026-10-15T08:00:00Z', meeting: null, summary_lines: ['They want SSO before they move 40 seats.'] },
37
+ ];
38
+ const NOTE = { id: 'n3', title: 'Call with a partner', state: 'ended', meeting: null, meeting_ms: 22 * 60000, final_notes: { overview: 'The partner wants SSO first.', decisions: [{ text: 'Price SSO in the team plan', why: 'Two partners asked.' }], actions: [{ text: 'Send the SSO plan', owner: 'Ana', due: '2026-10-24' }], questions: [] } };
39
+
40
+ (async () => {
41
+ const exe = findBrowser();
42
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
43
+ let chromium;
44
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
45
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
46
+ await T.waitForServer(BASE);
47
+ browser = await chromium.launch({ executablePath: exe });
48
+
49
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
50
+ const SESS = [];
51
+ const open = async ({ w = 1280, h = 900, theme = 'light', notes = ROWS } = {}) => {
52
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
53
+ const page = await ctx.newPage();
54
+ const S = { errors: [], reqs: [], linkPosts: [], oneGets: [], searches: [], note: { ...NOTE } };
55
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
56
+ page.on('request', (r) => { if (r.url().startsWith(BASE)) S.reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
57
+ await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }));
58
+ await page.route('**/api/calendar-views*', (r) => json(r, { ok: true, view: 'week', cells: [], events_source: 'calendar-memory', context: {}, link_boards: [], gantt: [] }));
59
+ await page.route('**/api/notes/search*', (r) => { const q = new URL(r.request().url()).searchParams.get('q'); S.searches.push(q); return json(r, { ok: true, ids: /runbook|said/.test(q) ? ['n0'] : [] }); });
60
+ await page.route('**/api/notes/one*', (r) => { const id = new URL(r.request().url()).searchParams.get('id'); S.oneGets.push(id);
61
+ const n = id === 'n3' ? S.note : { ...ROWS.find((x) => x.id === id), final_notes: { overview: 'Notes of ' + id, decisions: [], actions: [], questions: [] } };
62
+ return json(r, { ok: true, note: n, place: id === 'n3' ? null : { key: 'wk', title: 'Weekly sync', pos: id === 'n1' ? 2 : 1, count: 2, prev: id === 'n1' ? { id: 'n0', at: '2026-10-12T03:00:00Z' } : null, next: id === 'n0' ? { id: 'n1', at: '2026-10-19T03:00:00Z' } : null } }); });
63
+ await page.route('**/api/notes/link', (r) => { const b = JSON.parse(r.request().postData() || '{}'); S.linkPosts.push(b); if (b.initiative) S.note = { ...S.note, board: b.board, initiative: b.initiative }; return json(r, { ok: true }); });
64
+ await page.route(/\/api\/notes(\?.*)?$/, (r) => json(r, { ok: true, notes, series_open: { wk: { open: 2, carried: false } } }));
65
+ await page.route(/\/api\/boards(\?.*)?$/, (r) => json(r, { ok: true, boards: [{ id: 'b1', ws: 'w1', name: 'Growth' }] }));
66
+ await page.route('**/api/boards/backlog*', (r) => json(r, { ok: true, rows: [{ id: 'ux', title: 'Premium UX' }, { id: 'sso', title: 'SSO for teams' }] }));
67
+ await page.goto(BASE + '/premium.html?theme=' + theme);
68
+ S.up = await until(() => page.evaluate(() => !!document.querySelector('#vnOpen') && !!document.querySelector('#vnOpenFoot') && document.querySelectorAll('#rank .rr').length > 0), 20000);
69
+ if (S.up) { if (w <= 600 && await page.evaluate(() => document.querySelector('#todayCard').classList.contains('calhid'))) await page.click('#todayCard .foldb'); await page.click(w <= 600 ? '#vnOpenFoot' : '#vnOpen'); S.dlg = await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelectorAll('#vnBody .vn-g').length > 0)); }
70
+ SESS.push(S);
71
+ return Object.assign(S, { ctx, page });
72
+ };
73
+ const A = await open();
74
+ ok('N1 the Calendar card has a Notes button that opens the dialog with the list', A.up && A.dlg && await A.page.evaluate(() => document.querySelector('#dTitle').textContent === 'Notes'));
75
+ if (!A.up || !A.dlg) return finish(1);
76
+ const p = A.page;
77
+
78
+ /* N2 groups */
79
+ const g = await p.evaluate(() => ({ groups: [...document.querySelectorAll('#vnBody .vn-g h4')].map((x) => x.firstChild.textContent), count: document.querySelector('#vnCount').textContent }));
80
+ ok('N2 the notes are grouped: Portfolio, the board, then Not linked, with a count', g.groups.join('|') === 'Portfolio|Growth|Not linked' && g.count === '4 notes', JSON.stringify(g));
81
+ const r3 = await p.evaluate(() => document.querySelector('[data-vn-note="n3"]').textContent);
82
+ ok('N2 a note with no meeting is tagged no meeting; the Portfolio note shows its length', /no meeting/.test(r3) && /28 min/.test(await p.evaluate(() => document.querySelector('[data-vn-note="n2"]').textContent)), r3);
83
+
84
+ /* N3 series */
85
+ const ser = await p.evaluate(() => document.querySelector('[data-vn-series="wk"]').textContent);
86
+ ok('N3 the two notes of the series are one entry with 2 meetings, series and 2 open', /2 meetings/.test(ser) && /series/.test(ser) && /2 open/.test(ser), ser);
87
+ await p.click('[data-vn-fold="wk"]');
88
+ ok('N3 folding the series open lists its notes with their first summary line', await until(() => p.evaluate(() => !!document.querySelector('.vn-sub [data-vn-note="n0"]') && /The runbook was asked for\./.test(document.querySelector('#vnBody').textContent) && document.querySelector('[data-vn-fold="wk"]').getAttribute('aria-expanded') === 'true')));
89
+
90
+ /* N4 search */
91
+ await p.fill('#vnQ', 'sso');
92
+ ok('N4 typing filters the list at once and the count says N of M', await until(() => p.evaluate(() => document.querySelectorAll('#vnBody [data-vn-note]').length === 1 && !!document.querySelector('[data-vn-note="n3"]') && document.querySelector('#vnCount').textContent === '1 of 4 notes')));
93
+ await p.fill('#vnQ', 'what was said');
94
+ ok('N4 a note found by the server search in what was said is listed', await until(() => p.evaluate(() => !!document.querySelector('[data-vn-note="n0"]'))) && A.searches.includes('what was said'), JSON.stringify(A.searches));
95
+ await p.fill('#vnQ', 'zzz');
96
+ ok('N4 no match says so', await until(() => p.evaluate(() => /No note matches “zzz”/.test(document.querySelector('#vnBody').textContent))));
97
+ ok('N4 the search field keeps focus while typing', await p.evaluate(() => document.activeElement && document.activeElement.id === 'vnQ'));
98
+ await p.fill('#vnQ', '');
99
+
100
+ /* N5 the note tab */
101
+ await until(() => p.evaluate(() => !!document.querySelector('[data-vn-note="n3"]')));
102
+ await p.click('[data-vn-note="n3"]');
103
+ const tab = await until(() => p.evaluate(() => { const t = document.querySelector('#vTabs'), pane = document.querySelector('#dOut .obody.vw[data-vw="meet-note"]'); return t && !t.hidden && pane && !pane.hidden && /Price SSO in the team plan/.test(pane.textContent) ? { tabs: [...t.querySelectorAll('.vtab')].map((x) => x.textContent.trim()), ph: [...pane.querySelectorAll('.vm-ph [data-ph]')].map((b) => b.dataset.ph + ':' + b.getAttribute('aria-pressed')).join(), text: pane.textContent } : null; }));
104
+ ok('N5 a note opens as a viewer tab beside the list, on After', tab && tab.tabs.length === 2 && /Notes/.test(tab.tabs[0]) && /Call with a partner/.test(tab.tabs[1]) && tab.ph === 'before:false,during:false,after:true', JSON.stringify(tab && { tabs: tab.tabs, ph: tab.ph }));
105
+ ok('N5 the tab has the summary, the Decision and Why table and the next step table from the note', tab && /The partner wants SSO first\./.test(tab.text) && /Two partners asked\./.test(tab.text) && /Send the SSO plan/.test(tab.text) && /Ana/.test(tab.text) && /No meeting/.test(tab.text));
106
+ await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-ph="before"]');
107
+ ok('N5 Before says the note has no calendar event', await until(() => p.evaluate(() => { const b = document.querySelector('#dOut .obody.vw[data-vw="meet-note"] .vm-body[data-part="before"]'); return b && !b.hidden && /not linked to a calendar event/.test(b.textContent); })));
108
+ await p.click('#vTabs .vtab[data-vw="main"]');
109
+ await p.click('[data-vn-series="wk"]');
110
+ ok('N5 pressing a series opens its newest note, which says N of M', await until(() => p.evaluate(() => /Weekly sync · 2 of 2/.test((document.querySelector('#dOut .obody.vw[data-vw="meet-note"] .vm-ser') || {}).textContent || ''))) && A.oneGets.includes('n1'));
111
+ await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-vm="prev"]');
112
+ ok('N5 paging reads the meeting before into the same tab', await until(() => A.oneGets.includes('n0')) && await p.evaluate(() => document.querySelectorAll('#vTabs .vtab').length === 2));
113
+
114
+ /* N6 Change what it is about */
115
+ await p.click('#vTabs .vtab[data-vw="main"]');
116
+ await p.click('[data-vn-note="n3"]');
117
+ await until(() => p.evaluate(() => /Call with a partner/.test((document.querySelector('#dOut .obody.vw[data-vw="meet-note"] h3') || {}).textContent || '')));
118
+ await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-vm="nabout"]');
119
+ const opts = await until(() => p.evaluate(() => { const s = document.querySelector('#dOut .vm-nabout select'); return s ? [...s.options].map((o) => o.textContent) : null; }));
120
+ ok('N6 Choose what it is about lists Portfolio, the board and its initiatives', opts && opts.join('|') === 'Choose what it is about|Portfolio|Board: Growth|Initiative: Premium UX|Initiative: SSO for teams', JSON.stringify(opts));
121
+ await p.selectOption('#dOut .vm-nabout select', 'i:w1/sso');
122
+ await p.click('#dOut [data-vm="nsave"]');
123
+ await until(() => A.linkPosts.length === 1);
124
+ ok('N6 Save posts the console\'s link body for the note', JSON.stringify(A.linkPosts[0]) === JSON.stringify({ id: 'n3', board: { id: 'b1', ws: 'w1', title: 'Growth' }, initiative: { id: 'sso', ws: 'w1', title: 'SSO for teams' } }), JSON.stringify(A.linkPosts));
125
+ ok('N6 the note is read again and its head names the initiative, with Change', await until(() => p.evaluate(() => { const pn = document.querySelector('#dOut .obody.vw[data-vw="meet-note"]'); return /Growth › SSO for teams/.test(pn.textContent) && /Change/.test(pn.querySelector('[data-vm="nabout"]').textContent) && !pn.querySelector('.vm-nabout'); })));
126
+
127
+ /* N7 writes */
128
+ const posts = [...new Set(A.reqs.filter((r) => /^POST /.test(r)))].sort();
129
+ ok('N7 the only write is the note\'s link', posts.join() === 'POST /api/notes/link', posts.join());
130
+ const res = await fetch(BASE + '/api/notes/link', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'n-nothing', portfolio: true }) });
131
+ ok('N7 /api/notes/link without the launch nonce is refused', res.status === 403, String(res.status));
132
+ await A.ctx.close();
133
+
134
+ /* an empty store says so */
135
+ const Z = await open({ notes: [] });
136
+ ok('N2 with no notes the list says notes you record show here', Z.up && await until(() => Z.page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /No notes yet/.test((document.querySelector('#vnBody') || {}).textContent || ''))));
137
+ await Z.ctx.close();
138
+
139
+ /* N8 floors (PMOS_SHOTS=<dir> also saves pictures) */
140
+ const shotDir = process.env.PMOS_SHOTS || '';
141
+ for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
142
+ if (w === 1280 && !shotDir) continue;
143
+ const P = await open({ w, h, theme: th });
144
+ if (!P.dlg) { ok(`N8 ${w} ${th} opens`, false); await P.ctx.close(); continue; }
145
+ await P.page.click('[data-vn-fold="wk"]');
146
+ const fl = () => P.page.evaluate(() => { const pane = [...document.querySelectorAll('#oMain, #dOut .obody.vw')].find((x) => !x.hidden) || document.querySelector('#oMain');
147
+ return { scroll: document.documentElement.scrollWidth <= innerWidth + 1 && pane.scrollWidth <= pane.clientWidth + 1,
148
+ btn: [...pane.querySelectorAll('.vn-o, .vn-x, .vn-q, .vm-ph button, .vm-lk')].filter((b) => b.getClientRects().length).map((b) => Math.round(Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height))) }; });
149
+ const f0 = await fl();
150
+ if (w === 390) ok(`N8 at 390 px (${th}) the Calendar card header keeps one line and Notes sits under the day`, await P.page.evaluate(() => { const h = document.querySelector('#todayCard .ch'), r = (e) => e.getBoundingClientRect(); const bs = [...h.querySelectorAll('button')].filter((b) => b.getClientRects().length); return !document.querySelector('#vnOpen').getClientRects().length && bs.every((b) => Math.abs(r(b).top - r(bs[0]).top) < 4) && r(document.querySelector('#vnOpenFoot')).height >= 44; }));
151
+ if (shotDir) await P.page.screenshot({ path: path.join(shotDir, `list-${w}-${th}.png`) });
152
+ await P.page.click('[data-vn-note="n3"]');
153
+ await until(() => P.page.evaluate(() => /Price SSO/.test((document.querySelector('#dOut .obody.vw[data-vw="meet-note"]') || {}).textContent || '')));
154
+ const f1 = await fl();
155
+ if (shotDir) await P.page.screenshot({ path: path.join(shotDir, `note-${w}-${th}.png`) });
156
+ if (w === 390) ok(`N8 at 390 px (${th}) the list and the note have no sideways scroll and every press is at least 44 px`, f0.scroll && f1.scroll && f0.btn.length > 3 && [...f0.btn, ...f1.btn].every((n) => n >= 44), JSON.stringify([f0, f1]));
157
+ await P.ctx.close();
158
+ }
159
+ ok('N7 no page error in any run', SESS.every((x) => x.errors.length === 0), JSON.stringify(SESS.map((x) => x.errors).filter((e) => e.length)));
160
+ return finish();
161
+ })().catch((e) => { console.error(e); finish(1); });
@@ -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
+ })();
@@ -3,6 +3,7 @@
3
3
  * Coming up cards, Core documents, the dock and the standard dialog. The presses are Draft it on a core document, through POST /api/core-docs/draft,
4
4
  * and the board's own presses of pm/premium-acts.js (initiative premium-board-actions): the New asks card, New initiative, and a row's menu (move,
5
5
  * hold, cancel, archive and their Undo). Issue it on a document draft, read in a dialog, is POST /api/core-docs/issue (initiative premium-core-doc-issue). */
6
+ import { openWorkItem, recordPress } from './premium-vw-item.js';
6
7
  import { pmPost } from './http.js';
7
8
  import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, CHECK, AI, store, crumbHtml, wireCrumb, kv, H, openAddDoc, setPageGaps } from './premium-shell.js';
8
9
  import { issueBody } from './premium-doc-edit.js';
@@ -182,12 +183,13 @@ function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textConten
182
183
  function cardHtml(r) { return `<div class="acard" id="card"><p class="ct">What this page can do</p><p class="nodef" id="holdWhy">${esc(r.dialog.hold)}</p></div>`; }
183
184
  function paneHtml(r) {
184
185
  const p = r.dialog.pane;
185
- return `<article class="paper doc">${p.file ? `<p class="dpath">${esc(p.file)}</p>` : ''}${p.rows.length ? `<div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>` : ''}<p class="xn">${esc(p.note || 'The initiative as the board holds it.')}</p></article>`;
186
+ return `<article class="paper doc">${p.file ? `<p class="dpath">${esc(p.file)}</p>` : ''}${p.rows.length ? `<div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div>` : ''}<p class="xn">${esc(p.note || 'The initiative as the board holds it.')}</p>${r.id && r.dialog.eye === 'Initiative' ? recordPress() : ''}</article>`;
186
187
  }
187
188
  function openRow(r) {
188
189
  if (!r) return;
189
190
  const d = r.dialog;
190
191
  openDlg({ eye: d.eye + ' · real data', title: r.title, sub: r.sub + (r.statusLabel ? ' · ' + r.statusLabel : ''), say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.key, pane: paneHtml(r), label: d.pane.label });
192
+ const vb = $('#oMain [data-vwopen]'); if (vb) vb.onclick = () => openWorkItem({ kind: 'initiative', id: r.id, title: r.title, ws: M.board.ws, board: M.board.id }); // its record, checks, tasks and links as a viewer tab (premium-viewer S7)
191
193
  loadThread(r.key);
192
194
  if (r.key === 'board:sprint') openSprint({ ws: M.board.ws, board: M.board.id, name: r.title }); // the sprint as a board by status, beside its facts (premium-viewer S5)
193
195
  setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);