create-pmos 0.320.0 → 0.322.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.320.0",
3
+ "version": "0.322.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@aeaf614
1
+ kernel-source: pmos@de4bfa4
2
2
  assembled: 2026-10-19
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:07:56Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:07:56Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-19T15:07:56Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T15:33:17Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -168,6 +168,15 @@ A row or a Today item opens a dialog with the same parts every time. At the top
168
168
 
169
169
  The right side can hold more than one item. When the dialog opens a related item there, such as a document, a meeting or a ticket, the item opens as a tab beside the dialog's own detail. The first tab is always the dialog's own detail. You can have up to four more tabs; a fifth closes the oldest. Click a tab or use the arrow keys to move between them. Use the **×** on a tab, or press Delete, to close it. The tabs close when the dialog closes. With no extra item, there are no tabs.
170
170
 
171
+ ### The document page
172
+
173
+ Every markdown document opens as one page in a tab: a report, a PRD, a new document or any other `.md` file. On a document sheet, click **Open as a page**. On a report, click **Edit**.
174
+
175
+ - **Page** shows the document as it reads. **Edit** lets you type on the page itself, with a toolbar, a **/** menu for blocks, and Ctrl+S to save. **Markdown** shows the source text. Only the sections you changed are written; the other sections and the front matter keep their exact text.
176
+ - When the agent proposes an edit, the page shows it applied and highlighted. Click a highlight to see the old text, and click **Put it back** to restore it. The bar above the page has **Keep as vN**, which keeps the changes that remain, and **Undo all**, which asks first and then rejects the whole edit.
177
+ - **Health**, **Links** and **Copies** under the toolbar show the document's checks, the documents it links to, and its linked copies. The checks only read the file.
178
+ - A report also shows **Present**, **Print** and **Download** on the same toolbar.
179
+
171
180
  A decision opens with no option chosen, because no recommendation is on record. Choose one and the draft entry on the right changes. Nothing is written. The main button, "Not yet" and "Return this run to the agent" are off in this version, and each says why.
172
181
 
173
182
  ## The conversation
@@ -249,7 +258,7 @@ Board is the third place on the rail, at `/premium-board.html`. It reads what th
249
258
  - **List** shows the late and at-risk initiatives first, then the board's now view, up to 100 loaded and 25 on screen at a time. A row shows the owner and lane, a status chip when it is not on track, how far through the workflow it is (and "derived" when the workflow engine placed it), a progress bar only when a record holds progress, and the planned finish only when an end date was set ("Not planned" otherwise). "Do this first" appears only when the first row is late.
250
259
  - **By stage** has one column for each stage of the board's workflow with the board's own count and its first five initiatives.
251
260
  - **List** and **Timeline** show ten tasks a page with Previous and Next; **By stage** shows six cards a column with Show more. **Timeline** draws a bar for each initiative that has both a start and an end date, with the days left or over, and counts the rest. With no dates on record it says so and draws nothing.
252
- - **Sprint** appears when an agent session has read Jira for the board. Otherwise it says there is none. **Coming up** shows the next release, from the releases ledger.
261
+ - **Sprint** appears when an agent session has read Jira for the board. Otherwise it says there is none. Press it to open the sprint's facts, with the sprint as a board in a second tab: **To do**, **In progress** and **Done** columns from the last Jira read, with the goal, the dates, the days left and the points. When the board has more than one sprint, you can switch to another one. Press a card to open its ticket in another tab. A card that is on no initiative of this board is drawn, but it does not open. The board is read only: Jira owns each ticket's status and sprint, so you move tickets in Jira. Tickets with no sprint are not in this read. **Coming up** shows the next release, from the releases ledger.
253
262
  - **Metrics** appears above the Initiatives card on the board of any workspace except the home one (PMOS itself), and counts from that workspace's own repository. It has four tiles. **Corrections per 100 runs** is the corrections logged on the week's runs in `planning/runs/agent-runs.jsonl`; a week with fewer than 10 runs is left blank. **Merged a week** counts the commits on the first-parent line of the trunk. **Blocked** and **Idle for a month** come from the workflow engine, which keeps no history. From the first day the card is read, PMOS keeps their counts once a day in the workspace's state folder (`board-metric-history.jsonl`), so their charts start on that day and their caption says **history starts today** (later, the date). Earlier weeks read **Not kept yet**. Move over a chart, or use the arrow keys, to read a week. A tile that cannot be counted says **Not read** and why; a repository with no run log says **No runs yet**. The line above the tiles starts with how many tiles need a look, and those tiles have a **Needs a look** chip and an orange outline. The line ends with **open Insights**, which opens the same board's Insights page. Press a tile for its definition and values, with the read-only agent beside it. A target is set on Insights, not here. A measure with a target shows it under the value, draws it as a dashed line, and carries **On target** or its gap (for example **2 short**); off target, it also has the orange outline. A measure without a target draws no line. Day and Month are off. It was tested only on made-up repositories, not on a real IDPF or microsite repository.
254
263
  - **The top bar** names the page and the board. With more than one board a menu switches between them, and **Chat** opens the board in the dialog with the read-only agent.
255
264
  - **Core documents** lists the board's documents with their state, cadence and writer, a summary (drafts to review, not started, up to date), a progress bar, a filter and a search. A document with a file opens in the dialog, read only, with its path and state; a draft there has **Issue it**, which marks it issued through the console's own route and sends nothing, and **Draft it again**, which starts a new draft that replaces this one (a board draft has no Edit tab). **Draft it** starts the existing read-only run that writes a draft and sends nothing; **Draft the N not started** does that for each document that can be drafted. **Set it up** and **Open** go to the console. **Add a document** opens a form (title, who writes it, where it lives) and saves a document the core set does not cover on the board's record, in `custom-docs.jsonl`. A document with no link reads "Not started". A document with a link to Confluence or Google Docs reads "Linked" and shows its address. PMOS does not read or sync the linked page, so a linked document is never counted as up to date. Issue and Drop are not on this page.
@@ -270,7 +279,7 @@ The initiative page is at `/premium-initiative.html?id=<initiative>`. A click on
270
279
  - **The header** shows a status chip, the owner and the planned finish. Each appears only when a record holds it. Under it, the stage strip shows how far through the board's workflow the initiative is.
271
280
  - **Overview** shows the description (the part of the record's title after " — "), then the next step with its reason, its action and what happens if you wait, as the workflow engine states them, and who it waits on. **PMOS can help** offers up to three presses that do something real: a draft of the first core document not started (the existing read-only run) and a question for the read-only agent. The health reasons and the board's warnings are shown as written.
272
281
  - **Overview** is one full-width card, as in the mockup; there is no separate Checks card. A blocked step shows as a note, and "All N workflow steps" lists every step of the engine with the evidence each states.
273
- - **Tasks** lists the PRD requirements and the board's tracker items for this initiative. The repository records no result for each requirement, so a requirement says "No result" and is never drawn as done or open. **By stage** groups them by state. **Timeline** draws a bar for each task that has both a start and a due date, and lists the rest. Press a task to read its record; every Core documents row opens too: a document with no file shows what it is for, who writes it and what a draft will contain, with Draft it where a draft can run; for a PMOS task you can change its status. **Add a task** writes a PMOS task to the board's own record; with no dates the board plans it from tomorrow for a week. Jira tickets stay read-only. **Add a document** works as on the Board, with a phase as well, and saves on the initiative's record.
282
+ - **Tasks** lists the PRD requirements and the board's tracker items for this initiative. The repository records no result for each requirement, so a requirement says "No result" and is never drawn as done or open. **By stage** groups them by state. **Timeline** draws a bar for each task that has both a start and a due date, and lists the rest. Press a task to read its record; every Core documents row opens too: a document with no file shows what it is for, who writes it and what a draft will contain, with Draft it where a draft can run; for a PMOS task you can change its status. **Add a task** writes a PMOS task to the board's own record; with no dates the board plans it from tomorrow for a week. Jira tickets stay read-only. A Jira task also opens its ticket in a second tab. The tab shows the key, the title, the status, the sprint, the points, the priority and size, the ticket's text from the Jira draft, how many subtasks are done, the links to other tickets and the PRD, and **Open in Jira**. The assignee, comments, history and the other fields stay in Jira, because the Jira read holds no people. A ticket with no record says what is missing. **Add a document** works as on the Board, with a phase as well, and saves on the initiative's record.
274
283
  - **Core documents** has the same counts, filter and search as the Board's card, for this initiative. **Draft it** starts the existing read-only run that writes a draft and sends nothing. Technical documents (the record, the rubric, the stories, the review and the explainer) are grouped and not counted.
275
284
  - **The document sheet.** A document that has a file opens in a dialog with **Read** (the file's text, its front matter as a grid and an outline), **Edit** (the file as plain Markdown, a reason, and **Save**), **Proposals** (**Ask the agent**, the open proposals with **Accept** and **Reject**, and the closed ones), **Edit log** (the revisions and other entries of the document sheet; **Show change** on a revision marks the words it added and removed against the revision before), **Health** (the document-health checks; a check with no input is not counted) and **Relations** (the documents it draws on, its goals, and the documents that use it, from the document library; a related file opens in the same sheet, and a goal or a missing file is listed but cannot be opened). The status line also names each **copy in another tool** (a Confluence page or Google Doc, with its state: in step, behind, both changed and so on), or offers **Link a copy**. Pressing it opens a panel with each copy's state, a link to open it, **Check now** (one agent session reads the copies with your connectors) and a box to paste a link. The sheet never writes to a copy; updating one is in the console. The file changes only when you press Save or Accept, and every change is kept in the Edit log with its reason. Save and Reject need a reason. A proposal made on text that has since changed shows which sections are out of date and cannot take them. The agent beside the sheet still only reads. A draft shows a bar above its text: **Issue it** marks the draft issued, through the console's own route, and sends nothing; it refuses while the Edit tab holds unsaved changes. Bold and undo buttons and Drop are not built on this page.
276
285
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.320.0",
3
+ "version": "0.322.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.320.0",
9
+ "version": "0.322.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.320.0",
3
+ "version": "0.322.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -88,7 +88,7 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
88
88
 
89
89
  const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 }, acceptDownloads: true }), p = await ctx.newPage(), errs = [], posts = [];
90
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); });
91
+ p.on('request', (r) => { const u = new URL(r.url()).pathname; if (r.method() === 'POST' && u !== '/api/doc-health/check') posts.push(u); }); // the document page's health check is a read sent as a POST; it writes nothing
92
92
  const shot = async (n) => { if (process.env.READ_SHOTS) await p.screenshot({ path: path.join(process.env.READ_SHOTS, n + '.png') }); };
93
93
  const tap = (sel) => p.$eval(sel, (b) => b.click());
94
94
  const lastA = () => p.evaluate(() => { const a = [...document.querySelectorAll('#dBody .stream .turn.a .tt')]; return a.length ? a[a.length - 1].textContent : ''; });
@@ -151,6 +151,21 @@ fs.writeFileSync(path.join(base, 'q3-deck.png'), PNG);
151
151
  const pr = await p.evaluate(() => ({ h: window.__pr || '', printed: !!window.__printed }));
152
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
153
 
154
+ /* E: Edit opens the report's file as the one document page (premium-viewer S2), with this report's Present, Print and Download on its bar */
155
+ await tap('#oMain [data-rr="page"]');
156
+ const VP = '.obody.vw:not([hidden]) .vwdoc';
157
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' .cf'), VP));
158
+ ok('E1 Edit opens the report as a page in a viewer tab, with Page, Edit and Markdown', await p.evaluate((v) => { const st = window.__premiumViewer.vwState(); return st.on.startsWith('doc:') && document.querySelectorAll(v + ' .vwseg').length === 3 && /Partner review, 12 Oct/.test(document.querySelector(v + ' .cft').textContent); }, VP));
159
+ ok('E2 the page bar carries Present, Print and Download', await p.evaluate((v) => ['Present', 'Print', 'Download'].every((t) => [...document.querySelectorAll(v + ' .vwdt .vwbtn')].some((b) => b.textContent.trim() === t)), VP));
160
+ await p.click(VP + ' [data-vd="xm:dl"]');
161
+ const pitems = await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwxmn [role="menuitem"]')].map((a) => a.getAttribute('href') || a.dataset.vwx), VP);
162
+ ok('E3 its Download lists the same four files through report-export, and the Markdown file', pitems.length === 5 && pitems.slice(0, 4).every((h, i) => h.includes('/api/report-export?') && h.includes('fmt=' + ['pptx', 'docx', 'xlsx', 'csv'][i])) && pitems[4] === 'md', JSON.stringify(pitems));
163
+ await p.click(VP + ' [data-vd="xm:dl"]');
164
+ await p.click(VP + ' [data-vwx="present"]');
165
+ await until(() => p.$('#rdPres'));
166
+ ok('E4 Present from the page presents the deck over the whole page', !!(await p.$('#rdPres')) && await p.evaluate(() => window.__premiumViewer.vwState().on === 'main'));
167
+ await p.keyboard.press('Escape'); await sleep(200);
168
+
154
169
  /* L: the look */
155
170
  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
171
  await p.setInputFiles('#rdFile', path.join(base, 'q3-deck.png'));
@@ -0,0 +1,218 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-doc-test.js — a markdown document as a page in the premium viewer (initiative premium-viewer S2; planning/prd/premium-viewer-prd.md R2, R6, R7).
4
+ * Serves the real initiative page from the real server and opens its PRD sheet, then the page in the viewer. The /api/doc-sheet routes are answered by a
5
+ * small stateful stand-in, so each press can be read off the request the page sent. The routes' own behaviour is in briefing-premium-doc-edit.test.js.
6
+ * D1 the page · D2 edit in place · D3 Markdown · D4 an agent's edit · D5 Undo all · D6 ask · D7 the sheet reads again · D8 floors */
7
+ const path = require('path');
8
+ const { spawn } = require('child_process');
9
+ const { findBrowser } = require('./lib/find-browser');
10
+ const T = require('./test-run').configure({ name: 'premium-vw-doc' });
11
+ const IP = require('./lib/initiative-premium.js');
12
+ const F = require('./fixtures/initiative-premium-facts.js');
13
+
14
+ const BASE = T.BASE;
15
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
16
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
17
+ const results = [];
18
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
19
+ let srv = null; let 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-vw-doc assertions passed`);
26
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
27
+ };
28
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
29
+
30
+ const PATH = 'planning/prd/self-serve-v2-prd.md';
31
+ const TEXT = '---\ntype: PRD\ntitle: "Self-serve onboarding v2"\nstatus: Draft\ntimestamp: 2026-10-16\ntags: [onboarding, q4]\n---\n\n# PRD: Self-serve onboarding v2\n\n'
32
+ + '> [!NOTE]\n> Owned by the onboarding squad.\n\n## Problem\n\nA partner waits for a person.\nIt takes two days.\n\n## Goal\n\n- a first call without help\n\n'
33
+ + '## Requirements\n\n| Id | What | State |\n|---|---|---|\n| R1 | a first call | :status[In progress] |\n\n- [x] draft the flow\n- [ ] test it\n';
34
+ const AFTER = TEXT.replace('## Goal', '## Summary\n\nPartners reach a first call without help.\n\n## Goal').replace('- a first call without help', '- a first call in under ten minutes');
35
+ const prop = (o) => Object.assign({ id: 'prop-a', state: 'proposed', prompt: 'add a summary and tighten the goal', at: '2026-10-18T01:00:00Z', hash: 'ha', by: 'agent', why: null, after: AFTER, sections: [
36
+ { name: 'Summary', kind: 'added', before: '', after: 'Partners reach a first call without help.', current: null, stale: false },
37
+ { name: 'Goal', kind: 'changed', before: '- a first call without help', after: '- a first call in under ten minutes', current: '- a first call without help', stale: false },
38
+ { name: 'Requirements', kind: 'changed', before: 'x', after: 'y', current: 'z', stale: true }] }, o || {});
39
+
40
+ (async () => {
41
+ const exe = findBrowser();
42
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
43
+ let chromium;
44
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
45
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
46
+ await T.waitForServer(BASE);
47
+ browser = await chromium.launch({ executablePath: exe });
48
+
49
+ const open = async ({ w = 1280, h = 900, theme = 'light', props = [], post = null } = {}) => {
50
+ const ctx = await browser.newContext({ viewport: { width: w, height: h } });
51
+ const page = await ctx.newPage();
52
+ const S = { text: TEXT, revs: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z' }], props, ask: null, errors: [], posts: [], gets: [], links: [] };
53
+ page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
54
+ await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(F.facts()), as_of: F.NOW }) }));
55
+ await page.route('**/api/doc-health/check', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, health: { passed: 1, total: 1, checks: [{ id: 'fresh', pass: true, reason: 'ok' }] } }) }));
56
+ await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
57
+ await page.route('**/api/docs/library*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, kinds: ['cites'], files: [{ path: PATH, title: 'Self-serve PRD' }, { path: 'planning/research/interviews.md', title: 'Onboarding interviews' }, { path: 'planning/evals/self-serve-v2-rubric.md', title: 'Self-serve rubric' }], edges: [[1, 0, 0], [0, 2, 0]] }) }));
58
+ await page.route('**/api/docs?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, docs: [{ path: PATH, links: S.links }] }) }));
59
+ await page.route('**/api/docs/link', (r) => { const b = JSON.parse(r.request().postData() || '{}'); S.posts.push({ route: 'docs/link', body: b }); S.links.push({ kind: b.kind, target: b.target, signal: 'unchecked', title: 'Onboarding PRD' }); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
60
+ await page.route('**/api/doc-sheet/**', (r) => {
61
+ const rq = r.request(), u = new URL(rq.url()), route = u.pathname.replace('/api/doc-sheet/', ''), send = (b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
62
+ if (rq.method() === 'GET') {
63
+ S.gets.push({ route, query: u.search });
64
+ if (route === 'log') return send({ ok: true, path: PATH, revisions: S.revs, events: [] });
65
+ if (route === 'at') return send({ ok: true, path: PATH, rev: S.revs.length, text: S.text });
66
+ if (route === 'proposals') return send({ ok: true, path: PATH, proposals: S.props });
67
+ if (route === 'ask') return send(S.ask || { ok: true, id: 'ask-1', state: 'working' });
68
+ return send({ ok: false, error: 'not in this test' }, 404);
69
+ }
70
+ const body = JSON.parse(rq.postData() || '{}'); S.posts.push({ route, query: u.search, body });
71
+ if (post) { const a = post(route, body, S); if (a) return send(a.body, a.status || 200); }
72
+ if (route === 'edit') { S.text = body.text; S.revs.push({ rev: S.revs.length + 1, why: body.why, by: 'pm', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
73
+ if (route === 'accept') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'accepted' }) : p)); S.text = AFTER.replace('- a first call in under ten minutes', '- a first call without help'); S.revs.push({ rev: S.revs.length + 1, why: 'add a summary', by: 'pm', text_by: 'agent', at: '2026-10-18T02:00:00Z' }); return send({ ok: true }); }
74
+ if (route === 'reject') { S.props = S.props.map((p) => (p.id === body.id ? Object.assign({}, p, { state: 'rejected', why: body.why }) : p)); return send({ ok: true }); }
75
+ if (route === 'ask') { S.ask = { ok: true, id: 'ask-1', state: 'working' }; return send({ ok: true, id: 'ask-1', state: 'working' }); }
76
+ return send({ ok: false, error: 'not in this test' }, 404);
77
+ });
78
+ await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
79
+ await until(() => page.evaluate(() => document.querySelector('#cIniDoc')));
80
+ await page.locator('#dmList .dmo[data-doc="prd"]').click();
81
+ await until(() => page.evaluate(() => document.querySelector('#oMain [data-ds="page"]')));
82
+ await page.click('#oMain [data-ds="page"]');
83
+ await until(() => page.evaluate(() => document.querySelector('.vwdoc .cf, .vwdoc .vwempty:not(:empty)') && !/Reading the file/.test(document.querySelector('.vwdoc').textContent)));
84
+ return { ctx, page, S };
85
+ };
86
+ const V = '.obody.vw:not([hidden]) .vwdoc';
87
+ const txt = (p, q) => p.evaluate((s) => ((document.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' '), q);
88
+
89
+ /* D1 the page */
90
+ const A = await open(); const p = A.page;
91
+ ok('D1 Open as a page opens the document in a viewer tab, beside the sheet', await p.evaluate(() => { const st = window.__premiumViewer && window.__premiumViewer.vwState(); return !!st && st.ids.includes('doc:planning/prd/self-serve-v2-prd.md') && st.on === 'doc:planning/prd/self-serve-v2-prd.md'; }));
92
+ const head = await p.evaluate((v) => { const r = document.querySelector(v); return { t: r.querySelector('.cft').textContent, by: r.querySelector('.cfby').textContent, props: [...r.querySelectorAll('.cfpr tr')].map((x) => [...x.children].map((c) => c.textContent.trim()).join(' ')), labels: [...r.querySelectorAll('.cflb span')].map((x) => x.textContent), h1: r.querySelectorAll('.cfb h1, .cfb h2').length && r.querySelector('.cfb').textContent.includes('PRD: Self-serve'), foot: r.querySelector('.cff').textContent }; }, V);
93
+ ok('D1 the title comes from the front matter and the first heading is not drawn twice', head.t === 'Self-serve onboarding v2' && !head.h1, JSON.stringify(head));
94
+ ok('D1 the byline says who changed it last, the version and the read time, from the log', /Last change by Before the sheet · 16 Oct 2026 · v1 · 1 min read/.test(head.by), head.by);
95
+ ok('D1 the properties table and labels come from the front matter', head.props.join('|') === 'type PRD|status Draft|timestamp 16 Oct 2026' && head.labels.join() === 'onboarding,q4', JSON.stringify(head));
96
+ ok('D1 the body has the panel, the table with its status label, and the task list', await p.evaluate((v) => { const b = document.querySelector(v + ' .cfb'); return !!b.querySelector('.pnl.note') && !!b.querySelector('.tw table .lz.b') && b.querySelectorAll('.tasks li').length === 2 && b.querySelector('.tasks li[data-done="true"]') !== null; }, V));
97
+ ok('D1 the footer names the file', /planning\/prd\/self-serve-v2-prd\.md/.test(head.foot));
98
+ ok('D1 Page, Edit and Markdown are one control, with Page on', await p.evaluate((v) => [...document.querySelectorAll(v + ' .vwseg')].map((b) => b.textContent.trim() + ':' + b.getAttribute('aria-pressed')).join() === 'Page:true,Edit:false,Markdown:false', V));
99
+
100
+ /* D9 Health, Links and Copies */
101
+ ok('D9 the page shows Health with the checks that passed, Links and Copies', await until(() => p.evaluate((v) => [...document.querySelectorAll(v + ' .vwchip')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()).join('|') === 'Health 1 of 1|Links|Copies 0', V)), await txt(p, V + ' .vwmore'));
102
+ await p.click(V + ' [data-vd="more:health"]');
103
+ ok('D9 Health lists each check from the health route', /fresh\s*Passed/.test(await txt(p, V + ' .vwmp')) && /1 of 1 checks/.test(await txt(p, V + ' .vwmp')));
104
+ await p.click(V + ' [data-vd="more:links"]');
105
+ await until(() => p.evaluate((v) => /Built from/.test((document.querySelector(v + ' .vwmp') || {}).textContent || ''), V));
106
+ ok('D9 Links show what it is built from and what uses it, from the document library', /Built from · 1.*Onboarding interviews/.test(await txt(p, V + ' .vwmp')) && /Used by · 1.*Self-serve rubric/.test(await txt(p, V + ' .vwmp')) && /Links 2/.test(await txt(p, V + ' .vwmore')));
107
+ await p.click(V + ' [data-vd="open:planning/evals/self-serve-v2-rubric.md"]');
108
+ ok('D9 a linked document opens as a page in its own tab', await until(() => p.evaluate(() => window.__premiumViewer.vwState().on === 'doc:planning/evals/self-serve-v2-rubric.md')));
109
+ await p.evaluate(() => window.__premiumViewer.vwShow('doc:planning/prd/self-serve-v2-prd.md'));
110
+ await p.click(V + ' [data-vd="more:copies"]');
111
+ ok('D9 Copies says there is none yet and offers to link one', /no copy in Confluence or Google Docs yet/.test(await txt(p, V + ' .vwmp')));
112
+ await p.fill(V + ' #vwCpUrl', 'https://acme.atlassian.net/wiki/spaces/PM/pages/1'); await p.click(V + ' [data-vd="cplink"]');
113
+ await until(() => p.evaluate((v) => /Onboarding PRD/.test((document.querySelector(v + ' .vwmp') || {}).textContent || ''), V));
114
+ ok('D9 Link posts the copy to /api/docs/link and the copy is listed as not checked', A.S.posts.some((x) => x.route === 'docs/link' && x.body.kind === 'confluence' && x.body.path === PATH) && /Confluence.*Not checked/.test(await txt(p, V + ' .vwmp')));
115
+ await p.click(V + ' [data-vd="more:copies"]');
116
+ const nPosts = A.S.posts.length; A.S.posts.length = 0;
117
+ ok('D9 (setup) the copy link was the only post so far', nPosts === 1);
118
+
119
+ /* D3 Markdown */
120
+ await p.click(V + ' [data-vd="mode:md"]');
121
+ ok('D3 Markdown shows the file exactly as it is on disk', (await p.inputValue(V + ' #vwMd')) === TEXT);
122
+ await p.click(V + ' [data-vd="mode:read"]');
123
+
124
+ /* D2 edit in place */
125
+ await p.click(V + ' [data-vd="mode:edit"]');
126
+ ok('D2 Edit makes the page itself editable and shows the toolbar and a save row', await p.evaluate((v) => document.querySelector(v + ' .cfb').isContentEditable && !!document.querySelector(v + ' .vwetb') && /Save as v2/.test(document.querySelector(v + ' .vwsave').textContent), V));
127
+ await p.evaluate((v) => { const para = [...document.querySelectorAll(v + ' .cfb p')].find((x) => /A partner waits/.test(x.textContent)); const r = document.createRange(); r.setStart(para.firstChild, 'A partner'.length); r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); para.focus(); }, V);
128
+ await p.keyboard.type(' still');
129
+ await p.click(V + ' [data-vd="save"]');
130
+ ok('D2 Save with no reason posts nothing and says why', /Say why the document changes/.test(await txt(p, V + ' #vwErr')) && A.S.posts.length === 0);
131
+ ok('D2 the typing is still there after the refusal', /A partner still waits/.test(await txt(p, V + ' .cfb')));
132
+ await p.fill(V + ' #vwWhy', 'say the partner still waits'); await p.click(V + ' [data-vd="save"]');
133
+ await until(() => A.S.posts.length);
134
+ const e1 = A.S.posts[0];
135
+ const want = TEXT.replace('A partner waits for a person.\nIt takes two days.', 'A partner still waits for a person. It takes two days.');
136
+ ok('D2 Save posts path, text and why to /api/doc-sheet/edit for the workspace', e1 && e1.route === 'edit' && Object.keys(e1.body).sort().join() === 'path,text,why' && e1.body.path === PATH && e1.body.why === 'say the partner still waits' && /ws=w1/.test(e1.query), JSON.stringify(e1));
137
+ ok('D2 only the section that was typed in changes; the front matter, the panel, the table and the tasks keep their exact text', e1 && e1.body.text === want, JSON.stringify(e1 && e1.body.text));
138
+ await until(() => p.evaluate((v) => document.querySelector(v + ' .vwseg[aria-pressed="true"]') && /Page/.test(document.querySelector(v + ' .vwseg[aria-pressed="true"]').textContent) && /v2/.test(document.querySelector(v + ' .cfby').textContent), V));
139
+ ok('D2 after Save the page reads the file again and says v2', /Last change by You · 18 Oct 2026 · v2/.test(await txt(p, V + ' .cfby')));
140
+ ok('D7 a write in the page reads the sheet beside it again', A.S.gets.filter((g) => g.route === 'log').length >= 3);
141
+
142
+ /* D2 the editor's blocks: a / menu and a markdown shortcut */
143
+ await p.click(V + ' [data-vd="mode:edit"]');
144
+ await p.evaluate((v) => { const b = document.querySelector(v + ' .cfb'), last = b.lastElementChild; const pp = document.createElement('p'); pp.innerHTML = '<br>'; last.after(pp); const r = document.createRange(); r.setStart(pp, 0); r.collapse(true); const s = getSelection(); s.removeAllRanges(); s.addRange(r); b.focus(); }, V);
145
+ await p.keyboard.type('/'); await sleep(100);
146
+ ok('D2 / opens the block menu with headings, lists, panels, a table and more', await p.evaluate((v) => { const m = document.querySelector(v.replace(' .vwdoc', '') + ' .vwpop'); return !!m && /Heading 1/.test(m.textContent) && /Info panel/.test(m.textContent) && /Table/.test(m.textContent); }, V));
147
+ await p.keyboard.type('info'); await p.keyboard.press('Enter'); await sleep(100);
148
+ await p.keyboard.type('Ship to new workspaces first.');
149
+ ok('D2 picking Info panel puts a panel in the page where the caret was', await p.evaluate((v) => [...document.querySelectorAll(v + ' .cfb .pnl.info')].some((x) => /Ship to new workspaces first/.test(x.textContent)), V));
150
+ await p.fill(V + ' #vwWhy', 'add a note'); await p.click(V + ' [data-vd="save"]');
151
+ await until(() => A.S.posts.length > 1);
152
+ ok('D2 the panel is saved as a GitHub note block in plain markdown', /> \[!INFO\]\n> Ship to new workspaces first\./.test(A.S.posts[1].body.text) && A.S.posts[1].body.text.startsWith(want.split('## Requirements')[0]), JSON.stringify(A.S.posts[1].body.text));
153
+ ok('0 no page error', A.S.errors.length === 0, A.S.errors.join(' | '));
154
+ await A.ctx.close();
155
+
156
+ /* D4 an agent's edit, applied and highlighted, with one Keep */
157
+ {
158
+ const B = await open({ props: [prop()] }); const q = B.page;
159
+ await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
160
+ ok('D4 the bar says what was asked and how many places changed, with Undo all and Keep as v2', /Asked: add a summary and tighten the goal/.test(await txt(q, V + ' .vwag')) && /The agent changed 2 places/.test(await txt(q, V + ' .vwag')) && /Keep as v2/.test(await txt(q, V + ' [data-vd="keep"]')) && !!(await q.$(V + ' [data-vd="undoall"]')));
161
+ ok('D4 a stale section is not applied, and the bar says so', /1 more change does not apply/.test(await txt(q, V + ' .vwag')) && !(await q.$(V + ' .vwchg[data-sec="Requirements"]')));
162
+ ok('D4 the changes are in the page, highlighted: the new Summary and the new Goal text', await q.evaluate((v) => { const s = document.querySelector(v + ' .vwchg.added[data-sec="Summary"]'), g = document.querySelector(v + ' .vwchg.changed[data-sec="Goal"]'); return !!s && /Partners reach a first call without help/.test(s.textContent) && !!g && /under ten minutes/.test(g.textContent); }, V));
163
+ ok('D4 Edit and Markdown wait until the edit is kept or undone', await q.evaluate((v) => document.querySelector(v + ' [data-vd="mode:edit"]').disabled && document.querySelector(v + ' [data-vd="mode:md"]').disabled, V));
164
+ await q.click(V + ' .vwchg[data-sec="Goal"] .vwcl');
165
+ ok('D4 clicking a highlight shows what it said before', /What it said before.*a first call without help/.test(await txt(q, V + ' .vwchg[data-sec="Goal"] .vwbefore')));
166
+ await q.click(V + ' .vwchg[data-sec="Goal"] [data-vd="back:Goal"]');
167
+ ok('D4 Put it back shows the old text and the bar counts one place', /a first call without help/.test(await txt(q, V + ' .vwchg[data-sec="Goal"] .vwcb')) && /The agent changed 1 place\./.test(await txt(q, V + ' .vwag')) && await q.evaluate((v) => document.querySelector(v + ' .vwchg[data-sec="Goal"]').classList.contains('off'), V));
168
+ await q.click(V + ' [data-vd="keep"]');
169
+ await until(() => B.S.posts.length);
170
+ const ac = B.S.posts[0];
171
+ ok('D4 Keep accepts only the sections still applied, with the proposal id and hash', ac.route === 'accept' && Object.keys(ac.body).sort().join() === 'hash,id,path,sections' && ac.body.sections.join() === 'Summary' && ac.body.hash === 'ha' && /ws=w1/.test(ac.query), JSON.stringify(ac));
172
+ await until(() => q.evaluate((v) => !document.querySelector(v + ' .vwag') && /v2/.test((document.querySelector(v + ' .cfby') || {}).textContent || ''), V));
173
+ ok('D4 after Keep the page is the file as v2, with no highlight left', await q.evaluate((v) => !document.querySelector(v + ' .vwchg') && /Partners reach a first call/.test(document.querySelector(v + ' .cfb').textContent), V));
174
+ ok('0 no page error', B.S.errors.length === 0, B.S.errors.join(' | '));
175
+ await B.ctx.close();
176
+ }
177
+ /* D5 Undo all, D6 ask */
178
+ {
179
+ const C = await open({ props: [prop()] }); const q = C.page;
180
+ await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
181
+ await q.click(V + ' [data-vd="undoall"]');
182
+ await sleep(150);
183
+ const cf = await q.evaluate(() => { const b = [...document.querySelectorAll('.obody.vw button')].find((x) => x.textContent.trim() === 'Undo all' && !x.dataset.vd); return !!b; });
184
+ ok('D5 Undo all asks first, and nothing is posted yet', cf && C.S.posts.length === 0);
185
+ await q.evaluate(() => { const b = [...document.querySelectorAll('.obody.vw button')].find((x) => x.textContent.trim() === 'Undo all' && !x.dataset.vd); b.click(); });
186
+ await until(() => C.S.posts.length);
187
+ ok('D5 Undo all rejects the proposal with a reason for the Edit log, and the file is left as it is', C.S.posts[0].route === 'reject' && C.S.posts[0].body.id === 'prop-a' && /Undo all/.test(C.S.posts[0].body.why) && !C.S.posts.some((x) => x.route === 'edit' || x.route === 'accept'));
188
+ await until(() => q.evaluate((v) => !document.querySelector(v + ' .vwag'), V));
189
+ ok('D5 after Undo all the page shows the file with no highlight', await q.evaluate((v) => !document.querySelector(v + ' .vwchg') && /a first call without help/.test(document.querySelector(v + ' .cfb').textContent), V));
190
+ await q.click(V + ' [data-vd="askt"]');
191
+ await q.fill(V + ' #vwAsk', 'tighten the goal'); await q.click(V + ' [data-vd="ask"]');
192
+ await until(() => C.S.posts.length > 1);
193
+ ok('D6 Ask posts path and prompt to /api/doc-sheet/ask', C.S.posts[1].route === 'ask' && C.S.posts[1].body.prompt === 'tighten the goal' && C.S.posts[1].body.path === PATH);
194
+ ok('D6 while the agent works the page says so', await until(() => q.evaluate((v) => /The agent is reading the document/.test(document.querySelector(v).textContent), V)));
195
+ C.S.props = [prop({ id: 'prop-c', hash: 'hc', prompt: 'tighten the goal', sections: [prop().sections[1]], after: TEXT.replace('- a first call without help', '- a first call in under ten minutes') })];
196
+ C.S.ask = { ok: true, id: 'ask-1', state: 'proposed' };
197
+ ok('D6 when the agent answers, its edit shows applied and highlighted', await until(() => q.evaluate((v) => !!document.querySelector(v + ' .vwchg[data-sec="Goal"]') && /The agent changed 1 place/.test(document.querySelector(v + ' .vwag').textContent), V), 9000));
198
+ ok('0 no page error', C.S.errors.length === 0, C.S.errors.join(' | '));
199
+ await C.ctx.close();
200
+ }
201
+ /* D8 floors */
202
+ for (const [w, h, theme] of [[1280, 900, 'light'], [1280, 900, 'dark'], [390, 844, 'light'], [390, 844, 'dark']]) {
203
+ const R = await open({ w, h, theme, props: [prop()] });
204
+ await until(() => R.page.evaluate((v) => !!document.querySelector(v + ' .vwag'), V));
205
+ const f = await R.page.evaluate(([v, small]) => {
206
+ const bad = [], root = document.querySelector(v);
207
+ for (const e of root.querySelectorAll('button,input,textarea')) { const r = e.getBoundingClientRect(); if (r.width && r.height && r.height < (small ? 44 : 30)) bad.push(e.textContent.trim().slice(0, 20) + ':' + Math.round(r.height)); }
208
+ const out = [...root.querySelectorAll('*')].filter((e) => { const r = e.getBoundingClientRect(); return r.width && r.right > innerWidth + 1 && !e.closest('.tw,.vwetb,pre'); }).length;
209
+ const fs = [...root.querySelectorAll('*')].map((e) => getComputedStyle(e).fontSize).filter((x, i, a) => a.indexOf(x) === i);
210
+ return { sx: document.documentElement.scrollWidth - innerWidth, bad, out, fs };
211
+ }, [V, w < 600]);
212
+ ok(`D8 at ${w} px ${theme}: no sideways scroll, no small target, nothing past the edge, console sizes only`, f.sx <= 0 && f.bad.length === 0 && f.out === 0 && f.fs.every((x) => ['11px', '12px', '14px', '16px', '20px', '28px'].includes(x)), JSON.stringify(f));
213
+ const c = await R.page.evaluate((v) => { const e = document.querySelector(v + ' .cf'); return [getComputedStyle(e).backgroundColor, getComputedStyle(e).color]; }, V);
214
+ ok(`D8 at ${w} px ${theme}: the page follows the theme`, theme === 'dark' ? c[0] === 'rgb(23, 26, 35)' : c[0] === 'rgb(253, 253, 252)', JSON.stringify(c));
215
+ await R.ctx.close();
216
+ }
217
+ finish();
218
+ })();
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-vw-jira-test.js — the Jira tabs of the premium viewer in a real browser (initiative premium-viewer S5; planning/prd/premium-viewer-prd.md R5 to R7).
4
+ * A real server; the Board page's model and the two Jira reads are route stand-ins (GET /api/board-premium, /api/boards/sprints, /api/jira/tickets), since
5
+ * Jira readings are written only by an agent session holding the PM's Atlassian connection.
6
+ * B the Board's Sprint card opens the sprint as a board by status in a viewer tab · K a card opens its ticket · N no Jira data says so
7
+ * F floors: 390 px with no sideways scroll, 44 px targets, light and dark, no write */
8
+ const path = require('path');
9
+ const { spawn } = require('child_process');
10
+ const { findBrowser } = require('./lib/find-browser');
11
+ const T = require('./test-run').configure({ name: 'premium-vw-jira' });
12
+ const BP = require('./lib/board-premium.js');
13
+ const F = require('./fixtures/board-premium-facts.js');
14
+
15
+ const BASE = T.BASE;
16
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
17
+ const until = async (fn, ms = 15000, step = 120) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
18
+ const results = [];
19
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 500) : ''}`); };
20
+ let srv = null; let browser = null;
21
+ const finish = async (code) => {
22
+ if (browser) await browser.close().catch(() => {});
23
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
24
+ T.killTmux();
25
+ const bad = results.filter((x) => !x.cond).length;
26
+ console.log(`\n${results.length - bad}/${results.length} premium-vw-jira assertions passed`);
27
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
28
+ };
29
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
30
+
31
+ const SECTIONS = [['story', 'User Story'], ['acceptance', 'Acceptance Criteria']].map(([key, name]) => ({ key, name }));
32
+ const SP = { name: 'Sprint 14', state: 'active', start: '2026-10-07', end: '2026-10-21' };
33
+ const SPRINTS = {
34
+ ok: true, ws: 'w1', board: 'w1', source: 'jira', readAt: new Date().toISOString(), velocity: [],
35
+ sprints: [
36
+ { ...SP, goal: { from: 'tickets', text: 'Ship guided setup to new workspaces' }, points: { committed: 10, done: 3, unestimated: 0 }, pace: { daysLeft: 2 }, counts: { todo: 2, doing: 1, done: 1 },
37
+ issues: [
38
+ { key: 'PMOS-142', summary: 'Migration check for older workspaces', status: 'To Do', category: 'todo', initiative: 'self-serve-v2', flagged: true, reason: 'Flagged in Jira', points: 5 },
39
+ { key: 'PMOS-141', summary: 'Setup drops custom fields', status: 'Code review', category: 'doing', initiative: 'self-serve-v2', flagged: false, reason: null, points: 2 },
40
+ { key: 'PMOS-138', summary: 'Guided setup copy', status: 'Done', category: 'done', initiative: 'self-serve-v2', flagged: false, reason: null, points: 3 },
41
+ { key: 'OPS-9', summary: 'Rotate keys', status: 'To Do', category: 'todo', initiative: null, flagged: false, reason: null, points: null }] },
42
+ { name: 'Sprint 15', state: 'future', start: '2026-10-22', end: '2026-11-04', goal: null, jiraGoal: null, points: null, counts: { todo: 0, doing: 0, done: 0 }, issues: [] }],
43
+ };
44
+ const TICKETS = {
45
+ ok: true, initiative: 'self-serve-v2', title: 'Self-serve onboarding v2', prd: 'planning/prd/self-serve-v2-prd.md', checkedAt: new Date().toISOString(),
46
+ epic: { mode: 'existing', key: 'PMOS-100', summary: 'Self-serve v2' }, sectionNames: SECTIONS,
47
+ tickets: [
48
+ { id: 'TD-01', summary: 'Migration check for older workspaces', type: 'Story', priority: 'High', estimate: 'M', depends: [], key: 'PMOS-142',
49
+ sections: { story: 'As an admin I keep my **custom fields**.<img src=x onerror="window.__pwned=1">', acceptance: '- [ ] Runs on every older workspace\n- [ ] A report lists the failures' },
50
+ jira: { status: 'To Do', category: 'todo', sprint: SP, subtasks: { done: 1, total: 3 }, flagged: true, reason: 'Flagged in Jira', url: 'https://acme.atlassian.net/browse/PMOS-142', stale: false } },
51
+ { id: 'TD-02', summary: 'Release to existing workspaces', type: 'Task', priority: 'Medium', estimate: null, depends: ['TD-01'], key: 'PMOS-152', sections: { story: 'Ship it.' },
52
+ jira: { status: 'In Progress', category: 'doing', sprint: null, subtasks: { done: 0, total: 0 }, flagged: false, reason: null, url: 'https://acme.atlassian.net/browse/PMOS-152', stale: false } }],
53
+ };
54
+
55
+ (async () => {
56
+ const exe = findBrowser();
57
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
58
+ let chromium;
59
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
60
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_NO_OPEN: '1' }) });
61
+ await T.waitForServer(BASE);
62
+ browser = await chromium.launch({ executablePath: exe });
63
+
64
+ const model = (sprints) => BP.build(F.facts({ sprints }));
65
+ const open = async ({ w = 1280, h = 900, theme = 'light', sprints = SPRINTS, tickets = TICKETS } = {}) => {
66
+ const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme });
67
+ await ctx.addInitScript((t) => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); localStorage.setItem('pmos.c3.theme', t); } catch { /* none */ } }, theme);
68
+ const page = await ctx.newPage(), errors = [], posts = [], reads = [];
69
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
70
+ page.on('request', (rq) => { const u = new URL(rq.url()); if (rq.method() === 'POST') posts.push(u.pathname); if (/^\/api\/(jira|boards\/sprints)/.test(u.pathname)) reads.push(u.pathname + u.search); });
71
+ const json = (r, b) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) });
72
+ await page.route('**/api/board-premium*', (r) => json(r, { ok: true, state: 'ready', model: model(sprints), as_of: Date.now() }));
73
+ await page.route('**/api/boards/sprints*', (r) => json(r, sprints));
74
+ await page.route('**/api/jira/tickets*', (r) => json(r, tickets));
75
+ await page.goto(BASE + '/premium-board.html');
76
+ await until(() => page.evaluate(() => !!document.querySelector('#cSpr [data-open="board:sprint"]') || /No sprint/.test((document.querySelector('#cSpr') || {}).textContent || '')));
77
+ return { ctx, page, errors, posts, reads };
78
+ };
79
+ const tabIds = (p) => p.evaluate(() => [...document.querySelectorAll('#vTabs .vtab')].map((t) => t.dataset.vw));
80
+ const paneText = (p, id) => p.evaluate((x) => { const e = document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(x)}"]`); return e && !e.hidden ? e.textContent : null; }, id);
81
+
82
+ /* B the sprint */
83
+ const A = await open();
84
+ const p = A.page;
85
+ await p.click('#cSpr [data-open="board:sprint"]');
86
+ const board = await until(async () => { const t = await paneText(p, 'sprint:w1'); return t && /Migration check/.test(t) ? t : null; });
87
+ ok('B1 the Sprint card opens the dialog with the sprint as a second tab', !!board && (await tabIds(p)).join() === 'main,sprint:w1', JSON.stringify(await tabIds(p)));
88
+ ok('B2 the board names the sprint, its dates, goal, days left and points from the read', /Sprint 14 · 7 Oct – 21 Oct/.test(board) && /Goal: Ship guided setup/.test(board) && /2 days left/.test(board) && /3 of 10 points done/.test(board), board);
89
+ const cols = await p.evaluate(() => [...document.querySelectorAll('.jcol')].map((c) => c.querySelector('.jcolh').textContent + ':' + c.querySelectorAll('.jcrd').length).join());
90
+ ok('B3 the cards sit in To do, In progress and Done by the reading\'s category', cols === 'To do2:2,In progress1:1,Done1:1', cols);
91
+ ok('B4 a card shows its own Jira status where it differs from the column, a flag, and points', await p.evaluate(() => { const c = [...document.querySelectorAll('.jcrd')]; const r = c.find((x) => /PMOS-141/.test(x.textContent)), f = c.find((x) => /PMOS-142/.test(x.textContent)); return /Code review/.test(r.textContent) && /2/.test(r.querySelector('.jpts').textContent) && f.classList.contains('risk') && /Flagged in Jira/.test(f.textContent); }));
92
+ ok('B5 a ticket on no initiative of the board is drawn but not a button, and the note counts it', await p.evaluate(() => { const o = [...document.querySelectorAll('.jcrd')].find((x) => /OPS-9/.test(x.textContent)); return o.tagName === 'DIV' && o.classList.contains('off'); }) && /1 ticket is in this sprint but on no initiative/.test(board));
93
+ ok('B6 the view says it is read-only and moves nothing', /Read-only: Jira owns each ticket's status and sprint/.test(board) && !(await p.$('#dOut .obody.vw [draggable="true"]')));
94
+ await p.click('.jseg [data-sp="Sprint 15"]');
95
+ ok('B7 the other sprint is one press away, and an empty one draws empty columns', !!(await until(async () => { const t = await paneText(p, 'sprint:w1'); return t && /Sprint 15 · 22 Oct – 4 Nov/.test(t) && /No sprint goal on record/.test(t) && (t.match(/None/g) || []).length === 3; })));
96
+ await p.click('.jseg [data-sp="Sprint 14"]');
97
+ await until(() => p.$('.jcrd[data-k="PMOS-142"]'));
98
+
99
+ /* K the ticket */
100
+ await p.click('.jcrd[data-k="PMOS-142"]');
101
+ const tk = await until(async () => { const t = await paneText(p, 'jira:PMOS-142'); return t && /Acceptance Criteria/.test(t) ? t : null; });
102
+ ok('K1 a card opens its ticket as a third tab', !!tk && (await tabIds(p)).join() === 'main,sprint:w1,jira:PMOS-142', JSON.stringify(await tabIds(p)));
103
+ ok('K2 the ticket shows key, title, status, sprint, points and priority', /PMOS-142/.test(tk) && /Migration check for older workspaces/.test(tk) && /To Do/.test(tk) && /Sprint 14 · active/.test(tk) && /5 pt/.test(tk) && /High/.test(tk), tk);
104
+ ok('K3 the description is the draft\'s sections, rendered as markdown with nothing run', /User Story/.test(tk) && await p.evaluate(() => !!document.querySelector('.jmd strong') && !document.querySelector('.jmd img[onerror]') && !window.__pwned));
105
+ ok('K4 subtasks are the reading\'s count, and links come from the draft', /Subtasks · 1 of 3 done/.test(tk) && /blocks/.test(tk) && /PMOS-152/.test(tk) && /planning\/prd\/self-serve-v2-prd.md/.test(tk));
106
+ ok('K5 no comments, history or fields panel: a line sends the rest to Jira with a real link', /Assignee, comments, history and the other fields stay in Jira/.test(tk) && !/Comments \(/.test(tk)
107
+ && await p.evaluate(() => [...document.querySelectorAll('#dOut .obody.vw:not([hidden]) a[href]')].every((a) => a.href === 'https://acme.atlassian.net/browse/PMOS-142' && a.target === '_blank' && /noopener/.test(a.rel))));
108
+ await p.click('#dOut .obody.vw:not([hidden]) [data-jt="PMOS-152"]');
109
+ ok('K6 a linked ticket opens in its own tab', !!(await until(async () => { const t = await paneText(p, 'jira:PMOS-152'); return t && /Release to existing workspaces/.test(t) && /No sprint/.test(t); })));
110
+ await p.click('#vTabs .vtab[data-vw="main"]');
111
+ const k7 = await until(() => p.evaluate(() => { const m = document.querySelector('#oMain'); return !m.hidden && /Ship guided setup/.test(m.textContent) ? m.textContent : null; }));
112
+ ok('K7 the first tab is the sprint dialog\'s own facts, as before', !!k7, await p.evaluate(() => [document.querySelector('#oMain').hidden, document.querySelector('#oMain').textContent.slice(0, 300)].join(' | ')));
113
+ ok('K8 the views read the two Jira routes only, and wrote nothing', A.posts.filter((x) => !/thread|note/.test(x)).length === 0 && A.reads.every((r) => /^\/api\/(jira\/tickets|boards\/sprints)\?/.test(r)) && A.reads.some((r) => /jira\/tickets\?.*initiative=self-serve-v2/.test(r)), JSON.stringify([A.posts, A.reads]));
114
+ ok('K9 no page error', A.errors.length === 0, A.errors.join(' | '));
115
+ await A.ctx.close();
116
+
117
+ /* N no Jira data */
118
+ {
119
+ const N = await open({ sprints: { ok: true, source: 'none', readAt: null, sprints: [], velocity: [] }, tickets: { ok: false, error: 'no such initiative' } });
120
+ const r = await N.page.evaluate(async () => { const m = await import('/pm/premium-vw-jira.js'); m.openSprint({ ws: 'w1', board: 'w1' }); return true; }).catch(() => false);
121
+ const t = r && await until(async () => { const x = await paneText(N.page, 'sprint:w1'); return x && /Nothing to show/.test(x) ? x : null; });
122
+ ok('N1 with no Jira read the sprint tab says what is missing', !!t && /No sprint is on record for this board/.test(t), t);
123
+ await N.page.evaluate(async () => { const m = await import('/pm/premium-vw-jira.js'); m.openTicket({ ws: 'w1', board: 'w1', initiative: 'gone', ref: 'PMOS-1' }); });
124
+ const k = await until(async () => { const x = await paneText(N.page, 'jira:PMOS-1'); return x && /Nothing to show/.test(x) ? x : null; });
125
+ ok('N2 a ticket that cannot be read says why, and invents nothing', !!k && /no such initiative/.test(k), k);
126
+ await N.ctx.close();
127
+ }
128
+
129
+ /* I the initiative page loads the ticket view for its Jira tasks */
130
+ {
131
+ const I = await open();
132
+ await I.page.goto(BASE + '/premium-initiative.html');
133
+ ok('I1 the initiative page loads the Jira view module without a page error', !!(await until(() => I.page.evaluate(() => !!window.__premiumVwJira))) && I.errors.length === 0, I.errors.join(' | '));
134
+ await I.ctx.close();
135
+ }
136
+
137
+ /* F floors */
138
+ for (const theme of ['light', 'dark']) {
139
+ const S = await open({ w: 390, h: 844, theme });
140
+ await S.page.click('#cSpr [data-open="board:sprint"]');
141
+ await until(() => S.page.$('.jcrd[data-k="PMOS-142"]'));
142
+ await S.page.evaluate(() => { const d = document.querySelector('#dlg'); if (d) d.classList.add('vopen'); const b = document.querySelector('#dTabs button[data-t="out"]'); if (b) b.click(); });
143
+ await sleep(400);
144
+ const f = await S.page.evaluate(() => {
145
+ const pane = document.querySelector('#dOut .obody.vw:not([hidden])');
146
+ const small = [...pane.querySelectorAll('button.jcrd,.jseg button,.jbtn')].filter((b) => b.getBoundingClientRect().height && b.getBoundingClientRect().height < 44).map((b) => b.textContent.trim().slice(0, 30));
147
+ const crd = getComputedStyle(pane.querySelector('.jcrd')).backgroundColor, ink = getComputedStyle(pane.querySelector('.jcrd b')).color;
148
+ return { wide: document.documentElement.scrollWidth > innerWidth + 1, paneWide: pane.scrollWidth > pane.clientWidth + 1, small, crd, ink };
149
+ });
150
+ ok(`F1 ${theme}: 390 px has no sideways scroll and every target is 44 px or more`, !f.wide && !f.paneWide && !f.small.length, JSON.stringify(f));
151
+ const lum = (c) => { const m = c.match(/\d+(\.\d+)?/g).map(Number); return (m[0] * 299 + m[1] * 587 + m[2] * 114) / 1000; };
152
+ ok(`F2 ${theme}: cards follow the theme`, theme === 'dark' ? lum(f.ink) > lum(f.crd) : lum(f.ink) < lum(f.crd), JSON.stringify(f));
153
+ await S.ctx.close();
154
+ }
155
+ await finish();
156
+ })();
@@ -8,6 +8,7 @@ import { $, $$, esc, openDlg, closeDlg, toast, loadThread, onScroll, wireRail, l
8
8
  import { issueBody } from './premium-doc-edit.js';
9
9
  import { mountDocSheet } from './premium-doc-sheet.js';
10
10
  import * as MT from './premium-metric-tiles.js';
11
+ import { openSprint } from './premium-vw-jira.js';
11
12
  import { dotsBtn, openMenu, closeMenu, menuKey, asksHtml, onAsks, openIniForm } from './premium-acts.js';
12
13
 
13
14
  const MODE_KEY = 'pmos.premium.openAs';
@@ -188,6 +189,7 @@ function openRow(r) {
188
189
  const d = r.dialog;
189
190
  openDlg({ eye: d.eye + ' · real data', title: r.title, sub: r.sub + (r.statusLabel ? ' · ' + r.statusLabel : ''), say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.key, pane: paneHtml(r), label: d.pane.label });
190
191
  loadThread(r.key);
192
+ if (r.key === 'board:sprint') openSprint({ ws: M.board.ws, board: M.board.id, name: r.title }); // the sprint as a board by status, beside its facts (premium-viewer S5)
191
193
  setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
192
194
  }
193
195
  $('#dBody').addEventListener('click', (e) => { const lt = e.target.closest('#logT'); if (lt) { const c = $('#alog').classList.toggle('col'); lt.setAttribute('aria-expanded', !c); } });