create-pmos 0.388.0 → 0.390.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 (44) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-insights-test.js +22 -27
  8. package/workspace/changelog.json +24 -0
  9. package/workspace/guide/briefing-premium.md +38 -19
  10. package/workspace/lib/briefing-premium-agent.js +3 -0
  11. package/workspace/lib/insights-premium.js +10 -8
  12. package/workspace/lib/report-chat.js +37 -0
  13. package/workspace/lib/routes-insights-premium.js +3 -1
  14. package/workspace/package-lock.json +2 -2
  15. package/workspace/package.json +1 -1
  16. package/workspace/premium-chat-chart-tab-test.js +150 -0
  17. package/workspace/premium-chat-report-tab-test.js +127 -0
  18. package/workspace/premium-report-read-test.js +99 -59
  19. package/workspace/premium-vw-slides-test.js +17 -19
  20. package/workspace/public/pm/goal-chat.js +2 -1
  21. package/workspace/public/pm/premium-chart-draw.js +58 -0
  22. package/workspace/public/pm/premium-chart-tab.js +157 -0
  23. package/workspace/public/pm/premium-chat.js +8 -2
  24. package/workspace/public/pm/premium-insights.js +39 -85
  25. package/workspace/public/pm/premium-report-brief.js +132 -0
  26. package/workspace/public/pm/premium-report-read.js +276 -103
  27. package/workspace/public/pm/premium-report-tab.js +235 -0
  28. package/workspace/public/pm/premium-shell.js +35 -3
  29. package/workspace/public/pm/premium-vw-doc.js +9 -1
  30. package/workspace/public/pm/premium-vw-report.css +60 -0
  31. package/workspace/public/pm/premium-vw-slides.js +14 -5
  32. package/workspace/public/pm/premium.css +71 -122
  33. package/workspace/public/pm/report-chat.js +89 -0
  34. package/workspace/test-lists/premium-chat-chart-tab.json +12 -0
  35. package/workspace/test-lists/premium-chat-report-tab.json +12 -0
  36. package/workspace/premium-studio-chart-test.js +0 -193
  37. package/workspace/premium-studio-report-test.js +0 -277
  38. package/workspace/premium-studio-test.js +0 -185
  39. package/workspace/public/pm/premium-studio-design.js +0 -298
  40. package/workspace/public/pm/premium-studio-report.js +0 -291
  41. package/workspace/public/pm/premium-studio.js +0 -453
  42. package/workspace/test-lists/premium-studio-chart.json +0 -13
  43. package/workspace/test-lists/premium-studio-report.json +0 -9
  44. package/workspace/test-lists/premium-studio.json +0 -9
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-chart-tab-test.js — charts and dashboards from any chat, and the Insight Studio removed (initiative premium-reports-from-chat,
4
+ * slice C; PRD C1–C3). A real server on a scratch repository whose KR metric records hold two measures with a series and one without. The thread and
5
+ * the session's conversation are routed, so Claude's answers are set here; every save goes to the real premium-charts and premium-dashboards routes.
6
+ * C1 a chart block is a chip; it opens the Chart tab with the measure drawn from its readings, as proposed (bars)
7
+ * C2 a form pick redraws the chart and writes nothing; Save chart saves it with the picked form; Delete chart asks once and removes it
8
+ * C3 a dashboard block draws its charts in order and names a measure with no series; Save dashboard saves it
9
+ * I1 Insights has no Studio: Edit on a saved dashboard opens the Chat page with its tab; New chart opens it with a first message in the box
10
+ * F1 no page error and no sideways scroll at 1280 and 390
11
+ * Set CHART_TAB_SHOTS=<dir> to save the page at 1280 and 390. */
12
+ const fs = require('fs');
13
+ const os = require('os');
14
+ const path = require('path');
15
+ const { spawn } = require('child_process');
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ const T = require('./test-run').configure({ name: 'premium-chat-chart-tab' });
18
+ const PC = require('./lib/premium-charts.js');
19
+ const PD = require('./lib/premium-dashboards.js');
20
+
21
+ const BASE = T.BASE;
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ const until = async (fn, ms = 15000, step = 150) => { 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); } };
24
+ const results = [];
25
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
26
+ let srv = null, browser = null;
27
+ const finish = async (code) => {
28
+ if (browser) await browser.close().catch(() => {});
29
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
30
+ T.killTmux();
31
+ const bad = results.filter((x) => !x.cond).length;
32
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-chart-tab assertions passed`);
33
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
34
+ };
35
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
36
+
37
+ /* the scratch repository: Partner activation (5 readings), Time to first call (2 readings), Lonely (1 reading, no series) */
38
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'chart-tab-repo-'));
39
+ const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'chart-tab-state-'));
40
+ fs.mkdirSync(path.join(dir, 'planning', 'records'), { recursive: true });
41
+ const rd = (id, rid, at, value) => ({ id, kind: 'reading', rid, fields: { at, value } });
42
+ const L = [
43
+ { id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
44
+ rd('2', 'krm-a', '2026-06-01', 20), rd('3', 'krm-a', '2026-07-01', 24), rd('4', 'krm-a', '2026-08-01', 30), rd('5', 'krm-a', '2026-09-01', 28), rd('6', 'krm-a', '2026-10-01', 33),
45
+ { id: '7', kind: 'add', rid: 'krm-t', fields: { metric: 'Time to first call', baseline: 10, target: 4, by: '2026-12-31', pillar: 'Growth', unit: ' days' } },
46
+ rd('8', 'krm-t', '2026-08-01', 9), rd('9', 'krm-t', '2026-10-01', 7),
47
+ { id: '10', kind: 'add', rid: 'krm-l', fields: { metric: 'Lonely', baseline: 1, target: 2, by: '2026-12-31' } }, rd('11', 'krm-l', '2026-10-01', 1),
48
+ ];
49
+ fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), L.map((x) => JSON.stringify(x)).join('\n') + '\n');
50
+
51
+ const block = (o) => '```pmos-report\n' + JSON.stringify(o) + '\n```';
52
+ const ASK = (t) => ({ role: 'user', text: '[PMOS report] rule\n\nThe PM says: ' + t });
53
+ const CHART = { kind: 'chart', proposal: { measure: 'krm-a', title: 'Partners activating', question: 'Are partners activating?', form: 'bars', range: null, target: 50, better: 'higher', note: '' } };
54
+ const DASH = { kind: 'dashboard', proposal: { name: 'Partner growth', purpose: 'The Monday partner review', charts: ['krm-a', 'krm-t', 'krm-l'] } };
55
+
56
+ const look = () => {
57
+ const pane = [...document.querySelectorAll('#dOut .obody.vw')].find((x) => !x.hidden && /^(chart|dashboard):/.test(x.dataset.vw || '')) || null;
58
+ return { chip: (document.querySelector('#dBody [data-report-open]') || {}).textContent || null, tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.textContent.trim()),
59
+ pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null, tiles: pane ? [...pane.querySelectorAll('.mt1')].map((t) => t.className.split(' ').slice(0, 3).join(' ')) : [],
60
+ bars: pane ? pane.querySelectorAll('.bw i').length : 0, form: pane ? ((pane.querySelector('.rt-seg [aria-pressed="true"]') || {}).textContent || null) : null,
61
+ wide: document.documentElement.scrollWidth > innerWidth + 1, say: (document.querySelector('#askIn') || {}).value || '' };
62
+ };
63
+
64
+ (async () => {
65
+ const exe = findBrowser();
66
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
67
+ let chromium;
68
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
69
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: stateDir }) });
70
+ await T.waitForServer(BASE);
71
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
72
+ const shots = process.env.CHART_TAB_SHOTS;
73
+ const board = (await (await fetch(BASE + '/api/insights-premium')).json()).model.board.id;
74
+ const open = async (width, messages, url = '/premium-chat.html') => {
75
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 860 }, hasTouch: width < 1000 });
76
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
77
+ await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-ch', goal: null } }));
78
+ await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages } }));
79
+ await p.goto(BASE + url);
80
+ await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream')));
81
+ await sleep(500);
82
+ return { p, ctx, errs };
83
+ };
84
+
85
+ { const { p, ctx, errs } = await open(1280, [ASK('chart partner activation as bars'), { role: 'assistant', text: 'Partner activation is at 33%.\n\n' + block(CHART) }]);
86
+ const s0 = await p.evaluate(look);
87
+ ok('C1 the chart block is a chip under Claude\'s words', /Partners activating/.test(s0.chip || '') && /New chart/.test(s0.chip || ''), JSON.stringify(s0));
88
+ await p.click('#dBody [data-report-open]');
89
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
90
+ ok('C1 the Chart tab draws the measure from its five readings as bars, as proposed', s1.tabs.includes('Chart') && /New chart/.test(s1.pane || '') && s1.bars === 5 && s1.form === 'Bars', JSON.stringify(s1));
91
+ if (shots) await p.screenshot({ path: `${shots}/chart-1280.png` });
92
+ await p.click('#dOut [data-ct="form|line"]');
93
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.form === 'Line' ? v : null; }) || await p.evaluate(look);
94
+ ok('C2 a form pick redraws the chart and writes nothing', s2.bars === 0 && /mch/.test(s2.tiles.join()) && PC.list(dir, board).length === 0, JSON.stringify(s2));
95
+ await p.click('#dOut [data-ct="save"]');
96
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Saved\./.test(v.pane) ? v : null; }) || await p.evaluate(look);
97
+ const saved = PC.list(dir, board);
98
+ ok('C2 Save chart saves it with the picked form; the tab shows it saved', saved.length === 1 && saved[0].form === 'line' && saved[0].measure === 'krm-a' && saved[0].title === 'Partners activating' && /Saved chart/.test(s3.pane || ''), JSON.stringify([saved, s3.pane]));
99
+ await p.click('#dOut [data-ct="remove"]');
100
+ await p.click('#dOut .vcf [data-a="1"]');
101
+ const s4 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Deleted\./.test(v.pane) ? v : null; }) || await p.evaluate(look);
102
+ ok('C2 Delete chart asks once, then the chart is removed', /Deleted\./.test(s4.pane || '') && PC.list(dir, board).length === 0, JSON.stringify(s4));
103
+ ok('F1 no page error and no sideways scroll (chart, 1280)', !errs.length && !s4.wide, errs.join(' | '));
104
+ await ctx.close(); }
105
+
106
+ { const { p, ctx, errs } = await open(1280, [ASK('a dashboard for the partner review'), { role: 'assistant', text: 'Here it is.\n\n' + block(DASH) }]);
107
+ await p.click('#dBody [data-report-open]');
108
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
109
+ ok('C3 the Dashboard tab draws two charts in order and names the measure with no series', s1.tabs.includes('Dashboard') && s1.tiles.length === 2 && /Partner growth/.test(s1.pane || '') && /Lonely/.test(s1.pane || '') && /fewer than two readings/.test(s1.pane || ''), JSON.stringify(s1));
110
+ if (shots) await p.screenshot({ path: `${shots}/dashboard-1280.png` });
111
+ await p.click('#dOut [data-ct="save"]');
112
+ await until(async () => { const v = await p.evaluate(look); return v.pane && /Saved\./.test(v.pane) ? v : null; });
113
+ const D = PD.list(dir, board);
114
+ ok('C3 Save dashboard saves it with its charts in order', D.length === 1 && D[0].name === 'Partner growth' && D[0].charts.join() === 'krm-a,krm-t,krm-l', JSON.stringify(D));
115
+ ok('F1 no page error (dashboard, 1280)', !errs.length, errs.join(' | '));
116
+ await ctx.close(); }
117
+
118
+ { const ctx = await browser.newContext({ viewport: { width: 1280, height: 860 } }), p = await ctx.newPage(), errs = [];
119
+ p.on('pageerror', (e) => errs.push(String(e)));
120
+ await p.goto(BASE + '/premium-insights.html');
121
+ await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch')));
122
+ const D = PD.list(dir, board)[0];
123
+ await p.evaluate((id) => { const r = document.querySelector(`[data-d="${id}"]`); if (r) r.click(); }, D.id);
124
+ await sleep(400);
125
+ if (await p.locator('#dashBar').isHidden()) await p.click('#dashMore');
126
+ const hasStudio = await p.evaluate(() => !!document.querySelector('#oMain .stu') || [...document.scripts].some((s) => /premium-studio/.test(s.src)));
127
+ await Promise.all([p.waitForURL(/premium-chat\.html/), p.click('#pdEdit')]);
128
+ const u1 = new URL(p.url());
129
+ await until(() => p.evaluate(() => [...document.querySelectorAll('#dOut .obody.vw')].some((x) => !x.hidden && /Partner growth/.test(x.textContent))));
130
+ const s1 = await p.evaluate(look);
131
+ ok('I1 Edit on a saved dashboard opens the Chat page with its Dashboard tab, saved', !hasStudio && u1.searchParams.get('open') === 'dashboard:' + D.id && /Saved dashboard/.test(s1.pane || ''), JSON.stringify([u1.search, s1.pane]));
132
+ await p.goto(BASE + '/premium-insights.html');
133
+ await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch')));
134
+ await p.evaluate(() => { const r = document.querySelector('[data-d="all"]'); if (r) r.click(); });
135
+ if (await p.locator('#dashBar').isHidden()) await p.click('#dashMore');
136
+ await Promise.all([p.waitForURL(/premium-chat\.html/), p.click('#pcNew')]);
137
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.say ? v : null; }) || await p.evaluate(look);
138
+ ok('I1 New chart opens the Chat page with a first message in the box, not sent', s2.say === 'Make a chart of ', JSON.stringify(s2.say));
139
+ ok('F1 no page error (Insights to Chat)', !errs.length, errs.join(' | '));
140
+ await ctx.close(); }
141
+
142
+ { const { p, ctx, errs } = await open(390, [ASK('chart partner activation'), { role: 'assistant', text: 'Here.\n\n' + block(CHART) }]);
143
+ await p.click('#dBody [data-report-open]');
144
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane && v.tiles.length ? v : null; }) || await p.evaluate(look);
145
+ ok('C1 at 390 the chip opens the Chart tab over the page', s1.bars === 5, JSON.stringify(s1));
146
+ if (shots) await p.screenshot({ path: `${shots}/chart-390.png` });
147
+ ok('F1 no page error and no sideways scroll at 390', !errs.length && !s1.wide, errs.join(' | '));
148
+ await ctx.close(); }
149
+ return finish();
150
+ })();
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-chat-report-tab-test.js — reports from any chat (initiative premium-reports-from-chat, slice B; PRD R1–R4).
4
+ * A real server on a scratch repository (c3-scan-fixture.js). The thread and the session's conversation are routed, so Claude's answers are set
5
+ * here; every report press goes to the real report-setups and report-documents routes.
6
+ * R1 at 1280 a pmos-report block is a chip under Claude's words, never JSON; opening the chat opens no tab; the chip opens the Report tab
7
+ * R2 a new answer with a block opens the Report tab by itself
8
+ * R3 a new report shows its name, audience, format, the seven sections and Schedule Off · runs once; a pick changes the chip only
9
+ * R4 Set it up with Schedule Off records the report, writes its first draft and pauses it: the tab turns into the template, schedule Off
10
+ * R5 the Schedule chip on a template changes the schedule through the route
11
+ * R6 a draft is discarded after a confirm; the template is deleted after a confirm, and the tab says its reports stay
12
+ * R7 at 390 the chip covers the page with the Report tab; no sideways scroll; no page error
13
+ * Set REPORT_TAB_SHOTS=<dir> to save the page at 1280 and 390, light and dark. */
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ require('./test-run').configure({ name: 'premium-chat-report-tab' });
18
+ const Fx = require('./c3-scan-fixture.js');
19
+ const RS = require('./lib/report-setups.js');
20
+
21
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
22
+ const until = async (fn, ms = 10000, step = 120) => { 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); } };
23
+ const results = [];
24
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
25
+ let F = null, browser = null;
26
+ const finish = async (code) => {
27
+ if (browser) await browser.close().catch(() => {});
28
+ if (F) F.stop();
29
+ const bad = results.filter((x) => !x.cond).length;
30
+ console.log(`\n${results.length - bad}/${results.length} premium-chat-report-tab assertions passed`);
31
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
32
+ };
33
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
34
+
35
+ const block = (o) => '```pmos-report\n' + JSON.stringify(o) + '\n```';
36
+ const PROP = { kind: 'report', proposal: { name: 'Social login weekly', purpose: 'Are lightbox signups growing on the site and the app?', audience: 'Growth leads', output: 'google-slides', schedule: null, sources: ['GA4', 'This chat'] } };
37
+ const ASK = { role: 'user', text: '[PMOS report] rule\n\nThe PM says: make this a report for the growth leads' };
38
+ const ANSWER = { role: 'assistant', text: 'Signups from the lightbox rose to 1,240. I drafted a report from this chat.\n\n' + block(PROP) };
39
+
40
+ const look = () => {
41
+ const g = document.querySelector('#dlg'), pane = [...document.querySelectorAll('#dOut .obody.vw[data-vw^="report:"]')].find((x) => !x.hidden) || null;
42
+ return { shut: g.classList.contains('vw-shut'), layer: g.classList.contains('vw-layer'), chip: (document.querySelector('#dBody [data-report-open]') || {}).textContent || null,
43
+ json: /pmos-report|"kind"/.test((document.querySelector('#dBody .stream') || {}).textContent || ''), user: [...document.querySelectorAll('#dBody .turn.u')].map((u) => u.textContent.trim()),
44
+ tabs: [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.textContent.trim()), pane: pane ? pane.textContent.replace(/\s+/g, ' ').trim() : null,
45
+ secs: pane ? pane.querySelectorAll('.rt-secs li').length : 0, sched: pane && pane.querySelector('.rt-chip b') ? pane.querySelector('.rt-chip b').textContent : null,
46
+ wide: document.documentElement.scrollWidth > innerWidth + 1 };
47
+ };
48
+
49
+ (async () => {
50
+ const exe = findBrowser();
51
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
52
+ let chromium;
53
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
54
+ F = await Fx.start({ name: 'premium-chat-report-tab' });
55
+ browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
56
+ const shots = process.env.REPORT_TAB_SHOTS;
57
+ const chat = `${F.BASE}/premium-chat.html?ws=${encodeURIComponent(F.ws)}`;
58
+ const ledger = () => RS.readLines(RS.ledgerFile(F.team));
59
+ const open = async (width, scheme, messages) => {
60
+ const st = { messages };
61
+ const ctx = await browser.newContext({ viewport: { width, height: width < 1000 ? 844 : 860 }, colorScheme: scheme, hasTouch: width < 1000 });
62
+ const p = await ctx.newPage(); const errs = []; p.on('pageerror', (e) => errs.push(String(e)));
63
+ await p.route('**/api/briefing-premium/thread?**', (r) => r.fulfill({ json: { ok: true, turns: [], session: 's-rep', goal: null } }));
64
+ await p.route('**/api/sessions/conversation?**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'pm', messages: st.messages } }));
65
+ await p.goto(chat);
66
+ await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#dBody .stream #thr')));
67
+ await sleep(500);
68
+ return { p, ctx, errs, st };
69
+ };
70
+
71
+ { const { p, ctx, errs, st } = await open(1280, 'light', [ASK, ANSWER]);
72
+ const s0 = await p.evaluate(look);
73
+ ok('R1 the block is a chip under Claude\'s words, never JSON; the PM\'s turn shows as typed', /Social login weekly/.test(s0.chip || '') && /New report/.test(s0.chip || '') && !s0.json && s0.user.includes('make this a report for the growth leads'), JSON.stringify(s0));
74
+ ok('R1 opening the chat opens no tab by itself', s0.tabs.length === 0, JSON.stringify(s0));
75
+ await p.click('#dBody [data-report-open]');
76
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.pane ? v : null; }) || await p.evaluate(look);
77
+ ok('R3 the Report tab shows the new report: name, audience, format, seven sections, Schedule Off', /Report/.test(s1.tabs.join(' ')) && /Social login weekly/.test(s1.pane || '') && /For Growth leads · Google Slides/.test(s1.pane || '')
78
+ && s1.secs === 7 && s1.sched === 'Off · runs once' && /Set it up/.test(s1.pane || ''), JSON.stringify(s1));
79
+ if (shots) await p.screenshot({ path: `${shots}/new-1280-light.png` });
80
+ await p.click('#dOut .rt-chip');
81
+ await p.click('#dOut .rt-menu [data-rt="pick|2"]');
82
+ const s2 = await until(async () => { const v = await p.evaluate(look); return v.sched && /Weekly/.test(v.sched) ? v : null; }) || await p.evaluate(look);
83
+ ok('R3 a pick changes the chip only: nothing is written', /Weekly, Mondays at 09:00/.test(s2.sched || '') && !ledger().some((l) => l.ev === 'setup'), JSON.stringify(s2));
84
+ await p.click('#dOut .rt-chip'); await p.click('#dOut .rt-menu [data-rt="pick|0"]');
85
+ await p.click('#dOut [data-rt="setup"]');
86
+ const s3 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Report template/.test(v.pane) ? v : null; }, 15000) || await p.evaluate(look);
87
+ const L = ledger(), setup = L.find((l) => l.ev === 'setup');
88
+ ok('R4 Set it up records the report and pauses it (Schedule Off: it runs once); the tab shows the template', !!setup && L.some((l) => l.ev === 'pause' && l.id === setup.id) && s3.sched === 'Off · runs once' && /Report template/.test(s3.pane || ''), JSON.stringify([s3, L.map((l) => l.ev)]));
89
+ ok('R4 its first draft is written and listed as a draft with Discard', /Draft/.test(s3.pane || '') && /Discard/.test(s3.pane || ''), JSON.stringify(s3));
90
+ if (shots) await p.screenshot({ path: `${shots}/template-1280-light.png` });
91
+ await p.click('#dOut .rt-chip'); await p.click('#dOut .rt-menu [data-rt="pick|3"]');
92
+ const s4 = await until(async () => { const v = await p.evaluate(look); return v.sched && /Every two weeks/.test(v.sched) ? v : null; }) || await p.evaluate(look);
93
+ const changed = RS.fold(ledger()).setups.get(setup && setup.id);
94
+ ok('R5 the Schedule chip changes a template through the route and resumes it', !!changed && changed.status === 'active' && changed.schedule.cadence === 'bi-weekly' && /Every two weeks/.test(s4.sched || ''), JSON.stringify([s4.sched, changed]));
95
+ await p.click('#dOut [data-rt^="discard|"]');
96
+ await p.click('#dOut .vcf [data-a="1"]');
97
+ const s5 = await until(async () => { const v = await p.evaluate(look); return v.pane && /The draft is discarded/.test(v.pane) ? v : null; }) || await p.evaluate(look);
98
+ ok('R6 Discard asks once, then the draft is deleted and logged', /The draft is discarded/.test(s5.pane || '') && ledger().some((l) => l.ev === 'doc-discard'), (s5.pane || '').slice(-300));
99
+ await p.click('#dOut [data-rt="remove"]');
100
+ await p.click('#dOut .vcf [data-a="1"]');
101
+ const s6 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Template deleted/.test(v.pane) ? v : null; }) || await p.evaluate(look);
102
+ ok('R6 Delete template asks once, then the template is gone and the tab says its reports stay', /Template deleted/.test(s6.pane || '') && ledger().some((l) => l.ev === 'remove'), JSON.stringify(s6));
103
+ st.messages = [ASK, ANSWER, { role: 'user', text: '[PMOS report] rule\n\nThe PM says: one for the board too' }, { role: 'assistant', text: 'Here.\n\n' + block({ kind: 'report', proposal: { ...PROP.proposal, name: 'Board summary' } }) }];
104
+ const s7 = await until(async () => { const v = await p.evaluate(look); return v.pane && /Board summary/.test(v.pane) ? v : null; }) || await p.evaluate(look);
105
+ ok('R2 a new answer with a block opens the Report tab by itself', /Board summary/.test(s7.pane || ''), JSON.stringify(s7));
106
+ ok('F1 no page error and no sideways scroll', !errs.length && !s7.wide, errs.join(' | '));
107
+ await ctx.close(); }
108
+
109
+ for (const scheme of ['light', 'dark']) {
110
+ const { p, ctx, errs } = await open(390, scheme, [ASK, ANSWER]);
111
+ if (shots) await p.screenshot({ path: `${shots}/chip-390-${scheme}.png` });
112
+ await p.click('#dBody [data-report-open]');
113
+ const s1 = await until(async () => { const v = await p.evaluate(look); return v.layer && v.pane ? v : null; }) || await p.evaluate(look);
114
+ ok(`R7 (${scheme}) at 390 the chip covers the page with the Report tab`, s1.layer && /Social login weekly/.test(s1.pane || '') && s1.secs === 7, JSON.stringify(s1));
115
+ if (shots) await p.screenshot({ path: `${shots}/new-390-${scheme}.png` });
116
+ ok(`F1 (${scheme}) no page error and no sideways scroll at 390`, !errs.length && !s1.wide, errs.join(' | '));
117
+ await ctx.close();
118
+ }
119
+ if (shots) {
120
+ const { p, ctx } = await open(1280, 'dark', [ASK, ANSWER]);
121
+ await p.click('#dBody [data-report-open]'); await sleep(500);
122
+ await p.screenshot({ path: `${shots}/new-1280-dark.png` });
123
+ await ctx.close();
124
+ }
125
+ void fs; void path;
126
+ return finish();
127
+ })();
@@ -3,7 +3,8 @@
3
3
  /* premium-report-read-test.js — a report document read on the premium Insights page (initiative premium-report-read;
4
4
  * planning/prd/premium-report-read-prd.md R1 to R11). A real server on a scratch git repository with two cycles of one report (one issued), and a
5
5
  * stub `claude` on the PATH that plays the report-design job (as c3-report-design-real-test.js does). The real page presses the real routes:
6
- * O opening · D the deck · G the page · N Present · W download · X print · L the look · I issued · P the POST allow-list · F floors
6
+ * O opening · C the cycles · D the deck · G the page · N Present · W download · X print · E edit · L the look · K the Brief · I issued
7
+ * P the POST allow-list · F floors · S issue · A archive
7
8
  * Set READ_SHOTS=<dir> to save screenshots at 1280 and 390 wide. */
8
9
  const fs = require('fs');
9
10
  const os = require('os');
@@ -99,15 +100,25 @@ fs.writeFileSync(path.join(base, 'brand.png'), PNG);
99
100
  await p.goto(BASE + '/premium-insights.html');
100
101
  await until(() => p.evaluate(() => !!document.querySelector('#listSeg [data-f="rep"]')));
101
102
  await (async (pg, sel) => { if (await pg.locator('#listSeg').isHidden()) await pg.click('#listF'); await pg.click(sel); })(p, '#listSeg [data-f="rep"]'); // the one list (insights-one-list L5): the Reports filter holds the report files
102
- await until(() => p.evaluate(() => document.querySelectorAll('#listRows [data-rep]').length === 2));
103
- const rowSel = (slot) => `#listRows [data-rep="rep:${CAD}:${slot}"]`;
103
+ await until(() => p.evaluate(() => document.querySelectorAll('#listRows [data-rpt]').length === 1));
104
+ const ROW = `#listRows [data-rpt="${CAD}"]`;
105
+ ok('C0 one row for the report, with its cycles counted (PM 2026-10-22: no duplicate of the same report)', /1 draft/.test(await p.textContent(ROW)) && /1 issued/.test(await p.textContent(ROW)), await p.textContent(ROW));
106
+ const toCycle = async (rel) => { await p.click('#dSub [data-rr="cycm"]'); await p.click(`#dSub [data-rr="cyc|${rel}"]`); };
104
107
 
105
- /* O: a document row opens the reader on the page */
106
- await tap(rowSel('2026-10-12'));
108
+ /* O: the report row opens its latest cycle in the reader on the page */
109
+ await tap(ROW);
107
110
  await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
108
111
  ok('O1 a document row opens the reader on the page, not the console', p.url().includes('/premium-insights.html') && await p.evaluate(() => document.querySelector('#dlg').classList.contains('rdrd')), p.url());
109
112
  ok('O2 the dialog names the report, its date and its state', await p.textContent('#dTitle') === CAD && /2026-10-12|12 Oct/.test(await p.textContent('#dSub')) && /draft/.test(await p.textContent('#dEye')), await p.textContent('#dEye'));
110
- ok('O3 the reader says it reads the words, as written', /The words of the document, as written/.test(await p.textContent('#rdSrc')), await p.textContent('#rdSrc'));
113
+ const bar = await p.evaluate(() => { const L = [...document.querySelectorAll('#oMain .rdbar > *')].filter((x) => x.offsetWidth); return { rows: new Set(L.map((x) => Math.round(x.getBoundingClientRect().top + x.offsetHeight / 2))).size, words: [...document.querySelectorAll('#oMain .rdbar .rdib')].filter((b) => b.textContent.trim() || !b.getAttribute('aria-label') || !b.title).length }; });
114
+ await shot('reader-bar-1280');
115
+ ok('O3 the bar is one row of icon buttons, each named by its label and tooltip', bar.rows === 1 && bar.words === 0, JSON.stringify(bar));
116
+ ok('O4 no source line, no design row and no Add a sample in the report pane', await p.evaluate(() => !document.querySelector('#rdSrc') && !document.querySelector('.rdz') && !document.querySelector('#oMain [data-rr="pick"]')));
117
+ /* C: the cycle chip under the name lists this report's cycles, grouped */
118
+ await p.click('#dSub [data-rr="cycm"]');
119
+ const cm = await p.evaluate(() => ({ chip: document.querySelector('#dSub [data-rr="cycm"]').textContent, groups: [...document.querySelectorAll('#dSub .rdcm .label')].map((x) => x.textContent), items: document.querySelectorAll('#dSub .rdcm [data-rr^="cyc|"]').length }));
120
+ ok('C1 the cycle chip says the date and 2 cycles; its menu groups them Draft and Issued', /12 Oct · 2 cycles/.test(cm.chip) && cm.groups.join() === 'Draft,Issued' && cm.items === 2, JSON.stringify(cm));
121
+ await p.click('#dSub [data-rr="cycm"]');
111
122
 
112
123
  /* D: the deck */
113
124
  ok('D1 the deck has a title slide and one slide per section', await counter() === '1 / 5' && await bigTitle() === 'Partner review, 12 Oct', await counter());
@@ -122,14 +133,18 @@ fs.writeFileSync(path.join(base, 'brand.png'), PNG);
122
133
  await shot('reader-deck-1280');
123
134
 
124
135
  /* G: the page */
125
- await tap('#oMain [data-rr="fm"]'); await tap('#oMain [data-rr="view|doc"]');
136
+ await tap('#oMain [data-rr="view|doc"]');
126
137
  const heads = await p.evaluate(() => [...document.querySelectorAll('.rdpg h3')].map((h) => h.textContent));
127
138
  ok('G1 Document shows the headings as written', heads.join() === 'Headline,Initiatives,Needs your call,Sources' && await p.evaluate(() => document.querySelector('.rdpg h2').textContent) === 'Partner review, 12 Oct', heads.join());
128
- await tap('#oMain [data-rr="fm"]'); await tap('#oMain [data-rr="view|deck"]');
139
+ await tap('#oMain [data-rr="view|deck"]');
129
140
 
130
141
  /* N: Present */
131
142
  await tap('#oMain [data-rr="go|0"]');
132
- await tap('#oMain [data-rr="rm"]'); await tap('#oMain [data-rr="present"]');
143
+ ok('B1 one bar: Slides | Page, Brief, the schedule, Edit, Present, Share, Issue and More', await p.evaluate(() => [...document.querySelectorAll('#oMain .rdbar button')].map((b) => b.dataset.rr).join()) === 'view|deck,view|doc,brief,sched,edit,present,share,issue,mo', await p.evaluate(() => [...document.querySelectorAll('#oMain .rdbar button')].map((b) => b.dataset.rr).join()));
144
+ await tap('#oMain [data-rr="sched"]');
145
+ ok('B2 a report with no template says so in its schedule menu, and offers a chat to set one up', /None/.test(await p.textContent('#oMain [data-rr="sched"]')) && /no template/.test(await p.textContent('#oMain .rdsm')) && !!await p.$('#oMain .rdsm a[href*="premium-chat.html"]'));
146
+ await tap('#oMain [data-rr="sched"]');
147
+ await tap('#oMain [data-rr="present"]');
133
148
  await until(() => p.$('#rdPres'));
134
149
  ok('N1 Present shows the current slide over the whole page', await p.evaluate(() => { const r = document.querySelector('#rdPres').getBoundingClientRect(); return r.width >= innerWidth - 1 && r.height >= innerHeight - 1 && !!document.querySelector('#rdPres .rds.title'); }));
135
150
  await p.keyboard.press('ArrowRight');
@@ -138,86 +153,103 @@ fs.writeFileSync(path.join(base, 'brand.png'), PNG);
138
153
  ok('N3 Escape stops presenting and the reader stays open on that slide', !await p.$('#rdPres') && await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')) && await counter() === '2 / 5');
139
154
 
140
155
  /* W: download */
141
- await tap('#oMain [data-rr="dm"]');
156
+ await tap('#oMain [data-rr="mo"]');
142
157
  const items = await p.evaluate(() => [...document.querySelectorAll('.rpm [role="menuitem"]')].map((a) => a.textContent.split('(')[0].trim() + '|' + (a.getAttribute('href') || '')));
143
- ok('W1 Download offers PowerPoint, Word, Excel, CSV and Markdown, through report-export', items.length === 5 && items.slice(0, 4).every((x, i) => x.includes('/api/report-export?') && x.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i]) && x.includes('path=' + encodeURIComponent(pNew))), items.join(' / '));
158
+ ok('W0 More names the file first', await p.evaluate((f) => document.querySelector('.rdmo .rdfile').textContent === f, pNew.split('/').pop()));
159
+ ok('W1 More offers PowerPoint, Word, Excel, CSV and Markdown through report-export, then Print and Discard', items.length === 7 && /Print/.test(items[5]) && /Discard/.test(items[6]) && items.slice(0, 4).every((x, i) => x.includes('/api/report-export?') && x.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i]) && x.includes('path=' + encodeURIComponent(pNew))), items.join(' / '));
144
160
  const [dl] = await Promise.all([p.waitForEvent('download'), p.click('.rpm [data-rr="dl|pptx"]')]);
145
161
  const pptx = fs.readFileSync(await dl.path());
146
162
  ok('W2 PowerPoint downloads a .pptx of the document', /\.pptx$/.test(dl.suggestedFilename()) && pptx.slice(0, 2).toString() === 'PK', dl.suggestedFilename());
147
- await tap('#oMain [data-rr="dm"]');
163
+ await tap('#oMain [data-rr="mo"]');
148
164
  const [md] = await Promise.all([p.waitForEvent('download'), p.click('.rpm [data-rr="md"]')]);
149
165
  ok('W3 Markdown downloads the file as written', fs.readFileSync(await md.path(), 'utf8') === DOC && /\.md$/.test(md.suggestedFilename()), md.suggestedFilename());
150
166
 
151
167
  /* X: print */
152
168
  await p.evaluate(() => { window.__pr = null; window.open = () => ({ document: { open() {}, write(h) { window.__pr = h; }, close() {} }, focus() {}, print() { window.__printed = true; } }); });
153
- await tap('#oMain [data-rr="rm"]'); await tap('#oMain [data-rr="print"]'); await sleep(450);
169
+ await tap('#oMain [data-rr="mo"]'); await tap('#oMain [data-rr="print"]'); await sleep(450);
154
170
  const pr = await p.evaluate(() => ({ h: window.__pr || '', printed: !!window.__printed }));
155
171
  ok('X1 Print opens the print page with one slide to a page', pr.printed && /pmos-print-deck/.test(pr.h) && (pr.h.match(/class="pmos-slide"/g) || []).length === 5 && pr.h.includes('premium-report-print.css'), pr.h.slice(0, 300));
156
172
 
157
- /* E: Edit opens the report's file as the one document page (premium-viewer S2), with this report's Present, Print and Download on its bar */
158
- await tap('#oMain [data-rr="page"]');
159
- const VP = '.obody.vw:not([hidden]) .vwdoc';
160
- await until(() => p.evaluate((v) => !!document.querySelector(v + ' .cf'), VP));
161
- ok('E1 Edit opens the report as a page in a viewer tab, with Page, Edit and Markdown', await p.evaluate((v) => { const st = window.__premiumViewer.vwState(); return st.on.startsWith('doc:') && document.querySelectorAll(v + ' .vwseg').length === 3 && /Partner review, 12 Oct/.test(document.querySelector(v + ' .cft').textContent); }, VP));
162
- ok('E2 the page bar carries Present, Print and Download', await p.evaluate((v) => ['Present', 'Print', 'Download'].every((t) => [...document.querySelectorAll(v + ' .vwdt .vwbtn')].some((b) => b.textContent.trim() === t)), VP));
163
- await p.click(VP + ' [data-vd="xm:dl"]');
164
- const pitems = await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwxmn [role="menuitem"]')].map((a) => a.getAttribute('href') || a.dataset.vwx), VP);
165
- ok('E3 its Download lists the same four files through report-export, and the Markdown file', pitems.length === 5 && pitems.slice(0, 4).every((h, i) => h.includes('/api/report-export?') && h.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i])) && pitems[4] === 'md', JSON.stringify(pitems));
166
- await p.click(VP + ' [data-vd="xm:dl"]');
167
- await p.click(VP + ' [data-vwx="present"]');
168
- await until(() => p.$('#rdPres'));
169
- ok('E4 Present from the page presents the deck over the whole page', !!(await p.$('#rdPres')) && await p.evaluate(() => window.__premiumViewer.vwState().on === 'main'));
170
- await p.keyboard.press('Escape'); await sleep(200);
173
+ /* E: Edit edits in place (PM 2026-10-22): on Page the page editor, inside the dialog, with no viewer tab; Cancel brings the report back */
174
+ await tap('#oMain [data-rr="view|doc"]');
175
+ await tap('#oMain [data-rr="edit"]');
176
+ const VP = '#rdEd .vwdoc';
177
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' .cf.editing'), VP));
178
+ ok('E1 Edit on Page opens the page editor in the dialog, in Edit, with Edit and Markdown only', await p.evaluate((v) => document.querySelectorAll(v + ' .vwseg').length === 2 && /Partner review, 12 Oct/.test(document.querySelector(v + ' .cft').textContent) && !document.querySelector(v + ' .vwbtn[data-vwx]') && !document.querySelector(v + ' [data-vd="askt"]'), VP));
179
+ ok('E2 no viewer tab is opened, and the bar keeps only Slides | Page', await p.evaluate(() => !String(window.__premiumViewer.vwState().on || '').startsWith('doc:') && [...document.querySelectorAll('#oMain .rdbar button')].map((b) => b.dataset.rr).join() === 'view|deck,view|doc'));
180
+ await p.click(VP + ' [data-vd="cancel"]');
181
+ await until(() => p.evaluate(() => !document.querySelector('#rdEd') && !!document.querySelector('#oMain [data-rr="edit"]')));
182
+ ok('E3 Cancel brings the report back', await p.evaluate(() => !!document.querySelector('#oMain .rdpg') && !document.querySelector('#rdEd')));
183
+ await tap('#oMain [data-rr="view|deck"]');
171
184
 
172
- /* L: the look */
173
- ok('L1 with no design yet, the design row shows This cycle and no version', await p.evaluate(() => [...document.querySelectorAll('.rdv button')].map((b) => b.textContent).join()) === 'This cycle' && /No sample yet/.test(await p.textContent('.rdz')));
185
+ /* L: the look (PM 2026-10-22: no This cycle / D1 / D2 row; a new look waits on one line, Use it or Keep current; samples sit above the chat box) */
186
+ ok('L1 with no design yet, there is no look line and no sample chip', await p.evaluate(() => !document.querySelector('#oMain .rdlook') && document.querySelector('#rdSmp').hidden));
174
187
  await p.setInputFiles('#rdFile', path.join(base, 'q3-deck.png'));
175
- await until(() => p.evaluate(() => /Follows q3-deck\.png/.test(document.querySelector('.rdz').textContent)));
176
- ok('L2 Add a sample adds the file, and the row says the design follows it', /Follows q3-deck\.png/.test(await p.textContent('.rdz')) && /Added "q3-deck.png"/.test(await lastA()), await lastA());
188
+ await until(() => p.evaluate(() => /q3-deck\.png/.test(document.querySelector('#rdSmp').textContent)));
189
+ ok('L2 the clip adds a sample, shown as a chip above the chat box', /Follows/.test(await p.textContent('#rdSmp')) && !await p.evaluate(() => document.querySelector('#rdSmp').hidden) && /Added "q3-deck.png"/.test(await lastA()), await lastA());
177
190
  await say('A dark title band, like the sample');
178
191
  ok('L3 a turn says PMOS is working', /PMOS is working on it/.test(await lastA()));
179
- await until(() => p.evaluate(() => /This is D1/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
180
- ok('L4 the job\'s answer shows, and D1 is shown', /Made a dark title band\. This is D1/.test(await lastA()) && await p.evaluate(() => document.querySelector('.rdv [aria-pressed="true"]').textContent) === 'D1' && /Design version D1, not saved/.test(await p.textContent('#rdSrc')), await lastA());
192
+ await until(() => p.evaluate(() => /shown in the report/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
193
+ ok('L4 the job\'s answer shows, and the new look waits on one line with Use it and Keep current', /Made a dark title band\. It is shown in the report/.test(await lastA()) && /New look ready/.test(await p.textContent('#oMain .rdlook')) && !!await p.$('#oMain [data-rr="lookuse"]') && !!await p.$('#oMain [data-rr="lookno"]'), await lastA());
181
194
  const fr = await p.evaluate(() => [...document.querySelectorAll('#oMain iframe')].map((f) => ({ sb: f.getAttribute('sandbox'), doc: f.getAttribute('srcdoc') || '' })));
182
- ok('L5 the version shows in frames with an empty sandbox, and its script and handlers were dropped', fr.length >= 1 && fr.every((f) => f.sb === '' && !/<script|onclick|steal/.test(f.doc)) && await p.evaluate(() => !window.hacked), JSON.stringify(fr.map((f) => f.sb)));
183
- ok('L6 the deck of D1 has its two slides', await counter() === '1 / 2');
195
+ ok('L5 the new look shows in frames with an empty sandbox, and its script and handlers were dropped', fr.length >= 1 && fr.every((f) => f.sb === '' && !/<script|onclick|steal/.test(f.doc)) && await p.evaluate(() => !window.hacked), JSON.stringify(fr.map((f) => f.sb)));
196
+ ok('L6 the deck of the new look has its two slides', await counter() === '1 / 2');
184
197
  await say('Add a slide for what needs your call');
185
- await until(() => p.evaluate(() => /This is D2/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
186
- ok('L7 a second turn builds D2 on D1', await counter() === '1 / 3' && await p.evaluate(() => [...document.querySelectorAll('.rdv button')].map((b) => b.textContent).join()) === 'This cycle,D1,D2', await lastA());
187
- await tap('#oMain [data-rr="ver|1"]');
188
- await until(() => p.evaluate(() => document.querySelector('.rdv [aria-pressed="true"]').textContent === 'D1'));
189
- ok('L8 picking D1 goes back to it, and says the next change builds on it', /Back to D1/.test(await lastA()) && posts.filter((x) => x === '/api/report-design/revert').length === 1, await lastA());
190
- await tap('#oMain [data-rr="keep"]');
191
- await until(() => p.evaluate(() => /Saved as the design/.test(document.querySelector('.rdz').textContent)));
192
- ok('L9 This is it saves D1 as the design and says the cycle is drawn to match', /Saved D1 as the design of this report/.test(await lastA()) && !await p.$('#oMain [data-rr="keep"]'), await lastA());
193
- await until(() => p.evaluate(() => !/PMOS is working/.test(document.querySelector('.rdz').textContent)), 30000);
194
- await tap('#oMain [data-rr="ver|cycle"]');
195
- await until(() => p.evaluate(() => /drawn to the saved design/.test(document.querySelector('#rdSrc').textContent)), 10000);
196
- ok('L10 this cycle, redrawn, shows in the saved design in sandboxed frames', /This cycle, drawn to the saved design D1/.test(await p.textContent('#rdSrc')) && await bigTitle() === 'frame' && await p.evaluate(() => [...document.querySelectorAll('#oMain iframe')].every((f) => f.getAttribute('sandbox') === '')), await p.textContent('#rdSrc'));
198
+ await until(() => p.evaluate(() => /Added a slide/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
199
+ ok('L7 a second turn builds on it, and the line names the latest request', await counter() === '1 / 3' && /Add a slide for what needs your call/.test(await p.textContent('#oMain .rdlook')), await lastA());
200
+ const nPosts = posts.length;
201
+ await tap('#oMain [data-rr="lookno"]');
202
+ await until(() => p.evaluate(() => !document.querySelector('#oMain .rdlook')));
203
+ ok('L8 Keep current, with no look saved yet, puts the line away, shows the words again and posts nothing', await counter() === '1 / 5' && posts.length === nPosts && /Kept the current look/.test(await lastA()), await lastA());
204
+
205
+ /* K: the Brief, in its own viewer tab */
206
+ await tap('#oMain [data-rr="brief"]');
207
+ await until(() => p.evaluate(() => !!document.querySelector('[data-vw="brief:partner-review"] .rbs')));
208
+ const BR = '[data-vw="brief:partner-review"]';
209
+ const bk = await p.evaluate((B) => ({ tab: window.__premiumViewer.vwState().on, heads: [...document.querySelectorAll(B + ' .rbs h4')].map((h) => h.firstChild.textContent), conf: (document.querySelector(B + ' .rbto') || {}).textContent || '', glance: document.querySelector(B + ' #rb-glance').textContent }), BR);
210
+ ok('K1 Brief opens in its own viewer tab, not beside the report', bk.tab === 'brief:partner-review', JSON.stringify(bk));
211
+ ok('K2 a report with no template says so: no schedule, and a question to confirm', /None: it has no template/.test(bk.glance) && /1 to confirm/.test(bk.conf) && /no template/.test(await p.textContent(BR + ' #rb-open')), JSON.stringify(bk));
212
+ ok('K3 Why it looks like this lists the sample and the earlier looks, each with Go back to it', /q3-deck\.png/.test(await p.textContent(BR + ' #rb-design')) && await p.evaluate((B) => document.querySelectorAll(B + ' [data-rb^="back|"]').length === 2, BR));
213
+ await p.click(BR + ' [data-rb="back|1"]');
214
+ await until(() => p.evaluate(() => !!document.querySelector('#oMain .rdlook')));
215
+ ok('K4 Go back to it shows that earlier look in the report with the Use it line', /A dark title band, like the sample/.test(await p.textContent('#oMain .rdlook')) && await counter() === '1 / 2' && posts.filter((x) => x === '/api/report-design/revert').length === 1, await p.textContent('#oMain .rdlook'));
216
+ await tap('#oMain [data-rr="lookuse"]');
217
+ await until(() => p.evaluate(() => /This look is now the design/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 15000);
218
+ ok('L9 Use it saves the look as the design and puts the line away', !await p.$('#oMain .rdlook') && posts.filter((x) => x === '/api/report-design/accept').length === 1, await lastA());
219
+ await until(() => bigTitle().then((t) => t === 'frame'), 30000);
220
+ ok('L10 this cycle, redrawn, shows in the saved design in sandboxed frames', await bigTitle() === 'frame' && await p.evaluate(() => [...document.querySelectorAll('#oMain iframe')].every((f) => f.getAttribute('sandbox') === '')));
197
221
  await shot('reader-look-1280');
198
222
  await p.setInputFiles('#rdFile', path.join(base, 'brand.png'));
199
- await until(() => p.evaluate(() => /brand\.png/.test(document.querySelector('.rdz').textContent)));
200
- ok('L11 each sample has its own remove button, named for the sample', await p.evaluate(() => [...document.querySelectorAll('.rdz [data-rr^="unsample|"]')].map((b) => b.getAttribute('aria-label')).join()) === 'Remove the sample q3-deck.png,Remove the sample brand.png');
201
- await tap('#oMain [aria-label="Remove the sample q3-deck.png"]');
202
- await until(() => p.evaluate(() => !/q3-deck\.png/.test(document.querySelector('.rdz').textContent)));
203
- ok('L12 removing a sample drops it from the row, keeps the other, and says the next version stops following it', /Follows brand\.png/.test(await p.textContent('.rdz')) && !/q3-deck/.test(await p.textContent('.rdz')) && /Removed "q3-deck.png"\. The next version and each new cycle no longer follow it/.test(await lastA()), await lastA());
223
+ await until(() => p.evaluate(() => /brand\.png/.test(document.querySelector('#rdSmp').textContent)));
224
+ ok('L11 each sample chip has its own remove button, named for the sample', await p.evaluate(() => [...document.querySelectorAll('#rdSmp [data-rr^="unsample|"]')].map((b) => b.getAttribute('aria-label')).join()) === 'Remove the sample q3-deck.png,Remove the sample brand.png');
225
+ await p.click('#rdSmp [aria-label="Remove the sample q3-deck.png"]');
226
+ await until(() => p.evaluate(() => !/q3-deck\.png/.test(document.querySelector('#rdSmp').textContent)));
227
+ ok('L12 removing a sample drops its chip, keeps the other, and says the next version stops following it', /brand\.png/.test(await p.textContent('#rdSmp')) && /Removed "q3-deck.png"\. The next version and each new cycle no longer follow it/.test(await lastA()), await lastA());
228
+ await tap(BR + ' [data-rb="fix|Why it looks like this"]');
229
+ const fixT = await p.evaluate(() => document.querySelector('#rdIn').value);
230
+ ok('K5 Correct puts the section in the chat box', fixT === 'Correct "Why it looks like this": ', fixT);
231
+ await p.fill('#rdIn', 'Correct "Why it looks like this": the title band is navy'); await p.press('#rdIn', 'Enter');
232
+ await until(() => p.evaluate(() => /no template yet/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 10000);
233
+ ok('K6 a correction of a report with no template says how to set one up, and posts nothing', /no template yet/.test(await lastA()) && posts[posts.length - 1] === '/api/report-design/unsample', await lastA());
204
234
  await p.click('#dClose'); await sleep(200);
205
235
 
206
- /* I: an issued cycle is frozen */
207
- await tap(rowSel('2026-10-05'));
236
+ /* I: an issued cycle is frozen; the cycle chip opens it */
237
+ await tap(ROW);
208
238
  await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
209
- ok('I1 an issued cycle has no design versions and no turn, and says it is frozen', !await p.$('#rdF') && !await p.$('.rdv') && /issued, so it is frozen/.test(await p.textContent('.rdz')) && /issued/.test(await p.textContent('#dEye')));
239
+ await toCycle(pOld);
240
+ await until(() => p.evaluate(() => /issued/.test(document.querySelector('#dEye').textContent) && !!document.querySelector('#rdSlide')));
241
+ ok('I1 the cycle chip reads the issued cycle: no turn, no Edit, no Issue, and it says it is frozen', !await p.$('#rdF') && !await p.$('#oMain .rdlook') && !await p.$('#oMain [data-rr="edit"]') && !await p.$('#oMain [data-rr="issue"]') && /issued, so it is frozen/.test(await p.textContent('#dBody .stream')) && /5 Oct/.test(await p.textContent('#dSub')));
210
242
  ok('I2 an issued cycle still reads as a deck', await counter() === '1 / 3');
211
243
  await p.click('#dClose'); await sleep(200);
212
244
 
213
245
  /* P: the writes */
214
- const allowed = new Set(['/api/report-design/describe', '/api/report-design/sample', '/api/report-design/turn', '/api/report-design/accept', '/api/report-design/revert', '/api/report-design/unsample']);
215
- ok('P1 before Issue, the only POSTs are the report-design describe, sample, unsample, turn, accept and revert routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
246
+ const allowed = new Set(['/api/report-design/describe', '/api/report-design/sample', '/api/report-design/turn', '/api/report-design/accept', '/api/report-design/revert', '/api/report-design/unsample', '/api/report-structure/turn']);
247
+ ok('P1 before Issue, the only POSTs are the report-design describe, sample, unsample, turn, accept and revert routes and the structure turn of a correction', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
216
248
  ok('P2 the first turn described the look first, and each later press posted once', posts.join() === ['sample', 'describe', 'turn', 'turn', 'revert', 'accept', 'sample', 'unsample'].map((x) => '/api/report-design/' + x).join(), posts.join());
217
249
  ok('P3 the document file is unchanged', fs.readFileSync(path.join(dir, pNew), 'utf8') === DOC);
218
250
 
219
251
  /* F: floors */
220
- await tap(rowSel('2026-10-12'));
252
+ await tap(ROW);
221
253
  await until(() => p.evaluate(() => !!document.querySelector('#rdSlide')));
222
254
  const small = await p.evaluate(() => [...document.querySelectorAll('#oMain button, #oMain a')].filter((b) => b.offsetParent && !b.closest('.rdt')).map((b) => { return { t: (b.textContent || b.getAttribute('aria-label') || '').trim().slice(0, 30), h: b.offsetHeight }; }).filter((x) => x.h < 44 && x.t !== 'Open in the console'));
223
255
  ok('F1 every control of the reader is at least 44 px tall', small.length === 0, JSON.stringify(small));
@@ -235,10 +267,18 @@ fs.writeFileSync(path.join(base, 'brand.png'), PNG);
235
267
  const small2 = await p.evaluate(() => [...document.querySelectorAll('[data-issue-bar] button')].filter((b) => b.offsetHeight < 44).length);
236
268
  ok('S3 the confirm buttons are at least 44 px tall', small2 === 0);
237
269
  await p.click('#oMain [data-rr="issueok"]');
238
- ok('S4 Issue it issues the cycle on the report route and the reader says it is frozen', await until(() => p.evaluate(() => /issued/.test(document.querySelector('#dEye').textContent) && !document.querySelector('#oMain [data-rr="issue"]') && /Issued/.test(document.querySelector('#oMain .dsm2').textContent)), 15000)
270
+ ok('S4 Issue it issues the cycle on the report route and the reader says it is frozen', await until(() => p.evaluate(() => /issued/.test(document.querySelector('#dEye').textContent) && !document.querySelector('#oMain [data-rr="issue"]') && /Issued/.test(document.querySelector('#oMain .rdst').textContent)), 15000)
239
271
  && posts.slice(before).join() === '/api/report/issue', posts.slice(before).join());
240
272
  await shot('reader-issued-1280');
241
273
  ok('S5 the issue is recorded in the issues ledger', issues.isIssued(issues.readIssues(dir), CAD, '2026-10-12'));
274
+ /* A: an issued cycle archives from ⋯, after one confirm, and comes back */
275
+ const b2 = posts.length;
276
+ await tap('#oMain [data-rr="mo"]'); await tap('#oMain [data-rr="archive"]');
277
+ ok('A1 Archive first asks, and posts nothing', await until(() => p.$('[data-ask-bar="archive"]')) && posts.length === b2);
278
+ await tap('#oMain [data-rr="askok"]');
279
+ ok('A2 Archive it posts the archive route and the chip says Archived', await until(() => p.evaluate(() => /Archived/.test(document.querySelector('#oMain .rdst').textContent)), 8000) && posts.slice(b2).join() === '/api/report-documents/archive', posts.slice(b2).join());
280
+ await tap('#oMain [data-rr="mo"]'); await tap('#oMain [data-rr="unarchive"]');
281
+ ok('A3 Bring back undoes it', await until(() => p.evaluate(() => !/Archived/.test(document.querySelector('#oMain .rdst').textContent)), 8000));
242
282
  ok('F3 no page error', errs.length === 0, errs.join(' | '));
243
283
  return finish();
244
284
  })().catch((e) => { console.error(e); finish(1); });