create-pmos 0.396.0 → 0.398.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/scripts/nine-stages.js +49 -20
  6. package/payload/state/discoveries.md +1 -1
  7. package/payload/state/log.md +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +103 -74
  9. package/workspace/briefing-premium-board-test.js +316 -154
  10. package/workspace/briefing-premium-calendar-2-test.js +135 -195
  11. package/workspace/briefing-premium-calendar-3-test.js +143 -413
  12. package/workspace/briefing-premium-calendar-test.js +86 -185
  13. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  14. package/workspace/briefing-premium-initiative-test.js +166 -294
  15. package/workspace/briefing-premium-insights-test.js +351 -214
  16. package/workspace/briefing-premium-metrics-test.js +53 -118
  17. package/workspace/briefing-premium-products-test.js +40 -27
  18. package/workspace/briefing-premium-sources-test.js +91 -52
  19. package/workspace/briefing-premium-test.js +150 -633
  20. package/workspace/briefing-premium-work-test.js +88 -269
  21. package/workspace/changelog.json +24 -0
  22. package/workspace/fixtures/board-premium-facts.js +2 -1
  23. package/workspace/fixtures/board-premium-jira.js +28 -0
  24. package/workspace/fixtures/board-premium-trail.js +32 -0
  25. package/workspace/fixtures/initiative-premium-facts.js +2 -1
  26. package/workspace/fixtures/initiatives-api/list.json +30 -42
  27. package/workspace/fixtures/initiatives-api/roadmap.json +40 -56
  28. package/workspace/fixtures/initiatives-api/sheet.json +10 -14
  29. package/workspace/fixtures/insights-premium-facts.js +11 -2
  30. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  31. package/workspace/guide/briefing-premium.md +3 -1
  32. package/workspace/guide/home.md +47 -0
  33. package/workspace/guide/index.md +2 -0
  34. package/workspace/guide/lifecycle.md +51 -0
  35. package/workspace/home-shot.js +38 -0
  36. package/workspace/lib/agent-roles.js +71 -0
  37. package/workspace/lib/board-premium.js +160 -3
  38. package/workspace/lib/board-trail.js +223 -0
  39. package/workspace/lib/engine/boards.js +15 -14
  40. package/workspace/lib/engine/nine-stages.js +49 -20
  41. package/workspace/lib/engine/signals/detectors.js +13 -11
  42. package/workspace/lib/home-work-item.js +58 -0
  43. package/workspace/lib/insights-goals.js +196 -0
  44. package/workspace/lib/insights-premium.js +126 -1
  45. package/workspace/lib/insights-records.js +101 -0
  46. package/workspace/lib/jira-tickets.js +1 -1
  47. package/workspace/lib/route-modules.js +4 -0
  48. package/workspace/lib/routes-board-premium.js +3 -2
  49. package/workspace/lib/routes-board-trail.js +33 -0
  50. package/workspace/lib/routes-home-desk.js +176 -0
  51. package/workspace/lib/routes-initiatives.js +1 -1
  52. package/workspace/lib/routes-insights-premium.js +19 -3
  53. package/workspace/lib/routes-insights-records.js +129 -0
  54. package/workspace/lib/routes-notes.js +1 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/transcript-steps.js +123 -0
  57. package/workspace/lib/vendor/scripts/nine-stages.js +49 -20
  58. package/workspace/lib/viewer-meeting.js +205 -0
  59. package/workspace/lib/viewer-report.js +89 -0
  60. package/workspace/package-lock.json +2 -2
  61. package/workspace/package.json +1 -1
  62. package/workspace/premium-agreed-viewer-shots.js +76 -0
  63. package/workspace/premium-board-actions-test.js +85 -73
  64. package/workspace/premium-briefing-depth-test.js +66 -53
  65. package/workspace/premium-chat-attach-test.js +54 -63
  66. package/workspace/premium-chat-chart-tab-test.js +35 -36
  67. package/workspace/premium-chat-context-test.js +22 -19
  68. package/workspace/premium-chat-goal-view-test.js +28 -26
  69. package/workspace/premium-chat-notes-test.js +29 -33
  70. package/workspace/premium-chat-report-tab-test.js +35 -25
  71. package/workspace/premium-chat-term-test.js +16 -14
  72. package/workspace/premium-chat-viewer-test.js +60 -53
  73. package/workspace/premium-core-doc-issue-test.js +50 -41
  74. package/workspace/premium-html-viewer-test.js +17 -18
  75. package/workspace/premium-phone-card-test.js +8 -2
  76. package/workspace/premium-phone-room-test.js +42 -31
  77. package/workspace/premium-report-read-test.js +115 -197
  78. package/workspace/premium-viewer-download-test.js +19 -22
  79. package/workspace/premium-viewer-flicker-test.js +11 -16
  80. package/workspace/premium-viewer-share-test.js +6 -9
  81. package/workspace/premium-viewer-test.js +41 -60
  82. package/workspace/premium-vw-backlog-test.js +53 -31
  83. package/workspace/premium-vw-cal-test.js +82 -123
  84. package/workspace/premium-vw-copy-test.js +17 -33
  85. package/workspace/premium-vw-doc-test.js +12 -11
  86. package/workspace/premium-vw-item-test.js +50 -48
  87. package/workspace/premium-vw-jira-test.js +55 -26
  88. package/workspace/premium-vw-meet-test.js +118 -187
  89. package/workspace/premium-vw-notes-test.js +85 -107
  90. package/workspace/premium-vw-rec-test.js +72 -193
  91. package/workspace/premium-vw-slides-test.js +46 -50
  92. package/workspace/premium-welcome-test.js +3 -2
  93. package/workspace/premium-work-depth-test.js +63 -51
  94. package/workspace/public/pm/bd-acts.js +305 -0
  95. package/workspace/public/pm/bd-span.js +224 -0
  96. package/workspace/public/pm/bd-stages.js +47 -0
  97. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  98. package/workspace/public/pm/c3-md.js +3 -395
  99. package/workspace/public/pm/c3-phone-detail.js +1 -1
  100. package/workspace/public/pm/c3-phone-model.js +3 -68
  101. package/workspace/public/pm/chat-term.js +3 -3
  102. package/workspace/public/pm/cozy-board.css +640 -0
  103. package/workspace/public/pm/cozy-home.css +580 -0
  104. package/workspace/public/pm/cozy-home.js +172 -0
  105. package/workspace/public/pm/cozy-initiative.css +138 -0
  106. package/workspace/public/pm/cozy-insights.css +421 -0
  107. package/workspace/public/pm/cozy-md.js +396 -0
  108. package/workspace/public/pm/cozy-nav.js +65 -0
  109. package/workspace/public/pm/cozy-placeholder.js +26 -0
  110. package/workspace/public/pm/cozy-viewer.css +143 -0
  111. package/workspace/public/pm/cozy-viewer.js +144 -0
  112. package/workspace/public/pm/cozy-vw.css +485 -0
  113. package/workspace/public/pm/cozy.css +254 -0
  114. package/workspace/public/pm/home-adddoc.js +48 -0
  115. package/workspace/public/pm/home-app.js +905 -0
  116. package/workspace/public/pm/home-around.js +515 -0
  117. package/workspace/public/pm/home-chat.js +459 -0
  118. package/workspace/public/pm/home-data.js +312 -0
  119. package/workspace/public/pm/home-draft.js +68 -0
  120. package/workspace/public/pm/home-more.js +249 -0
  121. package/workspace/public/pm/home-phone-card.js +109 -0
  122. package/workspace/public/pm/home-work.js +519 -0
  123. package/workspace/public/pm/lifecycle-lens-model.js +45 -27
  124. package/workspace/public/pm/lifecycle-lens.js +22 -11
  125. package/workspace/public/pm/phone-moment.js +69 -0
  126. package/workspace/public/pm/pm-work-view.js +1 -1
  127. package/workspace/public/pm/premium-attach.js +4 -0
  128. package/workspace/public/pm/premium-board.js +544 -253
  129. package/workspace/public/pm/premium-brief.js +1 -1
  130. package/workspace/public/pm/premium-chart-tab.js +110 -62
  131. package/workspace/public/pm/premium-chat.js +17 -10
  132. package/workspace/public/pm/premium-deck.js +3 -3
  133. package/workspace/public/pm/premium-first.js +25 -21
  134. package/workspace/public/pm/premium-initiative-head.js +138 -0
  135. package/workspace/public/pm/premium-initiative.js +28 -4
  136. package/workspace/public/pm/premium-insights.js +950 -440
  137. package/workspace/public/pm/premium-meeting.js +61 -549
  138. package/workspace/public/pm/premium-notes.js +1 -1
  139. package/workspace/public/pm/premium-report-frame.css +20 -0
  140. package/workspace/public/pm/premium-report-read.js +509 -480
  141. package/workspace/public/pm/premium-report-tab.js +87 -63
  142. package/workspace/public/pm/premium-shell.js +107 -124
  143. package/workspace/public/pm/premium-viewer.js +27 -1
  144. package/workspace/public/pm/premium-vw-cal.js +187 -48
  145. package/workspace/public/pm/premium-vw-doc.css +6 -0
  146. package/workspace/public/pm/premium-vw-doc.js +40 -2
  147. package/workspace/public/pm/premium-vw-file.js +2 -2
  148. package/workspace/public/pm/premium-vw-jira-model.js +22 -5
  149. package/workspace/public/pm/premium-vw-jira.css +11 -0
  150. package/workspace/public/pm/premium-vw-jira.js +11 -4
  151. package/workspace/public/pm/premium-vw-meet.js +6 -83
  152. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  153. package/workspace/public/pm/premium-vw-notes.js +56 -69
  154. package/workspace/public/pm/premium-vw-open.js +35 -0
  155. package/workspace/public/pm/premium-vw-page.js +16 -0
  156. package/workspace/public/pm/premium-vw-rec.js +11 -215
  157. package/workspace/public/pm/premium-vw-slides.css +5 -0
  158. package/workspace/public/pm/premium-vw-slides.js +44 -8
  159. package/workspace/public/pm/term-view.js +22 -0
  160. package/workspace/public/premium-board.html +57 -64
  161. package/workspace/public/premium-chat.html +7 -33
  162. package/workspace/public/premium-initiative.html +8 -41
  163. package/workspace/public/premium-insights.html +63 -62
  164. package/workspace/public/premium-viewer.html +20 -0
  165. package/workspace/public/premium-work.html +6 -72
  166. package/workspace/public/premium.html +21 -66
  167. package/workspace/public/vendor/nunito-var.woff2 +0 -0
  168. package/workspace/server.js +25 -3
  169. package/workspace/test-files.json +1 -0
  170. package/workspace/test-lists/home-libs.json +9 -0
  171. package/workspace/test-lists/premium-agreed-viewer.json +9 -0
  172. package/workspace/test-lists/premium-report-read.json +1 -1
  173. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  174. package/workspace/test-lists/premium-vw-notes.json +1 -1
  175. package/workspace/third-party/README.md +1 -0
  176. package/workspace/public/pm/premium-work.js +0 -719
  177. package/workspace/public/pm/premium.js +0 -1133
@@ -1,24 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- /* briefing-premium-initiative-test.js — the premium initiative page (initiative briefing-premium-initiative; planning/prd/briefing-premium-initiative-prd.md I1 to I12).
4
- * Serves the real page from the real server. Most checks answer GET /api/initiative-premium with the model lib/initiative-premium.js builds from a fixture
5
- * (fixtures/initiative-premium-facts.js); the last blocks read this repository's own initiative through the real routes and compare with the mockup.
6
- * I1 place · I2 reading · I3 header · I4 overview · I5 checks · I6 tasks · I7 documents · I8 document sheet · I9 opening · I10 presses · I11 one count · I12 floors and fidelity */
7
- const fs = require('fs');
3
+ /* briefing-premium-initiative-test.js — the initiative (initiative briefing-premium-initiative; planning/prd/briefing-premium-initiative-prd.md I1 to I12),
4
+ * re-pointed for premium-agreed-design: the initiative is a layout inside Home (/premium.html?ini=<id>), not a page of its own, and the old
5
+ * /premium-initiative.html?id= link lands there. The card at the top of the chat is the mockup's ("Inside one initiative"); its Overview press opens
6
+ * the minimal Overview in the Viewer (stage, lifecycle, tasks, core documents; Waiting for design). What moved elsewhere has its own suite:
7
+ * a document's page premium-vw-doc-test.js, Add a document briefing-premium-adddoc-test.js, Issue it premium-core-doc-issue-test.js, the record and
8
+ * task views premium-vw-item-test.js, the Jira views premium-vw-jira-test.js. The old page's List / By stage / Timeline views, the document filter
9
+ * and search and the document sheet's tabs have no place in the Agreed design and are not drawn.
10
+ * Serves the real page from the real server. Most checks answer GET /api/initiative-premium with the model lib/initiative-premium.js builds from a
11
+ * fixture and GET /api/board-premium with lib/board-premium.js's; the last block reads this repository's own initiative through the real route.
12
+ * I1 place · I2 reading · I3 header · I4 overview · I6 tasks · I7 documents · I10 presses · I12 floors and fidelity */
8
13
  const path = require('path');
9
14
  const { spawn } = require('child_process');
10
15
  const { findBrowser } = require('./lib/find-browser');
11
- const CT = require('./lib/premium-console-type'); // the mockup is read with the console's type (PM, 2026-10-19), as premium.css is
12
- const CT_VENDOR = 'file://' + path.join(__dirname, 'public', 'vendor') + '/';
13
16
  const T = require('./test-run').configure({ name: 'briefing-premium-initiative' });
14
17
  const IP = require('./lib/initiative-premium.js');
15
18
  const F = require('./fixtures/initiative-premium-facts.js');
19
+ const BP = require('./lib/board-premium.js');
20
+ const BF = require('./fixtures/board-premium-facts.js');
21
+ const BRP = require('./lib/briefing-premium.js');
22
+ const BRF = require('./fixtures/briefing-premium-facts.js');
16
23
 
17
24
  const BASE = T.BASE;
18
25
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
26
  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); } };
20
27
  const results = [];
21
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
28
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
22
29
  let srv = null; let browser = null;
23
30
  const finish = async (code) => {
24
31
  if (browser) await browser.close().catch(() => {});
@@ -31,10 +38,9 @@ const finish = async (code) => {
31
38
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
32
39
 
33
40
  const mk = (o) => IP.build(F.facts(o));
34
- const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html');
35
- const LOG = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', revisions: [{ rev: 1, why: '', by: 'baseline', at: '2026-10-16T08:00:00Z' }, { rev: 2, why: 'tightened the goal', by: 'pm', at: '2026-10-17T08:00:00Z' }], events: [{ kind: 'asked', at: '2026-10-17T08:30:00Z', prompt: 'What is missing?' }] };
36
- const TEXT = '---\ntype: PRD\ntitle: "Self-serve onboarding v2"\n---\n\n# PRD: Self-serve onboarding v2\n\n## Problem\n\nA partner waits for a person.\n\n## Goal\n\n- a first call without help\n- a key shown once\n\n## Requirements\n\n```\nR1 a first call\n```\n';
37
- const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: { passed: 1, total: 2, checks: [{ id: 'fresh', pass: true, reason: 'no cited source changed after it' }, { id: 'traced', pass: false, reason: 'a line with a figure has no source' }, { id: 'readers', pass: null, reason: 'no input' }] } };
41
+ const BOARD = BP.build(BF.facts());
42
+ const BRIEF = BRP.build(BRF.facts());
43
+ const WRITES = /^\/api\/(?:boards\/(?:move|tasks\/(?:add|state))|lifecycle|core-docs\/draft)$/;
38
44
 
39
45
  (async () => {
40
46
  const exe = findBrowser();
@@ -45,275 +51,148 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
45
51
  await T.waitForServer(BASE);
46
52
  browser = await chromium.launch({ executablePath: exe });
47
53
 
48
- const open = async ({ w = 1280, h = 900, theme = 'light', model = mk(), answers = null, qs = '?id=self-serve-v2&ws=w1&board=w1' } = {}) => {
54
+ const open = async ({ w = 1280, h = 900, theme = 'light', model = mk(), answers = null, url = '/premium.html?ini=self-serve-v2&ws=w1&board=w1' } = {}) => {
49
55
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
50
56
  const page = await ctx.newPage();
51
- let copies = []; let current = model, calls = 0; const errors = [], posts = [], gets = []; let answer = { status: 200, body: { ok: true } }; let thread = { ok: true, turns: [], working: false };
57
+ let current = model, calls = 0, answer = { status: 200, body: { ok: true } };
58
+ const errors = [], posts = [];
52
59
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
53
- await page.route('**/api/initiative-premium*', (r) => { calls++; if (answers) { const a = answers(calls); return r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); } return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: current, as_of: F.NOW }) }); });
54
- await page.route('**/api/core-docs/**', (r) => { const rq = r.request(); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); r.fulfill({ status: answer.status, contentType: 'application/json', body: JSON.stringify(answer.body) }); });
55
- await page.route('**/api/doc-sheet/**', (r) => { const rq = r.request(), u = new URL(rq.url()); (rq.method() === 'GET' ? gets : posts).push({ path: u.pathname, query: u.search, method: rq.method() }); const b = u.pathname.endsWith('/log') ? LOG : u.pathname.endsWith('/at') ? { ok: true, path: LOG.path, rev: +u.searchParams.get('rev') || 2, text: u.searchParams.get('rev') === '1' ? TEXT.replace('waits', 'waited') : TEXT } : { ok: false, error: 'not in this test' }; r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) }); });
56
- await page.route(/\/api\/docs(\?.*)?$/, (r) => { const u = new URL(r.request().url()); gets.push({ path: u.pathname, query: u.search, method: 'GET' }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, docs: [{ path: 'planning/prd/self-serve-v2-prd.md', links: copies }] }) }); });
57
- await page.route('**/api/docs/link', (r) => { const rq = r.request(); const b = JSON.parse(rq.postData() || '{}'); posts.push({ path: '/api/docs/link', body: b, method: 'POST' }); copies = [{ kind: b.kind, target: b.target, title: 'PRD', signal: 'unchecked', url: b.target }]; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
58
- await page.route('**/api/docs/check', (r) => { posts.push({ path: '/api/docs/check', body: JSON.parse(r.request().postData() || '{}'), method: 'POST' }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, session: 's1' }) }); });
59
- await page.route('**/api/docs/library*', (r) => { const u = new URL(r.request().url()); gets.push({ path: u.pathname, query: u.search, method: 'GET' }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, kinds: ['cites'], files: [{ path: 'planning/prd/self-serve-v2-prd.md', title: 'PRD' }, { path: 'planning/briefs/self-serve-brief.md', title: 'Self-serve brief' }, { path: 'planning/okrs/q3.md', title: 'Activation goal', category: 'goal', node: 'Goal' }, { path: 'planning/evals/self-serve-rubric.md', title: 'Self-serve rubric' }], edges: [[1, 0, 0], [2, 0, 0], [0, 3, 0]] }) }); });
60
- await page.route('**/api/boards/tasks/**', (r) => { const rq = r.request(); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); r.fulfill({ status: answer.status, contentType: 'application/json', body: JSON.stringify(answer.body) }); });
61
- await page.route('**/api/doc-health/check', (r) => { posts.push({ path: '/api/doc-health/check', body: JSON.parse(r.request().postData() || '{}'), method: 'POST' }); r.fulfill({ contentType: 'application/json', body: JSON.stringify(HEALTH) }); });
62
- await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() === 'GET') return r.fulfill({ contentType: 'application/json', body: JSON.stringify(thread) }); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
63
- await page.goto(BASE + '/premium-initiative.html' + qs + '&theme=' + theme);
64
- const up = await until(() => page.evaluate(() => document.querySelector('#cIniTk') || /could not be read|No initiative|not on a board/.test(document.querySelector('#snap').textContent + document.querySelector('#iMain').textContent)), 20000);
65
- return { ctx, page, errors, posts, gets, up, calls: () => calls, setModel: (m) => { current = m; }, set: (a) => { answer = a; }, setThread: (t) => { thread = t; } };
60
+ page.on('request', (rq) => { if (rq.method() === 'POST') posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); });
61
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
62
+ await page.route('**/api/initiative-premium*', (r) => { calls++; if (answers) { const a = answers(calls, r.request().url()); return json(r, a.body, a.status); } return json(r, { ok: true, state: 'ready', model: current, as_of: Date.now() }); });
63
+ await page.route(/\/api\/board-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BOARD, as_of: Date.now() }));
64
+ await page.route(/\/api\/briefing-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BRIEF, as_of: Date.now() }));
65
+ for (const p of ['**/api/boards/move', '**/api/boards/tasks/**', '**/api/lifecycle', '**/api/core-docs/draft']) await page.route(p, (r) => json(r, answer.body, answer.status));
66
+ await page.route('**/api/briefing-premium/**', (r) => json(r, { ok: true, turns: [], working: false }));
67
+ await page.goto(BASE + url + (url.includes('?') ? '&' : '?') + 'theme=' + theme);
68
+ // ready: the card is drawn and the board's initiatives are read (the switcher and the card's kind line come from them)
69
+ const up = await ready(page, !answers);
70
+ return { ctx, page, errors, posts, up, calls: () => calls, setModel: (m) => { current = m; }, set: (a) => { answer = a; } };
66
71
  };
67
-
68
- const A = await open();
69
- ok('0 the page draws the cards', A.up && await A.page.evaluate(() => !!document.querySelector('#cIniOv') && !!document.querySelector('#cIniTk')));
70
- if (!A.up) return finish(1);
71
- const p = A.page, M = mk();
72
- const txt = (s) => p.evaluate((q) => (document.querySelector(q) || {}).textContent || '', s);
73
- const all = (s) => p.evaluate((q) => [...document.querySelectorAll(q)].map((e) => e.textContent.trim()), s);
72
+ const V = '#czViewer:not([hidden])';
73
+ // ready: the card is drawn from the board's row (kind · anchor) and, when the initiative reads, from its record (the ladder)
74
+ async function ready(page, full = true) { return until(() => page.evaluate((f) => !!document.querySelector('.hm-card [data-hm-ov]') && /·/.test((document.querySelector('.hm-card .hm-sw .k') || {}).textContent || '') && (!f || !!((document.querySelector('.hm-card .hm-lad b') || {}).textContent || '').trim()), full), 30000); }
75
+ const txt = (p, s) => p.evaluate((q) => ((document.querySelector(q) || {}).textContent || '').replace(/\s+/g, ' ').trim(), s);
76
+ const overview = async (p) => {
77
+ if (!(await p.evaluate(() => { const b = document.querySelector('.hm-card [data-hm-ov]'); return !!b && !!b.offsetParent; }))) await p.click('#hmNeeds'); // a phone shows the list (and its card) in the sheet
78
+ await p.click('.hm-card [data-hm-ov]'); return until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-move]') || /could not be read|Reading the initiative/.test((document.querySelector(v) || {}).textContent || ''), V), 15000); };
79
+ const writes = (X) => X.posts.filter((x) => WRITES.test(x.path));
80
+
81
+ const A = await open(), p = A.page;
82
+ ok('0 Home draws the initiative layout: its card at the top of the list', A.up && await p.evaluate(() => new URLSearchParams(location.search).get('ini') === 'self-serve-v2' && !!document.querySelector('#hmChat .hm-card, .hm-card')));
74
83
 
75
84
  /* I1 place */
76
- const rail = await p.evaluate(() => ({ names: [...document.querySelectorAll('.rail .pl')].map((b) => b.textContent.trim()), cur: document.querySelector('.rail [aria-current="page"]').textContent.trim() }));
77
- ok('I1 the rail names the five places and marks Board', rail.names.join() === 'Briefing,My work,Chat,Board,Insights' && rail.cur === 'Board');
78
- { await p.click('#moreBtn'); const tc = await p.evaluate(() => { const a = document.querySelector('#toConsole'); if (!a) return null; const r = a.getBoundingClientRect(); return { href: a.getAttribute('href'), label: a.getAttribute('aria-label'), w: Math.round(r.width), h: Math.round(r.height), tab: a.tabIndex }; }); ok('I1 the ⋯ menu links to the console (premium-console-link, premium-topbar)', tc && tc.href === '/console.html' && tc.label === 'Open the console' && tc.w >= 44 && tc.h >= 44 && tc.tab === 0, JSON.stringify(tc)); await p.keyboard.press('Escape'); }
79
- ok('I1 the bar has a back button to the board, the initiative with its switcher, and no chat button (Chat is in the rail)', await p.evaluate(() => document.querySelector('#crBoard').getAttribute('aria-label') === 'Back to Onboarding' && document.querySelector('#crIni').textContent === 'Self-serve onboarding v2' && !document.querySelector('#crSw') && !!document.querySelector('#crSw2') && !document.querySelector('#crAsk')));
80
- await p.route('**/premium-board.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<title>b</title>' }));
81
- await p.route('**/premium-initiative.html?id=partner*', (r) => r.fulfill({ contentType: 'text/html', body: '<title>i</title>' }));
82
- await p.click('#crSw2'); const im = await p.evaluate(() => [...document.querySelectorAll('#crMenu button')].map((b) => b.textContent + (b.hasAttribute('aria-current') ? '*' : '')).join('|'));
83
- ok('I1 the initiative switcher lists the board\'s initiatives and marks this one', im === 'Self-serve onboarding v2*|Partner API rate limits|Usage-based billing', im);
84
- await p.click('#crMenu [data-swi="partner-rate-limits"]'); await sleep(500);
85
- { const u = new URL(p.url()); ok('I1 choosing an initiative opens its page on the same board', u.pathname === '/premium-initiative.html' && u.searchParams.get('id') === 'partner-rate-limits' && u.searchParams.get('board') === 'w1', p.url()); await p.goBack(); await until(() => p.evaluate(() => !!document.querySelector('#cIniTk'))); }
86
- await p.click('#crBoard'); await sleep(500);
87
- { const u = new URL(p.url()); ok('I1 the back button leads back to the Board', u.pathname === '/premium-board.html' && u.searchParams.get('board') === 'w1', p.url()); await p.goBack(); await until(() => p.evaluate(() => !!document.querySelector('#cIniTk'))); }
88
- await p.click('.rail [data-go="chat"]'); await until(() => p.evaluate(() => /premium-chat\.html/.test(location.pathname) && document.querySelector('#dlg').classList.contains('on')), 10000); await sleep(500);
89
- { const u = new URL(p.url()); const t = await p.evaluate(() => document.querySelector('#dTitle').textContent);
90
- ok('I1 Chat opens the Chat page on the initiative\'s conversation (premium-chat-page)', /^init:/.test(u.searchParams.get('about') || '') && t === 'Ask about Self-serve onboarding v2', JSON.stringify({ url: p.url(), t })); }
91
- await p.goBack(); await until(() => p.evaluate(() => !!document.querySelector('#cIniTk')), 20000);
92
-
93
- /* I3 header */
94
- const head = await p.evaluate(() => ({ chip: document.querySelector('.ihead .chp').textContent.trim(), tone: document.querySelector('.ihead .chp').className, meta: document.querySelector('.ihm').textContent, segs: [...document.querySelectorAll('.iws .sg2 i')].map((i) => i.className).join('|'), cur: document.querySelector('.iws em b').textContent }));
95
- ok('I3 the chip, the meta and the stage strip are the record\'s', head.chip === 'At risk' && /warn/.test(head.tone) && head.meta === 'Onboarding · Dara · planned finish 30 Oct · stage derived by the workflow engine' && head.segs === 'p|p|p|p|p|n|||' && head.cur === 'Build', JSON.stringify(head));
96
-
97
- /* I4 overview and I5 checks */
98
- const ov = await p.evaluate(() => ({ who: document.querySelector('#cIniOv .tdw').textContent, h: document.querySelector('#cIniOv .todo b').textContent, p: document.querySelector('#cIniOv .todo p').textContent, more: document.querySelector('#cIniOv .todo small').textContent, skip: document.querySelector('#cIniOv .tdk').textContent, notes: [...document.querySelectorAll('#cIniOv .note')].map((n) => n.textContent) }));
99
- ok('I4 the next step, its reason, its action and what happens if you wait come from the workflow engine; the reasons are shown', ov.who === 'Waits on you' && ov.h === 'Next: contract' && /pre_run_contract/.test(ov.p) && /Agree done_criteria/.test(ov.more) && ov.skip === 'If you wait: it stays at contract.' && ov.notes.length === 2, JSON.stringify(ov));
100
- const chk = await p.evaluate(() => !!document.querySelector('#cIniChk'));
101
- ok('I5 there is no Checks card: the mockup has none, and the Overview is the full-width card', chk === false && await p.evaluate(() => document.querySelector('#cIniOv').classList.contains('ifull') && !document.querySelector('.bcols')));
102
- ok('I5 the Overview keeps the engine\'s evidence in "All 7 workflow steps"', /first-appeared at or before the first build commit/.test(await txt('#cIniOv .src .ckr:first-child small')) && /never claims a test result it did not run/.test(await all('#cIniOv .src .ckr small').then((x) => x.join(' '))));
103
- ok('I5 "All 7 workflow steps" lists every step of the ladder', /All 7 workflow steps/.test(await txt('#cIniOv .src summary')) && (await p.evaluate(() => document.querySelectorAll('#cIniOv .src .ckr').length)) === 7);
104
- ok('I4 the description line is shown only when the record has one', await p.evaluate(() => !document.querySelector('#cIniOv .lede')));
105
- /* PMOS can help: two real presses */
106
- ok('I4 PMOS can help offers a draft of the first document not started and a question for the agent', (await all('#cIniOv .agc')).join('|') === 'Draft the problem statement|Summarise the review findings');
107
- A.set({ status: 200, body: { ok: true, run: 'r0' } });
108
- await p.locator('#cIniOv .agc').first().click();
109
- ok('I10 the draft button posts the existing draft route with the initiative scope and the key', await until(() => A.posts.some((x) => x.path === '/api/core-docs/draft' && x.body.key === 'problem' && x.body.scope === 'initiative:self-serve-v2' && Object.keys(x.body).sort().join() === 'key,scope,ws')));
110
- const nH = A.posts.length;
111
- await p.locator('#cIniOv .agc').nth(1).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
112
- ok('I10 the question button opens the dialog and sends its question to the read-only agent, and nothing else', await until(() => A.posts.length > nH && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'init:self-serve-v2' && /^Summarise the review findings/.test(A.posts[A.posts.length - 1].body.text) && A.posts.slice(nH).every((x) => x.path === '/api/briefing-premium/ask')));
113
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
114
-
115
- /* I6 tasks, I11 one count */
116
- ok('I6 the caption, the bar and the list read one set', await txt('#hTk + small') === '3 PRD requirements · 3 from the board · no tracker link' && /1 done · 1 in progress · 1 to do/.test(await txt('#cIniTk .stb small')) && (await all('#cIniTk .tkq .tkn b')).join('|') === 'Sandbox key step|Checklist empty state|UAT with five partners|A partner reaches a first call|The key is shown once|Errors say what to do');
117
- ok('I6 another initiative\'s tracker item is not listed', !/Another initiative/.test(await txt('#cIniTk')));
118
- ok('I6 a requirement says no result; a tracker item says its state; a dated item shows its due date', (await all('#cIniTk .tkp')).join('|') === 'In progress|Done|To do|No result|No result|No result' && /Due 27 Oct/.test(await txt('#cIniTk')));
119
- ok('I6 the views are List, By stage and Timeline', (await all('#tkTabs button')).join('|') === 'List|By stage|Timeline');
120
- await p.click('#tkTabs [data-v="stage"]');
121
- const cols = await p.evaluate(() => [...document.querySelectorAll('#tkBody .isc')].map((c) => c.querySelector('.label').textContent.replace(/\s+/g, ' ').trim()));
122
- ok('I6 By stage groups by the records\' states, shows an empty column as None and puts the requirements under "No result recorded"', cols.join('|') === 'To do 1|In progress 1|On hold 0|Done 1|No result recorded 3', cols.join('|'));
123
- await p.click('#tkTabs [data-v="time"]');
124
- const tl = await p.evaluate(() => ({ bars: document.querySelectorAll('#tkBody .tkt').length, title: (document.querySelector('#tkBody .tkt .tlt b') || {}).textContent, und: [...document.querySelectorAll('#tkBody .tkch b')].map((b) => b.textContent).join('|'), months: [...document.querySelectorAll('#tkBody .tlax i')].map((i) => i.textContent).join(), today: !!document.querySelector('#tkBody .tlax b'), legend: document.querySelectorAll('#tkBody .gleg span').length }));
125
- ok('I6 the Timeline draws a bar for each task with both dates, lists the rest as "No dates set", and draws today', tl.bars === 1 && tl.title === 'UAT with five partners' && /Sandbox key step/.test(tl.und) && /A partner reaches a first call/.test(tl.und) && tl.today && tl.legend === 3 && /Oct/.test(tl.months), JSON.stringify(tl));
126
- await p.click('#tkTabs [data-v="list"]');
127
- await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
128
- const td = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, grid: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), ask: document.querySelector('#askF').hidden, seg: !!document.querySelector('#oMain .tkst') }));
129
- ok('I6 a Jira task opens its record as a grid, read-only: no status control, and its own conversation (premium-popup-context P1)', td.title === 'Sandbox key step' && /Reference\|ONB-12\|Source\|Jira \(read-only\)/.test(td.grid) && td.ask === false && td.seg === false, JSON.stringify(td));
130
- // popup context slice 3 (L2, L3): the stored lead comes first, with its time and reads, and Refresh asks the popup's own session
131
- A.setThread({ ok: true, working: false, turns: [], lead: { text: 'ONB-12 waits on the sandbox key. Ask Sam for a date.', cites: ['Jira read 07:02'], at: new Date().toISOString() } });
132
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
133
- await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => !!document.querySelector('#dlg.on #leadT .plead')), 6000);
134
- const ld = await p.evaluate(() => { const s = document.querySelector('#dBody .stream'); return { first: s.firstElementChild && s.firstElementChild.id, text: document.querySelector('#leadT').textContent }; });
135
- ok('I6 a task popup shows Claude\'s stored lead first, with when it was written and what it read (popup context L2)', ld.first === 'leadT' && /waits on the sandbox key/.test(ld.text) && /Lead · written \d\d:\d\d · from Jira read 07:02/.test(ld.text), JSON.stringify(ld));
136
- { const nA = A.posts.length; await p.click('#leadT [data-lead="refresh"]');
137
- ok('I6 Refresh asks the popup\'s own session to write the lead again and save it with pmos lead put (popup context L3)', await until(() => A.posts.slice(nA).some((x) => x.path === '/api/briefing-premium/ask' && /^pop:task:/.test(x.body.key) && x.body.text.includes('pmos lead put --key ' + x.body.key))), JSON.stringify(A.posts.slice(nA))); }
138
- A.setThread({ ok: true, working: false, turns: [] });
139
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
140
- /* a PMOS task: its status can be changed */
141
- A.set({ status: 200, body: { ok: true, item: {} } });
142
- await p.locator('#cIniTk .tkq', { hasText: 'UAT with five partners' }).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
143
- ok('I6 a PMOS task offers the board\'s four states, with its own marked', await p.evaluate(() => [...document.querySelectorAll('#oMain [data-tks]')].map((b) => b.textContent + (b.getAttribute('aria-pressed') === 'true' ? '*' : '')).join('|')) === 'To do*|In progress|In review|Done');
144
- await p.click('#oMain [data-tks="In progress"]');
145
- ok('I10 a status change posts the board, the task and the state to the board\'s own route, and nothing else', await until(() => A.posts.some((x) => x.path === '/api/boards/tasks/state' && x.body.ws === 'w1' && x.body.board === 'w1' && x.body.task === 't1' && x.body.state === 'In progress' && Object.keys(x.body).sort().join() === 'board,state,task,ws')));
146
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
147
- /* add a task */
148
- await p.click('[data-tkadd]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
149
- ok('I6 Add a task opens a form with common tasks, a title, an owner and optional dates, and says what empty dates mean', await p.evaluate(() => document.querySelectorAll('#oMain .chq button').length === 6 && !!document.querySelector('#atT') && !!document.querySelector('#atO') && !!document.querySelector('#atF') && !!document.querySelector('#atD') && /from tomorrow, for a week/.test(document.querySelector('#oMain').textContent)));
150
- await p.click('#atGo'); ok('I6 an empty title is refused before any post', /Give the task a title/.test(await txt('#atM')) && !A.posts.some((x) => x.path === '/api/boards/tasks/add'));
151
- await p.fill('#atT', 'UAT'); await p.fill('#atF', '2026-11-05'); await p.click('#atGo'); ok('I6 a start without a due date is refused', /Add a due date too/.test(await txt('#atM')));
152
- await p.fill('#atD', '2026-11-01'); await p.click('#atGo'); ok('I6 a due date before the start is refused', /due date is before the start/.test(await txt('#atM')) && !A.posts.some((x) => x.path === '/api/boards/tasks/add'));
153
- await p.click('#oMain [data-pre="1"]'); ok('I6 a common task fills the title', await p.inputValue('#atT') === 'Release plan');
154
- await p.fill('#atF', ''); await p.fill('#atD', '');
155
- A.set({ status: 400, body: { ok: false, error: 'no initiative self-serve-v2 on this board' } }); await p.click('#atGo');
156
- ok('I6 a refusal shows the route\'s reason, keeps the form and turns the button back on', await until(() => p.evaluate(() => /no initiative self-serve-v2 on this board/.test(document.querySelector('#atM').textContent) && !document.querySelector('#atGo').disabled)));
157
- A.set({ status: 200, body: { ok: true, item: {} } }); await p.fill('#atO', 'Dara'); await p.fill('#atF', '2026-11-01'); await p.fill('#atD', '2026-11-05'); await p.click('#atGo');
158
- ok('I10 Add task posts the workspace, the board, this initiative, the title, the owner and the dates to the board\'s own route', await until(() => A.posts.some((x) => x.path === '/api/boards/tasks/add' && x.body.ws === 'w1' && x.body.board === 'w1' && x.body.initiative === 'self-serve-v2' && x.body.title === 'Release plan' && x.body.owner === 'Dara' && x.body.start === '2026-11-01' && x.body.due === '2026-11-05' && Object.keys(x.body).sort().join() === 'board,due,initiative,owner,start,title,ws')));
159
- const mint0 = await T.nonce(BASE);
160
- ok('I10 both task presses carried the launch nonce and no writer field', !!mint0 && A.posts.filter((x) => /^\/api\/boards\/tasks\//.test(x.path)).every((x) => x.headers['x-pmos-nonce'] === mint0 && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)));
161
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
162
- ok('I6 Add a document is the one button of the Core documents card that adds (its own suite is briefing-premium-adddoc-test.js)', await p.evaluate(() => document.querySelectorAll('[data-adddoc]').length === 1 && /Add a document/.test(document.querySelector('#cIniDoc .ch').textContent)));
163
-
164
- /* I7 documents, I11 one count */
165
- ok('I7 the counts agree: caption, summary, filter and bar', await p.evaluate(() => { const s = document.querySelector('.dsum').textContent.replace(/\s+/g, ' '); const f = [...document.querySelectorAll('#dmF button')].map((b) => b.textContent.replace(/\s+/g, '')).join(','); return document.querySelector('#hDoc + small').textContent === '5' && /1 draft to review/.test(s) && /3 not started/.test(s) && /1 up to date/.test(s) && f === 'All5,Notstarted3,Draft1,Uptodate1' && document.querySelectorAll('.dprog i').length === 5; }));
166
- ok('I7 the technical documents are grouped and not counted', await p.evaluate(() => /Technical documents \(2\)/.test(document.querySelector('.dmtech summary').textContent)));
167
- await p.click('#dmF [data-dmf="none"]');
168
- ok('I7 the filter shows the documents not started', (await all('#dmList .dmn b')).join('|') === 'Problem statement|Research notes|Launch checklist and comms');
169
- await p.click('#dmF [data-dmf="all"]'); await p.fill('#dmQ', 'risk');
170
- ok('I7 the search finds a document and keeps the focus in the box', (await all('#dmList .dmn b')).join('|') === 'Risks' && await p.evaluate(() => document.activeElement.id === 'dmQ'));
171
- await p.fill('#dmQ', 'zzz'); ok('I7 no match says so', /No document matches/.test(await txt('#dmList')));
172
- await p.fill('#dmQ', '');
173
-
174
- /* I10 the press */
175
- A.set({ status: 200, body: { ok: true, run: 'r1' } });
176
- await p.locator('#dmList [data-draft="problem"]').click();
177
- ok('I10 Draft it posts the workspace, the initiative scope and the key and nothing else, and says what happens', await until(() => A.posts.some((x) => x.path === '/api/core-docs/draft' && x.body.ws === 'w1' && x.body.scope === 'initiative:self-serve-v2' && x.body.key === 'problem' && Object.keys(x.body).sort().join() === 'key,scope,ws')) && await until(() => p.evaluate(() => /drafting “Problem statement”/.test(document.querySelector('#toast').textContent))));
85
+ {
86
+ const R = await open({ url: '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1' });
87
+ const u = new URL(R.page.url());
88
+ ok('I1 the old initiative link lands on Home with this initiative, its workspace and board kept', R.up && u.pathname === '/premium.html' && u.searchParams.get('ini') === 'self-serve-v2' && u.searchParams.get('ws') === 'w1' && u.searchParams.get('board') === 'w1', R.page.url());
89
+ await R.ctx.close();
90
+ }
91
+ ok('I1 the console is not linked from Home', await p.evaluate(() => ![...document.querySelectorAll('a[href]')].some((a) => /console(\.html)?/.test(a.getAttribute('href')))));
92
+ await p.click('.hm-card .hm-sw[data-hm-switch]');
93
+ const sw = await until(() => p.evaluate(() => { const m = document.querySelector('#hmMenu'); return m && !m.hidden ? [...m.querySelectorAll('[data-hm-mi] b')].map((b) => b.textContent) : null; }));
94
+ ok('I1 the switcher lists Home, the product and the board\'s initiatives', !!sw && sw[0] === 'Home' && ['Self-serve onboarding v2', 'Partner API rate limits', 'Usage-based billing'].every((t) => sw.includes(t)), JSON.stringify(sw));
95
+ await p.click('#hmMenu [data-hm-mi]:has(b:text-is("Partner API rate limits"))');
96
+ { const u = new URL(p.url()); ok('I1 choosing an initiative opens its layout on the same board', await until(() => p.evaluate(() => new URLSearchParams(location.search).get('ini') === 'partner-rate-limits')) && u.searchParams.get('ws') === 'w1' && u.searchParams.get('board') === 'w1', p.url()); }
97
+ await p.click('.hm-card .hm-sw[data-hm-switch]'); await until(() => p.evaluate(() => !document.querySelector('#hmMenu').hidden));
98
+ await p.click('#hmMenu [data-hm-mi="0"]');
99
+ ok('I1 Home in the switcher leads back to all work', await until(() => p.evaluate(() => !new URLSearchParams(location.search).get('ini'))), p.url());
100
+ await p.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&board=w1&theme=light'); await ready(p);
101
+
102
+ /* I3 header: the card */
103
+ const card = await p.evaluate(() => { const c = document.querySelector('.hm-card'); const q = (s) => ((c.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' ').trim();
104
+ return { kind: q('.hm-sw .k'), title: q('.hm-sw b'), turn: q('.hm-turn'), stage: q('.hm-br .st'), lad: q('.hm-lad'), cur: q('.hm-lad b'), bars: c.querySelectorAll('.hm-bars i').length, now: c.querySelectorAll('.hm-bars i.now').length, ckh: q('.hm-ckh'), items: [...c.querySelectorAll('.hm-it')].map((x) => x.textContent.replace(/\s+/g, ' ').trim()), then: q('.hm-then'), time: q('.hm-time'), cta: q('[data-hm-cta]') }; });
105
+ ok('I3 the card names the initiative, its lane and its anchor', card.title === 'Self-serve onboarding v2' && /^Feature · \S/.test(card.kind), JSON.stringify(card));
106
+ ok('I3 the card shows the stage the workflow engine derives, with the ladder\'s current step and one bar a step', /Build/.test(card.stage + card.cur) && card.bars === 8 && card.now === 1, JSON.stringify(card));
107
+ ok('I1 the card lists what finishes the step, says whose turn it is, and has one CTA', card.items.length > 0 && !!card.turn && !!card.cta && !/pull request|builder agent/i.test(card.items.join(' ')), JSON.stringify(card));
108
+ ok('I1 the card has the payoff line and the time in the stage when the record has them', (!card.then || /^Then:/.test(card.then)) && (card.then || card.time), JSON.stringify(card));
109
+ if (await p.evaluate(() => !!document.querySelector('.hm-card [data-hm-done]'))) {
110
+ await p.click('.hm-card [data-hm-done]');
111
+ ok('I1 the done items open from their summary row', await until(() => p.evaluate(() => document.querySelector('.hm-card [data-hm-done]').getAttribute('aria-expanded') === 'true')));
112
+ }
113
+ ok('I3 Deliver is a milestone: the ladder and the checklist title carry the ◆ mark before it (Agreed design AgInitAgents)', await p.evaluate(() => !!document.querySelector('.hm-card .hm-lad .nx .cz-ms') && !!document.querySelector('.hm-card .hm-ckh .cz-ms') && /To reach Deliver/.test(document.querySelector('.hm-card .hm-ckh').textContent)));
114
+ await p.click('.hm-card [data-hm-cfold]');
115
+ const fold = await until(() => p.evaluate(() => { const c = document.querySelector('.hm-card'), f = c.querySelector('[data-hm-cfold]'); return f && f.getAttribute('aria-expanded') === 'false' ? { sum: f.textContent.replace(/\s+/g, ' ').trim(), items: c.querySelectorAll('.hm-it').length, then: !!c.querySelector('.hm-then'), time: !!c.querySelector('.hm-time'), cta: !!c.querySelector('[data-hm-cta]') } : null; }));
116
+ ok('I3 the checklist folds to one line with its summary; Then and the time line hide, the CTA stays (AgInitSpec)', fold && /^To reach Deliver ?\d+ of \d+ done/.test(fold.sum) && fold.items === 0 && !fold.then && !fold.time && fold.cta, JSON.stringify(fold));
117
+ await p.click('.hm-card [data-hm-cfold]');
118
+ ok('I3 it unfolds again', await until(() => p.evaluate(() => document.querySelector('.hm-card [data-hm-cfold]').getAttribute('aria-expanded') === 'true' && document.querySelectorAll('.hm-card .hm-it').length > 0)));
119
+ ok('I1 the card wrote nothing on its own', writes(A).length === 0, JSON.stringify(writes(A)));
120
+
121
+ /* I7 documents: the list's Files group opens a document's page in the Viewer */
122
+ ok('I7 the list holds the initiative\'s files, the PRD among them', await until(() => p.evaluate(() => !!document.querySelector('.hm-r[data-id="f:planning/prd/self-serve-v2-prd.md"]'))));
123
+ await p.click('.hm-r[data-id="f:planning/prd/self-serve-v2-prd.md"] .hm-rm');
124
+ ok('I7 a file opens as its page in the Viewer, not a dialog', await until(() => p.evaluate((v) => !!document.querySelector(v + ' .obody.vw[data-vw="doc:planning/prd/self-serve-v2-prd.md"]') && !(document.querySelector('#dlg') && !!document.querySelector('#dlg.on')), V), 15000));
125
+
126
+ /* I4 the Overview */
127
+ ok('I4 the card\'s Overview press opens the Overview in the Viewer, marked Waiting for design', await overview(p) && await p.evaluate((v) => /Overview/.test(document.querySelector('#czViewer .cz-vw-kind').textContent) && !!document.querySelector(v + ' .hx-wait'), V));
128
+ const ov = await p.evaluate((v) => { const o = document.querySelector(v); return { moves: [...o.querySelectorAll('[data-ov-move]')].map((b) => b.dataset.ovMove), cur: (o.querySelector('[data-ov-move][aria-pressed="true"]') || {}).textContent, life: [...o.querySelectorAll('[data-ov-life]')].map((b) => b.dataset.ovLife), tasks: [...o.querySelectorAll('[data-ov-tkrow] b')].map((b) => b.textContent), states: [...o.querySelectorAll('[data-ov-task]')].map((s) => s.dataset.ovTask + '=' + s.value), docs: [...o.querySelectorAll('[data-ov-doc]')].map((d) => d.dataset.ovDoc), draft: [...o.querySelectorAll('[data-ov-draft]')].map((b) => b.dataset.ovDraft), drafting: [...o.querySelectorAll('[data-ov-doc]')].filter((d) => /Drafting/.test(d.textContent)).map((d) => d.dataset.ovDoc), dread: [...o.querySelectorAll('[data-ov-dread]')].map((b) => b.dataset.ovDread), sum: (o.querySelector('[data-ov-dsum]') || {}).textContent || '' }; }, V);
129
+ const M = mk();
130
+ ok('I4 the stage row lists the board\'s stages with the current one pressed, and the lifecycle presses', JSON.stringify(ov.moves) === JSON.stringify(M.acts.stages) && ov.cur === 'Build' && ov.life.join() === 'on-hold,cancelled', JSON.stringify(ov));
131
+ ok('I6 the tasks are the record\'s, and only a PMOS task has a status control with its own state', JSON.stringify(ov.tasks) === JSON.stringify(M.tasks.rows.slice(0, 40).map((t) => t.title)) && JSON.stringify(ov.states) === JSON.stringify(M.tasks.rows.filter((t) => t.pmos && t.uid).map((t) => t.uid + '=' + t.state)), JSON.stringify(ov));
132
+ ok('I7 the core documents are the non-technical ones, with the engine\'s summary', JSON.stringify(ov.docs) === JSON.stringify(M.docs.rows.filter((d) => !d.tech).map((d) => d.key)) && ov.sum === M.docs.cap, JSON.stringify(ov));
133
+ ok('I7 a document not started offers Draft it; a running one says Drafting and has no press; a draft offers Read', ov.draft.join() === 'problem,research' && ov.drafting.join() === 'launch' && ov.dread.length === M.docs.rows.filter((d) => !d.tech && d.st === 'draft' && d.path && d.slot).length, JSON.stringify(ov));
134
+
135
+ /* I10 presses */
178
136
  const mint = await T.nonce(BASE);
179
- ok('I10 the press carried the launch nonce and no writer field', !!mint && A.posts.filter((x) => x.path === '/api/core-docs/draft').every((x) => x.headers['x-pmos-nonce'] === mint && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)));
180
- A.set({ status: 409, body: { ok: false, error: 'a run is already drafting that document' } });
181
- await p.locator('#dmList [data-draft="problem"]').click();
182
- ok('I10 a refused press shows the route\'s reason and turns the button back on', await until(() => p.evaluate(() => /already drafting/.test(document.querySelector('#toast').textContent) && !document.querySelector('#dmList [data-draft="problem"]').disabled)));
183
- ok('I10 Drop, Accept and editing are not on the page, and no Issue it press is in the list (it is on a draft\'s sheet)', !/\b(Drop|Accept|Edit)\b/.test(await txt('#iMain')) && await p.evaluate(() => ![...document.querySelectorAll('#iMain button')].some((b) => /Issue it/.test(b.textContent))));
184
- ok('I7 a running document shows Drafting and is off', await p.evaluate(() => { const b = document.querySelector('#dmList [data-draft="launch"]'); return !!b && b.disabled && /Drafting/.test(b.textContent); }));
185
-
186
- /* the batch press: one existing draft run for each document not started */
187
- ok('I7 "Draft the 2 not started" counts the documents a press can draft, not the one already running', /Draft the 2 not started/.test(await txt('.dsum .dlink')));
188
- A.set({ status: 200, body: { ok: true, run: 'rb' } }); const nB = A.posts.length;
189
- await p.click('.dsum .dlink');
190
- ok('I10 it posts one draft for each, with the initiative scope and nothing else', await until(() => A.posts.slice(nB).filter((x) => x.path === '/api/core-docs/draft').map((x) => x.body.key).sort().join() === 'problem,research' && A.posts.slice(nB).every((x) => x.path === '/api/core-docs/draft' && x.body.scope === 'initiative:self-serve-v2' && Object.keys(x.body).sort().join() === 'key,scope,ws')));
191
-
192
- /* I8 the document sheet */
193
- const nPost0 = A.posts.length;
194
- await p.locator('#dmList .dmo[data-doc="prd"]').click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /Self-serve onboarding v2/.test(document.querySelector('#oMain').textContent) && document.querySelector('#oMain .dsbody'))); await sleep(500); await p.click('#oMain [data-ds="meta"]');
195
- const sh = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, path: document.querySelector('#oMain [data-ds="meta"]').title, tabs: (() => { document.querySelector('#shV').click(); const t = [...document.querySelectorAll('#shT [data-sh]')].map((b) => b.textContent).join(','); document.querySelector('#shV').click(); return t; })(), fm: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), heads: [...document.querySelectorAll('#oMain h3.d2')].map((h) => h.textContent).join('|'), outline: [...document.querySelectorAll('#oMain .dso button')].map((b) => b.textContent).join('|'), pre: [...document.querySelectorAll('#oMain pre')].map((e) => e.textContent).join('|'), li: document.querySelectorAll('#oMain li').length }));
196
- ok('I8 Read shows the file\'s path, its front matter as a grid, its headings, list and code', sh.title === 'PRD' && sh.path === 'planning/prd/self-serve-v2-prd.md' && sh.tabs === 'Read,Edit,Proposals,Edit log,Health,Relations' && /type\|PRD\|title\|Self-serve onboarding v2/.test(sh.fm) && sh.heads === 'PRD: Self-serve onboarding v2|Problem|Goal|Requirements' && sh.li === 2 && /R1 a first call/.test(sh.pre), JSON.stringify(sh));
197
- ok('I8 Read asked for the log and the last revision, by GET, for this path', A.gets.some((g) => g.path === '/api/doc-sheet/log' && /path=planning%2Fprd%2Fself-serve-v2-prd.md/.test(g.query)) && A.gets.some((g) => g.path === '/api/doc-sheet/at' && /rev=2/.test(g.query)));
198
- await p.click('#shV'); await p.click('#shT [data-sh="log"]');
199
- const lg = await until(() => p.evaluate(() => document.querySelector('#oMain .hsr') && [...document.querySelectorAll('#oMain .hsr')].map((r) => r.textContent.replace(/\s+/g, ' ').trim())));
200
- ok('I8 Edit log lists the revisions newest first with their reasons and the other entries', lg && /v2 tightened the goal · pm/.test(lg[0]) && /v1 The file as the sheet first saw it · baseline/.test(lg[1]) && /asked What is missing\?/.test(lg[2]), JSON.stringify(lg));
201
- await p.click('#oMain [data-lgd="2"]');
202
- const cmp = await until(() => p.evaluate(() => { const d = document.querySelector('#oMain .lgdf'); return d && d.querySelector('ins') && { ins: d.querySelector('ins').textContent, del: d.querySelector('del') && d.querySelector('del').textContent, btn: document.querySelector('#oMain [data-lgd="2"]').textContent, first: !!document.querySelector('#oMain [data-lgd="1"]') }; }));
203
- ok('I8 Show change on a revision compares it with the one before: the new words are marked added, the old ones removed, and the first revision has no button', cmp && cmp.ins === 'waits' && cmp.del === 'waited' && cmp.btn === 'Hide change' && cmp.first === false, JSON.stringify(cmp));
204
- ok('I8 the comparison asked for both revisions by GET, and nothing else', A.gets.filter((g) => g.path === '/api/doc-sheet/at' && /rev=1\b/.test(g.query)).length >= 1 && !A.posts.some((q) => /doc-sheet/.test(q.path) && /log|at/.test(q.path)));
205
- await p.click('#oMain [data-lgd="2"]');
206
- ok('I8 Hide change closes it', await p.evaluate(() => !document.querySelector('#oMain .lgdf')));
207
- await p.click('#shV'); await p.click('#shT [data-sh="health"]');
208
- const hl = await until(() => p.evaluate(() => document.querySelector('#oMain .ckr') && { note: document.querySelector('#oMain .note').textContent, rows: [...document.querySelectorAll('#oMain .ckr')].map((r) => r.className + ':' + r.querySelector('span').textContent) }));
209
- ok('I8 Health shows each check as passed, not passed or no input, and says no input is not counted', hl && /1 of 2 checks/.test(hl.note) && hl.rows.join() === 'ckr done:Passed,ckr blocked:Not passed,ckr skipped:No input', JSON.stringify(hl));
210
- await p.click('#shV'); await p.click('#shT [data-sh="rel"]');
211
- const rl = await until(() => p.evaluate(() => document.querySelector('#oMain .dsrr') && [...document.querySelectorAll('#oMain .label, #oMain .dsrr')].map((r) => r.textContent.replace(/\s+/g, ' ').trim())));
212
- ok('I8 Relations lists the sources, the goals and the documents that use it, from the library route', rl && rl.join('|') === 'Sources · 1|Self-serve briefcites|Goals and initiative · 1|Activation goalcites · Goal|Used by · 1|Self-serve rubriccites', JSON.stringify(rl));
213
- ok('I8 Relations read the library by GET for this workspace and a goal that is a node is listed, not opened', A.gets.some((g) => g.path === '/api/docs/library' && /ws=w1/.test(g.query)) && await p.evaluate(() => document.querySelectorAll('#oMain [data-rel]').length) === 2);
214
- await p.click('#shV'); await p.click('#shT [data-sh="read"]');
215
- ok('I8 a document with no copy offers Link a copy in the status line', await p.evaluate(() => /Link a copy/.test(document.querySelector('#oMain .dsm2').textContent)));
216
- await p.click('#oMain [data-ds="cp"]'); await p.fill('#dsCpUrl', 'notes'); await p.click('[data-ds="cplink"]');
217
- ok('I8 a link that names no tool is refused on the sheet, and nothing is posted', /Confluence page or Google Doc/.test(await txt('#oMain .dscp [role="alert"]')) && !A.posts.some((x) => x.path === '/api/docs/link'));
218
- await p.fill('#dsCpUrl', 'https://docs.google.com/document/d/abc/edit'); await p.click('[data-ds="cplink"]');
219
- await until(() => p.evaluate(() => /Google Doc: not checked/.test(document.querySelector('#oMain .dsm2').textContent)));
220
- ok('I8 linking posts the path, the tool and the address, and the status line then names the copy', A.posts.some((x) => x.path === '/api/docs/link' && x.body.kind === 'google' && x.body.path === 'planning/prd/self-serve-v2-prd.md' && x.body.ws === 'w1' && /docs\.google\.com/.test(x.body.target)));
221
- await p.click('[data-ds="cpcheck"]');
222
- ok('I8 Check now posts the workspace only and the button reads Checking', A.posts.some((x) => x.path === '/api/docs/check' && Object.keys(x.body).join() === 'ws') && await until(() => p.evaluate(() => /Checking/.test(document.querySelector('[data-ds="cpcheck"]').textContent))));
223
- await p.click('#oMain [data-ds="cp"]');
224
- ok('I8 the health check posts the path and the workspace only', A.posts.some((x) => x.path === '/api/doc-health/check' && Object.keys(x.body).sort().join() === 'path,ws' && x.body.ws === 'w1'));
225
- ok('I8 the sheet wrote nothing: no edit, propose, accept, reject, why, mark or ask post went out', !A.posts.slice(nPost0).some((x) => /doc-sheet/.test(x.path)) && !A.posts.some((x) => /^\/api\/doc-sheet\/(edit|propose|accept|reject|why|mark-current|ask)/.test(x.path)));
226
- ok('I8 the sheet says the file changes only on Save or Accept', /only when you press Save or Accept/.test(await txt('#oMain .xn')));
227
- A.setThread({ ok: true, working: false, turns: [] });
228
- await p.fill('#askIn', 'What is missing?'); const nA = A.posts.length; await p.press('#askIn', 'Enter');
229
- ok('I8 a question posts the document key and the text', await until(() => A.posts.length > nA && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'doc:self-serve-v2:prd' && A.posts[A.posts.length - 1].body.text === 'What is missing?'));
230
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
231
- await p.fill('#dmQ', ''); await p.click('#dmF [data-dmf="all"]');
232
- ok('I8 every document row opens, including one with no file', await p.evaluate(() => [...document.querySelectorAll('#dmList .dmr')].every((r) => !!r.querySelector('.dmo[data-doc]'))));
233
- await p.click('#dmList .dmo[data-doc="problem"]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
234
- { const ab = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#oMain').textContent, draft: !!document.querySelector('#abDraft'), ask: document.querySelector('#askF').hidden }));
235
- ok('I8 a document with no file says what it is for, who writes it and offers Draft it', ab.title === 'Problem statement' && /Who writes it/.test(ab.body) && ab.draft && ab.ask === false, JSON.stringify(ab)); }
236
- const nD = A.posts.length; A.set({ status: 200, body: { ok: true, run: 'r1' } }); await p.click('#abDraft');
237
- ok('I8 Draft it in that popup posts the draft route and closes the popup', await until(() => A.posts.length > nD && A.posts[A.posts.length - 1].path === '/api/core-docs/draft' && A.posts[A.posts.length - 1].body.key === 'problem') && await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))));
238
- await p.click('#dmList .dmo[data-doc="research"]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dTitle').textContent === 'Research notes')); await sleep(400);
239
- { const rs = await p.evaluate(() => ({ say: document.querySelector('#dBody .stream').textContent, prd: (document.querySelector('#oMain .dprd') || {}).textContent || '', body: document.querySelector('#oMain').textContent, first: !!document.querySelector('#oMain .dprd') && document.querySelector('#oMain .dprd').compareDocumentPosition(document.querySelector('#oMain .kv2')) === Node.DOCUMENT_POSITION_FOLLOWING }));
240
- ok('I8 a derived document with no file shows the PRD section it comes from, before its details, and the first line says so', /The PRD’s “Evidence” section covers it/.test(rs.say) && /Five of eight trial teams stalled/.test(rs.prd) && /• Support tickets doubled/.test(rs.prd) && /From the PRD: Evidence/.test(rs.body) && /planning\/prd\/self-serve-v2-prd\.md § Evidence/.test(rs.body) && !/nothing to read here/.test(rs.body) && rs.first, JSON.stringify(rs)); }
241
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
137
+ const settle = async (fn) => { const c = A.calls(); await fn(); await until(() => A.calls() > c, 10000); await sleep(500); }; // a press that lands reads the initiative again and draws the Overview again
138
+ await settle(() => p.click(`${V} [data-ov-move="Deliver"]`));
139
+ const mv = await until(() => A.posts.find((x) => x.path === '/api/boards/move'));
140
+ ok('I10 a stage press posts the board, the initiative and the stage to the move route', mv && mv.body.ws === 'w1' && mv.body.board === 'w1' && mv.body.id === 'self-serve-v2' && mv.body.to === 'Deliver', JSON.stringify(mv && mv.body));
141
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-move]'), V));
142
+ await p.click(`${V} [data-ov-life="on-hold"]`);
143
+ ok('I10 a lifecycle press asks its reason inline before it posts', await until(() => p.evaluate((v) => !!document.querySelector(v + ' #ovWhy'), V)) && !A.posts.some((x) => x.path === '/api/lifecycle'));
144
+ await p.fill(`${V} #ovWhy`, 'x'); await p.click(`${V} [data-ov-life-go]`);
145
+ ok('I10 a reason too short is refused and nothing is posted', await until(async () => /Say why in a few words/.test(await txt(p, V + ' #ovMsg'))) && !A.posts.some((x) => x.path === '/api/lifecycle'));
146
+ await p.fill(`${V} #ovWhy`, 'Waiting on legal'); await settle(() => p.click(`${V} [data-ov-life-go]`));
147
+ const lf = await until(() => A.posts.find((x) => x.path === '/api/lifecycle'));
148
+ ok('I10 Record posts the state and the reason to the lifecycle route', lf && lf.body.initiative_id === 'self-serve-v2' && lf.body.state === 'on-hold' && lf.body.reason === 'Waiting on legal' && lf.body.ws === 'w1', JSON.stringify(lf && lf.body));
149
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' #ovTask'), V));
150
+ await p.click(`${V} [data-ov-add]`); await sleep(200);
151
+ ok('I6 Add with no title posts nothing', !A.posts.some((x) => x.path === '/api/boards/tasks/add'));
152
+ await p.fill(`${V} #ovTask`, 'Release plan'); await settle(() => p.click(`${V} [data-ov-add]`));
153
+ const ad = await until(() => A.posts.find((x) => x.path === '/api/boards/tasks/add'));
154
+ ok('I10 Add posts the workspace, the board, this initiative and the title to the board\'s own route', ad && ad.body.ws === 'w1' && ad.body.board === 'w1' && ad.body.initiative === 'self-serve-v2' && ad.body.title === 'Release plan', JSON.stringify(ad && ad.body));
155
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-task]'), V));
156
+ await settle(() => p.selectOption(`${V} [data-ov-task]`, 'In progress'));
157
+ const ts = await until(() => A.posts.find((x) => x.path === '/api/boards/tasks/state'));
158
+ ok('I10 a status change posts the board, the task and the state, and nothing else', ts && Object.keys(ts.body).sort().join() === 'board,state,task,ws' && ts.body.state === 'In progress', JSON.stringify(ts && ts.body));
159
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-draft="problem"]'), V));
160
+ await settle(() => p.click(`${V} [data-ov-draft="problem"]`));
161
+ const dr = await until(() => A.posts.find((x) => x.path === '/api/core-docs/draft'));
162
+ ok('I10 Draft it posts the workspace, the initiative scope and the key and nothing else', dr && Object.keys(dr.body).sort().join() === 'key,scope,ws' && dr.body.scope === 'initiative:self-serve-v2' && dr.body.key === 'problem', JSON.stringify(dr && dr.body));
163
+ A.set({ status: 409, body: { ok: false, error: 'PMOS is already drafting this document.' } });
164
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-draft="research"]'), V));
165
+ await p.click(`${V} [data-ov-draft="research"]`);
166
+ ok('I10 a refused press shows the route\'s reason in the Overview', await until(async () => /already drafting/.test(await txt(p, V + ' #ovMsg'))));
167
+ A.set({ status: 200, body: { ok: true } });
168
+ ok('I10 every press carried the launch nonce and no writer field', !!mint && writes(A).length >= 5 && writes(A).every((x) => x.headers['x-pmos-nonce'] === mint && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)), JSON.stringify(writes(A).map((x) => x.path)));
169
+ ok('I10 the Overview posts only to the move, lifecycle, task and draft routes', A.posts.filter((x) => /^\/api\/(boards|lifecycle|core-docs)/.test(x.path)).every((x) => WRITES.test(x.path)));
170
+ ok('I1 the old dialog never opened', await p.evaluate(() => { const d = document.querySelector('#dlg'); return !d || !d.classList.contains('on'); }));
242
171
  ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
243
172
  await A.ctx.close();
244
173
 
245
- /* I8 a file that cannot be read */
246
- {
247
- const B = await open();
248
- await B.page.unroute('**/api/doc-sheet/**'); await B.page.route('**/api/doc-sheet/**', (r) => r.fulfill({ status: 404, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'the file is not in this repository' }) }));
249
- await B.page.locator('#dmList .dmo[data-doc="prd"]').click();
250
- ok('I8 a file that cannot be read says why and shows no text', await until(() => B.page.evaluate(() => /the file is not in this repository/.test(document.querySelector('#oMain').textContent))));
251
- await B.ctx.close();
252
- }
253
-
254
- /* I2 reading and failure */
174
+ /* I2 reading and honest states */
255
175
  {
256
176
  let n = 0;
257
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), rp = await ctx.newPage();
258
- await rp.route('**/api/initiative-premium*', (r) => { n++; return r.fulfill(n < 3 ? { status: 202, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'reading' }) } : { contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: mk(), as_of: F.NOW }) }); });
259
- await rp.goto(BASE + '/premium-initiative.html?id=self-serve-v2');
260
- ok('I2 while the initiatives are read the page says so and shows no card', await until(() => rp.evaluate(() => /Reading the initiative/.test(document.querySelector('#snap').textContent) && !document.querySelector('#cIniTk'))));
261
- ok('I2 it asks again and draws when the read ends', await until(() => rp.evaluate(() => !!document.querySelector('#cIniTk')), 15000) && n >= 3);
262
- await ctx.close();
263
- const E = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'boom' } }) });
264
- ok('I2 a failed read says why and draws no card', await E.page.evaluate(() => /The initiative could not be read/.test(document.querySelector('#snap').textContent) && /boom/.test(document.querySelector('#iMain').textContent) && !document.querySelector('#cIniTk')));
177
+ const R = await open({ answers: (c) => { n = c; return c <= 2 ? { status: 202, body: { ok: true, state: 'reading' } } : { status: 200, body: { ok: true, state: 'ready', model: mk(), as_of: Date.now() } }; } });
178
+ await overview(R.page);
179
+ ok('I2 while the initiative is read the Overview says so, then draws when the read ends', await until(() => R.page.evaluate((v) => !!document.querySelector(v + ' [data-ov-move]'), V), 20000) && n >= 3, String(n));
180
+ await R.ctx.close();
181
+ const E = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'the board could not be read' } }) });
182
+ await overview(E.page);
183
+ ok('I2 a failed read says so in the Overview and draws no stage or task', await until(() => E.page.evaluate((v) => { const o = document.querySelector(v); return !!o && /could not be read/.test(o.textContent) && !o.querySelector('[data-ov-move], [data-ov-tkrow]'); }, V), 60000));
184
+ ok('I2 no page error on a failed read', E.errors.length === 0, E.errors.join(' | '));
265
185
  await E.ctx.close();
266
- const N = await open({ answers: () => ({ status: 404, body: { ok: false, state: 'error', error: 'nope is not an initiative on a board' } }), qs: '?id=nope' });
267
- ok('I2 an initiative that is not on a board says so and does not retry', await N.page.evaluate(() => /nope is not an initiative on a board/.test(document.querySelector('#iMain').textContent)) && N.calls() === 1);
268
- await N.ctx.close();
269
- const X = await open({ qs: '?x=1', answers: () => ({ status: 400, body: { ok: false, state: 'error', error: 'id must name an initiative' } }) });
270
- ok('I2 no initiative named says so', await X.page.evaluate(() => /needs an initiative/.test(document.querySelector('#iMain').textContent)));
271
- await X.ctx.close();
272
- }
273
-
274
- /* I4 the description */
275
- {
276
- const L = await open({ model: mk({ row: Object.assign({}, F.ROW, { title: 'Self-serve onboarding v2 — a partner reaches a first call without help' }) }) });
277
- ok('I4 a title "name — purpose" puts the name in the crumb and the purpose in the description line', await L.page.evaluate(() => document.querySelector('#crIni').textContent === 'Self-serve onboarding v2' && document.querySelector('#cIniOv .lede').textContent === 'A partner reaches a first call without help' && document.querySelector('#iH1').textContent.includes('—')));
278
- await L.ctx.close();
279
- }
280
-
281
- /* I6 a long task list is paged */
282
- {
283
- const many = Array.from({ length: 25 }, (_, n) => ({ uid: 'm' + n, key: 'M-' + n, kind: 'Task', src: 'jira', title: 'Task ' + n, status: n % 3 ? 'To do' : 'Done', blocked: false, owner: null, ini: 'self-serve-v2', start: null, end: null }));
284
- const D = await open({ model: mk({ items: many }) });
285
- const rows = () => D.page.evaluate(() => document.querySelectorAll('#tkBody .tkq').length);
286
- ok('I6 the List shows ten tasks and says where it is', await rows() === 10 && /1–10 of 28/.test(await D.page.evaluate(() => document.querySelector('.tkpg').textContent)));
287
- await D.page.click('[data-tkpg="1"]'); await D.page.click('[data-tkpg="1"]');
288
- ok('I6 Next walks to the last page, which holds the rest, and Next is then off', await rows() === 8 && await D.page.evaluate(() => document.querySelector('[data-tkpg="1"]').disabled));
289
- await D.page.click('#tkTabs [data-v="stage"]');
290
- ok('I6 By stage caps a column and Show more opens it', await D.page.evaluate(() => document.querySelectorAll('#tkBody .isc:nth-child(1) .tkc').length) <= 6 && (await D.page.locator('[data-tkmore]').count()) > 0);
291
- await D.page.locator('[data-tkmore]').first().click();
292
- ok('I6 Show more lists the whole column', await D.page.evaluate(() => document.querySelectorAll('#tkBody .tkc').length) >= 25);
293
- await D.page.click('#tkTabs [data-v="time"]');
294
- ok('I6 the Timeline keeps working and is paged too', /of 28/.test(await D.page.evaluate(() => document.querySelector('.tkpg').textContent)));
295
- await D.ctx.close();
296
186
  }
297
187
 
298
- /* I3 degraded: nothing invented */
188
+ /* I12 floors at 390 */
299
189
  {
300
- const D = await open({ model: mk({ row: Object.assign({}, F.ROW, { owner: null, end: null, status: null }), sheet: null, ladder: null, items: [], docs: null }) });
301
- const d = await D.page.evaluate(() => ({ chip: !!document.querySelector('.ihead .chp'), meta: document.querySelector('.ihm').textContent, ov: document.querySelector('#cIniOv').textContent, chk: !!document.querySelector('#cIniChk'), tk: document.querySelector('#cIniTk').textContent, docs: document.querySelector('#cIniDoc').textContent }));
302
- ok('I3 with no status, owner, finish, sheet, items or documents the page says so and draws none of them', !d.chip && d.meta === 'Onboarding · stage derived by the workflow engine' && /could not be read, so the next step is not shown/.test(d.ov) && !d.chk && /no PRD requirement list and no tracker item/.test(d.tk) && /could not be read, so none is shown/.test(d.docs), JSON.stringify(d));
303
- await D.ctx.close();
304
- }
305
-
306
- /* I12 floors */
307
- for (const [w, h] of [[1280, 900], [390, 844]]) {
308
- const R = await open({ w, h });
309
- const f = await R.page.evaluate(() => { const bad = []; for (const e of document.querySelectorAll('button,a,[role=button],input')) { if (e.closest('[hidden],[inert]')) continue; const r = (e.tagName === 'INPUT' && e.closest('label') ? e.closest('label') : e).getBoundingClientRect(); if (r.width && r.height && (r.height < 32 || r.width < 32) && !e.closest('.seg,.dprog')) bad.push((e.id || e.className || e.tagName) + ' ' + Math.round(r.width) + 'x' + Math.round(r.height)); } return { sx: document.documentElement.scrollWidth - innerWidth, small: bad.slice(0, 6) }; });
310
- ok(`I12 no sideways scroll and no tiny target at ${w} px`, f.sx <= 0 && f.small.length === 0, JSON.stringify(f));
311
- if (w === 390) {
312
- await R.page.locator('#dmList .dmo[data-doc="prd"]').click(); await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(700);
313
- const g = await R.page.evaluate(() => { const r = document.querySelector('#dlg').getBoundingClientRect(); return { l: Math.round(r.left), w: Math.round(r.width), vw: innerWidth }; });
314
- ok('I12 the sheet is full width on a phone', g.l <= 1 && g.w >= g.vw - 2, JSON.stringify(g));
315
- }
316
- await R.ctx.close();
190
+ const N = await open({ w: 390, h: 844 });
191
+ await overview(N.page);
192
+ const fl = await N.page.evaluate((v) => { const o = document.querySelector(v); const small = [...o.querySelectorAll('button, select, input')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent.trim().slice(0, 24) || b.id || b.tagName); return { over: document.documentElement.scrollWidth - innerWidth, small, vw: Math.round(o.getBoundingClientRect().width) }; }, V);
193
+ ok('I12 at 390 px the Overview has no sideways scroll and every target is 44 px', fl.over <= 0 && fl.small.length === 0, JSON.stringify(fl));
194
+ ok('I12 no page error at 390 px', N.errors.length === 0, N.errors.join(' | '));
195
+ await N.ctx.close();
317
196
  }
318
197
 
319
198
  /* the real routes against this repository */
@@ -329,35 +208,28 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
329
208
  const bad = await fetch(BASE + '/api/initiative-premium?id=../etc/passwd'); ok('I1 an id that is not an id is refused', bad.status === 400);
330
209
  const post = await fetch(BASE + '/api/initiative-premium?id=x', { method: 'POST' }); ok('I10 the route answers GET only', post.status === 405);
331
210
  }
332
- /* I12 fidelity against the mockup */
333
- if (!fs.existsSync(MOCKUP)) ok('I12 the mockup is in the repository', false, MOCKUP);
334
- else {
335
- const PAIRS = [['rail', '.rail'], ['crumb', '.crumb'], ['lede', '#cIniOv .lede'], ['agr', '#cIniOv .agr2'], ['agc', '#cIniOv .agc'], ['tkadd', '.tkadd'], ['chip', '.ihead .chp'], ['meta', '.ihm'], ['strip', '.iws em'], ['segs', '.iws .sg2'], ['ov', '#cIniOv'], ['ovh', '#cIniOv h2'], ['todo', '#cIniOv .todo'], ['tdw', '#cIniOv .tdw'], ['tk', '#cIniTk'], ['tkq', '#cIniTk .tkq:last-child'], ['tki', '#cIniTk .tkq:last-child .tki'], ['tkn', '#cIniTk .tkq:last-child .tkn b'], ['tkp', '#cIniTk .tkq:last-child .tkp'], ['doc', '#cIniDoc'], ['dsum', '.dsum'], ['dprog', '.dprog'], ['dtool', '.dtool'], ['dmr', '#cIniDoc .dmr'], ['dmi', '#cIniDoc .dmi.c-Plan'], ['dock', '.dock']];
336
- const SKIP_W = ['crumb', 'crb', 'lede', 'agr', 'agc', 'tkadd', 'ckrs', 'chip', 'meta', 'strip', 'segs', 'ov', 'ovh', 'todo', 'tdw', 'chk', 'ckr', 'tk', 'tkq', 'tki', 'tkn', 'tkp', 'doc', 'dsum', 'dprog', 'dtool', 'dmr', 'dmi'];
337
- const SKIP_L = ['crumb', 'crb', 'cri', 'crask', 'lede', 'agr', 'agc', 'tkadd', 'ckrs', 'chip', 'meta', 'strip', 'segs', 'tdw', 'ovh', 'ckr', 'tkq', 'tki', 'tkn', 'tkp', 'dmr', 'dmi', 'dsum', 'dprog', 'dtool', 'todo'];
338
- const PROPS = ['fontSize', 'fontWeight', 'fontFamily', 'color', 'backgroundColor', 'borderRadius', 'paddingTop', 'paddingLeft', 'letterSpacing', 'lineHeight', 'boxShadow', 'backdropFilter', 'borderTopColor'];
339
- const grab = (pg) => pg.evaluate(([pairs, props]) => { const o = {}; for (const [n, s0] of pairs) { const s = (n === 'rail' || n === 'dock') ? s0 : 'main.stage:not([hidden]) ' + s0; const e = document.querySelector(s); if (!e) { o[n] = null; continue; } const cs = getComputedStyle(e), r = e.getBoundingClientRect(), v = { left: Math.round(r.left), width: Math.round(r.width) }; props.forEach((k) => { v[k] = cs[k]; }); o[n] = v; } return o; }, [PAIRS, PROPS]);
340
- for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
341
- const m = await (await browser.newContext({ viewport: { width: w, height: h } })).newPage();
342
- await m.goto('file://' + MOCKUP); await CT.applyToPage(m, CT_VENDOR);
343
- await until(() => m.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
344
- await m.evaluate((t) => { document.documentElement.dataset.theme = t; document.querySelector('.pl[data-p="init"]').click(); }, th);
345
- await until(() => m.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0)); await sleep(500);
346
- await m.evaluate(() => { showInit('initiative', 'pmos', 0); });
347
- await until(() => m.evaluate(() => !!document.querySelector('#cIniTk') && !!document.querySelector('#cIniDoc .dmr'))); await sleep(900);
348
- const R = await open({ w, h, theme: th, model: mk({ row: Object.assign({}, F.ROW, { title: 'Self-serve onboarding v2 — a partner reaches a first call without help' }) }) }); await sleep(500);
349
- const a = await grab(m), c = await grab(R.page), diffs = [];
350
- for (const [n] of PAIRS) {
351
- if (!a[n] || !c[n]) { diffs.push(n + ' missing'); continue; }
352
- for (const k of Object.keys(a[n])) {
353
- const geom = k === 'left' || k === 'width';
354
- if (geom && ((k === 'width' && SKIP_W.includes(n)) || (k === 'left' && SKIP_L.includes(n)))) continue;
355
- if (geom ? Math.abs(a[n][k] - c[n][k]) > 2 : a[n][k] !== c[n][k]) diffs.push(`${n}.${k} ${a[n][k]} | ${c[n][k]}`);
356
- }
357
- }
358
- ok(`I12 styles and geometry match the mockup at ${w} px, ${th}`, diffs.length === 0, diffs.join(' ; '));
359
- await m.context().close(); await R.ctx.close();
360
- }
211
+
212
+ /* I12 fidelity: the Agreed design (premium-agreed-design, Inside one initiative): Nunito, the cozy card, the CTA in the solid colour, the floating
213
+ * menu. The colours are read from the page's own tokens, so each theme is checked against itself. */
214
+ for (const [w, h] of [[1440, 900], [390, 844]]) for (const th of ['light', 'dark']) {
215
+ const R = await open({ w, h, theme: th });
216
+ const g = await R.page.evaluate(() => {
217
+ const tok = (v) => { const x = document.createElement('i'); x.style.setProperty('background-color', 'var(' + v + ')'); document.body.appendChild(x); const c = getComputedStyle(x).backgroundColor; x.remove(); return c; };
218
+ const cs = (s) => { const e = document.querySelector(s); return e ? getComputedStyle(e) : null; };
219
+ const fab = document.querySelector('#czFab'), fr = fab && fab.getBoundingClientRect();
220
+ const c = document.querySelector('.hm-card').getBoundingClientRect();
221
+ return { font: cs('body').fontFamily, cta: cs('.hm-card [data-hm-cta]').backgroundColor, ctaAlt: document.querySelector('.hm-card [data-hm-cta]').classList.contains('alt'), solid: tok('--cz-solid'), blue: tok('--cz-blue'), well: tok('--cz-well'), card: tok('--cz-card'), box: cs('.hm-card .hm-box').backgroundColor, rad: parseFloat(cs('.hm-card .hm-box').borderTopLeftRadius), fab: fr ? [Math.round(fr.width), Math.round(fr.height)] : null, over: document.documentElement.scrollWidth - innerWidth, cardW: Math.round(c.width) };
222
+ });
223
+ const d = [];
224
+ if (!/^Nunito/.test(g.font)) d.push('font ' + g.font);
225
+ if (!g.ctaAlt && ![g.solid, g.blue].includes(g.cta)) d.push('cta ' + g.cta + ' want ' + g.solid + ' or ' + g.blue);
226
+ if (![g.well, g.card].includes(g.box) && !/rgba/.test(g.box)) d.push('card box ' + g.box);
227
+ if (g.rad < 12) d.push('card radius ' + g.rad);
228
+ if (!g.fab || g.fab[0] !== 56 || g.fab[1] !== 56) d.push('fab ' + JSON.stringify(g.fab));
229
+ if (g.over > 0) d.push('sideways scroll ' + g.over);
230
+ ok(`I12 the initiative follows the Agreed design at ${w} px, ${th}: Nunito, the cozy card, the CTA, the floating menu`, d.length === 0, d.join(' ; '));
231
+ ok(`I12 no page error at ${w} px, ${th}`, R.errors.length === 0, R.errors.join(' | '));
232
+ await R.ctx.close();
361
233
  }
362
234
  return finish();
363
235
  })().catch((e) => { console.error(e); finish(1); });