create-pmos 0.387.0 → 0.389.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 (37) hide show
  1. package/package.json +25 -25
  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-insights-test.js +16 -21
  7. package/workspace/changelog.json +24 -0
  8. package/workspace/guide/briefing-premium.md +19 -9
  9. package/workspace/lib/briefing-premium-agent.js +3 -0
  10. package/workspace/lib/report-chat.js +37 -0
  11. package/workspace/lib/report-setups.js +49 -7
  12. package/workspace/lib/routes-report-setups.js +38 -7
  13. package/workspace/package-lock.json +2 -2
  14. package/workspace/package.json +1 -1
  15. package/workspace/premium-chat-chart-tab-test.js +150 -0
  16. package/workspace/premium-chat-report-tab-test.js +127 -0
  17. package/workspace/public/pm/goal-chat.js +2 -1
  18. package/workspace/public/pm/premium-chart-draw.js +58 -0
  19. package/workspace/public/pm/premium-chart-tab.js +157 -0
  20. package/workspace/public/pm/premium-chat.js +8 -2
  21. package/workspace/public/pm/premium-insights.js +17 -79
  22. package/workspace/public/pm/premium-report-tab.js +233 -0
  23. package/workspace/public/pm/premium-shell.js +35 -3
  24. package/workspace/public/pm/premium-vw-report.css +60 -0
  25. package/workspace/public/pm/premium.css +1 -120
  26. package/workspace/public/pm/report-chat.js +89 -0
  27. package/workspace/test-lists/premium-chat-chart-tab.json +12 -0
  28. package/workspace/test-lists/premium-chat-report-tab.json +12 -0
  29. package/workspace/premium-studio-chart-test.js +0 -193
  30. package/workspace/premium-studio-report-test.js +0 -277
  31. package/workspace/premium-studio-test.js +0 -185
  32. package/workspace/public/pm/premium-studio-design.js +0 -298
  33. package/workspace/public/pm/premium-studio-report.js +0 -291
  34. package/workspace/public/pm/premium-studio.js +0 -453
  35. package/workspace/test-lists/premium-studio-chart.json +0 -13
  36. package/workspace/test-lists/premium-studio-report.json +0 -9
  37. package/workspace/test-lists/premium-studio.json +0 -9
@@ -1,277 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* premium-studio-report-test.js — the Insight Studio's Report mode on the premium Insights page (initiative premium-studio-report;
4
- * planning/prd/premium-studio-report-prd.md R1 to R13). A real server on a scratch git repository with KR metric records, and a stub `claude` on the PATH that
5
- * plays the report-structure job (as c3-report-structure-real-test.js does). The real page presses the real routes:
6
- * O opening · K the checks · C the conversation · U Undo · B the brief · S set it up · H shaping a set-up report · L the library · P the POST allow-list · F floors
7
- * Set STUDIO_SHOTS=<dir> to save screenshots of a new report and a set-up report, at 1280 and 390 wide. */
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-studio-report' });
14
- const RS = require('./lib/report-setups.js');
15
- const S = require('./lib/report-structure.js');
16
-
17
- const BASE = T.BASE;
18
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
- const until = async (fn, ms = 20000, 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); } };
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(), 'studio-report-'));
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-studio-report 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 with a series, so the page draws; a git repository, so a report draft can be written */
36
- const dir = path.join(base, 'repo'), stateDir = path.join(base, 'state'), fakeBin = path.join(base, 'bin'), fakeHome = path.join(base, 'home');
37
- for (const d of [path.join(dir, 'planning', 'records'), stateDir, fakeBin, 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), rd('4', 'krm-a', '2026-10-01', 33),
42
- ].map((x) => JSON.stringify(x)).join('\n') + '\n');
43
- fs.mkdirSync(path.join(dir, 'planning', 'initiatives'), { recursive: true });
44
- fs.writeFileSync(path.join(dir, 'planning', 'initiatives', 'partner-activation.md'), '---\ntype: Initiative\ntitle: "Partner activation"\nid: partner-activation\nlane: feature\nparent_kr: q4:o1:kr1\n---\n\n# Partner activation\n');
45
- const git = (...a) => execFileSync('git', a, { cwd: dir, stdio: 'ignore' });
46
- 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');
47
- /* The stub plays the structure job: the first turn builds a plan with five sections; a later turn builds on the previous version. Any other run is a no-op. */
48
- fs.writeFileSync(path.join(fakeBin, 'claude'), `#!/usr/bin/env node
49
- const fs = require('fs');
50
- let input = ''; process.stdin.on('data', (d) => { input += d; }); process.stdin.on('end', () => {
51
- const line = (k) => { const m = new RegExp('^- ' + k + ': (.*)$', 'm').exec(input); return m ? m[1].trim() : null; };
52
- const mode = line('Mode'); const out = line('Output path');
53
- const done = (o) => { process.stdout.write(JSON.stringify({ type: 'result', subtype: 'success', is_error: false, result: typeof o === 'string' ? o : JSON.stringify(o), num_turns: 2, duration_ms: 500, permission_denials: [] })); process.exit(0); };
54
- if (out && /\\.html$/.test(out) && /HTML contract/.test(input)) { // a report-design turn: two slides
55
- const sec = (id, title) => '<section class="pmos-slide" data-slide-id="' + id + '" data-kind="title" data-title="' + title + '"><h2>' + title + '</h2></section>';
56
- fs.writeFileSync(out, '<style>.pmos-slide{width:1280px;height:720px}</style>' + sec('title', 'Report') + sec('headline', 'Headline'));
57
- return setTimeout(() => done({ answer: 'Built the first look.', took: [], rules: { same: ['The order'], changes: [], learned: [] } }), 400);
58
- }
59
- if (!mode || !out || mode === 'dry') return done('Done.');
60
- const prev = line('Previous version');
61
- const plan = prev && prev.startsWith('/') ? JSON.parse(fs.readFileSync(prev, 'utf8')) : {
62
- purpose: { readers: 'Leadership', decision: 'Whether partners activate fast enough', scope: 'Partners', cadence: 'monthly', questions: ['Are partners activating?'] },
63
- sources: [{ id: 'board', kind: 'pmos-level', name: 'Board', ref: 'board', use: 'The KR metric records', state: 'reached' }],
64
- charts: [{ id: 'act', chart: null, name: 'Partner activation', source: 'board', from: 'KR metric record', how: 'Latest reading', compare: 'Previous reading', flag: 'Below the line', question: 'Are partners activating?', query: '', why: 'The KR' }],
65
- outline: [{ id: 'headline', title: 'Headline', fixed: true, charts: [], notes: '', show: 'Text' }, { id: 'funnel', title: 'Activation', charts: ['act'], notes: 'The KR against its line', show: 'Chart' },
66
- { id: 'changes', title: 'What changed', charts: [], notes: '', show: 'List' }, { id: 'needs', title: 'Needs your call', fixed: true, charts: [], notes: '', show: 'List' }, { id: 'sources', title: 'Sources', fixed: true, charts: [], notes: '', show: 'List' }],
67
- options: [],
68
- };
69
- fs.writeFileSync(out, JSON.stringify(plan));
70
- setTimeout(() => done({ answer: prev && prev.startsWith('/') ? 'Kept the sections as they are.' : 'Built the first version: the headline, activation, what changed, needs your call and sources.' }), 600);
71
- });
72
- `, { mode: 0o755 });
73
- const model = async () => (await (await fetch(BASE + '/api/insights-premium')).json()).model;
74
-
75
- (async () => {
76
- const exe = findBrowser();
77
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
78
- let chromium;
79
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
80
- srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore',
81
- 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, PATH: fakeBin + path.delimiter + process.env.PATH }) });
82
- await T.waitForServer(BASE);
83
- browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
84
-
85
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
86
- p.on('pageerror', (e) => errs.push(String(e)));
87
- const turnBodies = [];
88
- p.on('request', (r) => { if (r.method() === 'POST') { posts.push(new URL(r.url()).pathname); if (/report-design\/turn$/.test(r.url())) turnBodies.push(r.postData() || ''); } });
89
- await p.goto(BASE + '/premium-insights.html');
90
- await until(() => p.evaluate(() => !!document.querySelector('#repNew')));
91
- const M0 = await model(), bname = M0.board.name;
92
- const say = async (t, ms = 150) => { await p.fill('#stIn', t); await p.press('#stIn', 'Enter'); await sleep(ms); return p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; }); };
93
- const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
94
- const chipv = (k) => p.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
95
- const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
96
- const secs = () => p.evaluate(() => [...document.querySelectorAll('#stPv .stsec h4')].map((h) => h.firstChild.textContent));
97
- const tap = (sel) => p.$eval(sel, (b) => b.click());
98
- const mode = () => p.evaluate(() => (document.querySelector('#oMain .stmd [aria-pressed="true"]') || {}).textContent || '');
99
- const shot = async (n) => { if (process.env.STUDIO_SHOTS) await p.screenshot({ path: path.join(process.env.STUDIO_SHOTS, n + '.png') }); };
100
- const cta = () => p.evaluate(() => { const b = document.querySelector('#stFt [data-st="save"]'); return b ? b.textContent + (b.disabled ? ':off' : ':on') : ''; });
101
-
102
- /* O: New report opens the Studio in Report mode */
103
- await p.click('#listNew'); await p.click('#repNew');
104
- await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu')));
105
- ok('O1 New report opens the Studio in Report mode, with the brief of the mockup', await mode() === 'Report' && await chipv('title') === bname + ' weekly report' && await chipv('purpose') === 'Not set'
106
- && await chipv('aud') === 'The team' && await chipv('out') === 'Google Doc' && await chipv('sched') === 'Weekly, Mondays at 09:00' && await chipv('from') === 'Your work' && await chipv('secs') === '7', [await mode(), await chipv('title'), await chipv('sched')].join());
107
- ok('O2 the preview lists the frozen frame, headline first and sources last', (await secs()).join() === 'Headline,Timeline,Initiatives,New since last report,Decided this cycle,Needs your call,Sources', (await secs()).join());
108
-
109
- /* K and C: the checks and the conversation */
110
- ok('K1 without what it answers, 4 of 5 checks pass', await checksTxt() === '4 of 5 checks pass', await checksTxt());
111
- let a = await say('It answers: Are partners activating fast enough?');
112
- ok('C1 "it answers" sets What it answers, and 5 of 5 checks pass', await chipv('purpose') === 'Are partners activating fast enough?' && await checksTxt() === '5 of 5 checks pass', a);
113
- a = await say('for leadership, monthly');
114
- ok('C2 one turn sets the audience and the schedule', await chipv('aud') === 'Leadership' && await chipv('sched') === 'Monthly on the 1st at 09:00', a);
115
- ok('K2 leadership with a document fails "The format fits the audience"', await checksTxt() === '4 of 5 checks pass', await checksTxt());
116
- await tap('#oMain [data-st="ck"]'); await sleep(100);
117
- const fix = await p.evaluate(() => [...document.querySelectorAll('#stCk .sucl li.bad button')].map((b) => b.textContent));
118
- ok('K3 the failing check offers its fix', fix.join() === 'Make it slides', fix.join());
119
- await tap('#stCk .sucl li.bad button'); await sleep(150);
120
- ok('K4 the fix makes it slides, and the checks pass', await chipv('out') === 'Google Slides' && await checksTxt() === '5 of 5 checks pass');
121
- a = await say('leave out the timeline');
122
- ok('C3 a request to change a section of a new report changes nothing and says why', /^I changed nothing: a new report always has the same sections/.test(a) && (await secs()).length === 7, a);
123
- a = await say('call it Partner review, every two weeks on Thursday');
124
- ok('C4 one turn names it and sets every other Thursday', await chipv('title') === 'Partner review' && await chipv('sched') === 'Every other Thursday at 09:00', a);
125
- await tap('#oMain [data-st="undo"]'); await sleep(150);
126
- ok('U1 Undo steps back one turn', await chipv('title') === bname + ' weekly report' && await chipv('sched') === 'Monthly on the 1st at 09:00', await chipv('title'));
127
- await say('call it Partner review');
128
- await shot('report-new-1280');
129
- ok('C5 no turn on a new report posted anything', posts.length === 0, posts.join());
130
-
131
- /* B: the brief and its tray */
132
- await tap('#oMain [data-st="chip|from"]'); await sleep(100);
133
- const from = await p.evaluate(() => [...document.querySelectorAll('#stTr .sto b')].map((b) => b.textContent));
134
- ok('B1 Draw from offers your work and the board\'s dashboard', from.join() === 'Your work,The board\'s dashboard', from.join());
135
- await tap('#stTr [data-st="set|from|dash"]'); await sleep(100);
136
- ok('B2 the board\'s dashboard has no fixed frame to list, and says what it draws', await chipv('from') === 'The board\'s dashboard' && (await secs()).length === 0 && /dashboard: each of its charts/.test(await p.evaluate(() => document.querySelector('#stPv').textContent)));
137
- await tap('#oMain [data-st="chip|from"]'); await sleep(100); await tap('#stTr [data-st="set|from|work"]'); await sleep(100);
138
- await tap('#oMain [data-st="chip|sched"]'); await sleep(100);
139
- await tap('#stTr [data-st="set|cadence|weekly"]'); await sleep(100);
140
- await tap('#oMain [data-st="chip|sched"]'); await sleep(100);
141
- await tap('#stTr [data-st="set|day|Tue"]'); await sleep(100);
142
- ok('B3 the Schedule tray sets weekly on a Tuesday', await chipv('sched') === 'Weekly, Tuesdays at 09:00', await chipv('sched'));
143
- await tap('#oMain [data-st="chip|aud"]'); await sleep(100);
144
- await p.fill('#stI', 'Leadership team'); await sleep(150);
145
- ok('B4 the Audience field sets the audience as it is typed', await chipv('aud') === 'Leadership team');
146
- await p.press('#stI', 'Enter'); await sleep(100);
147
-
148
- /* S: set it up */
149
- await tap('#oMain [data-st="save"]');
150
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
151
- const st0 = [...RS.fold(RS.readLines(RS.ledgerFile(dir))).setups.values()];
152
- const su = st0[0] || {};
153
- ok('S1 Set it up writes one setup with what the brief shows', st0.length === 1 && su.name === 'Partner review' && su.audience === 'Leadership team' && su.output === 'google-slides' && su.source === 'work'
154
- && su.schedule.cadence === 'weekly' && su.schedule.day === 'Tue' && su.purpose === 'Are partners activating fast enough?', JSON.stringify(su));
155
- const toastT = await p.evaluate(() => (document.querySelector('#toast') || {}).textContent || '');
156
- const draftRel = (/first draft is (\S+\.md)/.exec(toastT) || [])[1];
157
- ok('S2 the answer says where the first draft is, and the file is there', !!draftRel && fs.existsSync(path.join(dir, draftRel)), toastT);
158
- ok('S3 Set it up posted the setup route only', posts.join() === '/api/report-setups/setup', posts.join());
159
-
160
- /* H: shape the set-up report */
161
- await until(() => p.evaluate((id) => !!document.querySelector(`#repBody [data-setup="${id}"]`), su.id));
162
- await p.click(`#repBody [data-setup="${su.id}"]`);
163
- await until(() => p.evaluate(() => !!document.querySelector('#oMain [data-rx="studio"]')));
164
- await tap('#oMain [data-rx="studio"]');
165
- await until(() => p.evaluate(() => !!document.querySelector('#oMain .stu')) && chipv('ver').then((v) => v === 'None yet'));
166
- ok('H1 Shape it in the Studio opens Report mode on the report, with no structure yet', await mode() === 'Report' && await chipv('facts') === 'Partner review' && await chipv('ver') === 'None yet' && (await secs()).length === 7, [await mode(), await chipv('facts'), (await secs()).join()].join(' | '));
167
- await tap('#oMain [data-st="chip|secs"]'); await sleep(100);
168
- ok('H2 with no structure, the sections cannot be left out by press, and the fixed ones say Always in', await p.evaluate(() => document.querySelectorAll('#stTr [data-st^="rsec|"]').length === 0 && [...document.querySelectorAll('#stTr .stlc small')].length === 3));
169
- ok('K5 with no structure, "The version shown is saved" fails, and seven sections are long for a leadership audience', await checksTxt() === '3 of 5 checks pass' && await cta() === 'Use this structure:off', await checksTxt() + ' ' + await cta());
170
- await p.fill('#stIn', 'Shape it for the partner review'); await p.press('#stIn', 'Enter');
171
- ok('H3 a turn shows PMOS working', await until(() => lastA().then((x) => x === 'PMOS is working on it.'), 3000));
172
- await until(() => chipv('ver').then((v) => v === 'S1, not saved'), 30000);
173
- a = await lastA();
174
- ok('H4 the job\'s answer replaces the working line, and S1 is shown', /^Built the first version/.test(a) && /Shown: S1, not saved yet\./.test(a) && (await secs()).join() === 'Headline,Activation,What changed,Needs your call,Sources', a + ' ' + (await secs()).join());
175
- ok('H5 the turn posted report-structure/turn', posts.includes('/api/report-structure/turn'), posts.join());
176
- await until(() => p.evaluate(() => !!document.querySelector('#stTr [data-st="rsec|changes"]')), 3000);
177
- await tap('#stTr [data-st="rsec|changes"]');
178
- await until(() => chipv('ver').then((v) => v === 'S2, not saved'));
179
- ok('H6 Leave out makes the next version without the section', (await secs()).join() === 'Headline,Activation,Needs your call,Sources' && posts.includes('/api/report-structure/remove'), (await secs()).join());
180
- await tap('#oMain [data-st="undo"]');
181
- await until(() => chipv('ver').then((v) => v === 'S1, not saved'));
182
- ok('U2 Undo on a set-up report goes back one version', (await secs()).length === 5 && posts.includes('/api/report-structure/revert'));
183
- ok('K6 Leadership with five sections passes the length check; the unsaved version fails', await checksTxt() === '4 of 5 checks pass', await checksTxt());
184
- await tap('#oMain [data-st="save"]');
185
- await until(() => chipv('ver').then((v) => v === 'S1, saved'));
186
- const sv = S.stateOf(dir, su.id).saved;
187
- ok('H7 Use this structure saves the version shown, and is then not offered', sv && sv.n === 1 && await cta() === 'Use this structure:off' && await checksTxt() === '5 of 5 checks pass', JSON.stringify(sv) + ' ' + await cta());
188
-
189
- /* R: the conversation is kept; opening the report again shows it */
190
- await p.click('#dlg [aria-label="Close"], #dlg .dx, #dClose').catch(() => {});
191
- await tap('#oMain [data-st="cancel"]'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
192
- await until(() => p.evaluate((id) => !!document.querySelector(`#repBody [data-setup="${id}"]`), su.id));
193
- await p.click(`#repBody [data-setup="${su.id}"]`);
194
- await until(() => p.evaluate(() => !!document.querySelector('#oMain [data-rx="studio"]')));
195
- await tap('#oMain [data-rx="studio"]');
196
- ok('R1 opening the report again shows what was said before', await until(() => p.evaluate(() => document.body.textContent.includes('Shape it for the partner review') && document.body.textContent.includes('Built the first version')), 5000));
197
- /* D: the Design tab of a set-up report */
198
- const dver = () => p.evaluate(() => [...document.querySelectorAll('#stPv [data-st^="dzver|"]')].map((b) => b.textContent.trim() + (b.getAttribute('aria-pressed') === 'true' ? '*' : '')).join());
199
- await p.click('#oMain [data-st="rtab|design"]');
200
- await until(() => chipv('dsv').then((v) => v === 'None yet'));
201
- ok('D1 the Design tab opens with no version yet, and the tab is pressed', await chipv('dsv') === 'None yet' && await p.evaluate(() => (document.querySelector('#oMain .stsub [aria-pressed="true"]') || {}).textContent) === '2 Design' && await cta() === 'This is it:off', await chipv('dsv'));
202
- await tap('#oMain [data-st="chip|dfmt"]'); await sleep(100);
203
- const fmtBtns = () => p.evaluate(() => [...document.querySelectorAll('#stTr [data-st^="dzfmt|"]')].map((b) => b.textContent + (b.getAttribute('aria-pressed') === 'true' ? '*' : '')).join());
204
- ok('F5 the Format chip offers Deck and Document, on Deck, and no first description is posted', await chipv('dfmt') === 'Deck' && await fmtBtns() === 'Deck*,Document' && !posts.includes('/api/report-design/describe'), await fmtBtns());
205
- await tap('#stTr [data-st="dzfmt|doc"]'); await sleep(200);
206
- ok('F6 Document is chosen for the next version before any description exists, without a post', await chipv('dfmt') === 'Document' && !posts.includes('/api/report-design/describe'), await chipv('dfmt'));
207
- await tap('#stTr [data-st="dzfmt|deck"]'); await sleep(200);
208
- await tap('#oMain [data-st="chip|dsmp"]'); await sleep(100);
209
- await p.setInputFiles('#dzFile', { name: 'sample.png', mimeType: 'image/png', buffer: Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', 'base64') });
210
- ok('D2 a sample file is added and listed', await until(() => p.evaluate(() => /sample\.png/.test((document.querySelector('#stTr') || {}).textContent || '') || /Added "sample\.png"/.test(document.body.textContent)), 8000) && posts.includes('/api/report-design/sample'), posts.join());
211
- await p.fill('#stIn', 'make it clean and light'); await p.press('#stIn', 'Enter');
212
- await until(() => dver().then((v) => /^D1/.test(v)), 60000);
213
- ok('D3 a turn makes D1 and shows it with two slides', /^D1\*/.test(await dver()) && await p.evaluate(() => document.querySelectorAll('#stPv .dzth button').length) === 2 && /Built the first look/.test(await lastA()), await dver() + ' ' + await lastA());
214
- ok('D4 This is it is offered for the version shown', await cta() === 'This is it:on', await cta());
215
- await tap('#oMain [data-st="save"]');
216
- await until(() => chipv('dsv').then((v) => v === 'D1, saved'));
217
- ok('D5 This is it saves D1 as the design, and is then not offered', await chipv('dsv') === 'D1, saved' && await cta() === 'This is it:off' && posts.includes('/api/report-design/accept'), await chipv('dsv'));
218
- await until(() => p.evaluate(() => { const b = document.querySelector('#stPv [data-st="dznext"]'); return !!b && !b.disabled; }), 30000); // the cycle redraw after This is it has finished
219
- ok('B3 the Design brief chip appears once a design is saved, and not before', await chipv('dbr') === 'D1');
220
- await tap('#oMain [data-st="chip|dbr"]'); await sleep(150);
221
- const brTxt = await p.evaluate(() => (document.querySelector('#stTr') || {}).textContent || '');
222
- ok('B4 the brief shows the description, the sample and the reference version', /make it clean and light/.test(brTxt) && /sample\.png/.test(brTxt) && /Reference version · D1/.test(brTxt), brTxt.slice(0, 300));
223
- const nDesc = posts.filter((x) => x === '/api/report-design/describe').length;
224
- await tap('#oMain [data-st="chip|dfmt"]'); await sleep(100); await tap('#stTr [data-st="dzfmt|doc"]'); await sleep(600);
225
- ok('F7 with a description saved, choosing Document posts it with the format', posts.filter((x) => x === '/api/report-design/describe').length === nDesc + 1 && await chipv('dfmt') === 'Document', posts.join());
226
- await tap('#oMain [data-st="chip|dsmp"]'); await sleep(100);
227
- await p.setInputFiles('#dzFile', { name: 'other.png', mimeType: 'image/png', buffer: Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==', 'base64') });
228
- await until(() => chipv('dsmp').then((v) => v === '2'), 8000);
229
- ok('D10 each listed sample has its own remove button, named for the sample', await p.evaluate(() => [...document.querySelectorAll('#stTr [data-st^="dzrm|"]')].map((b) => b.getAttribute('aria-label') + ':' + b.offsetHeight).join()) === 'Remove the sample sample.png:44,Remove the sample other.png:44');
230
- await shot('report-samples-1280');
231
- await tap('#stTr [aria-label="Remove the sample sample.png"]');
232
- await until(() => chipv('dsmp').then((v) => v === '1'), 8000);
233
- ok('D11 removing a sample drops it from the list and the count, and says the next version stops following it', await chipv('dsmp') === '1' && !/sample\.png/.test(await p.evaluate(() => document.querySelector('#stTr').textContent)) && /other\.png/.test(await p.evaluate(() => document.querySelector('#stTr').textContent))
234
- && posts.includes('/api/report-design/unsample') && /Removed "sample\.png"/.test(await lastA()), await lastA());
235
-
236
- /* D7 to D9: point and say, make the next version, compare two */
237
- await until(() => p.evaluate(() => { const b = document.querySelector('#stPv [data-st="dznext"]'); return !!b && !b.disabled; }), 30000);
238
- await p.click('#dzSlide', { position: { x: 200, y: 100 } });
239
- await until(() => p.evaluate(() => document.querySelectorAll('#stPv .dzpin').length === 1));
240
- await p.fill('#stPv [data-dzp="1"]', 'Make this bigger');
241
- ok('D7 a click on the slide attaches a request, typed under the preview', await p.evaluate(() => document.querySelectorAll('#stPv .dzsay li').length === 1 && document.querySelector('#stPv [data-dzp="1"]').value === 'Make this bigger'));
242
- await tap('#stPv [data-st="dznext"]');
243
- await until(() => dver().then((v) => /D2\*/.test(v)), 60000);
244
- const tb = turnBodies[turnBodies.length - 1] || '';
245
- ok('D8 Make the next version makes D2 and sends the pointed request with its slide, x and y', /D2\*/.test(await dver()) && /"points":\[\{"n":1,"slide":"[a-z]+","x":[0-9.]+,"y":[0-9.]+,"text":"Make this bigger"\}\]/.test(tb), (await dver()) + ' ' + tb);
246
- await tap('#stPv [data-st="dzcmp"]'); await sleep(500);
247
- ok('D9 Compare two shows the same slide of two versions side by side', await p.evaluate(() => document.querySelectorAll('#stPv .dzcc').length === 2 && document.querySelectorAll('#stPv .dzcc .rdbig').length === 2));
248
- await tap('#stPv [data-st="dzcmp"]'); await sleep(200);
249
- await tap('#oMain [data-st="save"]'); await until(() => chipv('dsv').then((v) => v === 'D2, saved'));
250
- await shot('report-design-1280');
251
- await p.click('#oMain [data-st="rtab|structure"]');
252
- await until(() => chipv('ver').then((v) => /^S/.test(v)));
253
- ok('D6 back to Structure keeps its version', /^S1/.test(await chipv('ver')), await chipv('ver'));
254
- await tap('#oMain [data-st="chip|secs"]'); await sleep(150); await shot('report-shape-1280'); await tap('#oMain [data-st="chip|secs"]');
255
- /* L: the library */
256
- await tap('#oMain [data-st="lib"]'); await sleep(100);
257
- const lib = await p.evaluate(() => [...document.querySelectorAll('#stLb .stli')].map((b) => b.querySelector('b').textContent + ':' + b.querySelector('em').textContent));
258
- ok('L1 the library lists the set-up reports', lib.join() === 'Partner review:Open', lib.join());
259
- await tap('#oMain [data-st="lib"]');
260
- /* P: the writes */
261
- const allowed = new Set(['/api/briefing-premium/seen', '/api/report-design/unsample', '/api/report-setups/setup', '/api/report-setups/from-dashboard', '/api/report-structure/turn', '/api/report-structure/remove', '/api/report-structure/revert', '/api/report-structure/accept', '/api/report-design/describe', '/api/report-design/sample', '/api/report-design/turn', '/api/report-design/accept', '/api/report-design/revert']);
262
- ok('P1 every POST is one of the existing report routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
263
-
264
- /* F: floors */
265
- await p.setViewportSize({ width: 390, height: 844 }); await sleep(300);
266
- const wide = await p.evaluate(() => { const d = document.querySelector('#oMain'); return [document.documentElement.scrollWidth - innerWidth, d ? d.scrollWidth - d.clientWidth : 0]; });
267
- await shot('report-shape-390');
268
- ok('F1 at 390 wide, Report mode does not scroll sideways', wide[0] <= 0 && wide[1] <= 1, wide.join());
269
- const small = await p.evaluate(() => [...document.querySelectorAll('#oMain .stmd button, #oMain .suc, #stFt button')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
270
- ok('F2 the mode switch, the chips and the footer are 44 px tall', small.length === 0, small.join());
271
- await p.click('#oMain [data-st="rtab|design"]'); await sleep(600); await shot('report-design-390');
272
- const wide2 = await p.evaluate(() => { const d = document.querySelector('#oMain'); return [document.documentElement.scrollWidth - innerWidth, d ? d.scrollWidth - d.clientWidth : 0]; });
273
- const small2 = await p.evaluate(() => [...document.querySelectorAll('#oMain .stmd button, #oMain .suc, #stFt button, #stPv .rdv button, #stPv .rdnv button')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
274
- ok('F4 at 390 wide, the Design tab does not scroll sideways and its presses are 44 px tall', wide2[0] <= 0 && wide2[1] <= 1 && small2.length === 0, wide2.join() + ' ' + small2.join());
275
- ok('F3 no script error', errs.length === 0, errs.join(' | '));
276
- return finish();
277
- })().catch((e) => { console.error(e); finish(1); });
@@ -1,185 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* premium-studio-test.js — the Insight Studio's Dashboard mode on the premium Insights page (initiative premium-studio-dashboard;
4
- * planning/prd/premium-studio-dashboard-prd.md S1 to S10). A real server on a scratch repository whose KR metric records hold two measures with a series
5
- * and one without. The real page presses the real save route:
6
- * O opening · C the conversation · B the brief and tray · K the checks · U Undo · S save, edit and remove · P the POST allow-list · F floors */
7
- const fs = require('fs');
8
- const os = require('os');
9
- const path = require('path');
10
- const { spawn } = require('child_process');
11
- const { findBrowser } = require('./lib/find-browser');
12
- const T = require('./test-run').configure({ name: 'premium-studio' });
13
-
14
- const BASE = T.BASE;
15
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
16
- const until = async (fn, ms = 20000, step = 150) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
17
- const results = [];
18
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
19
- let srv = null, browser = null;
20
- const finish = async (code) => {
21
- if (browser) await browser.close().catch(() => {});
22
- if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
23
- T.killTmux();
24
- const bad = results.filter((x) => !x.cond).length;
25
- console.log(`\n${results.length - bad}/${results.length} premium-studio assertions passed`);
26
- process.exit(code !== undefined ? code : (bad ? 1 : 0));
27
- };
28
- process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
29
-
30
- /* the scratch repository: Partner activation (3 readings), Time to first call (2 readings), Lonely (1 reading, no series) */
31
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-repo-'));
32
- const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), 'studio-state-'));
33
- fs.mkdirSync(path.join(dir, 'planning', 'records'), { recursive: true });
34
- const L = [
35
- { id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
36
- { id: '2', kind: 'reading', rid: 'krm-a', fields: { at: '2026-07-01', value: 20 } }, { id: '3', kind: 'reading', rid: 'krm-a', fields: { at: '2026-08-01', value: 24 } }, { id: '4', kind: 'reading', rid: 'krm-a', fields: { at: '2026-10-01', value: 30 } },
37
- { id: '5', kind: 'add', rid: 'krm-t', fields: { metric: 'Time to first call', baseline: 10, target: 4, by: '2026-12-31', pillar: 'Growth', unit: ' days' } },
38
- { id: '6', kind: 'reading', rid: 'krm-t', fields: { at: '2026-08-01', value: 9 } }, { id: '7', kind: 'reading', rid: 'krm-t', fields: { at: '2026-10-01', value: 7 } },
39
- { id: '8', kind: 'add', rid: 'krm-l', fields: { metric: 'Lonely', baseline: 1, target: 2, by: '2026-12-31' } }, { id: '9', kind: 'reading', rid: 'krm-l', fields: { at: '2026-10-01', value: 1 } },
40
- ];
41
- fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), L.map((x) => JSON.stringify(x)).join('\n') + '\n');
42
- const saved = async () => { const j = await (await fetch(BASE + '/api/insights-premium')).json(); return (j.model && j.model.dashboards || []).filter((d) => d.saved); };
43
-
44
- (async () => {
45
- const exe = findBrowser();
46
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
47
- let chromium;
48
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
49
- 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 }) });
50
- await T.waitForServer(BASE);
51
- browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
52
-
53
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
54
- p.on('pageerror', (e) => errs.push(String(e)));
55
- p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
56
- await p.goto(BASE + '/premium-insights.html');
57
- await until(() => p.evaluate(() => !!document.querySelector('#dashBody .mch') && !!document.querySelector('#pdNew')));
58
- const say = async (t) => { await p.fill('#stIn', t); await p.press('#stIn', 'Enter'); await sleep(150); return p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; }); };
59
- const chipv = (k) => p.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
60
- const tiles = () => p.evaluate(() => [...document.querySelectorAll('#stPv .mch .mlab')].map((e) => e.firstChild.textContent));
61
- const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
62
- const tap = (sel) => p.$eval(sel, (b) => b.click());
63
- const open = async (sel) => { if (sel === '#pdNew' || sel === '#repNew') await p.click('#listNew'); if (['#pdEdit', '#pcNew', '#pdPin', '#pdBack'].includes(sel) && await p.locator('#dashBar').isHidden()) await p.click('#dashMore'); await p.click(sel); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu'))); await sleep(300); };
64
- const shut = async () => { for (let i = 0; i < 2 && await p.evaluate(() => document.querySelector('#dlg').classList.contains('on')); i++) { await p.keyboard.press('Escape'); await sleep(150); } };
65
-
66
- /* O0: Chat is the rail's middle place and goes to the Chat page (premium-chat-page); the Studio opens from the page's own buttons */
67
- ok('O0 the bar has no chat button; Chat is the rail\'s middle place (premium-chat-rail)', await p.evaluate(() => !document.querySelector('#crAsk') && !!document.querySelector('.rail [data-go="chat"] svg')));
68
- await p.click('.rail [data-go="chat"]'); await until(() => p.evaluate(() => /premium-chat\.html/.test(location.pathname) && document.querySelector('#dlg').classList.contains('on')), 10000);
69
- ok('O0b Chat goes to the Chat page, on the PM\'s own chat', await p.evaluate(() => document.querySelector('#dTitle').textContent === 'Chat'), p.url());
70
- await p.goBack(); await until(() => p.evaluate(() => !!document.querySelector('#listRows .dmr')), 20000);
71
- /* O: New dashboard opens the Studio */
72
- await open('#pdNew');
73
- const o = await p.evaluate(() => ({ eye: document.querySelector('#dEye').textContent, full: document.querySelector('#dlg').classList.contains('full'), lib: [...document.querySelectorAll('#stLb .stli b')].map((b) => b.textContent), agent: getComputedStyle(document.querySelector('#askF')).display === 'none', own: !!document.querySelector('#stF') }));
74
- ok('O1 New dashboard opens the Studio as the wide dialog, full screen at 1280 px', /^Insight Studio · /.test(o.eye) && o.full, JSON.stringify(o));
75
- ok('O2 the library lists the three measures of the records and nothing else', o.lib.join() === 'Partner activation,Time to first call,Lonely', o.lib.join());
76
- ok('O3 the agent\'s ask bar is hidden and the Studio\'s own sits in its place', o.agent && o.own);
77
- ok('O4 a new draft shows Not set on Name and Purpose and 0 charts', await chipv('name') === 'Not set' && await chipv('use') === 'Not set' && await chipv('charts') === '0');
78
- ok('K1 the checks start at 2 of 6 (count and repeats pass)', await checksTxt() === '2 of 6 checks pass', await checksTxt());
79
-
80
- /* Z: the Studio's size (Normal, Half, 3/4, Whole), as the console's Design studio has it */
81
- const sz = () => p.evaluate(() => { const d = document.querySelector('#dlg'), r = d.getBoundingClientRect(); return { w: Math.round(r.width), full: d.classList.contains('full'), on: (document.querySelector('#stSz [aria-pressed="true"]') || {}).textContent, n: document.querySelectorAll('#stSz button').length, saved: localStorage.getItem('pmos.premium.studio-size') }; });
82
- let z = await sz();
83
- ok('Z1 the Studio offers Normal, Half, 3/4 and Whole, and opens on Whole', z.n === 4 && z.on === 'Whole' && z.full, JSON.stringify(z));
84
- await tap('#stSz [data-st="size|half"]'); await sleep(900); z = await sz();
85
- ok('Z2 Half is half the window and leaves full screen', !z.full && z.on === 'Half' && Math.abs(z.w - 640) < 12 && z.saved === 'half', JSON.stringify(z));
86
- ok('Z3 at Half the conversation and the Studio are two tabs', await p.evaluate(() => getComputedStyle(document.querySelector('#dTabs')).display !== 'none'));
87
- await tap('#stSz [data-st="size|three-quarters"]'); await sleep(900); z = await sz();
88
- ok('Z4 3/4 is three-quarters of the window', z.on === '3/4' && Math.abs(z.w - 960) < 12, JSON.stringify(z));
89
- await tap('#stSz [data-st="size|normal"]'); await sleep(900); z = await sz();
90
- ok('Z5 Normal is the dialog\'s own size', z.on === 'Normal' && z.w > 1000 && z.w < 1270 && !z.full, JSON.stringify(z));
91
- await tap('#dExpand'); await sleep(300); z = await sz();
92
- ok('Z6 the full-screen button of the dialog moves the size to Whole', z.on === 'Whole' && z.full, JSON.stringify(z));
93
- await tap('#stSz [data-st="size|three-quarters"]'); await sleep(300);
94
- await shut(); await open('#pdNew'); z = await sz();
95
- ok('Z7 the size is kept for the next time', z.on === '3/4' && !z.full, JSON.stringify(z));
96
- await tap('#stSz [data-st="size|half"]'); await sleep(500);
97
- ok('Z8 the Detail / Conversation switch shows its pill at Half', await p.evaluate(() => { const b = document.querySelector('#dTabs .pill'); return !!b && b.getBoundingClientRect().width > 20; }));
98
- await shut(); await open('#pdNew'); z = await sz();
99
- ok('Z9 Half is not kept: the Studio opens on Whole, with its conversation beside it', z.on === 'Whole' && z.full, JSON.stringify(z));
100
- await tap('#stSz [data-st="size|whole"]'); await sleep(300);
101
-
102
- /* C: the conversation */
103
- let a = await say('add Partner activation and Time to first call');
104
- ok('C1 "add" names the measures it added and draws them', /^Done: added Partner activation, added Time to first call/.test(a) && (await tiles()).join() === 'Partner activation,Time to first call', a);
105
- a = await say('call it Partner review');
106
- ok('C2 "call it" sets the name chip', /^Done: named it "Partner review"/.test(a) && await chipv('name') === 'Partner review', a);
107
- a = await say('it is for the Monday partner review');
108
- ok('C3 "it is for" sets the purpose', await chipv('use') === 'the Monday partner review', a);
109
- a = await say('make it the main dashboard');
110
- ok('C4 "make it the main dashboard" sets Main, and the checks pass 6 of 6', await chipv('main') === 'Yes' && await checksTxt() === '6 of 6 checks pass', a + ' ' + await checksTxt());
111
- a = await say('add Revenue per seat');
112
- ok('C5 a measure the board does not have changes nothing and says so', /^I changed nothing/.test(a) && await chipv('charts') === '2', a);
113
- a = await say('move Time to first call first');
114
- ok('C6 "move … first" reorders the preview', (await tiles()).join() === 'Time to first call,Partner activation', a);
115
- ok('C7 no turn posted anything', posts.length === 0, posts.join());
116
-
117
- /* U: Undo */
118
- await tap('#oMain [data-st="undo"]'); await sleep(150);
119
- ok('U1 Undo steps back one change (the move)', (await tiles()).join() === 'Partner activation,Time to first call');
120
- a = await say('undo');
121
- ok('U2 "undo" in words steps back again (Main)', await chipv('main') === 'No' && /^Done: one step undone/.test(a), a);
122
-
123
- /* B and K: the brief, the library and a check's fix */
124
- await tap('#stLb [data-st="libc|krm-l"]'); await sleep(150);
125
- const gone = await p.evaluate(() => [...document.querySelectorAll('#stPv .stgone')].map((e) => e.textContent).join(' | '));
126
- ok('B1 a measure with no series is added, listed as not drawn with the reason, and not drawn', /Lonely has fewer than two readings, so it has no chart/.test(gone) && (await tiles()).length === 2 && await chipv('charts') === '3', gone);
127
- await tap('#oMain [data-st="ck"]'); await sleep(100);
128
- const fix = await p.evaluate(() => [...document.querySelectorAll('#stCk .sucl li.bad button')].map((b) => b.textContent));
129
- ok('K2 the failing check (no main dashboard) offers its fix', fix.join() === 'Make it the main one', fix.join());
130
- await tap('#stCk .sucl li.bad button'); await sleep(150);
131
- ok('K3 the fix sets what it names', await chipv('main') === 'Yes' && await checksTxt() === '6 of 6 checks pass');
132
- await tap('#oMain [data-st="chip|charts"]'); await sleep(100);
133
- await tap('#stTr [data-st="rm|2"]'); await sleep(100);
134
- ok('B2 the Charts tray removes a measure', await chipv('charts') === '2');
135
-
136
- /* S: save, read back, edit, remove */
137
- await tap('#oMain [data-st="save"]');
138
- ok('S1 Save closes the Studio and the page draws the saved dashboard as the main one', await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.querySelector('#hDash').textContent === 'Partner review' && document.querySelector('#dashTag').textContent === 'Pinned')));
139
- let S = await saved();
140
- ok('S2 the ledger holds the name, purpose, order and Main', S.length === 1 && S[0].name === 'Partner review' && S[0].purpose === 'the Monday partner review' && S[0].charts.join() === 'krm-a,krm-t' && S[0].main, JSON.stringify(S));
141
- await open('#pdEdit');
142
- ok('S3 Edit opens the Studio on the saved dashboard', await chipv('name') === 'Partner review' && await chipv('main') === 'Yes' && (await tiles()).join() === 'Partner activation,Time to first call');
143
- await say('move Time to first call first'); await say('remove Partner activation');
144
- await tap('#oMain [data-st="save"]');
145
- await until(async () => { const x = await saved(); return x.length === 1 && x[0].charts.join() === 'krm-t'; });
146
- S = await saved();
147
- ok('S4 an edit made in words is saved', S.length === 1 && S[0].charts.join() === 'krm-t', JSON.stringify(S));
148
- await open('#pdEdit');
149
- await tap('#oMain [data-st="del"]'); await sleep(100);
150
- const armed = await p.evaluate(() => ({ b: document.querySelector('#oMain [data-st="del"]').textContent, m: document.querySelector('#stMsg').textContent }));
151
- ok('S5 Remove asks for a second press and says what stays', armed.b === 'Press again to remove it' && /measures and their records stay/.test(armed.m), JSON.stringify(armed));
152
- await tap('#oMain [data-st="del"]');
153
- await until(async () => (await saved()).length === 0);
154
- ok('S6 the second press removes the dashboard', (await saved()).length === 0);
155
-
156
- /* P: the POST allow-list and the guard */
157
- ok('P1 the page posted only to the dashboard save route', posts.length === 3 && posts.every((x) => x === '/api/premium-dashboards/save'), posts.join());
158
- const j = await (await fetch(BASE + '/api/insights-premium')).json(), body = JSON.stringify({ ws: j.model.board.ws, board: j.model.board.id, name: 'From an agent', purpose: 'x', charts: [] });
159
- const H = await T.pressHeaders(BASE);
160
- const asAgent = await fetch(BASE + '/api/premium-dashboards/save', { method: 'POST', headers: { ...H, 'x-pmos-session': 's1' }, body }).then((x) => x.status);
161
- ok('P2 an agent session is refused by the save route, unchanged', asAgent === 403, String(asAgent));
162
- ok('P3 no script error', errs.length === 0, errs.join(' | '));
163
- await ctx.close();
164
-
165
- /* F: floors at 390 px, both themes */
166
- for (const theme of ['light', 'dark']) {
167
- const c2 = await browser.newContext({ viewport: { width: 390, height: 844 }, colorScheme: theme }), q = await c2.newPage();
168
- await q.goto(BASE + '/premium-insights.html');
169
- await until(() => q.evaluate(() => !!document.querySelector('.rail [data-go="chat"]') && !!document.querySelector('#listRows .dmr')));
170
- const pill = await q.evaluate(() => { const b = document.querySelector('.rail [data-go="chat"] .orb'), r = b.getBoundingClientRect(); return { txt: b.textContent.trim(), w: r.width, h: r.height, right: r.right, vw: innerWidth, vis: !!b.offsetParent }; });
171
- ok(`F0 at 390 px (${theme}) the rail's Chat shows, fits the width and is 44 px`, pill.vis && pill.right <= pill.vw && Math.round(pill.h) >= 44 && Math.round(pill.w) >= 44, JSON.stringify(pill));
172
- await q.click('#listNew'); await q.click('#pdNew'); await until(() => q.evaluate(() => !!document.querySelector('#oMain .stu'))); await sleep(400);
173
- // measured once the dialog has finished opening: its rise animation scales the targets while it runs
174
- const measure = () => q.evaluate(() => {
175
- const sm = [...document.querySelectorAll('#oMain .stu button')].filter((b) => b.offsetParent).filter((b) => { const r = b.getBoundingClientRect(); return r.height < 44 || r.width < 44; }).map((b) => (b.dataset.st || b.textContent) + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height));
176
- const pane = document.querySelector('#dOut'); return { small: sm.length, which: sm, side: pane.scrollWidth - pane.clientWidth, doc: document.documentElement.scrollWidth - innerWidth };
177
- });
178
- await until(async () => (await measure()).small === 0, 4000);
179
- const f = await measure();
180
- ok(`F1 at 390 px (${theme}) every Studio target is 44 px or more and nothing scrolls sideways`, f.small === 0 && f.side <= 1 && f.doc <= 1, JSON.stringify(f));
181
- await c2.close();
182
- }
183
- await shut().catch(() => {});
184
- finish();
185
- })().catch((e) => { console.error(e); finish(1); });