create-pmos 0.397.0 → 0.399.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 (195) 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/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +105 -52
  8. package/workspace/briefing-premium-board-test.js +284 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +85 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +99 -83
  13. package/workspace/briefing-premium-initiative-test.js +175 -290
  14. package/workspace/briefing-premium-insights-test.js +414 -219
  15. package/workspace/briefing-premium-metrics-test.js +55 -97
  16. package/workspace/briefing-premium-products-test.js +44 -28
  17. package/workspace/briefing-premium-sources-test.js +70 -49
  18. package/workspace/briefing-premium-test.js +155 -648
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +24 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/board-premium-trail.js +32 -0
  23. package/workspace/fixtures/premium-viewer-fixtures.js +187 -0
  24. package/workspace/guide/briefing-premium.md +3 -1
  25. package/workspace/guide/home.md +68 -0
  26. package/workspace/guide/index.md +1 -0
  27. package/workspace/lib/agent-roles.js +71 -0
  28. package/workspace/lib/board-grill.js +63 -0
  29. package/workspace/lib/board-premium.js +121 -24
  30. package/workspace/lib/board-trail.js +223 -0
  31. package/workspace/lib/home-work-item.js +58 -0
  32. package/workspace/lib/initiative-layout.js +77 -0
  33. package/workspace/lib/insights-goals.js +196 -0
  34. package/workspace/lib/insights-premium.js +64 -15
  35. package/workspace/lib/insights-records.js +115 -0
  36. package/workspace/lib/jira-tickets.js +1 -1
  37. package/workspace/lib/meeting-points.js +52 -0
  38. package/workspace/lib/news-for-you.js +88 -0
  39. package/workspace/lib/notes-series.js +29 -6
  40. package/workspace/lib/report-confirm.js +48 -0
  41. package/workspace/lib/route-modules.js +12 -0
  42. package/workspace/lib/routes-board-docs.js +46 -0
  43. package/workspace/lib/routes-board-grill.js +90 -0
  44. package/workspace/lib/routes-board-trail.js +33 -0
  45. package/workspace/lib/routes-home-desk.js +176 -0
  46. package/workspace/lib/routes-home-review.js +108 -0
  47. package/workspace/lib/routes-initiative-layout.js +57 -0
  48. package/workspace/lib/routes-insights-premium.js +16 -4
  49. package/workspace/lib/routes-insights-records.js +133 -0
  50. package/workspace/lib/routes-meeting-points.js +37 -0
  51. package/workspace/lib/routes-news.js +57 -0
  52. package/workspace/lib/routes-notes.js +3 -1
  53. package/workspace/lib/routes-report-confirm.js +31 -0
  54. package/workspace/lib/routes-search.js +38 -0
  55. package/workspace/lib/routes-viewer.js +108 -0
  56. package/workspace/lib/search-index.js +176 -0
  57. package/workspace/lib/transcript-steps.js +123 -0
  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-board-actions-test.js +128 -82
  63. package/workspace/premium-briefing-depth-test.js +104 -90
  64. package/workspace/premium-chat-attach-test.js +54 -63
  65. package/workspace/premium-chat-chart-tab-test.js +37 -37
  66. package/workspace/premium-chat-context-test.js +19 -18
  67. package/workspace/premium-chat-goal-view-test.js +23 -23
  68. package/workspace/premium-chat-notes-test.js +26 -31
  69. package/workspace/premium-chat-report-tab-test.js +46 -28
  70. package/workspace/premium-chat-term-test.js +16 -16
  71. package/workspace/premium-chat-viewer-test.js +60 -59
  72. package/workspace/premium-core-doc-issue-test.js +52 -43
  73. package/workspace/premium-html-viewer-test.js +14 -17
  74. package/workspace/premium-phone-card-test.js +10 -3
  75. package/workspace/premium-phone-room-test.js +41 -35
  76. package/workspace/premium-report-read-test.js +152 -197
  77. package/workspace/premium-viewer-download-test.js +19 -22
  78. package/workspace/premium-viewer-flicker-test.js +11 -16
  79. package/workspace/premium-viewer-share-test.js +6 -9
  80. package/workspace/premium-viewer-test.js +41 -60
  81. package/workspace/premium-vw-backlog-test.js +53 -33
  82. package/workspace/premium-vw-cal-test.js +97 -128
  83. package/workspace/premium-vw-copy-test.js +17 -33
  84. package/workspace/premium-vw-doc-test.js +17 -10
  85. package/workspace/premium-vw-item-test.js +50 -49
  86. package/workspace/premium-vw-jira-test.js +53 -27
  87. package/workspace/premium-vw-meet-test.js +115 -187
  88. package/workspace/premium-vw-notes-test.js +88 -109
  89. package/workspace/premium-vw-rec-test.js +71 -194
  90. package/workspace/premium-vw-slides-test.js +46 -50
  91. package/workspace/premium-welcome-test.js +3 -2
  92. package/workspace/premium-work-depth-test.js +61 -53
  93. package/workspace/public/pm/bd-acts.js +383 -0
  94. package/workspace/public/pm/bd-asks.js +261 -0
  95. package/workspace/public/pm/bd-pop.js +59 -0
  96. package/workspace/public/pm/bd-span.js +222 -82
  97. package/workspace/public/pm/bd-stages.js +25 -11
  98. package/workspace/public/pm/bd-views.js +169 -0
  99. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  100. package/workspace/public/pm/c3-md.js +3 -395
  101. package/workspace/public/pm/c3-phone-detail.js +1 -1
  102. package/workspace/public/pm/c3-phone-model.js +3 -68
  103. package/workspace/public/pm/chat-term.js +3 -3
  104. package/workspace/public/pm/cozy-board.css +798 -230
  105. package/workspace/public/pm/cozy-ev.css +228 -0
  106. package/workspace/public/pm/cozy-evmodel.js +106 -0
  107. package/workspace/public/pm/cozy-evui.js +47 -0
  108. package/workspace/public/pm/cozy-home.css +570 -142
  109. package/workspace/public/pm/cozy-home.js +5 -3
  110. package/workspace/public/pm/cozy-insights.css +437 -170
  111. package/workspace/public/pm/cozy-md.js +396 -0
  112. package/workspace/public/pm/cozy-nav.js +104 -29
  113. package/workspace/public/pm/cozy-news.js +140 -0
  114. package/workspace/public/pm/cozy-placeholder.js +26 -0
  115. package/workspace/public/pm/cozy-search.js +203 -0
  116. package/workspace/public/pm/cozy-settings.js +198 -0
  117. package/workspace/public/pm/cozy-sources.js +89 -0
  118. package/workspace/public/pm/cozy-today.css +217 -0
  119. package/workspace/public/pm/cozy-viewer.css +3 -3
  120. package/workspace/public/pm/cozy-viewer.js +145 -0
  121. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  122. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  123. package/workspace/public/pm/cozy-vw.css +485 -0
  124. package/workspace/public/pm/cozy.css +83 -1
  125. package/workspace/public/pm/home-adddoc.js +48 -0
  126. package/workspace/public/pm/home-app.js +1179 -0
  127. package/workspace/public/pm/home-around.js +413 -0
  128. package/workspace/public/pm/home-chat.js +512 -0
  129. package/workspace/public/pm/home-data.js +312 -0
  130. package/workspace/public/pm/home-dictate.js +54 -0
  131. package/workspace/public/pm/home-draft.js +68 -0
  132. package/workspace/public/pm/home-ini-model.js +190 -0
  133. package/workspace/public/pm/home-ini.css +171 -0
  134. package/workspace/public/pm/home-ini.js +456 -0
  135. package/workspace/public/pm/home-list.js +276 -0
  136. package/workspace/public/pm/home-more.js +132 -0
  137. package/workspace/public/pm/home-phone-card.js +109 -0
  138. package/workspace/public/pm/home-review.js +104 -0
  139. package/workspace/public/pm/home-task.js +67 -0
  140. package/workspace/public/pm/home-today.js +144 -0
  141. package/workspace/public/pm/home-work.js +547 -0
  142. package/workspace/public/pm/phone-moment.js +69 -0
  143. package/workspace/public/pm/pm-work-view.js +1 -1
  144. package/workspace/public/pm/premium-attach.js +4 -0
  145. package/workspace/public/pm/premium-board.js +548 -395
  146. package/workspace/public/pm/premium-chart-tab.js +109 -62
  147. package/workspace/public/pm/premium-deck.js +3 -3
  148. package/workspace/public/pm/premium-first.js +23 -21
  149. package/workspace/public/pm/premium-insights.js +1102 -581
  150. package/workspace/public/pm/premium-meeting.js +61 -549
  151. package/workspace/public/pm/premium-mtg-present.js +138 -0
  152. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  153. package/workspace/public/pm/premium-notes.js +1 -1
  154. package/workspace/public/pm/premium-report-frame.css +20 -0
  155. package/workspace/public/pm/premium-report-read.js +669 -476
  156. package/workspace/public/pm/premium-report-tab.js +116 -67
  157. package/workspace/public/pm/premium-shell.js +76 -123
  158. package/workspace/public/pm/premium-viewer.js +22 -1
  159. package/workspace/public/pm/premium-vw-cal.js +277 -48
  160. package/workspace/public/pm/premium-vw-doc.css +6 -0
  161. package/workspace/public/pm/premium-vw-doc.js +40 -2
  162. package/workspace/public/pm/premium-vw-file.js +2 -2
  163. package/workspace/public/pm/premium-vw-meet.js +6 -83
  164. package/workspace/public/pm/premium-vw-mtg.js +958 -0
  165. package/workspace/public/pm/premium-vw-notes.js +116 -68
  166. package/workspace/public/pm/premium-vw-open.js +35 -0
  167. package/workspace/public/pm/premium-vw-page.js +16 -0
  168. package/workspace/public/pm/premium-vw-rec.js +11 -218
  169. package/workspace/public/pm/premium-vw-slides.css +5 -0
  170. package/workspace/public/pm/premium-vw-slides.js +44 -8
  171. package/workspace/public/pm/rp-parts.js +269 -0
  172. package/workspace/public/pm/term-view.js +22 -0
  173. package/workspace/public/premium-board.html +29 -70
  174. package/workspace/public/premium-initiative.html +8 -48
  175. package/workspace/public/premium-insights.html +26 -64
  176. package/workspace/public/premium-viewer.html +20 -0
  177. package/workspace/public/premium.html +18 -107
  178. package/workspace/r/m1.png +0 -0
  179. package/workspace/r/m2.png +0 -0
  180. package/workspace/r/m3.png +0 -0
  181. package/workspace/r/nl.png +0 -0
  182. package/workspace/server.js +18 -3
  183. package/workspace/test-files.json +1 -0
  184. package/workspace/test-lists/home-libs.json +9 -0
  185. package/workspace/test-lists/initiative-layout.json +9 -0
  186. package/workspace/test-lists/premium-report-read.json +1 -1
  187. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  188. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  189. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  190. package/workspace/test-lists/premium-vw-notes.json +1 -1
  191. package/workspace/test-lists/uf-everywhere.json +15 -0
  192. package/workspace/test-lists/uf-home.json +9 -0
  193. package/workspace/test-lists/uncovered-board.json +9 -0
  194. package/workspace/public/pm/premium-work.js +0 -729
  195. package/workspace/public/pm/premium.js +0 -1146
@@ -1,21 +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 */
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 (Tasks, Documents, Stage: premium-uncovered-features) · I6 tasks · I7 documents · I10 presses · I12 floors and fidelity */
7
13
  const path = require('path');
8
14
  const { spawn } = require('child_process');
9
15
  const { findBrowser } = require('./lib/find-browser');
10
16
  const T = require('./test-run').configure({ name: 'briefing-premium-initiative' });
11
17
  const IP = require('./lib/initiative-premium.js');
12
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');
13
23
 
14
24
  const BASE = T.BASE;
15
25
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
16
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); } };
17
27
  const results = [];
18
- 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) : ''}`); };
19
29
  let srv = null; let browser = null;
20
30
  const finish = async (code) => {
21
31
  if (browser) await browser.close().catch(() => {});
@@ -28,9 +38,9 @@ const finish = async (code) => {
28
38
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
29
39
 
30
40
  const mk = (o) => IP.build(F.facts(o));
31
- 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?' }] };
32
- 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';
33
- 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)$/;
34
44
 
35
45
  (async () => {
36
46
  const exe = findBrowser();
@@ -41,295 +51,170 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
41
51
  await T.waitForServer(BASE);
42
52
  browser = await chromium.launch({ executablePath: exe });
43
53
 
44
- 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' } = {}) => {
45
55
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
46
56
  const page = await ctx.newPage();
47
- 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 = [];
48
59
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
49
- 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 }) }); });
50
- 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) }); });
51
- 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) }); });
52
- 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 }] }) }); });
53
- 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 }) }); });
54
- 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' }) }); });
55
- 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]] }) }); });
56
- 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) }); });
57
- 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) }); });
58
- 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 }) }); });
59
- await page.goto(BASE + '/premium-initiative.html' + qs + '&theme=' + theme);
60
- 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);
61
- 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; } };
62
71
  };
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
+ // the Overview opens on Tasks, with Documents and Stage beside it (premium-uncovered-features, canvas InTasks, InDocs, InStage); view names the one to show
77
+ const show = async (p, view) => { await p.click(`${V} [data-hi-view="${view}"]`); return until(() => p.evaluate((a) => !!document.querySelector(a[0] + ` [data-hi-v="${a[1]}"]`), [V, view])); };
78
+ const overview = async (p, view = 'stage') => {
79
+ 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
80
+ await p.click('.hm-card [data-hm-ov]');
81
+ const s = await until(() => p.evaluate((v) => { const o = document.querySelector(v); if (!o) return null; if (o.querySelector('[data-hi-view]')) return 'ok'; return /could not be read/.test(o.textContent) ? 'err' : null; }, V), 30000);
82
+ if (s === 'ok' && view) await show(p, view);
83
+ return !!s; };
84
+ const writes = (X) => X.posts.filter((x) => WRITES.test(x.path));
63
85
 
64
- const A = await open();
65
- ok('0 the page draws the cards', A.up && await A.page.evaluate(() => !!document.querySelector('#cIniOv') && !!document.querySelector('#cIniTk')));
66
- if (!A.up) return finish(1);
67
- const p = A.page, M = mk();
68
- const txt = (s) => p.evaluate((q) => (document.querySelector(q) || {}).textContent || '', s);
69
- const all = (s) => p.evaluate((q) => [...document.querySelectorAll(q)].map((e) => e.textContent.trim()), s);
86
+ const A = await open(), p = A.page;
87
+ 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')));
70
88
 
71
89
  /* I1 place */
72
- // the Agreed design (premium-agreed-design N1): the floating place menu replaces the rail on screen, and this page belongs to Home
73
- const nav = await p.evaluate(() => ({ rail: getComputedStyle(document.querySelector('.rail')).display, fab: document.querySelector('#czFab').getAttribute('aria-label'), names: [...document.querySelectorAll('#czMenu a, #czMenu button')].map((b) => b.textContent.trim()), cur: document.querySelector('#czMenu [aria-current="page"]').textContent.trim() }));
74
- ok('I1 the floating menu names Home, Board, Insights and Settings, marks Home, and the rail is off screen', nav.rail === 'none' && nav.names.join() === 'Home,Board,Insights,Settings' && nav.cur === 'Home' && nav.fab === 'Open the menu. You are in Home', JSON.stringify(nav));
75
- { 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'); }
76
- 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')));
77
- await p.route('**/premium-board.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<title>b</title>' }));
78
- await p.route('**/premium-initiative.html?id=partner*', (r) => r.fulfill({ contentType: 'text/html', body: '<title>i</title>' }));
79
- await p.click('#crSw2'); const im = await p.evaluate(() => [...document.querySelectorAll('#crMenu button')].map((b) => b.textContent + (b.hasAttribute('aria-current') ? '*' : '')).join('|'));
80
- 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);
81
- await p.click('#crMenu [data-swi="partner-rate-limits"]'); await sleep(500);
82
- { 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'))); }
83
- await p.click('#crBoard'); await sleep(500);
84
- { 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'))); }
85
- // the Agreed design: the card's C button opens the initiative's own conversation with Claude (the thread key the Chat page used, init:<id>)
86
- { const nT = A.posts.length; await p.click('#czBox [data-czov]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on')), 10000); await sleep(300);
87
- const t = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, label: document.querySelector('#czBox [data-czov]').getAttribute('aria-label') }));
88
- ok('I1 the header card\'s C button opens the initiative\'s conversation with Claude, and sends nothing', t.title === 'Self-serve onboarding v2' && t.label === 'Overview of Self-serve onboarding v2 with Claude' && A.posts.length === nT, JSON.stringify(t));
89
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on'))); }
90
-
91
- /* I3 header */
92
- 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('#czBox .cz-ladder i')].map((i) => i.className).join('|'), cur: document.querySelector('#czBox .czi-lad b').textContent, lad: document.querySelector('#czBox .czi-lad').textContent, stage: document.querySelector('#czBox .czi-stage').textContent, turn: document.querySelector('#czBox .czi-turn').textContent }));
93
- ok('I3 the chip and the meta 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', JSON.stringify(head));
94
- // premium-agreed-design I1: the header card's eight-step ladder, Deliver and Evaluate as milestones; Build is step 5
95
- ok('I1 the header card shows the eight-step ladder with two milestones, the current step and the next', head.segs === 'done|done|done|done|now|ms||ms' && head.cur === 'Build' && /Prioritize/.test(head.lad) && /Deliver/.test(head.lad) && head.stage === '5 of 8 · Build' && head.turn === 'Your turn', JSON.stringify(head));
96
90
  {
97
- const card = await p.evaluate(() => ({ items: [...document.querySelectorAll('#czBox .czi-it')].map((e) => e.textContent.trim()), pay: (document.querySelector('#czBox .czi-pay') || {}).textContent, time: (document.querySelector('#czBox .czi-time') || {}).textContent, cta: document.querySelector('#czBox [data-czcta]').textContent, text: document.querySelector('#czHead').textContent }));
98
- ok('I1 what finishes it: done, your steps and the Jira tickets, never a PMOS builder agent or a pull request', card.items.some((x) => /1 done: PRD and rubric written/.test(x)) && card.items.some((x) => /Your go on the done criteria\s*You/.test(x)) && card.items.some((x) => /1 of 2 tickets Done in Jira/.test(x)) && !/pull request|\bPR\b|builder/i.test(card.text), JSON.stringify(card));
99
- ok('I1 the payoff line, the time in the stage and one primary CTA', /^Then: The features are delivered in Jira/.test(card.pay) && /Moves q3-2026:o1:kr1/.test(card.pay) && card.time === 'In Build · planned finish 30 Oct' && card.cta === 'Review the done criteria' && (await p.$$('#czBox .czi-cta')).length === 1, JSON.stringify(card));
100
- await p.click('#czBox [data-czfold]');
101
- const fold = await p.evaluate(() => ({ items: document.querySelectorAll('#czBox .czi-it').length, sum: (document.querySelector('#czBox .czi-fold') || {}).textContent, exp: document.querySelector('#czBox [data-czfold]').getAttribute('aria-expanded') }));
102
- ok('I1 the card folds to one line and opens again', fold.items === 0 && /To reach Deliver/.test(fold.sum) && /1 of 4 done · 2 for you, in Jira/.test(fold.sum) && fold.exp === 'false', JSON.stringify(fold));
103
- await p.click('#czBox [data-czfold]');
104
- ok('I1 opened again it lists the items', await p.evaluate(() => document.querySelectorAll('#czBox .czi-it').length === 4));
105
- await p.click('#czBox [data-czdone]');
106
- ok('I1 the done items open from their summary row', await p.evaluate(() => document.querySelector('#czBox [data-czdone]').getAttribute('aria-expanded') === 'true' && [...document.querySelectorAll('#czBox .czi-it.done')].some((e) => e.textContent.replace('✓', '').trim() === 'PRD and rubric written')));
107
- await p.click('#czBox [data-czdone]');
108
- const nC = A.posts.length; await p.click('#czBox [data-czcta]');
109
- ok('I1 the CTA asks the read-only agent about the step that waits on you', await until(() => A.posts.length > nC && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'init:self-serve-v2'), JSON.stringify(A.posts.slice(-1)));
110
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
91
+ const R = await open({ url: '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1' });
92
+ const u = new URL(R.page.url());
93
+ 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());
94
+ await R.ctx.close();
111
95
  }
96
+ ok('I1 the console is not linked from Home', await p.evaluate(() => ![...document.querySelectorAll('a[href]')].some((a) => /console(\.html)?/.test(a.getAttribute('href')))));
97
+ await p.click('.hm-card .hm-sw[data-hm-switch]');
98
+ 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; }));
99
+ 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));
100
+ await p.click('#hmMenu [data-hm-mi]:has(b:text-is("Partner API rate limits"))');
101
+ { 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()); }
102
+ await p.click('.hm-card .hm-sw[data-hm-switch]'); await until(() => p.evaluate(() => !document.querySelector('#hmMenu').hidden));
103
+ await p.click('#hmMenu [data-hm-mi="0"]');
104
+ ok('I1 Home in the switcher leads back to all work', await until(() => p.evaluate(() => !new URLSearchParams(location.search).get('ini'))), p.url());
105
+ await p.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&board=w1&theme=light'); await ready(p);
112
106
 
113
- /* I4 overview and I5 checks */
114
- 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) }));
115
- 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));
116
- const chk = await p.evaluate(() => !!document.querySelector('#cIniChk'));
117
- 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')));
118
- 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(' '))));
119
- 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);
120
- ok('I4 the description line is shown only when the record has one', await p.evaluate(() => !document.querySelector('#cIniOv .lede')));
121
- /* PMOS can help: two real presses */
122
- 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');
123
- A.set({ status: 200, body: { ok: true, run: 'r0' } });
124
- await p.locator('#cIniOv .agc').first().click();
125
- 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')));
126
- const nH = A.posts.length;
127
- await p.locator('#cIniOv .agc').nth(1).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
128
- 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')));
129
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
107
+ /* I3 header: the card */
108
+ const card = await p.evaluate(() => { const c = document.querySelector('.hm-card'); const q = (s) => ((c.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' ').trim();
109
+ 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]') }; });
110
+ 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));
111
+ 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));
112
+ 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));
113
+ 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));
114
+ if (await p.evaluate(() => !!document.querySelector('.hm-card [data-hm-done]'))) {
115
+ await p.click('.hm-card [data-hm-done]');
116
+ 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')));
117
+ }
118
+ 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)));
119
+ await p.click('.hm-card [data-hm-cfold]');
120
+ 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; }));
121
+ 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));
122
+ await p.click('.hm-card [data-hm-cfold]');
123
+ 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)));
124
+ ok('I1 the card wrote nothing on its own', writes(A).length === 0, JSON.stringify(writes(A)));
130
125
 
131
- /* I6 tasks, I11 one count */
132
- 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');
133
- ok('I6 another initiative\'s tracker item is not listed', !/Another initiative/.test(await txt('#cIniTk')));
134
- 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')));
135
- ok('I6 the views are List, By stage and Timeline', (await all('#tkTabs button')).join('|') === 'List|By stage|Timeline');
136
- await p.click('#tkTabs [data-v="stage"]');
137
- const cols = await p.evaluate(() => [...document.querySelectorAll('#tkBody .isc')].map((c) => c.querySelector('.label').textContent.replace(/\s+/g, ' ').trim()));
138
- 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('|'));
139
- await p.click('#tkTabs [data-v="time"]');
140
- 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 }));
141
- 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));
142
- await p.click('#tkTabs [data-v="list"]');
143
- await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
144
- 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') }));
145
- 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));
146
- // popup context slice 3 (L2, L3): the stored lead comes first, with its time and reads, and Refresh asks the popup's own session
147
- 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() } });
148
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
149
- await p.locator('#cIniTk .tkq').first().click(); await until(() => p.evaluate(() => !!document.querySelector('#dlg.on #leadT .plead')), 6000);
150
- const ld = await p.evaluate(() => { const s = document.querySelector('#dBody .stream'); return { first: s.firstElementChild && s.firstElementChild.id, text: document.querySelector('#leadT').textContent }; });
151
- 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));
152
- { const nA = A.posts.length; await p.click('#leadT [data-lead="refresh"]');
153
- 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))); }
154
- A.setThread({ ok: true, working: false, turns: [] });
155
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
156
- /* a PMOS task: its status can be changed */
157
- A.set({ status: 200, body: { ok: true, item: {} } });
158
- await p.locator('#cIniTk .tkq', { hasText: 'UAT with five partners' }).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
159
- 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');
160
- await p.click('#oMain [data-tks="In progress"]');
161
- 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')));
162
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
163
- /* add a task */
164
- await p.click('[data-tkadd]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
165
- 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)));
166
- 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'));
167
- 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')));
168
- 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'));
169
- await p.click('#oMain [data-pre="1"]'); ok('I6 a common task fills the title', await p.inputValue('#atT') === 'Release plan');
170
- await p.fill('#atF', ''); await p.fill('#atD', '');
171
- A.set({ status: 400, body: { ok: false, error: 'no initiative self-serve-v2 on this board' } }); await p.click('#atGo');
172
- 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)));
173
- 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');
174
- 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')));
175
- const mint0 = await T.nonce(BASE);
176
- 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)));
177
- await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
178
- 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)));
126
+ /* I7 documents: the list's Core documents group (in place of the Files group) shows the ones that need a look and opens them all in the Viewer (InDocs) */
127
+ ok('I7 the list holds Core documents with its count and an All documents line; the Files group is gone', await until(() => p.evaluate(() => { const g = document.querySelector('#hmList section[data-hi="docs"]'); const f = document.querySelector('#hmList section.hm-g[aria-label="Files"]'); return !!g && /Core documents/.test(g.textContent) && !!g.querySelector('[data-hi-open="docs"]') && (!f || f.hidden); })));
128
+ await p.click('#hmList [data-hi-open="docs"]');
129
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-open="planning/prd/self-serve-v2-prd.md"]'), V), 15000);
130
+ await p.click(`${V} [data-ov-open="planning/prd/self-serve-v2-prd.md"]`);
131
+ 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));
179
132
 
180
- /* I7 documents, I11 one count */
181
- 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; }));
182
- ok('I7 the technical documents are grouped and not counted', await p.evaluate(() => /Technical documents \(2\)/.test(document.querySelector('.dmtech summary').textContent)));
183
- await p.click('#dmF [data-dmf="none"]');
184
- ok('I7 the filter shows the documents not started', (await all('#dmList .dmn b')).join('|') === 'Problem statement|Research notes|Launch checklist and comms');
185
- await p.click('#dmF [data-dmf="all"]'); await p.fill('#dmQ', 'risk');
186
- 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'));
187
- await p.fill('#dmQ', 'zzz'); ok('I7 no match says so', /No document matches/.test(await txt('#dmList')));
188
- await p.fill('#dmQ', '');
133
+ /* I4 the Overview */
134
+ ok('I4 the card\'s Overview press opens the initiative in the Viewer on its Tasks, with Documents and Stage beside it, and no Waiting for design marker', await overview(p, null) && await p.evaluate((v) => /Tasks/.test(document.querySelector('#czViewer .cz-vw-kind').textContent) && [...document.querySelectorAll(v + ' [data-hi-view]')].map((b) => b.textContent).join() === 'Tasks,Documents,Stage' && !document.querySelector(v + ' .hx-wait'), V));
135
+ const tk = await p.evaluate((v) => { const o = document.querySelector(v); return { tasks: [...o.querySelectorAll('[data-ov-tkrow]')].map((r) => r.dataset.ovTkrow).sort(), checks: [...o.querySelectorAll('button[data-hi-chk]')].map((b) => b.dataset.hiChk).sort() }; }, V);
136
+ await show(p, 'stage');
137
+ const st = 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) }; }, V);
138
+ await show(p, 'docs');
139
+ const ov = await p.evaluate((v) => { const o = document.querySelector(v); return { docs: [...o.querySelectorAll('[data-ov-doc]')].map((d) => d.dataset.ovDoc).sort(), draft: [...o.querySelectorAll('[data-ov-draft]')].map((b) => b.dataset.ovDraft).sort(), 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);
140
+ const M = mk();
141
+ ok('I4 the Stage view lists the board\'s stages with the current one pressed, and the lifecycle presses', JSON.stringify(st.moves) === JSON.stringify(M.acts.stages) && st.cur === 'Build' && st.life.join() === 'on-hold,cancelled', JSON.stringify(st));
142
+ ok('I6 the tasks are the record\'s, and only a PMOS task has a check box it can change', JSON.stringify(tk.tasks) === JSON.stringify(M.tasks.rows.map((t) => t.key).sort()) && JSON.stringify(tk.checks) === JSON.stringify(M.tasks.rows.filter((t) => t.pmos && t.uid).map((t) => t.key).sort()), JSON.stringify(tk));
143
+ 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).sort()) && ov.sum === M.docs.cap, JSON.stringify(ov));
144
+ 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));
189
145
 
190
- /* I10 the press */
191
- A.set({ status: 200, body: { ok: true, run: 'r1' } });
192
- await p.locator('#dmList [data-draft="problem"]').click();
193
- 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))));
146
+ /* I10 presses */
194
147
  const mint = await T.nonce(BASE);
195
- 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)));
196
- A.set({ status: 409, body: { ok: false, error: 'a run is already drafting that document' } });
197
- await p.locator('#dmList [data-draft="problem"]').click();
198
- 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)));
199
- 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))));
200
- 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); }));
201
-
202
- /* the batch press: one existing draft run for each document not started */
203
- 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')));
204
- A.set({ status: 200, body: { ok: true, run: 'rb' } }); const nB = A.posts.length;
205
- await p.click('.dsum .dlink');
206
- 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')));
207
-
208
- /* I8 the document sheet */
209
- const nPost0 = A.posts.length;
210
- 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"]');
211
- 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 }));
212
- 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));
213
- 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)));
214
- await p.click('#shV'); await p.click('#shT [data-sh="log"]');
215
- const lg = await until(() => p.evaluate(() => document.querySelector('#oMain .hsr') && [...document.querySelectorAll('#oMain .hsr')].map((r) => r.textContent.replace(/\s+/g, ' ').trim())));
216
- 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));
217
- await p.click('#oMain [data-lgd="2"]');
218
- 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"]') }; }));
219
- 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));
220
- 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)));
221
- await p.click('#oMain [data-lgd="2"]');
222
- ok('I8 Hide change closes it', await p.evaluate(() => !document.querySelector('#oMain .lgdf')));
223
- await p.click('#shV'); await p.click('#shT [data-sh="health"]');
224
- 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) }));
225
- 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));
226
- await p.click('#shV'); await p.click('#shT [data-sh="rel"]');
227
- const rl = await until(() => p.evaluate(() => document.querySelector('#oMain .dsrr') && [...document.querySelectorAll('#oMain .label, #oMain .dsrr')].map((r) => r.textContent.replace(/\s+/g, ' ').trim())));
228
- 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));
229
- 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);
230
- await p.click('#shV'); await p.click('#shT [data-sh="read"]');
231
- 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)));
232
- await p.click('#oMain [data-ds="cp"]'); await p.fill('#dsCpUrl', 'notes'); await p.click('[data-ds="cplink"]');
233
- 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'));
234
- await p.fill('#dsCpUrl', 'https://docs.google.com/document/d/abc/edit'); await p.click('[data-ds="cplink"]');
235
- await until(() => p.evaluate(() => /Google Doc: not checked/.test(document.querySelector('#oMain .dsm2').textContent)));
236
- 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)));
237
- await p.click('[data-ds="cpcheck"]');
238
- 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))));
239
- await p.click('#oMain [data-ds="cp"]');
240
- 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'));
241
- 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)));
242
- 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')));
243
- A.setThread({ ok: true, working: false, turns: [] });
244
- await p.fill('#askIn', 'What is missing?'); const nA = A.posts.length; await p.press('#askIn', 'Enter');
245
- 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?'));
246
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
247
- await p.fill('#dmQ', ''); await p.click('#dmF [data-dmf="all"]');
248
- 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]'))));
249
- await p.click('#dmList .dmo[data-doc="problem"]'); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
250
- { const ab = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#oMain').textContent, draft: !!document.querySelector('#abDraft'), ask: document.querySelector('#askF').hidden }));
251
- 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)); }
252
- const nD = A.posts.length; A.set({ status: 200, body: { ok: true, run: 'r1' } }); await p.click('#abDraft');
253
- 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'))));
254
- 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);
255
- { 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 }));
256
- 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)); }
257
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
148
+ 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
149
+ await show(p, 'stage');
150
+ await settle(() => p.click(`${V} [data-ov-move="Deliver"]`));
151
+ const mv = await until(() => A.posts.find((x) => x.path === '/api/boards/move'));
152
+ 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));
153
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-move]'), V));
154
+ await p.click(`${V} [data-ov-life="on-hold"]`);
155
+ 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'));
156
+ await p.fill(`${V} #ovWhy`, 'x'); await p.click(`${V} [data-ov-life-go]`);
157
+ 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'));
158
+ await p.fill(`${V} #ovWhy`, 'Waiting on legal'); await settle(() => p.click(`${V} [data-ov-life-go]`));
159
+ const lf = await until(() => A.posts.find((x) => x.path === '/api/lifecycle'));
160
+ 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));
161
+ await show(p, 'tasks');
162
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' #ovTask'), V));
163
+ await p.click(`${V} [data-ov-add]`); await sleep(200);
164
+ ok('I6 Add with no title posts nothing', !A.posts.some((x) => x.path === '/api/boards/tasks/add'));
165
+ await p.fill(`${V} #ovTask`, 'Release plan'); await settle(() => p.click(`${V} [data-ov-add]`));
166
+ const ad = await until(() => A.posts.find((x) => x.path === '/api/boards/tasks/add'));
167
+ 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));
168
+ // a PMOS task's status is in its row's menu (InTasks)
169
+ const pk = M.tasks.rows.find((t) => t.pmos && t.uid).key;
170
+ await until(() => p.evaluate((a) => !!document.querySelector(a[0] + ` [data-hi-tmore="${a[1]}"]`), [V, pk]));
171
+ await p.click(`${V} [data-hi-tmore="${pk}"]`);
172
+ await until(() => p.evaluate(() => !!document.querySelector('.hi-pop[role="menu"]')));
173
+ await settle(() => p.click('.hi-pop[role="menu"] [role="menuitemradio"]:has(span:text-is("In progress"))'));
174
+ const ts = await until(() => A.posts.find((x) => x.path === '/api/boards/tasks/state'));
175
+ 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));
176
+ await show(p, 'docs');
177
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-draft="problem"]'), V));
178
+ await settle(() => p.click(`${V} [data-ov-draft="problem"]`));
179
+ const dr = await until(() => A.posts.find((x) => x.path === '/api/core-docs/draft'));
180
+ 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));
181
+ A.set({ status: 409, body: { ok: false, error: 'PMOS is already drafting this document.' } });
182
+ await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-draft="research"]'), V));
183
+ await p.click(`${V} [data-ov-draft="research"]`);
184
+ ok('I10 a refused press shows the route\'s reason in the Overview', await until(async () => /already drafting/.test(await txt(p, V + ' #ovMsg'))));
185
+ A.set({ status: 200, body: { ok: true } });
186
+ 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)));
187
+ 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)));
188
+ ok('I1 the old dialog never opened', await p.evaluate(() => { const d = document.querySelector('#dlg'); return !d || !d.classList.contains('on'); }));
258
189
  ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
259
190
  await A.ctx.close();
260
191
 
261
- /* I8 a file that cannot be read */
262
- {
263
- const B = await open();
264
- 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' }) }));
265
- await B.page.locator('#dmList .dmo[data-doc="prd"]').click();
266
- 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))));
267
- await B.ctx.close();
268
- }
269
-
270
- /* I2 reading and failure */
192
+ /* I2 reading and honest states */
271
193
  {
272
194
  let n = 0;
273
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), rp = await ctx.newPage();
274
- 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 }) }); });
275
- await rp.goto(BASE + '/premium-initiative.html?id=self-serve-v2');
276
- 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'))));
277
- ok('I2 it asks again and draws when the read ends', await until(() => rp.evaluate(() => !!document.querySelector('#cIniTk')), 15000) && n >= 3);
278
- await ctx.close();
279
- const E = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'boom' } }) });
280
- 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')));
195
+ 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() } }; } });
196
+ await overview(R.page);
197
+ 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));
198
+ await R.ctx.close();
199
+ const E = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'the board could not be read' } }) });
200
+ await overview(E.page);
201
+ 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));
202
+ ok('I2 no page error on a failed read', E.errors.length === 0, E.errors.join(' | '));
281
203
  await E.ctx.close();
282
- const N = await open({ answers: () => ({ status: 404, body: { ok: false, state: 'error', error: 'nope is not an initiative on a board' } }), qs: '?id=nope' });
283
- 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);
284
- await N.ctx.close();
285
- const X = await open({ qs: '?x=1', answers: () => ({ status: 400, body: { ok: false, state: 'error', error: 'id must name an initiative' } }) });
286
- ok('I2 no initiative named says so', await X.page.evaluate(() => /needs an initiative/.test(document.querySelector('#iMain').textContent)));
287
- await X.ctx.close();
288
204
  }
289
205
 
290
- /* I4 the description */
206
+ /* I12 floors at 390 */
291
207
  {
292
- const L = await open({ model: mk({ row: Object.assign({}, F.ROW, { title: 'Self-serve onboarding v2 — a partner reaches a first call without help' }) }) });
293
- 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('—')));
294
- await L.ctx.close();
295
- }
296
-
297
- /* I6 a long task list is paged */
298
- {
299
- 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 }));
300
- const D = await open({ model: mk({ items: many }) });
301
- const rows = () => D.page.evaluate(() => document.querySelectorAll('#tkBody .tkq').length);
302
- 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)));
303
- await D.page.click('[data-tkpg="1"]'); await D.page.click('[data-tkpg="1"]');
304
- 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));
305
- await D.page.click('#tkTabs [data-v="stage"]');
306
- 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);
307
- await D.page.locator('[data-tkmore]').first().click();
308
- ok('I6 Show more lists the whole column', await D.page.evaluate(() => document.querySelectorAll('#tkBody .tkc').length) >= 25);
309
- await D.page.click('#tkTabs [data-v="time"]');
310
- ok('I6 the Timeline keeps working and is paged too', /of 28/.test(await D.page.evaluate(() => document.querySelector('.tkpg').textContent)));
311
- await D.ctx.close();
312
- }
313
-
314
- /* I3 degraded: nothing invented */
315
- {
316
- const D = await open({ model: mk({ row: Object.assign({}, F.ROW, { owner: null, end: null, status: null }), sheet: null, ladder: null, items: [], docs: null }) });
317
- 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 }));
318
- 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));
319
- await D.ctx.close();
320
- }
321
-
322
- /* I12 floors */
323
- for (const [w, h] of [[1280, 900], [390, 844]]) {
324
- const R = await open({ w, h });
325
- 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) }; });
326
- ok(`I12 no sideways scroll and no tiny target at ${w} px`, f.sx <= 0 && f.small.length === 0, JSON.stringify(f));
327
- if (w === 390) {
328
- await R.page.locator('#dmList .dmo[data-doc="prd"]').click(); await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(700);
329
- 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 }; });
330
- ok('I12 the sheet is full width on a phone', g.l <= 1 && g.w >= g.vw - 2, JSON.stringify(g));
208
+ const N = await open({ w: 390, h: 844 });
209
+ await overview(N.page, null);
210
+ const fls = [];
211
+ for (const view of ['tasks', 'docs', 'stage']) {
212
+ await show(N.page, view);
213
+ fls.push(await N.page.evaluate((a) => { const o = document.querySelector(a[0]); 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.getAttribute('aria-label') || b.tagName); return { view: a[1], over: document.documentElement.scrollWidth - innerWidth, small }; }, [V, view]));
331
214
  }
332
- await R.ctx.close();
215
+ ok('I12 at 390 px the Overview\'s Tasks, Documents and Stage have no sideways scroll and every target is 44 px', fls.every((fl) => fl.over <= 0 && fl.small.length === 0), JSON.stringify(fls));
216
+ ok('I12 no page error at 390 px', N.errors.length === 0, N.errors.join(' | '));
217
+ await N.ctx.close();
333
218
  }
334
219
 
335
220
  /* the real routes against this repository */
@@ -345,27 +230,27 @@ const HEALTH = { ok: true, path: 'planning/prd/self-serve-v2-prd.md', health: {
345
230
  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);
346
231
  const post = await fetch(BASE + '/api/initiative-premium?id=x', { method: 'POST' }); ok('I10 the route answers GET only', post.status === 405);
347
232
  }
348
- /* I12 fidelity: the Agreed design (premium-agreed-design, Inside one initiative frames) replaces the old mockup's look.
349
- * The cozy panel, Nunito, the header card and its blue CTA, the floating menu where the frames put it, in light and dark. */
233
+
234
+ /* I12 fidelity: the Agreed design (premium-agreed-design, Inside one initiative): Nunito, the cozy card, the CTA in the solid colour, the floating
235
+ * menu. The colours are read from the page's own tokens, so each theme is checked against itself. */
350
236
  for (const [w, h] of [[1440, 900], [390, 844]]) for (const th of ['light', 'dark']) {
351
- const R = await open({ w, h, theme: th }); await sleep(300);
237
+ const R = await open({ w, h, theme: th });
352
238
  const g = await R.page.evaluate(() => {
353
- const cs = (s) => { const e = document.querySelector(s); return e ? getComputedStyle(e) : null; }, box = (s) => { const e = document.querySelector(s); if (!e) return null; const r = e.getBoundingClientRect(); return { l: Math.round(r.left), t: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height), r: Math.round(innerWidth - r.right), b: Math.round(innerHeight - r.bottom) }; };
354
- return { font: cs('body').fontFamily, rail: cs('.rail').display, panel: { bg: cs('main.stage').backgroundColor, rad: cs('main.stage').borderTopLeftRadius, box: box('main.stage') }, card: cs('#czHead').borderTopLeftRadius,
355
- well: cs('#czBox .czi-box').backgroundColor, cta: cs('#czBox .czi-cta').backgroundColor, ctaInk: cs('#czBox .czi-cta').color, fab: box('#czFab'), top: box('#czHead'), h1: cs('#iH1').position };
239
+ 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; };
240
+ const cs = (s) => { const e = document.querySelector(s); return e ? getComputedStyle(e) : null; };
241
+ const fab = document.querySelector('#czFab'), fr = fab && fab.getBoundingClientRect();
242
+ const c = document.querySelector('.hm-card').getBoundingClientRect();
243
+ 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) };
356
244
  });
357
- const desk = w > 720, dark = th === 'dark', d = [];
245
+ const d = [];
358
246
  if (!/^Nunito/.test(g.font)) d.push('font ' + g.font);
359
- if (g.rail !== 'none') d.push('rail ' + g.rail);
360
- if (g.panel.bg !== (dark ? 'rgb(36, 38, 43)' : 'rgb(255, 255, 255)')) d.push('panel bg ' + g.panel.bg);
361
- if (desk ? g.panel.rad !== '28px' || g.panel.box.l !== 16 || g.panel.box.t !== 16 : g.panel.rad !== '0px' || g.panel.box.l !== 0) d.push('panel ' + JSON.stringify(g.panel));
362
- if (g.card !== '20px') d.push('card radius ' + g.card);
363
- if (g.well !== (dark ? 'rgb(27, 29, 33)' : 'rgb(244, 243, 240)')) d.push('well ' + g.well);
364
- if (g.cta !== (dark ? 'rgb(155, 199, 244)' : 'rgb(47, 95, 179)')) d.push('cta ' + g.cta);
365
- if (!g.fab || g.fab.w !== 56 || g.fab.h !== 56 || (desk ? g.fab.l !== 36 || g.fab.b !== 36 : g.fab.r !== 18)) d.push('fab ' + JSON.stringify(g.fab));
366
- if (g.top.t > (desk ? 40 : 16)) d.push('the header card does not start at the top ' + JSON.stringify(g.top));
367
- if (g.h1 !== 'absolute') d.push('a visible page header ' + g.h1);
368
- ok(`I12 the page follows the Agreed design at ${w} px, ${th}: Nunito, the cozy panel, the header card at the top, the blue CTA, the floating menu`, d.length === 0, d.join(' ; '));
247
+ if (!g.ctaAlt && ![g.solid, g.blue].includes(g.cta)) d.push('cta ' + g.cta + ' want ' + g.solid + ' or ' + g.blue);
248
+ if (![g.well, g.card].includes(g.box) && !/rgba/.test(g.box)) d.push('card box ' + g.box);
249
+ if (g.rad < 12) d.push('card radius ' + g.rad);
250
+ if (!g.fab || g.fab[0] !== 56 || g.fab[1] !== 56) d.push('fab ' + JSON.stringify(g.fab));
251
+ if (g.over > 0) d.push('sideways scroll ' + g.over);
252
+ 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(' ; '));
253
+ ok(`I12 no page error at ${w} px, ${th}`, R.errors.length === 0, R.errors.join(' | '));
369
254
  await R.ctx.close();
370
255
  }
371
256
  return finish();