create-pmos 0.271.0 → 0.273.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-calendar-3-test.js +3 -1
- package/workspace/briefing-premium-insights-test.js +4 -3
- package/workspace/guide/briefing-premium.md +5 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-report-read-test.js +206 -0
- package/workspace/premium-studio-report-test.js +203 -0
- package/workspace/public/pm/premium-insights.js +22 -7
- package/workspace/public/pm/premium-report-print.css +9 -0
- package/workspace/public/pm/premium-report-read.js +358 -0
- package/workspace/public/pm/premium-studio-report.js +264 -0
- package/workspace/public/pm/premium-studio.js +56 -23
- package/workspace/public/pm/premium.css +67 -0
- package/workspace/public/premium-insights.html +1 -1
- package/workspace/test-lists/premium-report-read.json +9 -0
- package/workspace/test-lists/premium-studio-report.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.273.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T14:48:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T14:48:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T14:48:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -208,7 +208,9 @@ const RECORDER = () => {
|
|
|
208
208
|
await Lv.page.goto(BASE + '/premium-work.html').catch(() => {});
|
|
209
209
|
ok('R4 leaving the Briefing while it records makes the browser ask first, and staying pauses nothing', Lv.dialogs.includes('beforeunload') && Lv.pausePosts.length === 0 && /premium\.html/.test(Lv.page.url()), Lv.dialogs.join() + ' ' + Lv.page.url());
|
|
210
210
|
Lv.leave = true;
|
|
211
|
-
|
|
211
|
+
// After the stay above, Chromium on CI reports the next navigation as ERR_ABORTED while it still leaves the page: wait for the page itself.
|
|
212
|
+
await Lv.page.goto(BASE + '/premium-work.html').catch(() => {});
|
|
213
|
+
await Lv.page.waitForURL(/premium-work\.html/, { timeout: 10000 }).catch(() => {});
|
|
212
214
|
ok('R4 leaving anyway sends the pause for that note (a request that leaves with the page)', await until(() => Lv.pauseSeen.length >= 1) && Lv.pauseSeen[0].id === 'n1', JSON.stringify(Lv.pauseSeen));
|
|
213
215
|
if (!Lv.pausePosts.length) { const n = Lv.notes.find((x) => x.id === 'n1'); n.state = 'paused'; n.resume_until = new Date(Date.now() + 3600000).toISOString(); } // the stand-in could not answer a request sent as the page left
|
|
214
216
|
await Lv.page.reload();
|
|
@@ -125,9 +125,10 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
125
125
|
/* I8 reports */
|
|
126
126
|
const rp = await p.evaluate(() => ({ rows: [...document.querySelectorAll('#repDocs .dmr')].map((r) => r.querySelector('.dmn b').textContent + ' / ' + r.querySelector('.s').textContent), note: document.querySelector('#repBody .mhint').textContent, cap: document.querySelector('#repCap').textContent }));
|
|
127
127
|
ok('I8 the Reports card lists the report files: cadence, slot, draft or issued', rp.rows.join() === 'biweekly · 14 Oct / Draft,monthly · 30 Sep / Issued 1 Oct' && /Nothing is sent from here/.test(rp.note) && rp.cap === '2', JSON.stringify(rp));
|
|
128
|
-
{ const R = await open(); await R.page.locator('#repDocs .dmo').first().click(); ok('I8 a report opens the
|
|
128
|
+
{ const R = await open(); await R.page.locator('#repDocs .dmo').first().click(); ok('I8 a report opens in the page\'s reader, not the console (premium-report-read R1)', await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('rdrd') && document.querySelector('#dlg').classList.contains('on')), 5000) && /premium-insights\.html/.test(R.page.url()), R.page.url());
|
|
129
|
+
await R.page.click('#dClose'); await R.page.click('#repOpen'); ok('I8 the Reports tab link still opens the console to edit or issue', await until(() => /\/c3\.html\?tab=rep/.test(R.page.url()), 5000), R.page.url()); await R.ctx.close(); }
|
|
129
130
|
/* I9 labels */
|
|
130
|
-
ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out:
|
|
131
|
+
ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out: run-based charts/.test(await txt('#foot')) && /Real data/.test(await txt('#snap')));
|
|
131
132
|
ok('I9 the page makes no write request on its own', A.posts.length === 0, A.posts.join());
|
|
132
133
|
/* I10 empty */
|
|
133
134
|
{
|
|
@@ -200,7 +201,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
200
201
|
await shut();
|
|
201
202
|
await q.click('#repSetups .dmo'); await dlgOn();
|
|
202
203
|
const su = await q.evaluate(() => ({ kv: document.querySelector('#oMain .kv2').textContent, acts: [...document.querySelectorAll('#oMain [data-rx]')].map((b) => b.dataset.rx).join() }));
|
|
203
|
-
ok('R4 a set-up report shows its schedule and next draft, with Draft it now and
|
|
204
|
+
ok('R4 a set-up report shows its schedule and next draft, with Draft it now, Pause and Shape it in the Studio', /ScheduleEvery other Monday at 09:00/.test(su.kv) && /Next draft26 Oct/.test(su.kv) && su.acts === 'draft,pause,studio', JSON.stringify(su));
|
|
204
205
|
await q.click('#oMain [data-rx="pause"]'); await sleep(300);
|
|
205
206
|
ok('R4 Pause posts that report', last()[0] === '/api/report-setups/pause' && last()[1].id === 'partner-update', JSON.stringify(last()));
|
|
206
207
|
ok('R7 every press went to the dashboard save route or an existing report-setups route', R.posts.every((x) => /^POST \/api\/(premium-dashboards\/save|report-setups\/(ask|change|cancel|setup|dismiss|pause|resume|draft))$/.test(x)), R.posts.join());
|
|
@@ -204,11 +204,14 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
204
204
|
- **Dashboards.** The switch lists All measures first, then your saved dashboards (the main one first, marked Main), then the pillars the metrics name. A saved dashboard draws its charts in the order you saved them. A chart whose record is gone, or that has fewer than two readings, is listed in its place with the reason and is not drawn.
|
|
205
205
|
- **Make or edit a dashboard.** **New dashboard**, or **Edit** on a saved one, opens the **Insight Studio**, a wide dialog. On the right, the brief shows the Name, Purpose, Charts and Main dashboard; press a chip to change it. **Library** lists the board's measures and saved dashboards to add. The preview draws the dashboard as the page will, and lists a measure with no series as not drawn. The checks (a name, a purpose, a chart, six or fewer, no repeat, a main dashboard on the board) say what fails, with a one-press fix. On the left you can say it instead: "add Partner activation", "remove …", "move … first", "call it …", "it is for …", "make it the main dashboard", "undo" or "start a new one". A turn changes the draft only. **Undo** steps back one change. **Save the dashboard** records it; **Remove the dashboard** asks once more and then removes it. In a chart's dialog, **On your dashboards** has a switch for each saved dashboard, which adds the chart to it or takes it off.
|
|
206
206
|
- **Make your own chart.** **New chart**, or **Edit** on one of your charts, opens the Insight Studio in **Chart** mode; the switch at the top moves between Chart and Dashboard, and each keeps its own draft. The brief shows the Question, Measure, Form (line, bars, number or meter), Range (all readings or the last few) and Target; **More** adds the Title, Better when, Note and Add to (a dashboard). The Studio suggests a form from the question and says why. The checks (a question, a target, enough readings, a form that fits the question, one scale) say what fails, with a one-press fix. You can say it instead: "show it as bars", "last 4 readings", "target 35", "lower is better", "call it …", "note: …", "add it to Weekly", or a question. A pie is declined, with the reason. **Save the chart** records it in the workspace's state folder, and adds it to the dashboard you named. Your charts are listed under **All measures**, and a dashboard can hold them beside the measures. **Remove the chart** asks once more; a dashboard that held it then says it was removed.
|
|
207
|
+
- **Set up a report in the Studio.** **New report** on the Reports card opens the Insight Studio in **Report** mode. The brief shows the Title, What it answers, Audience, Format, Schedule, Draw from (your work, or the board's dashboard) and the Sections. A new report always has the same sections, in the same order, so they are listed, not edited. The checks (what it answers, an audience, a format that fits the audience, a new title, the answer first) say what fails, with a one-press fix. You can say it instead: "it answers: …", "for leadership", "slides", "monthly", "every two weeks on Thursday", "call it …". **Set it up** records the report and writes its first draft as a file.
|
|
208
|
+
- **Shape a report's sections.** On a report drawn from your work, **Shape it in the Studio** opens Report mode on it. Tell PMOS how to shape the sections in your own words; PMOS proposes the next version and says what it changed. **Leave out** on a section makes the next version without it; the headline, Needs your call and Sources are always in. **Undo** goes back one version. **Use this structure** saves the version shown, and the next cycle follows it.
|
|
207
209
|
- **What stands out.** Up to three plain sentences taken from the series: behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. There is no forecast and no cause.
|
|
208
210
|
- **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
|
|
209
211
|
- **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
|
|
210
212
|
- **Found in your work.** Up to three reports PMOS found in your calendar, mail or documents, each with why and what it saw. **Set it up** records the report and drafts its first cycle as a file. **Not a report** hides it and records it after 5 seconds, unless you press **Undo**.
|
|
211
213
|
- **Set up.** Your recurring reports, with their schedule and next draft. A report opens with **Draft it now** (for a report drawn from your work) and **Pause** or **Resume**.
|
|
212
|
-
- **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the
|
|
214
|
+
- **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens it on the page as a **Deck**: a title slide, then one slide for each section, with the arrow keys and a strip of slides. **Document** shows it as a page. **Present** shows the slide on the whole screen; the arrow keys move and Escape stops. **Download** gives PowerPoint, Word, Excel, CSV or the Markdown file; the files carry the words, not the look. **Print or save as PDF** prints one slide to a page. **Open in the console** is where a document is edited or issued. Nothing is sent from this page.
|
|
215
|
+
- **Shape a report's look.** On a draft, **Add a sample** takes a PDF, PowerPoint, Word, PNG or JPG file to follow. Say how it should look in the conversation; PMOS draws the next design version (D1, D2, …) and says what it changed. Press a version to go back to it. **This is it** saves the version shown as the report's design, and PMOS draws the cycle to match. An issued cycle is frozen with its look.
|
|
213
216
|
|
|
214
|
-
Not built:
|
|
217
|
+
Not built: a second measure next to a chart, bar highlights, speaker notes and notes on a slide, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.273.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.273.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-report-read-test.js — a report document read on the premium Insights page (initiative premium-report-read;
|
|
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
|
+
* 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
|
|
7
|
+
* Set READ_SHOTS=<dir> to save screenshots 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-report-read' });
|
|
14
|
+
const issues = require('./lib/issues.js');
|
|
15
|
+
const RDraft = require('./lib/report-draft.js');
|
|
16
|
+
|
|
17
|
+
const BASE = T.BASE;
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
const until = async (fn, ms = 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(), 'report-read-'));
|
|
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-report-read assertions passed`);
|
|
31
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
32
|
+
};
|
|
33
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
34
|
+
|
|
35
|
+
/* the scratch repository: one measure, so the page draws; two cycles of the partner-review report, the older one issued */
|
|
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
|
+
const CAD = 'partner-review';
|
|
44
|
+
const DOC = '---\ntype: Report\ntitle: "Partner review, 12 Oct"\n---\n\n# Partner review, 12 Oct\n\n## Headline\nPartner activation is **33%**, short of its line.\n\n## Initiatives\n- Partner activation: in build\n- Onboarding emails: shipped\n\n## Needs your call\n- Extend the pilot to two more partners?\n\n## Sources\n- KR metric record krm-a\n';
|
|
45
|
+
const OLD = '---\ntype: Report\ntitle: "Partner review, 5 Oct"\n---\n\n# Partner review, 5 Oct\n\n## Headline\nPartner activation is 30%.\n\n## Sources\n- KR metric record krm-a\n';
|
|
46
|
+
const pNew = RDraft.draftPath(dir, CAD, '2026-10-12'), pOld = RDraft.draftPath(dir, CAD, '2026-10-05');
|
|
47
|
+
fs.mkdirSync(path.join(dir, path.dirname(pNew)), { recursive: true });
|
|
48
|
+
fs.writeFileSync(path.join(dir, pNew), DOC); fs.writeFileSync(path.join(dir, pOld), OLD);
|
|
49
|
+
const git = (...a) => execFileSync('git', a, { cwd: dir, stdio: 'ignore' });
|
|
50
|
+
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');
|
|
51
|
+
const iss = issues.appendFromCli(dir, [{ ev: 'issued', cadence: CAD, slot: '2026-10-05', path: pOld, sha: issues.blobSha(fs.readFileSync(path.join(dir, pOld))) }], { actor: { by: 'pm:wawan', via: 'cli' } });
|
|
52
|
+
/* The stub plays the report-design run: a turn writes a two-slide deck (a third slide on a later turn); a cycle render copies the reference. */
|
|
53
|
+
fs.writeFileSync(path.join(fakeBin, 'claude'), `#!/usr/bin/env node
|
|
54
|
+
const fs = require('fs');
|
|
55
|
+
let input = ''; process.stdin.on('data', (d) => { input += d; }); process.stdin.on('end', () => {
|
|
56
|
+
const line = (k) => { const m = new RegExp('^- ' + k + ': (.*)$', 'm').exec(input); return m ? m[1].trim() : null; };
|
|
57
|
+
const mode = line('Mode'); const out = line('Output path');
|
|
58
|
+
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); };
|
|
59
|
+
if (!mode || !out) return done('Done.');
|
|
60
|
+
const sec = (id, title, body) => '<section class="pmos-slide" data-slide-id="' + id + '" data-kind="text" data-title="' + title + '">' + body + '</section>';
|
|
61
|
+
if (mode === 'turn') {
|
|
62
|
+
const prev = line('Previous version');
|
|
63
|
+
const more = prev && prev.startsWith('/');
|
|
64
|
+
const html = '<style>.pmos-slide{width:1280px;height:720px}.pmos-slide h1{font-size:64px;margin:80px}</style><script>window.parent.hacked = 1</script>'
|
|
65
|
+
+ sec('title', 'Partner review', '<h1 onclick="steal()">Partner review</h1>') + sec('headline', 'Headline', '<h2>Partner activation is 33%</h2>') + (more ? sec('needs', 'Needs your call', '<h2>Extend the pilot?</h2>') : '');
|
|
66
|
+
const took = [...input.matchAll(/^ {2}- (s-[0-9a-f]{8}) \\(NEW\\) "([^"]*)"/gm)].map((m) => ({ id: m[1], took: 'The dark title band from ' + m[2], readable: true }));
|
|
67
|
+
fs.writeFileSync(out, html);
|
|
68
|
+
setTimeout(() => done({ answer: more ? 'Added a slide for what needs your call.' : 'Made a dark title band.', took, rules: { same: ['The slide order'], changes: ['The numbers'], learned: [] } }), 400);
|
|
69
|
+
} else {
|
|
70
|
+
fs.writeFileSync(out, fs.readFileSync(line('Reference version'), 'utf8'));
|
|
71
|
+
done({ answer: 'Rendered the cycle.' });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
`, { mode: 0o755 });
|
|
75
|
+
const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==', 'base64');
|
|
76
|
+
fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
|
|
77
|
+
|
|
78
|
+
(async () => {
|
|
79
|
+
ok('setup: the older cycle is issued', iss && iss.ok === true, JSON.stringify(iss));
|
|
80
|
+
const exe = findBrowser();
|
|
81
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
82
|
+
let chromium;
|
|
83
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
84
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore',
|
|
85
|
+
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 }) });
|
|
86
|
+
await T.waitForServer(BASE);
|
|
87
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
88
|
+
|
|
89
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, acceptDownloads: true }), p = await ctx.newPage(), errs = [], posts = [];
|
|
90
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
91
|
+
p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
|
|
92
|
+
const shot = async (n) => { if (process.env.READ_SHOTS) await p.screenshot({ path: path.join(process.env.READ_SHOTS, n + '.png') }); };
|
|
93
|
+
const tap = (sel) => p.$eval(sel, (b) => b.click());
|
|
94
|
+
const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
|
|
95
|
+
const counter = () => p.evaluate(() => (document.querySelector('#rdN') || {}).textContent || '');
|
|
96
|
+
const bigTitle = () => p.evaluate(() => { const h = document.querySelector('#rdSlide h3'); return h ? h.textContent : (document.querySelector('#rdSlide iframe') ? 'frame' : ''); });
|
|
97
|
+
const say = async (t) => { await p.fill('#rdIn', t); await p.press('#rdIn', 'Enter'); };
|
|
98
|
+
await p.goto(BASE + '/premium-insights.html');
|
|
99
|
+
await until(() => p.evaluate(() => document.querySelectorAll('#repDocs [data-rep]').length === 2));
|
|
100
|
+
const rowSel = (slot) => `#repDocs [data-rep="rep:${CAD}:${slot}"]`;
|
|
101
|
+
|
|
102
|
+
/* O: a document row opens the reader on the page */
|
|
103
|
+
await tap(rowSel('2026-10-12'));
|
|
104
|
+
await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
|
|
105
|
+
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());
|
|
106
|
+
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'));
|
|
107
|
+
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'));
|
|
108
|
+
|
|
109
|
+
/* D: the deck */
|
|
110
|
+
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());
|
|
111
|
+
const strip = await p.evaluate(() => [...document.querySelectorAll('.rdt button span')].map((s) => s.textContent));
|
|
112
|
+
ok('D2 the strip lists the slides in the document\'s order', strip.join() === 'Partner review, 12 Oct,Headline,Initiatives,Needs your call,Sources', strip.join());
|
|
113
|
+
await tap('#oMain [data-rr="next"]');
|
|
114
|
+
ok('D3 Next moves to the headline, with its words as written', await counter() === '2 / 5' && await p.evaluate(() => document.querySelector('#rdSlide').textContent.includes('Partner activation is 33%, short of its line.') && document.querySelector('#rdSlide b').textContent === '33%'));
|
|
115
|
+
await p.focus('#rdSlide'); await p.keyboard.press('ArrowRight');
|
|
116
|
+
ok('D4 the arrow keys move, and a list stays a list', await counter() === '3 / 5' && await p.evaluate(() => document.querySelectorAll('#rdSlide li').length === 2));
|
|
117
|
+
await tap('#oMain [data-rr="go|4"]');
|
|
118
|
+
ok('D5 the strip goes to a slide', await counter() === '5 / 5' && await bigTitle() === 'Sources' && await p.evaluate(() => document.querySelector('[data-rr="next"]').disabled));
|
|
119
|
+
await shot('reader-deck-1280');
|
|
120
|
+
|
|
121
|
+
/* G: the page */
|
|
122
|
+
await tap('#oMain [data-rr="view|doc"]');
|
|
123
|
+
const heads = await p.evaluate(() => [...document.querySelectorAll('.rdpg h3')].map((h) => h.textContent));
|
|
124
|
+
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());
|
|
125
|
+
await tap('#oMain [data-rr="view|deck"]');
|
|
126
|
+
|
|
127
|
+
/* N: Present */
|
|
128
|
+
await tap('#oMain [data-rr="go|0"]');
|
|
129
|
+
await tap('#oMain [data-rr="present"]');
|
|
130
|
+
await until(() => p.$('#rdPres'));
|
|
131
|
+
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'); }));
|
|
132
|
+
await p.keyboard.press('ArrowRight');
|
|
133
|
+
ok('N2 the arrow keys move while presenting', await p.evaluate(() => document.querySelector('#rdPres .rdpn span').textContent) === '2 / 5');
|
|
134
|
+
await p.keyboard.press('Escape'); await sleep(200);
|
|
135
|
+
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');
|
|
136
|
+
|
|
137
|
+
/* W: download */
|
|
138
|
+
await tap('#oMain [data-rr="dm"]');
|
|
139
|
+
const items = await p.evaluate(() => [...document.querySelectorAll('.rpm [role="menuitem"]')].map((a) => a.textContent.split('(')[0].trim() + '|' + (a.getAttribute('href') || '')));
|
|
140
|
+
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(' / '));
|
|
141
|
+
const [dl] = await Promise.all([p.waitForEvent('download'), p.click('.rpm [data-rr="dl|pptx"]')]);
|
|
142
|
+
const pptx = fs.readFileSync(await dl.path());
|
|
143
|
+
ok('W2 PowerPoint downloads a .pptx of the document', /\.pptx$/.test(dl.suggestedFilename()) && pptx.slice(0, 2).toString() === 'PK', dl.suggestedFilename());
|
|
144
|
+
await tap('#oMain [data-rr="dm"]');
|
|
145
|
+
const [md] = await Promise.all([p.waitForEvent('download'), p.click('.rpm [data-rr="md"]')]);
|
|
146
|
+
ok('W3 Markdown downloads the file as written', fs.readFileSync(await md.path(), 'utf8') === DOC && /\.md$/.test(md.suggestedFilename()), md.suggestedFilename());
|
|
147
|
+
|
|
148
|
+
/* X: print */
|
|
149
|
+
await p.evaluate(() => { window.__pr = null; window.open = () => ({ document: { open() {}, write(h) { window.__pr = h; }, close() {} }, focus() {}, print() { window.__printed = true; } }); });
|
|
150
|
+
await tap('#oMain [data-rr="print"]'); await sleep(450);
|
|
151
|
+
const pr = await p.evaluate(() => ({ h: window.__pr || '', printed: !!window.__printed }));
|
|
152
|
+
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));
|
|
153
|
+
|
|
154
|
+
/* L: the look */
|
|
155
|
+
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')));
|
|
156
|
+
await p.setInputFiles('#rdFile', path.join(base, 'q3-deck.png'));
|
|
157
|
+
await until(() => p.evaluate(() => /Follows q3-deck\.png/.test(document.querySelector('.rdz').textContent)));
|
|
158
|
+
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());
|
|
159
|
+
await say('A dark title band, like the sample');
|
|
160
|
+
ok('L3 a turn says PMOS is working', /PMOS is working on it/.test(await lastA()));
|
|
161
|
+
await until(() => p.evaluate(() => /This is D1/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
|
|
162
|
+
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());
|
|
163
|
+
const fr = await p.evaluate(() => [...document.querySelectorAll('#oMain iframe')].map((f) => ({ sb: f.getAttribute('sandbox'), doc: f.getAttribute('srcdoc') || '' })));
|
|
164
|
+
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)));
|
|
165
|
+
ok('L6 the deck of D1 has its two slides', await counter() === '1 / 2');
|
|
166
|
+
await say('Add a slide for what needs your call');
|
|
167
|
+
await until(() => p.evaluate(() => /This is D2/.test([...document.querySelectorAll('#dBody .stream .turn.a .tt')].pop().textContent)), 30000);
|
|
168
|
+
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());
|
|
169
|
+
await tap('#oMain [data-rr="ver|1"]');
|
|
170
|
+
await until(() => p.evaluate(() => document.querySelector('.rdv [aria-pressed="true"]').textContent === 'D1'));
|
|
171
|
+
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());
|
|
172
|
+
await tap('#oMain [data-rr="keep"]');
|
|
173
|
+
await until(() => p.evaluate(() => /Saved as the design/.test(document.querySelector('.rdz').textContent)));
|
|
174
|
+
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());
|
|
175
|
+
await until(() => p.evaluate(() => !/PMOS is working/.test(document.querySelector('.rdz').textContent)), 30000);
|
|
176
|
+
await tap('#oMain [data-rr="ver|cycle"]');
|
|
177
|
+
await until(() => p.evaluate(() => /drawn to the saved design/.test(document.querySelector('#rdSrc').textContent)), 10000);
|
|
178
|
+
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'));
|
|
179
|
+
await shot('reader-look-1280');
|
|
180
|
+
await p.click('#dClose'); await sleep(200);
|
|
181
|
+
|
|
182
|
+
/* I: an issued cycle is frozen */
|
|
183
|
+
await tap(rowSel('2026-10-05'));
|
|
184
|
+
await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#rdSlide')));
|
|
185
|
+
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')));
|
|
186
|
+
ok('I2 an issued cycle still reads as a deck', await counter() === '1 / 3');
|
|
187
|
+
await p.click('#dClose'); await sleep(200);
|
|
188
|
+
|
|
189
|
+
/* P: the writes */
|
|
190
|
+
const allowed = new Set(['/api/report-design/describe', '/api/report-design/sample', '/api/report-design/turn', '/api/report-design/accept', '/api/report-design/revert']);
|
|
191
|
+
ok('P1 the only POSTs are the report-design describe, sample, turn, accept and revert routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
|
|
192
|
+
ok('P2 the first turn described the look first, and each later press posted once', posts.join() === ['sample', 'describe', 'turn', 'turn', 'revert', 'accept'].map((x) => '/api/report-design/' + x).join(), posts.join());
|
|
193
|
+
ok('P3 the document file is unchanged', fs.readFileSync(path.join(dir, pNew), 'utf8') === DOC);
|
|
194
|
+
|
|
195
|
+
/* F: floors */
|
|
196
|
+
await tap(rowSel('2026-10-12'));
|
|
197
|
+
await until(() => p.evaluate(() => !!document.querySelector('#rdSlide')));
|
|
198
|
+
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'));
|
|
199
|
+
ok('F1 every control of the reader is at least 44 px tall', small.length === 0, JSON.stringify(small));
|
|
200
|
+
await p.setViewportSize({ width: 390, height: 844 }); await sleep(400);
|
|
201
|
+
ok('F2 no sideways scroll at 390 px', await p.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1 && document.querySelector('#oMain').scrollWidth <= document.querySelector('#oMain').clientWidth + 1));
|
|
202
|
+
await shot('reader-deck-390');
|
|
203
|
+
ok('F4 the read-only ask of the dialog is hidden; the reader\'s own form is the one it has', await p.evaluate(() => getComputedStyle(document.querySelector('#askF')).display === 'none' && getComputedStyle(document.querySelector('#rdF')).display !== 'none'));
|
|
204
|
+
ok('F3 no page error', errs.length === 0, errs.join(' | '));
|
|
205
|
+
return finish();
|
|
206
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -0,0 +1,203 @@
|
|
|
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 (!mode || !out || mode === 'dry') return done('Done.');
|
|
55
|
+
const prev = line('Previous version');
|
|
56
|
+
const plan = prev && prev.startsWith('/') ? JSON.parse(fs.readFileSync(prev, 'utf8')) : {
|
|
57
|
+
purpose: { readers: 'Leadership', decision: 'Whether partners activate fast enough', scope: 'Partners', cadence: 'monthly', questions: ['Are partners activating?'] },
|
|
58
|
+
sources: [{ id: 'board', kind: 'pmos-level', name: 'Board', ref: 'board', use: 'The KR metric records', state: 'reached' }],
|
|
59
|
+
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' }],
|
|
60
|
+
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' },
|
|
61
|
+
{ 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' }],
|
|
62
|
+
options: [],
|
|
63
|
+
};
|
|
64
|
+
fs.writeFileSync(out, JSON.stringify(plan));
|
|
65
|
+
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);
|
|
66
|
+
});
|
|
67
|
+
`, { mode: 0o755 });
|
|
68
|
+
const model = async () => (await (await fetch(BASE + '/api/insights-premium')).json()).model;
|
|
69
|
+
|
|
70
|
+
(async () => {
|
|
71
|
+
const exe = findBrowser();
|
|
72
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
73
|
+
let chromium;
|
|
74
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
75
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore',
|
|
76
|
+
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 }) });
|
|
77
|
+
await T.waitForServer(BASE);
|
|
78
|
+
browser = await chromium.launch({ executablePath: exe, headless: true, args: ['--no-sandbox'] });
|
|
79
|
+
|
|
80
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p = await ctx.newPage(), errs = [], posts = [];
|
|
81
|
+
p.on('pageerror', (e) => errs.push(String(e)));
|
|
82
|
+
p.on('request', (r) => { if (r.method() === 'POST') posts.push(new URL(r.url()).pathname); });
|
|
83
|
+
await p.goto(BASE + '/premium-insights.html');
|
|
84
|
+
await until(() => p.evaluate(() => !!document.querySelector('#repNew')));
|
|
85
|
+
const M0 = await model(), bname = M0.board.name;
|
|
86
|
+
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 : ''; }); };
|
|
87
|
+
const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
|
|
88
|
+
const chipv = (k) => p.evaluate((x) => (document.querySelector(`#oMain [data-st="chip|${x}"] b`) || {}).textContent || '', k);
|
|
89
|
+
const checksTxt = () => p.evaluate(() => (document.querySelector('#stCk .suckb b') || {}).textContent || '');
|
|
90
|
+
const secs = () => p.evaluate(() => [...document.querySelectorAll('#stPv .stsec h4')].map((h) => h.firstChild.textContent));
|
|
91
|
+
const tap = (sel) => p.$eval(sel, (b) => b.click());
|
|
92
|
+
const mode = () => p.evaluate(() => (document.querySelector('#oMain .stmd [aria-pressed="true"]') || {}).textContent || '');
|
|
93
|
+
const shot = async (n) => { if (process.env.STUDIO_SHOTS) await p.screenshot({ path: path.join(process.env.STUDIO_SHOTS, n + '.png') }); };
|
|
94
|
+
const cta = () => p.evaluate(() => { const b = document.querySelector('#stFt [data-st="save"]'); return b ? b.textContent + (b.disabled ? ':off' : ':on') : ''; });
|
|
95
|
+
|
|
96
|
+
/* O: New report opens the Studio in Report mode */
|
|
97
|
+
await p.click('#repNew');
|
|
98
|
+
await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .stu')));
|
|
99
|
+
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'
|
|
100
|
+
&& 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());
|
|
101
|
+
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());
|
|
102
|
+
|
|
103
|
+
/* K and C: the checks and the conversation */
|
|
104
|
+
ok('K1 without what it answers, 4 of 5 checks pass', await checksTxt() === '4 of 5 checks pass', await checksTxt());
|
|
105
|
+
let a = await say('It answers: Are partners activating fast enough?');
|
|
106
|
+
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);
|
|
107
|
+
a = await say('for leadership, monthly');
|
|
108
|
+
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);
|
|
109
|
+
ok('K2 leadership with a document fails "The format fits the audience"', await checksTxt() === '4 of 5 checks pass', await checksTxt());
|
|
110
|
+
await tap('#oMain [data-st="ck"]'); await sleep(100);
|
|
111
|
+
const fix = await p.evaluate(() => [...document.querySelectorAll('#stCk .sucl li.bad button')].map((b) => b.textContent));
|
|
112
|
+
ok('K3 the failing check offers its fix', fix.join() === 'Make it slides', fix.join());
|
|
113
|
+
await tap('#stCk .sucl li.bad button'); await sleep(150);
|
|
114
|
+
ok('K4 the fix makes it slides, and the checks pass', await chipv('out') === 'Google Slides' && await checksTxt() === '5 of 5 checks pass');
|
|
115
|
+
a = await say('leave out the timeline');
|
|
116
|
+
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);
|
|
117
|
+
a = await say('call it Partner review, every two weeks on Thursday');
|
|
118
|
+
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);
|
|
119
|
+
await tap('#oMain [data-st="undo"]'); await sleep(150);
|
|
120
|
+
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'));
|
|
121
|
+
await say('call it Partner review');
|
|
122
|
+
await shot('report-new-1280');
|
|
123
|
+
ok('C5 no turn on a new report posted anything', posts.length === 0, posts.join());
|
|
124
|
+
|
|
125
|
+
/* B: the brief and its tray */
|
|
126
|
+
await tap('#oMain [data-st="chip|from"]'); await sleep(100);
|
|
127
|
+
const from = await p.evaluate(() => [...document.querySelectorAll('#stTr .sto b')].map((b) => b.textContent));
|
|
128
|
+
ok('B1 Draw from offers your work and the board\'s dashboard', from.join() === 'Your work,The board\'s dashboard', from.join());
|
|
129
|
+
await tap('#stTr [data-st="set|from|dash"]'); await sleep(100);
|
|
130
|
+
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)));
|
|
131
|
+
await tap('#oMain [data-st="chip|from"]'); await sleep(100); await tap('#stTr [data-st="set|from|work"]'); await sleep(100);
|
|
132
|
+
await tap('#oMain [data-st="chip|sched"]'); await sleep(100);
|
|
133
|
+
await tap('#stTr [data-st="set|cadence|weekly"]'); await sleep(100);
|
|
134
|
+
await tap('#oMain [data-st="chip|sched"]'); await sleep(100);
|
|
135
|
+
await tap('#stTr [data-st="set|day|Tue"]'); await sleep(100);
|
|
136
|
+
ok('B3 the Schedule tray sets weekly on a Tuesday', await chipv('sched') === 'Weekly, Tuesdays at 09:00', await chipv('sched'));
|
|
137
|
+
await tap('#oMain [data-st="chip|aud"]'); await sleep(100);
|
|
138
|
+
await p.fill('#stI', 'Leadership team'); await sleep(150);
|
|
139
|
+
ok('B4 the Audience field sets the audience as it is typed', await chipv('aud') === 'Leadership team');
|
|
140
|
+
await p.press('#stI', 'Enter'); await sleep(100);
|
|
141
|
+
|
|
142
|
+
/* S: set it up */
|
|
143
|
+
await tap('#oMain [data-st="save"]');
|
|
144
|
+
await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
145
|
+
const st0 = [...RS.fold(RS.readLines(RS.ledgerFile(dir))).setups.values()];
|
|
146
|
+
const su = st0[0] || {};
|
|
147
|
+
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'
|
|
148
|
+
&& su.schedule.cadence === 'weekly' && su.schedule.day === 'Tue' && su.purpose === 'Are partners activating fast enough?', JSON.stringify(su));
|
|
149
|
+
const toastT = await p.evaluate(() => (document.querySelector('#toast') || {}).textContent || '');
|
|
150
|
+
const draftRel = (/first draft is (\S+\.md)/.exec(toastT) || [])[1];
|
|
151
|
+
ok('S2 the answer says where the first draft is, and the file is there', !!draftRel && fs.existsSync(path.join(dir, draftRel)), toastT);
|
|
152
|
+
ok('S3 Set it up posted the setup route only', posts.join() === '/api/report-setups/setup', posts.join());
|
|
153
|
+
|
|
154
|
+
/* H: shape the set-up report */
|
|
155
|
+
await until(() => p.evaluate((id) => !!document.querySelector(`#repBody [data-setup="${id}"]`), su.id));
|
|
156
|
+
await p.click(`#repBody [data-setup="${su.id}"]`);
|
|
157
|
+
await until(() => p.evaluate(() => !!document.querySelector('#oMain [data-rx="studio"]')));
|
|
158
|
+
await tap('#oMain [data-rx="studio"]');
|
|
159
|
+
await until(() => p.evaluate(() => !!document.querySelector('#oMain .stu')) && chipv('ver').then((v) => v === 'None yet'));
|
|
160
|
+
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(' | '));
|
|
161
|
+
await tap('#oMain [data-st="chip|secs"]'); await sleep(100);
|
|
162
|
+
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));
|
|
163
|
+
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());
|
|
164
|
+
await p.fill('#stIn', 'Shape it for the partner review'); await p.press('#stIn', 'Enter');
|
|
165
|
+
ok('H3 a turn shows PMOS working', await until(() => lastA().then((x) => x === 'PMOS is working on it.'), 3000));
|
|
166
|
+
await until(() => chipv('ver').then((v) => v === 'S1, not saved'), 30000);
|
|
167
|
+
a = await lastA();
|
|
168
|
+
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());
|
|
169
|
+
ok('H5 the turn posted report-structure/turn', posts.includes('/api/report-structure/turn'), posts.join());
|
|
170
|
+
await until(() => p.evaluate(() => !!document.querySelector('#stTr [data-st="rsec|changes"]')), 3000);
|
|
171
|
+
await tap('#stTr [data-st="rsec|changes"]');
|
|
172
|
+
await until(() => chipv('ver').then((v) => v === 'S2, not saved'));
|
|
173
|
+
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());
|
|
174
|
+
await tap('#oMain [data-st="undo"]');
|
|
175
|
+
await until(() => chipv('ver').then((v) => v === 'S1, not saved'));
|
|
176
|
+
ok('U2 Undo on a set-up report goes back one version', (await secs()).length === 5 && posts.includes('/api/report-structure/revert'));
|
|
177
|
+
ok('K6 Leadership with five sections passes the length check; the unsaved version fails', await checksTxt() === '4 of 5 checks pass', await checksTxt());
|
|
178
|
+
await tap('#oMain [data-st="save"]');
|
|
179
|
+
await until(() => chipv('ver').then((v) => v === 'S1, saved'));
|
|
180
|
+
const sv = S.stateOf(dir, su.id).saved;
|
|
181
|
+
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());
|
|
182
|
+
|
|
183
|
+
await tap('#oMain [data-st="chip|secs"]'); await sleep(150); await shot('report-shape-1280'); await tap('#oMain [data-st="chip|secs"]');
|
|
184
|
+
/* L: the library */
|
|
185
|
+
await tap('#oMain [data-st="lib"]'); await sleep(100);
|
|
186
|
+
const lib = await p.evaluate(() => [...document.querySelectorAll('#stLb .stli')].map((b) => b.querySelector('b').textContent + ':' + b.querySelector('em').textContent));
|
|
187
|
+
ok('L1 the library lists the set-up reports', lib.join() === 'Partner review:Open', lib.join());
|
|
188
|
+
await tap('#oMain [data-st="lib"]');
|
|
189
|
+
|
|
190
|
+
/* P: the writes */
|
|
191
|
+
const allowed = new Set(['/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']);
|
|
192
|
+
ok('P1 every POST is one of the existing report routes', posts.length > 0 && posts.every((x) => allowed.has(x)), posts.join());
|
|
193
|
+
|
|
194
|
+
/* F: floors */
|
|
195
|
+
await p.setViewportSize({ width: 390, height: 844 }); await sleep(300);
|
|
196
|
+
const wide = await p.evaluate(() => { const d = document.querySelector('#oMain'); return [document.documentElement.scrollWidth - innerWidth, d ? d.scrollWidth - d.clientWidth : 0]; });
|
|
197
|
+
await shot('report-shape-390');
|
|
198
|
+
ok('F1 at 390 wide, Report mode does not scroll sideways', wide[0] <= 0 && wide[1] <= 1, wide.join());
|
|
199
|
+
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));
|
|
200
|
+
ok('F2 the mode switch, the chips and the footer are 44 px tall', small.length === 0, small.join());
|
|
201
|
+
ok('F3 no script error', errs.length === 0, errs.join(' | '));
|
|
202
|
+
return finish();
|
|
203
|
+
})().catch((e) => { console.error(e); finish(1); });
|