create-pmos 0.397.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 (145) hide show
  1. package/package.json +13 -13
  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 +101 -52
  8. package/workspace/briefing-premium-board-test.js +252 -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 +86 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  13. package/workspace/briefing-premium-initiative-test.js +159 -296
  14. package/workspace/briefing-premium-insights-test.js +337 -219
  15. package/workspace/briefing-premium-metrics-test.js +53 -97
  16. package/workspace/briefing-premium-products-test.js +40 -27
  17. package/workspace/briefing-premium-sources-test.js +66 -48
  18. package/workspace/briefing-premium-test.js +150 -647
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +12 -0
  21. package/workspace/fixtures/board-premium-trail.js +32 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  23. package/workspace/guide/briefing-premium.md +3 -1
  24. package/workspace/guide/home.md +47 -0
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/lib/agent-roles.js +71 -0
  27. package/workspace/lib/board-premium.js +85 -19
  28. package/workspace/lib/board-trail.js +223 -0
  29. package/workspace/lib/home-work-item.js +58 -0
  30. package/workspace/lib/insights-goals.js +196 -0
  31. package/workspace/lib/insights-premium.js +62 -14
  32. package/workspace/lib/insights-records.js +101 -0
  33. package/workspace/lib/jira-tickets.js +1 -1
  34. package/workspace/lib/route-modules.js +4 -0
  35. package/workspace/lib/routes-board-trail.js +33 -0
  36. package/workspace/lib/routes-home-desk.js +176 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +129 -0
  39. package/workspace/lib/routes-notes.js +1 -0
  40. package/workspace/lib/routes-viewer.js +108 -0
  41. package/workspace/lib/transcript-steps.js +123 -0
  42. package/workspace/lib/viewer-meeting.js +205 -0
  43. package/workspace/lib/viewer-report.js +89 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/premium-board-actions-test.js +85 -75
  47. package/workspace/premium-briefing-depth-test.js +66 -53
  48. package/workspace/premium-chat-attach-test.js +54 -63
  49. package/workspace/premium-chat-chart-tab-test.js +35 -37
  50. package/workspace/premium-chat-context-test.js +19 -18
  51. package/workspace/premium-chat-goal-view-test.js +23 -23
  52. package/workspace/premium-chat-notes-test.js +26 -31
  53. package/workspace/premium-chat-report-tab-test.js +32 -28
  54. package/workspace/premium-chat-term-test.js +16 -16
  55. package/workspace/premium-chat-viewer-test.js +60 -59
  56. package/workspace/premium-core-doc-issue-test.js +50 -43
  57. package/workspace/premium-html-viewer-test.js +14 -17
  58. package/workspace/premium-phone-card-test.js +7 -2
  59. package/workspace/premium-phone-room-test.js +41 -35
  60. package/workspace/premium-report-read-test.js +115 -197
  61. package/workspace/premium-viewer-download-test.js +19 -22
  62. package/workspace/premium-viewer-flicker-test.js +11 -16
  63. package/workspace/premium-viewer-share-test.js +6 -9
  64. package/workspace/premium-viewer-test.js +41 -60
  65. package/workspace/premium-vw-backlog-test.js +53 -33
  66. package/workspace/premium-vw-cal-test.js +82 -128
  67. package/workspace/premium-vw-copy-test.js +17 -33
  68. package/workspace/premium-vw-doc-test.js +11 -10
  69. package/workspace/premium-vw-item-test.js +50 -49
  70. package/workspace/premium-vw-jira-test.js +53 -27
  71. package/workspace/premium-vw-meet-test.js +118 -187
  72. package/workspace/premium-vw-notes-test.js +85 -108
  73. package/workspace/premium-vw-rec-test.js +72 -194
  74. package/workspace/premium-vw-slides-test.js +46 -50
  75. package/workspace/premium-welcome-test.js +3 -2
  76. package/workspace/premium-work-depth-test.js +61 -53
  77. package/workspace/public/pm/bd-acts.js +305 -0
  78. package/workspace/public/pm/bd-span.js +186 -82
  79. package/workspace/public/pm/bd-stages.js +25 -11
  80. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  81. package/workspace/public/pm/c3-md.js +3 -395
  82. package/workspace/public/pm/c3-phone-detail.js +1 -1
  83. package/workspace/public/pm/c3-phone-model.js +3 -68
  84. package/workspace/public/pm/chat-term.js +3 -3
  85. package/workspace/public/pm/cozy-board.css +497 -230
  86. package/workspace/public/pm/cozy-home.css +570 -142
  87. package/workspace/public/pm/cozy-home.js +5 -3
  88. package/workspace/public/pm/cozy-insights.css +296 -167
  89. package/workspace/public/pm/cozy-md.js +396 -0
  90. package/workspace/public/pm/cozy-nav.js +17 -6
  91. package/workspace/public/pm/cozy-placeholder.js +26 -0
  92. package/workspace/public/pm/cozy-viewer.css +3 -3
  93. package/workspace/public/pm/cozy-viewer.js +144 -0
  94. package/workspace/public/pm/cozy-vw.css +485 -0
  95. package/workspace/public/pm/cozy.css +83 -1
  96. package/workspace/public/pm/home-adddoc.js +48 -0
  97. package/workspace/public/pm/home-app.js +905 -0
  98. package/workspace/public/pm/home-around.js +515 -0
  99. package/workspace/public/pm/home-chat.js +459 -0
  100. package/workspace/public/pm/home-data.js +312 -0
  101. package/workspace/public/pm/home-draft.js +68 -0
  102. package/workspace/public/pm/home-more.js +249 -0
  103. package/workspace/public/pm/home-phone-card.js +109 -0
  104. package/workspace/public/pm/home-work.js +519 -0
  105. package/workspace/public/pm/phone-moment.js +69 -0
  106. package/workspace/public/pm/pm-work-view.js +1 -1
  107. package/workspace/public/pm/premium-attach.js +4 -0
  108. package/workspace/public/pm/premium-board.js +423 -394
  109. package/workspace/public/pm/premium-chart-tab.js +110 -62
  110. package/workspace/public/pm/premium-deck.js +3 -3
  111. package/workspace/public/pm/premium-first.js +25 -21
  112. package/workspace/public/pm/premium-insights.js +792 -568
  113. package/workspace/public/pm/premium-meeting.js +61 -549
  114. package/workspace/public/pm/premium-notes.js +1 -1
  115. package/workspace/public/pm/premium-report-frame.css +20 -0
  116. package/workspace/public/pm/premium-report-read.js +509 -480
  117. package/workspace/public/pm/premium-report-tab.js +87 -63
  118. package/workspace/public/pm/premium-shell.js +72 -119
  119. package/workspace/public/pm/premium-viewer.js +22 -1
  120. package/workspace/public/pm/premium-vw-cal.js +187 -48
  121. package/workspace/public/pm/premium-vw-doc.css +6 -0
  122. package/workspace/public/pm/premium-vw-doc.js +40 -2
  123. package/workspace/public/pm/premium-vw-file.js +2 -2
  124. package/workspace/public/pm/premium-vw-meet.js +6 -83
  125. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  126. package/workspace/public/pm/premium-vw-notes.js +56 -69
  127. package/workspace/public/pm/premium-vw-open.js +35 -0
  128. package/workspace/public/pm/premium-vw-page.js +16 -0
  129. package/workspace/public/pm/premium-vw-rec.js +11 -218
  130. package/workspace/public/pm/premium-vw-slides.css +5 -0
  131. package/workspace/public/pm/premium-vw-slides.js +44 -8
  132. package/workspace/public/pm/term-view.js +22 -0
  133. package/workspace/public/premium-board.html +28 -70
  134. package/workspace/public/premium-initiative.html +8 -48
  135. package/workspace/public/premium-insights.html +22 -60
  136. package/workspace/public/premium-viewer.html +20 -0
  137. package/workspace/public/premium.html +16 -107
  138. package/workspace/server.js +18 -3
  139. package/workspace/test-files.json +1 -0
  140. package/workspace/test-lists/home-libs.json +9 -0
  141. package/workspace/test-lists/premium-report-read.json +1 -1
  142. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  143. package/workspace/test-lists/premium-vw-notes.json +1 -1
  144. package/workspace/public/pm/premium-work.js +0 -729
  145. package/workspace/public/pm/premium.js +0 -1146
@@ -1,21 +1,20 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
- /* briefing-premium-test.js — the premium Briefing page (initiative briefing-premium; planning/prd/briefing-premium-prd.md R1 to R13).
3
+ /* briefing-premium-test.js — the premium Briefing, now Home in the Agreed design (initiative briefing-premium, planning/prd/briefing-premium-prd.md
4
+ * R1 to R13; re-pointed by premium-agreed-design: the Briefing, My work, Chat and the initiative page are one Home — a list, a chat and the
5
+ * Viewer — so the old hero, rail, dock, "N of M done" and row dialog are gone by design, and their checks move to what replaced them).
4
6
  * Serves the real page from the real server and answers GET /api/briefing-premium with the model lib/briefing-premium.js builds from a
5
7
  * fixture (fixtures/briefing-premium-facts.js), so the page is checked against known data.
6
- * R1 the rail, the dock, the page opens at /premium.html and the console stays the default page
7
- * R2 the hero is the model's sentences, with the numbers marked
8
- * R4 rows: numbered, one "Do this first", two lines each (title, then subject · next step), "If you skip" in the dialog, Detail first on a phone
9
- * R5 "N of M done" counts rows that cleared since the page first read today
10
- * R7 Today: Ahead, a now marker, Earlier today, source chips that filter
11
- * R8 the dock count equals the list count
12
- * R9 the header names what could not be read
8
+ * R1 Home is the default page; the console stays at /console.html and nothing on Home links to it; the place menu; Settings and Ctrl K
9
+ * R2 the list head: Today, New with its four choices, and the fold
10
+ * R4 Needs you: the top three rows and "N more · Show", 30 px tiles, title and hint; the first row opens its chat and its Viewer
11
+ * R8 the phone's "N need you" equals the Needs-you rows
12
+ * R9 a page that cannot read the repository says so
13
13
  * R10 a page where nothing was pressed to record sends only GETs
14
- * W1-W8 (slice 2) record decisions, put rows off, return runs; the POST answers are mocked here, the refusals are the real server's
15
- * R11 floors: 44 px targets, focus walk, inert background, reduced motion, no sideways scroll at 390 px in both themes
16
- * R12 fidelity: computed styles and geometry against the mockup at 1280 and 390 px, light and dark
17
- * Every wait polls the page; no fixed sleep stands in for a state.
18
- */
14
+ * W1-W8 record a decision, put a row off, start an agent; the POST answers are mocked here, the refusals are the real server's
15
+ * R11 floors: 44 px targets on a phone, no sideways scroll at 390 px in both themes, Escape closes the Viewer
16
+ * R12 fidelity to the Agreed design at 1440 and 390 px, light and dark: cozy tokens, the 316 px list, the selected row's lift
17
+ * Every wait polls the page. */
19
18
  const fs = require('fs');
20
19
  const path = require('path');
21
20
  const { spawn } = require('child_process');
@@ -26,9 +25,9 @@ const F = require('./fixtures/briefing-premium-facts.js');
26
25
 
27
26
  const BASE = T.BASE;
28
27
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
29
- 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); } };
28
+ const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
30
29
  const results = [];
31
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
30
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
32
31
  let srv = null; let browser = null;
33
32
  const finish = async (code) => {
34
33
  if (browser) await browser.close().catch(() => {});
@@ -39,450 +38,140 @@ const finish = async (code) => {
39
38
  process.exit(code !== undefined ? code : (bad ? 1 : 0));
40
39
  };
41
40
  process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
42
-
43
- /* premium-agreed-design H2: on a desktop Home the chat is docked and always open (#dlg.on), and closing a row's conversation goes back to
44
- * the PM's own chat (title "Chat"). So "a row's dialog is open" is __rowOn(): the dialog is on and shows something other than that own chat.
45
- * On a phone, and on every other page, it is the dialog being on, as before. */
46
- const ROW_ON = () => { window.__rowOn = () => { const g = document.querySelector('#dlg'); return !!g && g.classList.contains('on') && !(document.body.classList.contains('cz-dock') && document.querySelector('#dTitle').textContent === 'Chat'); }; };
47
41
  const MODEL = B.build(F.facts());
42
+ const NEEDS = '#hmList .hm-g[aria-label="Needs you"] .hm-r';
43
+ const vw = () => { const v = document.querySelector('#czViewer:not([hidden])'); return v ? { kind: (v.querySelector('.cz-vw-kind') || {}).textContent || '', title: (v.querySelector('#czVwTitle') || {}).textContent || '', text: v.textContent } : null; };
48
44
 
49
45
  (async () => {
50
46
  const exe = findBrowser();
51
47
  if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the briefing-premium suite cannot run'); return finish(1); }
52
48
  let chromium;
53
49
  try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed — the briefing-premium suite cannot run'); return finish(1); }
54
- // the Claude config the server reads the session's connectors from (premium-settings S5): two that back a source, BigQuery that backs none
55
- const CFG = path.join(T.STATE_DIR, 'claude-config'); fs.mkdirSync(CFG, { recursive: true });
56
- fs.writeFileSync(path.join(CFG, '.claude.json'), JSON.stringify({ claudeAiMcpEverConnected: ['claude.ai Google Calendar', 'claude.ai Slack', 'claude.ai Google Cloud BigQuery'] }));
57
- srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), CLAUDE_CONFIG_DIR: CFG }) });
50
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
58
51
  await T.waitForServer(BASE);
59
52
  browser = await chromium.launch({ executablePath: exe });
60
- { /* every context starts with the console's Needs you read off (see open below); a page route set by `console` wins over it */
61
- const nc = browser.newContext.bind(browser);
62
- browser.newContext = async (...args) => { const c = await nc(...args); await c.addInitScript(ROW_ON); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
63
- }
64
53
 
65
- /* The console's Needs you reads (premium-brief.js): off by default, so the page keeps the model's records-only hero and rows, which most of
66
- * this suite checks. `console` stubs them: { briefing, page, agent }; the C block checks that path. */
67
- const open = async ({ w = 1280, h = 900, theme = 'light', model = MODEL, ctxOpts = {}, pre = null, console: cn = null, inbox = null } = {}) => {
68
- const ctx = await browser.newContext({ viewport: { width: w, height: h }, ...ctxOpts });
54
+ const open = async ({ w = 1440, h = 900, theme = 'light', model = MODEL, fail = false, mock = true, touch = false } = {}) => {
55
+ const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: theme, hasTouch: touch });
69
56
  const page = await ctx.newPage();
70
- const errors = [], reqs = [];
57
+ const errors = [], reqs = [], posts = [];
71
58
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
72
- page.on('request', (r) => { if (r.url().startsWith(BASE)) reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
73
- await page.route('**/api/briefing-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model, as_of: Date.now() }) }));
74
- const json = (body) => (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) });
75
- if (cn) { await page.route('**/api/brief-page*', json(cn.page)); await page.route('**/api/briefing', json(cn.briefing)); await page.route('**/api/needs?*', json({ needs: cn.agent || [] })); }
76
- if (cn && cn.props) await page.route('**/api/driver/open*', (r) => { const k = new URL(r.request().url()).searchParams.get('target_kind'); return json({ ok: true, ws: 'w0', mode: 'approve', targets: cn.props[k] || {} })(r); });
77
- if (inbox) await page.route('**/api/inbox', json(inbox));
78
- if (pre) await page.addInitScript(pre);
59
+ page.on('request', (r) => { if (!r.url().startsWith(BASE)) return; const u = new URL(r.url()); reqs.push(r.method() + ' ' + u.pathname); if (r.method() === 'POST') posts.push({ path: u.pathname, body: (() => { try { return JSON.parse(r.postData() || 'null'); } catch { return null; } })(), headers: r.headers() }); });
60
+ const json = (body, status = 200) => (r) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(body) });
61
+ await page.route(/\/api\/briefing-premium(\?.*)?$/, fail ? json({ ok: false, error: 'the repository could not be read' }, 500) : json({ ok: true, state: 'ready', model, as_of: Date.now() }));
62
+ if (fail) await page.route(/\/api\/board-premium(\?.*)?$/, json({ ok: false, error: 'the repository could not be read' }, 500));
63
+ await page.route('**/api/briefing-premium/thread**', json({ ok: true, turns: [], working: false }));
64
+ if (mock) for (const act of ['decide', 'put-off', 'return', 'start']) await page.route('**/api/briefing-premium/' + act + '*', json({ ok: true, session: 's-new' }));
65
+ if (mock) await page.route('**/api/agent/start*', json({ ok: true, session: 's-new', id: 's-new' })); // Start opens a real agent session: answered here
79
66
  await page.goto(BASE + '/premium.html?theme=' + theme);
80
- const up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 || !document.querySelector('#calm').hidden), 20000);
81
- return { ctx, page, errors, reqs, up };
67
+ const up = await until(() => page.evaluate((sel) => document.querySelectorAll(sel).length > 0 || /could not read/.test((document.querySelector('#hmList') || {}).textContent || ''), NEEDS), 20000);
68
+ return { ctx, page, errors, reqs, posts, up };
82
69
  };
83
70
 
84
- /* the bell's inbox (premium-agent-inbox): two new agent results and one piece of work still waiting */
85
- const ibIt = (id, kind, title, open, pws, at) => ({ id, kind, title, open, pws, at, ws: pws, product: 'IDPF', session: kind.startsWith('goal') ? open.slice(4) : 'src:drv:' + pws + ':x', target: kind.startsWith('goal') ? null : { kind: 'initiative', id: 'checkout', title: 'Checkout' }, isNew: true });
86
- const INBOX = { ok: true, count: 4, newCount: 2, more: 0, oldest: Date.now() - 5 * 86400000, seenAt: null,
87
- items: [ibIt('prop:w0:p1', 'proposal', 'Problem statement: Checkout drops one in five carts', 'prop:p1', 'w0', Date.now() - 12 * 60000), ibIt('goal:src:this-page', 'goal-done', 'Check the goal Claude finished: Ship it', 'row:goal:src:this-page', '', Date.now() - 60 * 60000)],
88
- bundles: [{ key: 'w0|initiative|checkout', title: 'Checkout', product: 'IDPF', count: 2, oldest: Date.now() - 5 * 86400000, open: 'target:initiative:checkout', pws: 'w0', sub: '2 proposals' }] };
89
- const A = await open({ inbox: INBOX });
90
- ok('0 the page draws the list', A.up);
71
+ /* R1 */
72
+ const A = await open();
73
+ ok('0 the page draws the list', !!A.up);
91
74
  if (!A.up) return finish(1);
92
75
  const p = A.page;
93
-
94
- /* R1 */
95
- const rail = await p.evaluate(() => ({ names: [...document.querySelectorAll('.rail .pl')].map((b) => b.textContent.trim()), cur: document.querySelector('.rail [aria-current="page"]').textContent.trim(), go: [...document.querySelectorAll('.rail [data-go]')].map((b) => b.dataset.go) }));
96
- ok('R1 the rail names five places, Chat in the middle, and Briefing is current (premium-chat-rail)', rail.names.join() === 'Briefing,My work,Chat,Board,Insights' && rail.cur === 'Briefing' && rail.go.join() === 'brief,work,chat,init,rep', JSON.stringify(rail));
97
- ok('R1b no round chat button beside the page name, and no Sessions in the ⋯ menu (premium-chat-rail C4)', await p.evaluate(() => !document.querySelector('#pgChat,#crAsk,#sessBtn')));
98
- ok('R1 each place has a target: the four pages and Chat', rail.go.join() === 'brief,work,chat,init,rep');
99
- const def = await fetch(BASE + '/').then((r) => r.text());
100
- ok('R1 the premium Briefing is the default page', /class="rail/.test(def) && !/id="c3-root"/.test(def));
101
- { const con = await fetch(BASE + '/console.html').then((r) => r.text()); ok('R1 the console is served at /console.html', /id="c3-root"/.test(con)); const old = await fetch(BASE + '/c3.html', { redirect: 'manual' }); const oldQ = await fetch(BASE + '/c3.html?tab=rep', { redirect: 'manual' }); ok('R1 /c3.html goes to the premium Briefing, and with a query to the console with the same query', old.status === 302 && old.headers.get('location') === '/premium.html' && oldQ.status === 302 && oldQ.headers.get('location') === '/console.html?tab=rep', old.headers.get('location') + ' | ' + oldQ.headers.get('location')); }
102
- { 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('R1 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'); }
103
-
104
- /* premium-search-bell: the Search button, the bell and Ctrl K, from the shared shell */
105
- {
106
- await p.route('**/api/boards/backlog*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, ws: 'w1', board: 'b1', rows: [{ id: 'sb-alpha', title: 'Alpha launch plan', lane: 'feature', stage: 'Build' }] }) }));
107
- await p.route('**/api/core-docs*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, scope: { name: 'PMOS' }, docs: [{ key: 'roadmap', title: 'Roadmap' }] }) }));
108
- await p.route('**/api/sessions', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ sessions: [{ id: 's1', name: 'Fix the footer', state: 'idle', cwd: '.' }, { id: 's2', name: 'Nightly run', state: 'idle', automatic: true }] }) }));
109
- await p.click('#moreBtn');
110
- const sb = await until(() => p.evaluate(() => { const s = document.querySelector('#pvSearch'), b = document.querySelector('#pvBell'), g = document.querySelector('#pvBdg'); if (!s || !b || !g || g.hidden) return null; const rs = s.getBoundingClientRect(), rb = b.getBoundingClientRect(); return { sw: Math.round(rs.width), sh: Math.round(rs.height), bw: Math.round(rb.width), bh: Math.round(rb.height), n: g.textContent, lab: b.getAttribute('aria-label') }; }), 8000);
111
- ok('SB1 the ⋯ menu has Search and the header has the bell, 44 px, and the bell counts the agent\'s new results', sb && sb.sw >= 44 && sb.sh >= 44 && sb.bw >= 44 && sb.bh >= 44 && sb.n === '2' && sb.lab === 'Needs you: 2 new from the agent', JSON.stringify(sb));
76
+ { const def = await fetch(BASE + '/').then((r) => r.text());
77
+ ok('R1 the premium Home is the default page', /class="cz cz-home"/.test(def) && !/id="c3-root"/.test(def));
78
+ const con = await fetch(BASE + '/console.html').then((r) => r.text()); ok('R1 the console is served at /console.html', /id="c3-root"/.test(con));
79
+ const old = await fetch(BASE + '/c3.html', { redirect: 'manual' }); ok('R1 /c3.html with no query goes to Home', old.status === 302 && /\/premium\.html$/.test(old.headers.get('location') || ''));
80
+ const rail = await p.evaluate(() => ({ gone: !document.querySelector('nav.rail, .rail [data-go], #dlg'), places: [...document.querySelectorAll('#czMenu a')].map((a) => a.textContent.trim() + '>' + a.getAttribute('href')), cur: (document.querySelector('#czMenu [aria-current="page"]') || {}).textContent || '' }));
81
+ ok('R1 no old rail and no old dialog; the place menu names Home, Board and Insights and Home is current', rail.gone && rail.places.join() === 'Home>/premium.html,Board>/premium-board.html,Insights>/premium-insights.html' && /Home/.test(rail.cur), JSON.stringify(rail));
82
+ ok('R1 nothing on Home links to the console', await p.evaluate(() => !document.querySelector('a[href*="console"], a[href*="c3.html"], [data-href*="console"]')));
83
+ await p.click('#czFab'); await p.click('[data-cz-settings]');
84
+ const st = await until(async () => { const v = await p.evaluate(vw); return v && /Settings/.test(v.kind + v.title) ? v : null; }) || await p.evaluate(vw);
85
+ ok('R1 Settings opens in the Viewer', !!st && /Settings/.test(st.kind + st.title), JSON.stringify(st));
112
86
  await p.keyboard.press('Escape');
87
+ ok('R11 Escape closes the Viewer', !!(await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')))));
88
+ await p.route('**/api/sessions', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ sessions: [{ id: 's1', name: 'Fix the footer', state: 'idle', shown: 'quiet' }] }) }));
113
89
  await p.keyboard.press('Control+k');
114
- const pal = await until(() => p.evaluate(() => { const o = document.querySelector('#pvOv'); return o && !o.hidden && document.activeElement && document.activeElement.id === 'pvQ' ? { rail: document.querySelector('.rail').inert, groups: [...document.querySelectorAll('#pvList .pv-grp')].map((x) => x.textContent) } : null; }), 6000);
115
- ok('SB2 Ctrl K opens the search with the box focused and the page behind it inert', pal && pal.rail === true, JSON.stringify(pal));
116
- await p.keyboard.type('alpha');
117
- const hit = await until(() => p.evaluate(() => { const r = [...document.querySelectorAll('#pvList .pv-row b')].map((x) => x.textContent); return r.length === 1 && r[0] === 'Alpha launch plan' ? r : null; }), 6000);
118
- ok('SB3 typing narrows the results to a record read from the board', !!hit);
119
- await p.keyboard.press('Control+a'); await p.keyboard.type('fix');
120
- const ses = await until(() => p.evaluate(() => [...document.querySelectorAll('#pvList .pv-row b')].map((x) => x.textContent).join() === 'Fix the footer' ? 1 : 0), 6000);
121
- ok('SB4 sessions are listed and automatic ones are left out', !!ses);
122
- await p.keyboard.press('Escape');
123
- const closed = await until(() => p.evaluate(() => document.querySelector('#pvOv').hidden && !document.querySelector('.rail').inert && document.activeElement.id === 'moreBtn'), 4000);
124
- ok('SB5 Escape closes it and puts the focus back on the ⋯ button', !!closed);
125
- await p.click('#pvBell');
126
- const bell = await until(() => p.evaluate(() => { const o = document.querySelector('#pvOv'); return !o.hidden && document.querySelector('#pvList .ib-it') ? { items: document.querySelectorAll('#pvList .ib-it').length, sess: document.querySelectorAll('#pvList .ib-it .cta.alt').length, bun: document.querySelectorAll('#pvList .ib-bun').length, yours: /Your own work/.test(document.querySelector('#pvList').textContent) } : null; }), 6000);
127
- ok('SB6 the bell lists each new agent result with its action, a Session button for a proposal, a line per piece of work still waiting, and a line for your own work', bell && bell.items === 2 && bell.sess === 1 && bell.bun === 1 && bell.yours, JSON.stringify(bell));
128
- await p.keyboard.press('Escape');
129
- ok('SB7 search and the bell only read: the one POST is closing the bell, which marks the new results seen', A.reqs.filter((x) => x.startsWith('POST ')).every((x) => x === 'POST /api/inbox/seen'), A.reqs.filter((x) => x.startsWith('POST ')).join());
130
- }
131
- /* premium-settings: the dialog holds Workspaces and Connectors only; each press goes to its existing route */
132
- { await p.click('#moreBtn'); const bt = await p.evaluate(() => { const b = document.querySelector('#settingsBtn'); if (!b) return null; const r = b.getBoundingClientRect(); return { label: b.textContent.trim(), w: Math.round(r.width), h: Math.round(r.height) }; });
133
- ok('S1 the ⋯ menu has a Settings item of at least 44 px', bt && bt.label === 'Settings' && bt.w >= 44 && bt.h >= 44, JSON.stringify(bt));
134
- await p.click('#settingsBtn');
135
- const drawn = await until(() => p.evaluate(() => document.querySelectorAll('#oMain .sr').length > 0), 8000);
136
- const labs = await p.evaluate(() => [...document.querySelectorAll('#oMain .label')].map((x) => x.textContent));
137
- ok('S2 the dialog has Updates and What\'s new (premium-updates), then the two choices, Workspaces and Connectors', drawn && labs.join() === "Updates,What's new,Workspaces,Connectors", labs.join());
138
- const upd = await until(() => p.evaluate(() => { const b = document.querySelector('#oMain [data-upd="check"]'); return !!b && /PMOS/.test(document.querySelector('#oMain .updb').textContent); }), 6000);
139
- ok('S2 premium-updates: Updates names the installed PMOS and offers Check now; nothing asked the registry by itself', upd && !A.reqs.some((r) => /\/api\/kit\/check/.test(r)), A.reqs.filter((r) => /kit/.test(r)).join());
140
- const sw = await p.evaluate(() => { const b = document.querySelector('#oMain [data-src="mail"]'); return b ? b.getAttribute('aria-checked') : null; });
141
- await p.click('#oMain [data-src="mail"]');
142
- const flipped = await until(() => p.evaluate((v) => document.querySelector('#oMain [data-src="mail"]').getAttribute('aria-checked') !== v, sw), 6000);
143
- ok('S3 a source switch saves through /api/proactive/settings and flips', flipped && A.reqs.includes('POST /api/proactive/settings'));
144
- await p.click('#oMain [data-src="mail"]'); await until(() => p.evaluate((v) => document.querySelector('#oMain [data-src="mail"]').getAttribute('aria-checked') === v, sw), 6000);
145
- const bq = await p.evaluate(() => { const b = document.querySelector('#oMain [data-conn="claude.ai Google Cloud BigQuery"]'); const r = b && b.closest('.sr');
146
- return { row: r ? r.textContent : null, on: b ? b.getAttribute('aria-checked') : null, dup: document.querySelectorAll('#oMain [data-conn]').length }; });
147
- ok('S5 every connector of the session is listed: BigQuery has its own row, Off, and says nothing in PMOS reads it on its own yet; Calendar and Slack stay under their source', bq.on === 'false' && /Google Cloud BigQuery/.test(bq.row) && !/claude\.ai/.test(bq.row) && /Nothing in PMOS reads it on its own yet/.test(bq.row) && bq.dup === 1, JSON.stringify(bq));
148
- await p.click('#oMain [data-conn="claude.ai Google Cloud BigQuery"]');
149
- const bqOn = await until(() => p.evaluate(() => document.querySelector('#oMain [data-conn="claude.ai Google Cloud BigQuery"]').getAttribute('aria-checked') === 'true'), 6000);
150
- const saved = await (await fetch(BASE + '/api/proactive/settings')).json();
151
- ok('S6 its switch saves the choice through /api/proactive/settings', bqOn && saved.settings.connectors['claude.ai Google Cloud BigQuery'] === true, JSON.stringify(saved.settings.connectors));
152
- await p.click('#oMain [data-conn="claude.ai Google Cloud BigQuery"]'); await until(() => p.evaluate(() => document.querySelector('#oMain [data-conn="claude.ai Google Cloud BigQuery"]').getAttribute('aria-checked') === 'false'), 6000);
153
- const bare = await fetch(BASE + '/api/workspaces/forget', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'no-such' }) });
154
- ok('S4 Remove is a page press: no nonce, no removal (403)', bare.status === 403, String(bare.status));
155
- for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/proactive\/settings$/.test(A.reqs[i])) A.reqs.splice(i, 1); // R10 below counts presses on a page where nothing was pressed
156
- await p.keyboard.press('Escape'); }
157
-
158
- /* premium-session-list, reached from the rail's Chat (premium-chat-rail): Chat opens the page's conversation full screen with the list beside it.
159
- * The list reads /api/sessions; PMOS sessions that need nothing fold into one line; the viewer holds the session's facts, its question and Stop. */
160
- { const now = Date.now();
161
- // premium-chat-page: the session list lives on the Chat page. The Briefing stays open on p; this block works in a second tab, xp.
162
- const xp = await A.ctx.newPage(); xp.on('pageerror', (e) => A.errors.push(String((e && e.message) || e)));
163
- await xp.route('**/api/briefing-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: MODEL, as_of: Date.now() }) }));
164
- const fake = [
165
- { id: 'sess-1', name: 'Draft the brief', agent: 'claude', note: 'Writing the brief', cwd: 'planning', created: new Date(now - 14 * 60000).toISOString(), shown: 'needs', label: 'needs you', automatic: false, origin: 'next-step' },
166
- { id: 'sess-2', name: 'Refresh metrics', agent: 'claude', note: '', cwd: '.', created: new Date(now - 6 * 60000).toISOString(), shown: 'working', label: 'working', automatic: true, origin: 'schedule:metrics', headless: 'skill' },
167
- { id: 'sess-3', name: 'Old one', agent: 'claude', note: '', cwd: '.', created: new Date(now).toISOString(), shown: 'exited', label: 'exited', automatic: false },
168
- { id: 'sess-4', name: 'Driver · drafts search', agent: 'claude', note: '', cwd: '.', created: new Date(now - 3 * 60000).toISOString(), shown: 'blocked', label: 'maybe blocked', automatic: true, origin: 'drive:drafts:search' }];
169
- let removes = 0, slowOnce = true; const said = [];
170
- await xp.route('**/api/sessions', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ sessions: fake }) }));
171
- await xp.route('**/api/briefing-premium/goals', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, goals: {} }) }));
172
- await xp.route('**/api/sessions/conversation**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'conv', turn: 'user', messages: [{ role: 'user', text: 'Draft the brief' }, { role: 'assistant', text: 'The brief is drafted in planning/briefs.' }] }) }));
173
- await xp.route('**/api/session/say', (r) => { said.push({ ...JSON.parse(r.request().postData()), hasNonce: !!r.request().headers()['x-pmos-nonce'] }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
174
- await xp.route('**/api/session/remove', (r) => { removes++; const id = JSON.parse(r.request().postData()).id; if (id === 'sess-4' && slowOnce) { slowOnce = false; return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: false, note: 'asked it to end' }) }); } const i = fake.findIndex((x) => x.id === id); if (i >= 0) fake.splice(i, 1); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, removed: true }) }); });
175
- await xp.goto(BASE + '/premium.html?theme=light'); await until(() => xp.evaluate(() => document.querySelectorAll('#rank .rr').length > 0), 20000);
176
- // premium-agreed-design H2/H3: Home docks the chat beside the list (no rail, no veil), and the Chat page's address opens Home with its query
177
- const dock = await until(() => xp.evaluate(() => { const d = document.querySelector('#dlg'), r = document.querySelector('#hSessions #sRail'); return d.classList.contains('on') && r ? { veil: getComputedStyle(document.querySelector('#veil')).display, inert: document.querySelector('main.stage').inert, list: !!r } : null; }), 10000);
178
- ok('X1 on a desktop Home docks the chat: it is open with no veil, the list stays live and holds the session list', dock && dock.veil === 'none' && dock.inert === false && dock.list, JSON.stringify(dock));
179
- await xp.goto(BASE + '/premium-chat.html?theme=light&about=src%3Athis-page&label=the%20Briefing'); await until(() => xp.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /Briefing/.test(document.querySelector('#dTitle').textContent)), 10000);
180
- ok('X1b /premium-chat.html opens Home with its query, on the conversation it names', /\/premium\.html\?/.test(xp.url()) && /about=src%3Athis-page/.test(xp.url()), xp.url());
181
- const lay = await until(() => xp.evaluate(() => { const d = document.querySelector('#dlg'), r = document.querySelector('#sRail'); if (!d.classList.contains('full') || !r || !r.offsetWidth || !document.querySelector('#srlList .srl-r')) return null; const o = { rail: Math.round(r.getBoundingClientRect().width), work: Math.round(document.querySelector('#dBody').getBoundingClientRect().width), out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width) }; return o.out > 300 ? o : null; }), 8000) || (await xp.evaluate(() => ({ rail: document.querySelector('#sRail').getBoundingClientRect().width, work: document.querySelector('#dBody').getBoundingClientRect().width, out: document.querySelector('#dOut').getBoundingClientRect().width, cls: document.querySelector('#dlg').className, mode: document.querySelector('#dlg').dataset.mode, w: document.querySelector('#dlg').getBoundingClientRect().width })));
182
- ok('X2 the Chat page opens the Briefing\'s conversation with the list and the conversation; the viewer is closed until something opens in it (premium-chat-viewer V1)', /Ask about the Briefing/.test(await xp.evaluate(() => document.querySelector('#dTitle').textContent)) && lay && lay.out === 0 && lay.rail > 150 && lay.work > 600 && /vw-shut/.test(lay.cls), JSON.stringify(lay));
183
- const grpOf = () => xp.evaluate(() => [...document.querySelectorAll('#srlList .srl-g')].map((g) => g.querySelector('.srl-gh span').textContent + ':' + g.querySelectorAll('.srl-r').length + (g.querySelector('.srl-more') ? '+' + g.querySelector('.srl-more').textContent : '')));
184
- const grp = (await until(async () => { const v = await grpOf(); return v.join('|') === 'Yours:1|Started by PMOS:1+1 more working on their own · Show' ? v : null; }, 8000)) || (await grpOf());
185
- ok('X3 the list groups by who started each session, exited ones are gone, and PMOS runs that need nothing fold into one line', grp.join('|') === 'Yours:1|Started by PMOS:1+1 more working on their own · Show', grp.join('|'));
186
- const chatName = () => xp.evaluate(() => { const a = document.querySelector('.rail [data-go="chat"]'); return a.getAttribute('aria-label') + (a.querySelector('.cdot').hidden ? '' : ' +dot'); });
187
- ok('X4 the Chat dot counts the sessions that need you (Ready or Maybe blocked), not every running one', !!(await until(async () => (await chatName()) === 'Chat, 2 sessions need you +dot', 6000)), await chatName());
188
- await xp.click('#srlList [data-sid="sess-1"]');
189
- const first = await until(() => xp.evaluate(() => { const on = document.querySelector('#srlList .srl-r.on'); return on && /Draft the brief/.test(document.querySelector('#dTitle').textContent) && /brief is drafted/.test(document.querySelector('#dBody').textContent) ? on.dataset.sid : null; }), 8000);
190
- ok('X5 a press on the Ready session opens its conversation from the transcript', first === 'sess-1', String(first));
191
- await xp.fill('#askIn', 'Put it in planning/research instead'); await xp.click('#askGo');
192
- await until(() => said.length, 6000);
193
- ok('X6 a message to a session with no chat row goes to that session, as a page press', said.length === 1 && said[0].id === 'sess-1' && /planning\/research/.test(said[0].text) && said[0].hasNonce, JSON.stringify(said));
194
- await xp.click('#srlList [data-smore]');
195
- ok('X7 Show lists the PMOS runs that need nothing', (await xp.evaluate(() => document.querySelectorAll('#srlList .srl-r').length)) === 3);
196
- await xp.click('#srlList [data-sid="sess-4"]');
197
- await until(() => xp.evaluate(() => /Driver · drafts search/.test(document.querySelector('#dTitle').textContent) && !!document.querySelector('#oMain [data-stop]')), 6000);
198
- await xp.click('#oMain [data-stop]');
199
- const asked = await xp.evaluate(() => { const c = document.querySelector('#oMain .ssc'); return c ? c.textContent : ''; });
200
- ok('X8 Stop in the viewer asks first and says what it ends, and nothing is sent yet', /Stop “Driver · drafts search”\?/.test(asked) && /closes its terminal/.test(asked) && removes === 0, asked);
201
- await xp.click('#oMain [data-no]');
202
- ok('X9 Keep running closes the question and sends nothing', (await xp.evaluate(() => !document.querySelector('#oMain .ssc'))) && removes === 0);
203
- await xp.click('#oMain [data-stop]'); await xp.click('#oMain [data-yes]');
204
- const slow = await until(() => xp.evaluate(() => { const c = document.querySelector('#oMain .ssc'); return c ? c.textContent : ''; }), 6000);
205
- ok('X10 a session that has not exited says so and offers Stop again, never "Ended"', /has not exited yet/.test(slow), slow);
206
- await xp.click('#oMain [data-yes]');
207
- ok('X11 the second press ends it, the toast confirms, and the list drops it', !!(await until(() => xp.evaluate(() => /Ended “Driver · drafts search”/.test(document.querySelector('#toast').textContent) && !document.querySelector('#srlList [data-sid="sess-4"]')), 8000)));
208
- await xp.click('#sessGrp .cz-fold'); // premium-agreed-design H1: on Home the session list is a group of the list, and folds with the group's own fold
209
- const folded = await until(() => xp.evaluate(() => document.querySelector('#sRail').getBoundingClientRect().width === 0 && document.querySelector('#sessGrp .cz-fold').getAttribute('aria-expanded') === 'false'), 4000);
210
- ok('X12 the Sessions group folds away and says so', !!folded, String(folded));
211
- await xp.click('#sessGrp .cz-fold');
212
- await xp.click('#vFold'); // premium-chat-viewer V3: on the Chat page the viewer's button closes it, and the head's Viewer chip opens it again
213
- const vf = await until(() => xp.evaluate(() => document.querySelector('#dOut').getBoundingClientRect().width === 0 && document.querySelector('#dlg').classList.contains('vw-shut')), 4000);
214
- ok('X13 the viewer closes and the conversation takes the width', !!vf && (await xp.evaluate(() => document.querySelector('#dBody').getBoundingClientRect().width)) > 800, String(vf));
215
- await xp.click('#vwPill');
216
- ok('X13b the head\'s Viewer chip opens the viewer again', !!(await until(() => xp.evaluate(() => document.querySelector('#dOut').getBoundingClientRect().width > 300 && !document.querySelector('#dlg').classList.contains('vw-shut')), 4000)));
217
- await xp.click('#vFold');
218
- const shell = await xp.evaluate(() => ({ close: !!document.querySelector('#dClose').offsetParent, expand: !!document.querySelector('#dExpand').offsetParent, rail: !document.querySelector('.rail').inert }));
219
- await xp.keyboard.press('Escape');
220
- ok('X13c the Chat page has no close and no full-screen button, its rail stays live, and Escape keeps it open', !shell.close && !shell.expand && shell.rail && await xp.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelector('#dlg').classList.contains('full')), JSON.stringify(shell));
221
- // the Sessions group was unfolded again above (X12), so the list is back for X14 and X15
222
- /* the soft warning: silent at 6 working agents, speaks at 7, at the top of the list */
223
- const before = fake.slice();
224
- const mk = (n) => Array.from({ length: n }, (_, i) => ({ id: 'w-' + i, name: 'Agent ' + i, agent: 'claude', note: '', cwd: '.', created: new Date().toISOString(), shown: 'working', label: 'working', automatic: false }));
225
- fake.splice(0, fake.length, ...mk(6));
226
- ok('X14 six agents working: no warning', !!(await until(() => xp.evaluate(() => document.querySelectorAll('#srlList .srl-r').length === 6 && !document.querySelector('#srlList .srl-warn')), 8000)));
227
- fake.push({ ...mk(7)[6] });
228
- const warnText = await until(() => xp.evaluate(() => { const w = document.querySelector('#srlList .srl-warn'); return w ? w.textContent : ''; }), 8000);
229
- ok('X15 seven agents working: the warning names the count and says why, with no button', /^7 agents are working at once\./.test(warnText) && /Stop the ones you are not watching/.test(warnText) && (await xp.evaluate(() => document.querySelectorAll('#srlList .srl-warn button').length)) === 0, warnText);
230
- fake.splice(0, fake.length, ...before);
231
- const bare = await fetch(BASE + '/api/session/remove', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'sess-1' }) });
232
- ok('X16 Stop is a page press: no nonce, no end (403)', bare.status === 403, String(bare.status));
233
- const bareSay = await fetch(BASE + '/api/session/say', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'sess-1', text: 'hi' }) });
234
- ok('X17 writing to a session is a page press: no nonce, nothing typed (403)', bareSay.status === 403, String(bareSay.status));
235
- /* premium-run-questions: the question a run asks shows in its viewer; a press is the one write, /api/runs/answer */
236
- let asking = true; const answers = [];
237
- await xp.route('**/api/runs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, cards: asking ? { 'sess-1': { state: 'asking', asked: 'q-7', ask: { id: 'q-7', q: 'Which folder should the brief go in?', options: [{ label: 'planning/briefs', rec: true }, { label: 'planning/research' }] } } } : {} }) }));
238
- await xp.route('**/api/runs/answer', (r) => { answers.push({ ...JSON.parse(r.request().postData()), hasNonce: !!r.request().headers()['x-pmos-nonce'] }); asking = false; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true }) }); });
239
- await until(() => xp.evaluate(() => !!document.querySelector('#srlList [data-sid="sess-1"]')), 8000);
240
- await xp.click('#srlList [data-sid="sess-1"]');
241
- const q = await until(() => xp.evaluate(() => { const b = document.querySelector('#oMain .ssq'); return b ? b.textContent : ''; }), 8000);
242
- ok('Q1 a session that is asking shows its question and the options it offered, in its own words', /Which folder should the brief go in\?/.test(q) && /planning\/briefs/.test(q) && /planning\/research/.test(q), q);
243
- await xp.click('#oMain [data-ans="planning/research"]');
244
- await until(() => answers.length, 6000);
245
- ok('Q3 a press sends the chosen option to /api/runs/answer with the run, the request id and the page nonce', answers.length === 1 && answers[0].run === 'sess-1' && answers[0].request === 'q-7' && answers[0].behavior === 'answer' && answers[0].message === 'planning/research' && answers[0].hasNonce, JSON.stringify(answers));
246
- ok('Q4 the question leaves once answered, and the toast says so', !!(await until(() => xp.evaluate(() => !document.querySelector('#oMain .ssq') && /Answered/.test(document.querySelector('#toast').textContent)), 6000)));
247
- const bareAns = await fetch(BASE + '/api/runs/answer', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ run: 'sess-1', request: 'q-7', behavior: 'answer', message: 'planning/research' }) });
248
- ok('Q5 answering is a page press: no nonce, no answer (403)', bareAns.status === 403, String(bareAns.status));
249
- await xp.unroute('**/api/runs'); await xp.unroute('**/api/runs/answer');
250
- await xp.unroute('**/api/sessions'); await xp.unroute('**/api/session/remove'); await xp.unroute('**/api/session/say'); await xp.unroute('**/api/sessions/conversation**'); await xp.unroute('**/api/briefing-premium/goals');
251
- await xp.close();
252
- for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/(session\/remove|session\/say|runs\/answer)$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
253
-
254
- /* R2: with the console reads off, the hero is the model's records-only sentences */
255
- const hero = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, k: [...document.querySelectorAll('#brief .k')].map((x) => x.textContent) }));
256
- const want = MODEL.hero.map((s) => s.parts.map((x) => x.t).join('')).join(' ');
257
- ok('R2 the hero reads the model, word for word, while the console reads fail', hero.text === want, hero.text);
258
- ok('R2 the numbers and the stuck items are marked', hero.k.some((t) => /three changes today/.test(t)) && hero.k.some((t) => /20 to 10 per 100 runs/.test(t)) && hero.k.length >= 5, JSON.stringify(hero.k));
259
- ok('R2 the date line is the model\'s', await p.evaluate((d) => document.querySelector('#date').textContent === d, MODEL.date));
260
-
261
- /* R3, R4 */
262
- const rows = await p.evaluate(() => [...document.querySelectorAll('#rank .rr')].map((r) => ({ n: r.querySelector('.rn').textContent, t: r.querySelector('.rt').childNodes[0].textContent, skip: r.querySelectorAll('.skip, .sug').length, line2: r.querySelector('.rs').textContent, chev: !!r.querySelector('.rchev'), first: !!r.querySelector('.tgf') })));
263
- ok('R3 the rows follow the model\'s order', rows.map((r) => r.t).join('|') === MODEL.list.rows.map((r) => r.title).join('|'), JSON.stringify(rows.map((r) => r.t)));
264
- ok('R4 rows are numbered 01, 02, …', rows.map((r) => r.n).join() === '01,02,03,04,05');
265
- ok('R4 exactly one row says Do this first, and it is the first', rows.filter((r) => r.first).length === 1 && rows[0].first);
266
- ok('R4 every row is two lines: the title, then subject · next step, with a chevron and no "If you skip" line', rows.every((r) => r.skip === 0 && r.chev && r.line2) && MODEL.list.rows.every((m, i) => rows[i].line2.startsWith(m.subject)), JSON.stringify(rows.map((r) => r.line2)));
267
- ok('R4 a row with a next step on record shows it after the subject', MODEL.list.rows.every((m, i) => !/^Next step: /.test(m.prepared) || rows[i].line2 === m.subject + ' · ' + m.prepared.replace(/^Next step: /, '')));
268
- ok('R3 the order line is shown', await p.evaluate(() => /blocked work first, then decisions only you can make/.test(document.querySelector('#order').textContent)));
269
-
270
- /* R5 */
271
- ok('R5 the header counts rows left and rows done', await p.evaluate(() => /^0 of 5 done · 5 rows left$/.test(document.querySelector('#movesCap').textContent.trim())));
272
- ok('R5 the progress bar says the same', await p.evaluate(() => { const b = document.querySelector('#mprog'); return b.getAttribute('role') === 'progressbar' && b.getAttribute('aria-valuemax') === '5' && b.getAttribute('aria-valuenow') === '0'; }));
273
- {
274
- const fewer = B.build({ ...F.facts(), initiatives: F.facts().initiatives.filter((i) => i.id !== 'console-3-boards') });
275
- const R = await open({ model: fewer, pre: `try{localStorage.setItem('pmos.premium.base.'+(()=>{const d=new Date();return d.getFullYear()+'-'+String(d.getMonth()+1).padStart(2,'0')+'-'+String(d.getDate()).padStart(2,'0')})(),JSON.stringify(${JSON.stringify(MODEL.list.rows.map((r) => r.key))}))}catch(e){}` });
276
- ok('R5 a row that cleared since the first read counts as done', await p.evaluate(() => true) && await R.page.evaluate(() => /^1 of 5 done · 4 rows left$/.test(document.querySelector('#movesCap').textContent.trim())), await R.page.evaluate(() => document.querySelector('#movesCap').textContent));
277
- await R.ctx.close();
90
+ ok('SB2 Ctrl K opens Search in the Viewer with the box focused', !!(await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) #hxQ') && document.activeElement && document.activeElement.id === 'hxQ'))), await p.evaluate(() => JSON.stringify({ vw: !!document.querySelector('#czViewer:not([hidden])'), q: !!document.querySelector('#hxQ'), act: document.activeElement && (document.activeElement.id || document.activeElement.tagName) })));
91
+ await p.keyboard.type('fix');
92
+ ok('SB4 typing finds the session by its name', !!(await until(() => p.evaluate(() => [...document.querySelectorAll('#hxRes .hx-hit b')].some((b) => b.textContent === 'Fix the footer')))));
93
+ await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')));
278
94
  }
279
95
 
280
- /* R8 */
281
- const dock = await p.evaluate(() => ({ n: document.querySelector('#dN').textContent, lab: document.querySelector('#dLab').textContent, next: document.querySelector('#dNext').textContent }));
282
- ok('R8 the dock count equals the list count', dock.n === String(rows.length) && /need you/.test(dock.lab), JSON.stringify(dock));
283
- ok('R8 the dock names the next event, not a portfolio total', /Next 18:30 Design review/.test(dock.next) && !/boards|running/.test(dock.next));
284
-
285
- /* R7 */
286
- const tl = await p.evaluate(() => ({ groups: [...document.querySelectorAll('#tl .grp')].map((g) => g.textContent), now: document.querySelector('#tl .nowl').textContent, ahead: document.querySelectorAll('#tl .nowl ~ .early .ev').length, all: document.querySelectorAll('#tl .ev').length, chips: [...document.querySelectorAll('#srcChips .fchip')].map((c) => c.textContent), cap: document.querySelector('#todayCap').textContent }));
287
- ok('R7 Today has Ahead, a now marker and Earlier today', tl.groups.join() === 'Ahead,Earlier today' && /^18:05 · snapshot$/.test(tl.now), JSON.stringify(tl));
288
- ok('R7 the caption counts earlier and ahead', tl.cap === `${MODEL.today.earlier.length} earlier · ${MODEL.today.ahead.length} ahead`, tl.cap);
289
- ok('R7 one chip per source with its count', tl.chips.join() === 'Calendar2,Merges3,Agent runs0', tl.chips.join());
290
- { const cal = await p.evaluate(() => { const h = document.querySelector('#todayCard .ch'), seen = [...h.querySelectorAll('button')].filter((b) => b.getClientRects().length).map((b) => b.id || b.className); const m = document.querySelector('#calMenu'); return { seen: seen.join(), shut: m.hidden, menu: !!m.querySelector('.fbtn') && !!m.querySelector('#vnOpen') && !!m.querySelector('.vc-open') }; });
291
- // premium-agreed-design H1: on Home the Calendar is a group of the list, so its header also carries the group's own fold (cz-fold) first
292
- ok('R7 the Calendar header shows only the group fold, ⋯ and the calendar fold; Notes, the source filter and the full calendar wait in the shut ⋯ (premium-calmer-first-screen)', cal.seen === 'cz-fold,calMore,foldb' && cal.shut && cal.menu, JSON.stringify(cal)); }
293
- await p.click('#calMore');
294
- ok('R7 ⋯ opens the menu with Notes, Filter sources and Full calendar', await p.evaluate(() => { const m = document.querySelector('#calMenu'); return !m.hidden && document.querySelector('#calMore').getAttribute('aria-expanded') === 'true' && /Notes.*Filter sources.*Full calendar/.test(m.textContent); }));
295
- await p.click('.fbtn');
296
- ok('R7 a press in the menu runs and shuts it', await p.evaluate(() => document.querySelector('#calMenu').hidden && document.querySelector('#todayOpts').classList.contains('on')));
297
- await p.click('#srcChips [data-k="merge"]');
298
- ok('R7 turning a source off removes its rows', await p.evaluate(() => ![...document.querySelectorAll('#tl .ev')].some((e) => e.classList.contains('src-merge'))));
299
- await p.click('#srcChips [data-k="merge"]');
300
- await p.click('#calMore'); await p.click('.fbtn');
301
-
302
- /* dialog */
303
- const row0 = p.locator('#rank .rhd').first();
304
- await row0.focus();
305
- await row0.press('Enter');
306
- const dlg = await until(() => p.evaluate(() => __rowOn()), 4000);
307
- ok('R4 Enter on a row opens the standard dialog', dlg);
308
- const d = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, live: ['.rail', 'main.stage'].every((s) => !document.querySelector(s).inert), veil: getComputedStyle(document.querySelector('#veil')).display, pane: document.querySelector('#oMain').textContent, card: document.querySelector('#card') ? document.querySelector('#card').textContent : '', log: document.querySelector('#logT') ? document.querySelector('#logT').textContent : '', label: document.querySelector('#oLab').textContent, input: document.querySelector('#askIn').disabled, role: document.querySelector('#dlg').getAttribute('aria-modal') }));
309
- // premium-agreed-design H2: on a desktop Home the row's chat docks beside the list, so the list stays live and the dialog is not modal
310
- // (a phone still opens it as a modal popup over an inert page: checked at 390 px below)
311
- ok('R11 on a desktop Home the row\'s chat docks beside the list: the list and the rail stay live, nothing is veiled and the dialog is not modal', d.live && d.role === 'false' && d.veil === 'none', JSON.stringify({ live: d.live, role: d.role, veil: d.veil }));
312
- ok('R4 the dialog offers Pin to the top for a list row (premium-calmer-first-screen)', await p.evaluate(() => { const b = document.querySelector('#card .dpin'); return !!b && /Pin to the top/.test(b.textContent) && b.getAttribute('aria-pressed') === 'false'; }));
313
- ok('R4 the dialog names the row, with an activity log of what was read', d.title === MODEL.list.rows[0].title && /Readfromtherepository3steps/.test(d.log.replace(/\s+/g, '')), d.log);
314
- ok('R4 the detail pane opens with the record\'s path and does not repeat the title the dialog head shows (popup context slice 2)', await p.evaluate(() => { const o = document.querySelector('#oMain'), t = document.querySelector('#dTitle').textContent.trim(); return !!o.querySelector('.dpath') && ![...o.querySelectorAll('.d1, h1, h2, h3')].some((h) => h.textContent.trim() === t); }));
315
- ok('R4 the card holds the evidence and the next step, and the right pane the record', /The way through/.test(d.card) && /Blocked at/.test(d.card) && /Initiative record/.test(d.label) && /planning\/initiatives|console-3-boards/.test(d.pane), d.card.slice(0, 120));
316
- // premium-agreed-design H2: the docked chat has no hide-the-conversation, close or full-screen button; the record sits in the Viewer on the
317
- // right, which folds from its own button and opens again from the head's Viewer chip, and the conversation stays in view throughout
318
- const pane0 = await until(() => p.evaluate(() => { const hid = (s) => { const e = document.querySelector(s); return !e || !e.getClientRects().length; }, o = document.querySelector('#dOut').getBoundingClientRect(); return o.width > 300 ? { pane: hid('#dPane'), close: hid('#dClose'), expand: hid('#dExpand'), fold: !hid('#vFold'), out: Math.round(o.width), convo: getComputedStyle(document.querySelector('#dBody')).display } : null; }), 4000);
319
- ok('R4 the docked chat shows the record in the Viewer beside the conversation, with a fold for the Viewer and no hide-the-conversation, close or full-screen button', pane0 && pane0.pane && pane0.close && pane0.expand && pane0.fold && pane0.convo !== 'none', JSON.stringify(pane0));
320
- const w0 = await p.evaluate(() => Math.round(document.querySelector('#dBody').getBoundingClientRect().width));
321
- await p.click('#vFold');
322
- const pane1 = await until(() => p.evaluate(() => { const g = document.querySelector('#dlg'), pill = document.querySelector('#vwPill'); return g.classList.contains('vw-shut') ? { out: Math.round(document.querySelector('#dOut').getBoundingClientRect().width), convo: Math.round(document.querySelector('#dBody').getBoundingClientRect().width), pill: !!pill && !pill.hidden } : null; }), 4000);
323
- ok('R4 folding the Viewer leaves the conversation, wider, and the head\'s Viewer chip says how to bring it back', pane1 && pane1.out === 0 && pane1.convo > w0 && pane1.pill, JSON.stringify({ w0, pane1 }));
324
- await p.click('#vwPill');
325
- ok('R4 the Viewer chip opens the record again', !!(await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('vw-shut') && document.querySelector('#dOut').getBoundingClientRect().width > 300 && /planning\/initiatives|console-3-boards/.test(document.querySelector('#oMain').textContent)), 4000)));
326
- ok('D12 the reply box talks to a Claude Code session, and says what it can do', !d.input && await p.evaluate(() => !document.querySelector('#askIn').disabled && /Claude Code session/.test(document.querySelector('#askNote').textContent)));
327
- { const nq = await p.evaluate(() => { const n = document.querySelector('#askNote'); document.activeElement && document.activeElement.blur(); const off = getComputedStyle(n).display; document.querySelector('#askIn').focus(); return { quiet: n.classList.contains('quiet'), off, on: getComputedStyle(n).display }; });
328
- ok('D12 the standing note under the message box shows while you write there (premium-calmer-first-screen)', nq.quiet && nq.off === 'none' && nq.on !== 'none', JSON.stringify(nq)); }
329
- let startBody = null;
330
- await p.route('**/api/agent/start', (r) => { startBody = JSON.parse(r.request().postData()); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, session: { id: 'sx', name: 'draft' } }) }); });
331
- ok('W8 the start button of a blocked row is live and says what starting does', await p.evaluate(() => { const b = document.querySelector('#startBtn'); const h = document.querySelector('#holdWhy'); return !!b && !b.disabled && /^Start:/.test(b.textContent.trim()) && !!h && /sends nothing outside PMOS/.test(h.textContent); }));
332
- await p.click('#startBtn');
333
- ok('W8 pressing Start asks to confirm and starts nothing yet', await p.evaluate(() => !!document.querySelector('#startGo') && /Start this agent session/.test(document.querySelector('#card').textContent)) && startBody === null);
334
- await p.click('[data-start="no"]');
335
- ok('W8 Not now goes back to the Start button', await p.evaluate(() => !!document.querySelector('#startBtn') && !document.querySelector('#startGo')) && startBody === null);
336
- await p.click('#startBtn'); await p.click('#startGo');
337
- ok('W8 confirming starts a draft session for that initiative and closes the dialog', await until(() => startBody && p.evaluate(() => !__rowOn())) && startBody.task === 'draft' && !!startBody.initiative && !!startBody.what, JSON.stringify(startBody));
338
- await p.unroute('**/api/agent/start');
339
- await row0.focus(); await row0.press('Enter');
340
- await until(() => p.evaluate(() => __rowOn()));
341
- await p.keyboard.press('Escape');
342
- await until(() => p.evaluate(() => !__rowOn()));
343
- // a decision row: no option is chosen for the PM, choosing one drafts the record, and "Not yet" is off
344
- await p.locator('#rank .rhd').nth(3).click();
345
- await until(() => p.evaluate(() => __rowOn()));
346
- const dc = await p.evaluate(() => ({ ops: document.querySelectorAll('#card .op').length, pressed: document.querySelectorAll('#card .op[aria-pressed="true"]').length, rec: !!document.querySelector('#card .op em'), cta: document.querySelector('#card .cta').textContent, pane: document.querySelector('#oMain').textContent, label: document.querySelector('#oLab').textContent, snooze: [...document.querySelectorAll('#card .seg2 button')].every((b) => !b.disabled && b.hasAttribute('data-until')) }));
347
- ok('R6 a decision opens with three options and none chosen, and none marked Recommended', dc.ops === 3 && dc.pressed === 0 && !dc.rec && /Your call: choose one/.test(dc.cta), JSON.stringify(dc));
348
- ok('R6 the right pane is a draft decision record that says nothing is written until Record', /Decision record/.test(dc.label) && /pm-decisions.md · draft entry/.test(dc.pane) && /Nothing is written to the journal until you press Record/.test(dc.pane) && /Choose an option to draft the entry/.test(dc.pane));
349
- await p.locator('#card .op').nth(1).click();
350
- const dc2 = await p.evaluate(() => ({ pressed: document.querySelector('#card .op[aria-pressed="true"]').textContent, cta: document.querySelector('#card .cta').textContent, dis: document.querySelector('#card .cta').disabled, pane: document.querySelector('#oMain').textContent }));
351
- ok('R6 choosing an option updates the button and the draft, and the button stays off', /Extend the date/.test(dc2.pressed) && /Record: extend/i.test(dc2.cta) && dc2.dis && /Extend the date/.test(dc2.pane) && /extend the date/.test(dc2.pane), JSON.stringify(dc2).slice(0, 200));
352
- ok('W3 "Not yet" has three live choices', dc.snooze);
353
- await p.keyboard.press('Escape');
354
- await until(() => p.evaluate(() => !__rowOn()));
355
- // the failed-reviews row lists every review with its score
356
- await p.locator('#rank .rhd').nth(4).click();
357
- await until(() => p.evaluate(() => __rowOn()));
358
- ok('R4 the reviews row lists each review with its age and score, and proposes nothing', await p.evaluate(() => document.querySelectorAll('#card .tri').length === 5 && /Scored|No score recorded/.test(document.querySelector('#card').textContent) && !document.querySelector('#card .cta') && /No proposal is on record/.test(document.querySelector('#dBody').textContent)));
359
- await row0.focus();
360
- await p.keyboard.press('Escape');
361
- ok('R11 Escape closes the dialog and focus returns to the row', await until(() => p.evaluate(() => !__rowOn() && document.activeElement.classList.contains('rhd'))));
362
- ok('R11 the page is live again after the dialog', await p.evaluate(() => !document.querySelector('main.stage').inert));
363
-
364
- /* the Today dialogs: a merge shows its files and message, a meeting its time and people */
365
- await p.locator('#tl .ev.src-meeting').first().click();
366
- await until(() => p.evaluate(() => __rowOn()));
367
- const ev = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, card: document.querySelector('#card').textContent, pane: document.querySelector('#oMain').textContent, label: document.querySelector('#oLab').textContent }));
368
- ok('R7 a meeting opens a dialog with its time, length and people, from the calendar', /Design review/.test(ev.title) && /Time/.test(ev.card) && /18:30 to 19:15/.test(ev.card) && /Lee, Priya/.test(ev.card) && ev.label === 'Meeting', JSON.stringify(ev).slice(0, 200));
369
- await p.keyboard.press('Escape');
370
- await until(() => p.evaluate(() => !__rowOn()));
371
- await p.locator('#tl .ev.src-merge').first().click();
372
- await until(() => p.evaluate(() => __rowOn()));
373
- ok('R7 a merge opens a dialog that says it reached main, with a disabled "Return this run to the agent"', await p.evaluate(() => /merged to main/.test(document.querySelector('#oMain').textContent) && /reached main today/.test(document.querySelector('#dBody').textContent) && document.querySelector('#card .cta').disabled && /Return this run to the agent/.test(document.querySelector('#card .cta').textContent) && /no run of its own/.test(document.querySelector('#holdWhy').textContent)));
374
- await p.keyboard.press('Escape');
375
- await until(() => p.evaluate(() => !__rowOn()));
96
+ /* R2 */
97
+ { await p.click('[data-hm-new]');
98
+ const nw = await until(() => p.evaluate(() => { const m = document.querySelector('#hmMenu:not([hidden])'); return m ? [...m.querySelectorAll('[role=menuitem], button')].map((b) => b.textContent.trim()).filter(Boolean) : null; }));
99
+ ok('R2 the list head reads Today, and New offers four choices', await p.evaluate(() => document.querySelector('#hmList .hm-hd h1').textContent === 'Today') && !!nw && nw.length === 4, JSON.stringify(nw));
100
+ await p.keyboard.press('Escape');
101
+ ok('R2 the fold button folds the list away and back', await p.evaluate(() => !!document.querySelector('[data-hm-fold]'))); }
102
+
103
+ /* R4 */
104
+ { const L = await p.evaluate((sel) => ({ rows: [...document.querySelectorAll(sel)].map((r) => ({ id: r.dataset.id, t: r.querySelector('.hm-rt b').textContent, h: r.querySelector('.hm-rt em').textContent, tile: Math.round((r.querySelector('.hm-tile, [class*="tile"]') || r).getBoundingClientRect().width) })), more: (document.querySelector('[data-hm-allneeds]') || {}).textContent || '', sel: (document.querySelector('.hm-r.sel') || {}).dataset ? document.querySelector('.hm-r.sel').dataset.id : null }), NEEDS);
105
+ const all = MODEL.list.rows.length + 1; // the five rows of the model and nothing else from the fixture repository
106
+ ok('R4 Needs you shows the top three rows and folds the rest into "N more · Show"', L.rows.length === 3 && /\d+ more · Show/.test(L.more), JSON.stringify(L));
107
+ ok('R4 every row has a 30 px tile, its title and a hint', L.rows.every((r) => r.tile === 30 && r.t.length > 3), JSON.stringify(L.rows));
108
+ ok('R4 on a desktop the first row is selected when Home opens', L.sel === L.rows[0].id, JSON.stringify(L));
109
+ await p.click(`.hm-r[data-id="${L.rows[0].id}"] .hm-rm`); // Settings and Search took the Viewer above; selecting the row again opens its own
110
+ const v0 = await until(() => p.evaluate(vw));
111
+ ok('R4 the selected row opens its Viewer beside its chat', !!v0 && v0.title === L.rows[0].t && await p.evaluate(() => !!document.querySelector('#hmLog')), JSON.stringify(v0));
112
+ await p.click('[data-hm-allneeds]');
113
+ const n2 = await p.evaluate((sel) => document.querySelectorAll(sel).length, NEEDS);
114
+ ok('R4 Show lists every row that needs the PM', n2 >= MODEL.list.rows.length && n2 <= all + 1, String(n2));
115
+ const lift = await p.evaluate(() => getComputedStyle(document.querySelector('.hm-r.sel')).boxShadow);
116
+ ok('R12 the selected row is a card with a lift shadow', lift && lift !== 'none', lift); }
376
117
 
377
118
  /* R10 */
378
- ok('R10 a page where nothing was pressed to record sent only GET requests (the one confirmed Start, closing the bell and recording an opened popup aside)', A.reqs.every((r) => r.startsWith('GET ') || r === 'POST /api/agent/start' || r === 'POST /api/inbox/seen' || r === 'POST /api/briefing-premium/seen'), A.reqs.filter((r) => !r.startsWith('GET ')).join());
379
- ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
380
-
381
- /* slice 2: the buttons that record (initiative briefing-premium-writes). The POST routes are answered by the test, so no real file is written;
382
- the refusals of the real server are checked after, with requests that cannot write. */
383
- {
384
- const facts = F.facts(); facts.runs = facts.runs.concat([{ run_id: 'run-x1', initiative_id: 'x', created_at: new Date(facts.now - 3600e3).toISOString(), human_corrections: 0 }]);
385
- const model2 = B.build(facts);
386
- const posts = []; let answer = { status: 200, body: { ok: true } }; let gets = 0; let thread = { ok: true, turns: [], working: false };
387
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
388
- pg.on('pageerror', (e) => errs.push(String(e)));
389
- await pg.route('**/api/briefing-premium', (r) => { gets++; r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: model2, as_of: Date.now() }) }); });
390
- await pg.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({ status: answer.status, contentType: 'application/json', body: JSON.stringify(answer.body) }); });
391
- await pg.goto(BASE + '/premium.html');
392
- await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
393
- const openIdx = async (i) => { await pg.locator('#rank .rhd').nth(i).click(); await until(() => pg.evaluate(() => __rowOn())); await sleep(700); };
394
- const shut = async () => { await pg.keyboard.press('Escape'); await until(() => pg.evaluate(() => !__rowOn())); };
395
- // a decision: the button waits for a choice and a reason
396
- await openIdx(3);
397
- const btn = () => pg.evaluate(() => { const b = document.querySelector('#recBtn'); return { dis: b.disabled, t: b.textContent.trim(), h: b.getBoundingClientRect().height }; });
119
+ ok('R10 a page where nothing was pressed to record sends no POST', A.posts.filter((x) => /briefing-premium\/(decide|put-off|return|start)/.test(x.path)).length === 0, JSON.stringify(A.posts.map((x) => x.path)));
120
+
121
+ /* W1-W7: record a decision */
122
+ { const key = 'decision:KC5';
123
+ await p.click(`.hm-r[data-id="n:${key}"] .hm-rm`);
124
+ const v = await until(() => p.evaluate(() => { const x = document.querySelector('#czViewer:not([hidden])'); return x && x.querySelector('[data-hv-opt]') ? [...x.querySelectorAll('[data-hv-opt]')].map((b) => b.dataset.hvOpt) : null; }));
125
+ ok('W1 the decision opens in the Viewer with its three choices', JSON.stringify(v) === JSON.stringify(['reshape', 'extend', 'retire']), JSON.stringify(v));
126
+ const btn = () => p.evaluate(() => { const b = document.querySelector('[data-hv-rec]'); return { dis: b.disabled, h: b.getBoundingClientRect().height }; });
398
127
  ok('W1 before a choice the record button is off', (await btn()).dis);
399
- await pg.locator('#card .op').nth(1).click();
400
- ok('W1 with a choice and no reason it is still off', (await btn()).dis && /Record: extend/i.test((await btn()).t));
401
- await pg.fill('#why', 'ab');
128
+ await p.click('[data-hv-opt="extend"]');
129
+ ok('W1 with a choice and no reason it is still off', (await btn()).dis);
130
+ await p.fill('#hvWhy', 'ok');
402
131
  ok('W1 a reason under three characters keeps it off', (await btn()).dis);
403
- await pg.fill('#why', 'Give it a quarter');
404
- ok('W1 a choice and a reason turn it on, at 48 px', !(await btn()).dis && (await btn()).h >= 44);
405
- ok('W1 the reason box is labelled and tall enough to type in', await pg.evaluate(() => { const t = document.querySelector('#why'); const l = document.querySelector('label[for="why"]'); return !!l && t.getBoundingClientRect().height >= 44; }));
406
- // a refusal: the reason is shown and what was typed is kept
407
- answer = { status: 409, body: { ok: false, error: 'a decision that names KC5 is already on record' } };
408
- await pg.click('#recBtn');
409
- ok('W6 a refused press shows the server reason, keeps the dialog open and keeps the typed reason', await until(() => pg.evaluate(() => !document.querySelector('#cardErr').hidden && /already on record/.test(document.querySelector('#cardErr').textContent) && document.querySelector('#why').value === 'Give it a quarter' && __rowOn() && !document.querySelector('#recBtn').disabled)));
410
- ok('W6 the refused press was sent once with the key, the choice and the reason, and no writer field', posts.length === 1 && posts[0].path === '/api/briefing-premium/decide' && posts[0].body.key === 'decision:KC5' && posts[0].body.choice === 'extend' && posts[0].body.why === 'Give it a quarter' && !['by', 'via', 'at', 'actor', 'pm'].some((k) => k in posts[0].body), JSON.stringify(posts[0]));
411
- // success: the dialog closes and the page reads again
412
- answer = { status: 200, body: { ok: true } }; const g0 = gets;
413
- await pg.click('#recBtn');
414
- ok('W7 a recorded press closes the dialog and reads the model again', await until(() => pg.evaluate(() => !__rowOn())) && await until(() => gets > g0, 4000));
415
- ok('W7 the page says where it was recorded', await pg.evaluate(() => /pm-decisions\.md/.test(document.querySelector('#toast').textContent)));
416
- // not yet
417
- await openIdx(3);
418
- ok('W3 "Later" is one quiet button in the bottom bar, and its menu stays shut until pressed', await pg.evaluate(() => { const b = document.querySelector('#card .dbar #laterBtn'), m = document.querySelector('#laterMenu'); return !!b && b.getAttribute('aria-expanded') === 'false' && m.hidden && !!document.querySelector('#card .dbar #recBtn') && !document.querySelector('#card .mv2'); }));
419
- await pg.click('#laterBtn');
420
- await pg.locator('#card .seg2 button[data-until="tomorrow"]').click();
421
- ok('W3 "Tomorrow" posts the key and the time, and closes the dialog', await until(() => posts.some((x) => x.path === '/api/briefing-premium/put-off' && x.body.key === 'decision:KC5' && x.body.until === 'tomorrow')) && await until(() => pg.evaluate(() => !__rowOn())));
422
- // slice 3: the read-only agent behind the reply box
423
- await shut(); await openIdx(3);
424
- ok('A1 the reply box has one Send to Claude button, 44 px, and no note button', await pg.evaluate(() => { const a = document.querySelector('#askGo'); const h = (e) => e.getBoundingClientRect().height; return !!a && h(a) >= 44 && /Send to Claude/.test(a.title) && !document.querySelector('#noteGo') && ![...document.querySelector('#askF').childNodes].filter((n) => n.id !== 'plusM').some((n) => /note/i.test(n.textContent)); })); // the + menu's Notes item opens the notepad, not a note button
425
- ok('A1b a hidden question box is not drawn (the Mentions dialog has no agent thread)', await pg.evaluate(() => { const f = document.querySelector('#askF'); if (!f) return false; f.hidden = true; const d = getComputedStyle(f).display; f.hidden = false; return d === 'none'; }));
426
- answer = { status: 200, body: { ok: true, id: 'bq-1', state: 'working' } };
427
- await pg.fill('#askIn', 'Why is KC5 on my list?');
428
- const n0 = posts.length;
429
- await pg.press('#askIn', 'Enter');
430
- ok('A1 Enter asks the agent: one POST to /ask with the row key and the question, and no writer field', await until(() => posts.length === n0 + 1) && posts[n0].path === '/api/briefing-premium/ask' && posts[n0].body.key === 'decision:KC5' && posts[n0].body.text === 'Why is KC5 on my list?' && Object.keys(posts[n0].body).sort().join() === 'key,text', JSON.stringify(posts[n0]));
431
- thread = { ok: true, working: true, turns: [{ id: 'bq-1', q: 'Why is KC5 on my list?', state: 'working' }] };
432
- ok('A8 while it works the question stays visible, the page says it is reading, promises no time, and Ask is off', await until(() => pg.evaluate(() => /Why is KC5 on my list\?/.test(document.querySelector('#dBody .stream').textContent) && /The agent is reading the records/.test(document.querySelector('#dBody .stream').textContent) && document.querySelector('#askGo').disabled && !/seconds|minute/.test(document.querySelector('[role="status"]').textContent)), 8000));
433
- thread = { ok: true, working: false, turns: [{ id: 'bq-1', q: 'Why is KC5 on my list?', state: 'answered', a: 'Its date, 30 Sep, passed.\n\nSee <b>planning/okrs/kill-conditions.md</b>.' }] };
434
- ok('A5 the answer appears labelled, as text and never as markup, and Ask is on again', await until(() => pg.evaluate(() => { const s = document.querySelector('#dBody .stream'); return /Earlier read-only answer/.test(s.textContent) && /Its date, 30 Sep, passed\./.test(s.textContent) && s.textContent.includes('<b>planning/okrs/kill-conditions.md</b>') && !s.querySelector('#thr b') && !document.querySelector('#askGo').disabled; }), 8000));
435
- await shut(); await openIdx(3);
436
- ok('A5 the answer is back when the row is opened again (it is read from the thread, not kept in the page)', await until(() => pg.evaluate(() => /Its date, 30 Sep, passed\./.test(document.querySelector('#dBody .stream').textContent)), 5000));
437
- thread = { ok: true, working: false, turns: [{ id: 'bq-2', q: 'Again?', state: 'failed', error: 'The agent took too long and was stopped. Ask again with a narrower question.' }] };
438
- await shut(); await openIdx(3);
439
- ok('A5 a failed run shows its own reason', await until(() => pg.evaluate(() => /The agent did not answer\. The agent took too long/.test(document.querySelector('#dBody .stream').textContent)), 5000));
440
- answer = { status: 409, body: { ok: false, error: 'The agent is still answering the last question on this row.' } };
441
- await pg.fill('#askIn', 'second question');
442
- await pg.press('#askIn', 'Enter');
443
- ok('A4 a refused question shows the reason and keeps what was typed', await until(() => pg.evaluate(() => /still answering/.test(document.querySelector('#askNote').textContent) && document.querySelector('#askIn').value === 'second question' && !document.querySelector('#askGo').disabled), 4000));
444
- thread = { ok: true, turns: [], working: false }; answer = { status: 200, body: { ok: true } };
445
- await pg.fill('#askIn', '');
446
- ok('A1 an empty question is not sent', await (async () => { const n = posts.length; await pg.press('#askIn', 'Enter'); await sleep(200); return posts.length === n && /Write a message/.test(await pg.textContent('#askNote')); })());
447
- { // the reply box is several lines: Shift+Enter is a new line, the box grows to a cap and then scrolls, Enter sends all the lines
448
- await pg.click('#askIn'); const h1 = await pg.evaluate(() => document.querySelector('#askIn').getBoundingClientRect().height);
449
- await pg.keyboard.type('line one'); await pg.keyboard.press('Shift+Enter'); await pg.keyboard.type('line two');
450
- const two = await pg.evaluate(() => ({ v: document.querySelector('#askIn').value, h: document.querySelector('#askIn').getBoundingClientRect().height, tag: document.querySelector('#askIn').tagName }));
451
- ok('A9 Shift+Enter adds a line and the box grows with it, nothing is sent', two.tag === 'TEXTAREA' && two.v === 'line one\nline two' && two.h > h1 + 10, JSON.stringify({ h1, two }));
452
- for (let i = 0; i < 20; i++) await pg.keyboard.press('Shift+Enter');
453
- const cap = await pg.evaluate(() => { const t = document.querySelector('#askIn'), g = document.querySelector('#askGo').getBoundingClientRect(); return { h: t.getBoundingClientRect().height, sh: t.scrollHeight, go: g.bottom <= innerHeight && g.top >= 0 }; });
454
- ok('A9 a long message stops growing at the cap and scrolls, and Send stays on screen', cap.h <= 222 && cap.sh > cap.h && cap.go, JSON.stringify(cap));
455
- await pg.fill('#askIn', 'line one\nline two'); const n = posts.length; await pg.press('#askIn', 'Enter');
456
- ok('A9 Enter sends both lines, then the box shrinks back to one line', await until(() => posts.length === n + 1) && posts[n].body.text === 'line one\nline two' && await until(() => pg.evaluate(() => document.querySelector('#askIn').value === '' && document.querySelector('#askIn').getBoundingClientRect().height < 50), 4000), JSON.stringify(posts[n] && posts[n].body));
457
- }
458
- await shut();
459
- // return a run
460
- await pg.locator('#tl .ev.src-run').first().click();
461
- await until(() => pg.evaluate(() => __rowOn())); await sleep(700);
462
- ok('W2 a run dialog offers the four reasons and the return button waits for one', await pg.evaluate(() => [...document.querySelectorAll('#retWhy button')].map((b) => b.textContent).join() === 'wrong facts,wrong scope,not now,too long' && document.querySelector('#recBtn').disabled));
463
- await pg.locator('#retWhy button').nth(1).click();
464
- ok('W2 choosing a reason turns it on', await pg.evaluate(() => !document.querySelector('#recBtn').disabled && document.querySelector('#retWhy button[aria-pressed="true"]').textContent === 'wrong scope'));
465
- await pg.click('#recBtn');
466
- ok('W2 the press posts the run and the reason', await until(() => posts.some((x) => x.path === '/api/briefing-premium/return' && x.body.run === 'run-x1' && x.body.reason === 'wrong scope' && Object.keys(x.body).sort().join() === 'reason,run')));
467
- await until(() => pg.evaluate(() => !__rowOn()));
468
- // W10 floors on a phone, both themes: the new controls are 44 px and nothing scrolls sideways
469
- for (const theme of ['light', 'dark']) {
470
- const c = await browser.newContext({ viewport: { width: 390, height: 800 } }), q = await c.newPage();
471
- await q.route('**/api/briefing-premium', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: model2, as_of: Date.now() }) }));
472
- await q.goto(BASE + '/premium.html?theme=' + theme);
473
- await until(() => q.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
474
- await q.locator('#rank .rhd').nth(3).click(); await until(() => q.evaluate(() => __rowOn())); await sleep(800);
475
- await q.click('#dTabs [data-t="chat"]'); await sleep(300);
476
- await q.locator('#card .op').nth(0).click(); await q.fill('#why', 'A reason'); await q.click('#laterBtn');
477
- const m = await q.evaluate(() => { const hs = (sel) => [...document.querySelectorAll(sel)].map((b) => Math.round(b.getBoundingClientRect().height)); return { over: document.documentElement.scrollWidth > innerWidth + 1 || document.querySelector('#dlg').scrollWidth > document.querySelector('#dlg').clientWidth + 1, small: [].concat(hs('#card .seg2 button'), hs('#recBtn'), hs('#askIn'), hs('#askGo'), hs('#card .op')).filter((h) => h < 44) }; });
478
- ok('W10 at 390 px (' + theme + ') the decision card has no sideways scroll and every new control is 44 px', !m.over && m.small.length === 0, JSON.stringify(m));
479
- await c.close();
480
- }
132
+ await p.fill('#hvWhy', 'The partner needs two more weeks');
133
+ ok('W1 a choice and a reason turn it on', !(await btn()).dis);
134
+ await p.click('[data-hv-rec]');
135
+ const post = await until(() => A.posts.find((x) => x.path === '/api/briefing-premium/decide'));
136
+ ok('W6 the press posts the key, the choice and the reason, and no writer field', !!post && post.body.key === key && post.body.choice === 'extend' && post.body.why === 'The partner needs two more weeks' && !('by' in post.body), JSON.stringify(post && post.body));
137
+ ok('W7 a recorded press closes the Viewer and says where it was recorded', !!(await until(() => p.evaluate(() => /pm-decisions\.md/.test(document.querySelector('#toast').textContent)))));
138
+ /* W3 put off */
139
+ const k2 = 'decision:premium-ux';
140
+ await p.click(`.hm-r[data-id="n:${k2}"] .hm-rm`);
141
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hv-later]')));
142
+ ok('W3 "Put off" is one quiet button, and its menu stays shut until pressed', await p.evaluate(() => document.querySelector('[data-hv-later] + .hv-lm').hidden));
143
+ await p.click('[data-hv-later]');
144
+ ok('W3 its menu has three live choices', await p.evaluate(() => [...document.querySelectorAll('[data-hv-until]')].map((b) => b.dataset.hvUntil).join() === 'later,tomorrow,nextweek'));
145
+ await p.click('[data-hv-until="tomorrow"]');
146
+ ok('W3 "Tomorrow" posts the key and the time', !!(await until(() => A.posts.find((x) => x.path === '/api/briefing-premium/put-off' && x.body.key === k2 && x.body.until === 'tomorrow'))));
147
+ /* the row's × puts it off until tomorrow */
148
+ const k3 = 'blocked:onboarding-scan';
149
+ await p.click(`.hm-r[data-id="n:${k3}"] [data-hm-end]`).catch(() => {});
150
+ ok('W3 the row\'s × puts it off until tomorrow', !!(await until(() => A.posts.find((x) => x.path === '/api/briefing-premium/put-off' && x.body.key === k3))));
151
+ /* W8 start */
152
+ const k4 = 'blocked:console-3-boards';
153
+ await p.click(`.hm-r[data-id="n:${k4}"] .hm-rm`);
154
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hv-start]')));
155
+ ok('W8 a blocked row offers Start and says what starting does', await p.evaluate(() => /drafts/.test(document.querySelector('#czViewer').textContent)));
156
+ await p.click('[data-hv-start]');
157
+ const sp = await until(() => { const l = A.posts.filter((x) => x.path === '/api/agent/start'); return l.length ? l : null; });
158
+ ok('W8 Start posts one agent start for that row', !!sp && sp.length === 1, JSON.stringify(A.posts.map((x) => [x.path, x.body])));
481
159
  const mint = await T.nonce(BASE);
482
- ok('W5 every press carried the launch nonce the server minted', !!mint && posts.length >= 4 && posts.every((x) => x.headers['x-pmos-nonce'] === mint), String(mint).slice(0, 4) + ' ' + posts.length);
483
- ok('0 no page error on the write flow', errs.length === 0, errs.join(' | '));
484
- await ctx.close();
160
+ const writes = A.posts.filter((x) => /briefing-premium\/(decide|put-off)|\/api\/agent\/start/.test(x.path));
161
+ ok('W5 every press carried the launch nonce the server minted', !!mint && writes.length >= 4 && writes.every((x) => x.headers['x-pmos-nonce'] === mint), String(mint).slice(0, 4) + ' ' + writes.length);
162
+ ok('0 no page error on the write flow', A.errors.length === 0, A.errors.join(' | '));
485
163
  }
164
+ await A.ctx.close();
165
+
166
+ /* W6: a refused press keeps the Viewer and the typed reason */
167
+ { const R = await open({ mock: false });
168
+ await R.page.route('**/api/briefing-premium/decide*', (r) => r.fulfill({ status: 409, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'This decision is already on record.' }) }));
169
+ await R.page.click('.hm-r[data-id="n:decision:KC5"] .hm-rm').catch(async () => { await R.page.click('[data-hm-allneeds]'); await R.page.click('.hm-r[data-id="n:decision:KC5"] .hm-rm'); });
170
+ await until(() => R.page.evaluate(() => !!document.querySelector('[data-hv-opt]')));
171
+ await R.page.click('[data-hv-opt="retire"]'); await R.page.fill('#hvWhy', 'No longer worth the date'); await R.page.click('[data-hv-rec]');
172
+ ok('W6 a refused press shows the server reason, keeps the Viewer open and keeps the typed reason', !!(await until(() => R.page.evaluate(() => /already on record/.test((document.querySelector('#hvMsg') || {}).textContent || '') && document.querySelector('#hvWhy').value === 'No longer worth the date'))));
173
+ await R.ctx.close(); }
174
+
486
175
  {
487
176
  // the real server refuses what it must, with requests that cannot write
488
177
  const hdr = await T.pressHeaders(BASE);
@@ -512,225 +201,39 @@ const MODEL = B.build(F.facts());
512
201
  ok('W5 a GET on a recording route is refused', get === 405, String(get));
513
202
  }
514
203
 
515
- /* the first read: the page says how long it has run, asks again, and draws when the answer is ready */
516
- {
517
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
518
- pg.on('pageerror', (e) => errs.push(String(e)));
519
- let calls = 0;
520
- await pg.route('**/api/briefing-premium*', (r) => { calls++; if (calls < 2) return r.fulfill({ status: 202, contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'reading', elapsed_ms: 12000 }) }); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: MODEL, as_of: Date.now() - 20 * 60000, refreshing: true }) }); });
521
- await pg.goto(BASE + '/premium.html');
522
- ok('R13 while the first read goes on the page says how long it has run, and promises no time', await until(() => pg.evaluate(() => /for the first time\. \d+ s so far/.test(document.querySelector('#brief').textContent) && !/half a minute|30 s/.test(document.querySelector('#brief').textContent)), 4000));
523
- ok('R13 it asks again and draws when the answer is ready', await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length === 5), 8000));
524
- ok('R13 an answer older than 5 minutes says when it was read and that it is refreshing', await pg.evaluate(() => /read 20 min ago, refreshing/.test(document.querySelector('#snap').textContent)), await pg.evaluate(() => document.querySelector('#snap').textContent));
525
- await ctx.close();
526
- const c2 = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p2 = await c2.newPage();
527
- await p2.route('**/api/briefing-premium*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, state: 'error', error: 'spawn failed' }) }));
528
- await p2.goto(BASE + '/premium.html');
529
- ok('R9 a failed read says why, on the page', await until(() => p2.evaluate(() => /The reason: spawn failed/.test(document.querySelector('#brief').textContent)), 4000));
530
- await c2.close();
531
- }
532
-
533
- /* a partial answer: the quick sources are drawn at once, and what depends on the initiative state is not claimed */
534
- {
535
- const part = B.build({ ...F.facts(), initiatives: [], pending: true });
536
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
537
- pg.on('pageerror', (e) => errs.push(String(e)));
538
- let release = false; // the full answer waits until the partial one has been read: on Home the page's load event can come after the 3 s re-ask
539
- await pg.route('**/api/briefing-premium*', (r) => { const body = !release ? { ok: true, state: 'ready', model: part, as_of: Date.now(), pending: true } : { ok: true, state: 'ready', model: MODEL, as_of: Date.now() }; return r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) }); });
540
- await pg.goto(BASE + '/premium.html');
541
- await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
542
- const pv = await pg.evaluate(() => ({ snap: document.querySelector('#snap').textContent, cap: document.querySelector('#movesCap').textContent, calm: document.querySelector('#calm').hidden, note: document.querySelector('#order').textContent, dock: document.querySelector('#dN').textContent + ' ' + document.querySelector('#dLab').textContent, rows: [...document.querySelectorAll('#rank .rt')].map((x) => x.childNodes[0].textContent), bar: document.querySelector('#mprog').hidden }));
543
- ok('R13 a partial answer says it is still reading the initiative state, in the header, the list and the dock', /reading initiative state/.test(pv.snap) && /so far · still reading/.test(pv.cap) && /appear when the initiative state has been read/.test(pv.note) && /still reading/.test(pv.dock), JSON.stringify(pv));
544
- ok('R13 it never says nothing needs you or all clear while the state is unread', pv.calm === true && !/All clear/.test(pv.cap) && pv.bar === true);
545
- ok('R13 it shows only what the quick sources hold (the kill-condition decision), not blocked work', pv.rows.length === 1 && /missed KC5 date/.test(pv.rows[0]), JSON.stringify(pv.rows));
546
- release = true;
547
- ok('R13 it asks again and replaces the partial answer with the full one', await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length === 5 && !/reading initiative state/.test(document.querySelector('#snap').textContent)), 9000));
548
- ok('0 no page error on a partial answer', errs.length === 0, errs.join(' | '));
549
- await ctx.close();
550
- }
551
-
552
- /* a record the page cannot build a dialog for still opens, and a failed read says why instead of staying on "reading" */
553
- {
554
- const m = JSON.parse(JSON.stringify(MODEL)); m.list.rows[0].dialog = null; m.today.earlier[0].dialog = null;
555
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
556
- pg.on('pageerror', (e) => errs.push(String(e)));
557
- await pg.route('**/api/briefing-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: m, as_of: Date.now(), pending: false, error: 'boom in build' }) }));
558
- await pg.goto(BASE + '/premium.html');
559
- await until(() => pg.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
560
- ok('R9 a failed read says why in the header, and the page does not keep saying it is reading', await pg.evaluate(() => /the latest read failed: boom in build/.test(document.querySelector('#snap').textContent) && !/reading initiative state/.test(document.querySelector('#snap').textContent)));
561
- await pg.locator('#rank .rhd').first().click();
562
- ok('R4 a row with no dialog still opens one from what the row says', await until(() => pg.evaluate(() => __rowOn() && /What is known/.test(document.querySelector('#card').textContent) && /If you skip/.test(document.querySelector('#card').textContent)), 4000));
563
- await pg.keyboard.press('Escape');
564
- await until(() => pg.evaluate(() => !__rowOn()));
565
- await pg.locator('#tl .ev').first().click();
566
- ok('R7 a Today item with no dialog still opens one', await until(() => pg.evaluate(() => __rowOn() && !!document.querySelector('#card')), 4000));
567
- ok('0 no page error when a dialog is missing', errs.length === 0, errs.join(' | '));
568
- await ctx.close();
569
- }
570
204
 
571
205
  /* R9 */
572
- {
573
- const m2 = B.build({ ...F.facts(), meetings: null, tripwires: null });
574
- const R = await open({ model: m2 });
575
- ok('R9 the header names what could not be read', await R.page.evaluate(() => /not read: the calendar, kill conditions/.test(document.querySelector('#snap').textContent)));
576
- ok('R9 no calendar rows are drawn when the calendar is unread', await R.page.evaluate(() => ![...document.querySelectorAll('#tl .ev')].some((e) => e.classList.contains('src-meeting'))));
577
- await R.ctx.close();
578
- const empty = B.build({ now: F.NOW, initiatives: [], runs: [], merges: [], evals: [], meetings: [], tripwires: [] });
579
- const E = await open({ model: empty });
580
- ok('R2 an empty repository says nothing happened and shows no row', await E.page.evaluate(() => !document.querySelector('#brief').textContent.match(/\d/) && !document.querySelector('#calm').hidden && document.querySelectorAll('#rank .rr').length === 0));
581
- ok('R8 and the dock says nothing needs you', await E.page.evaluate(() => document.querySelector('#dN').textContent === '0'));
582
- await E.ctx.close();
583
- }
584
-
585
- /* C: the console's Needs you, read the way the console reads it, is the hero and the list (premium-brief.js) */
586
- {
587
- const CN = {
588
- briefing: { cards: [], needs: [{ key: 'mw:J-7', itemId: 'J-7', origin: 'jira', kind: 'Decide', headline: 'Pick the launch market', time: null, dueText: null, src: 'J-7', why: 'Assigned to you as a decision.', facts: [{ text: 'J-7 · In progress', source: 'Jira' }], url: 'https://example.atlassian.net/browse/J-7', url_label: 'Open J-7 in Jira' }] },
589
- page: { ok: true, today: [], mentions: null, needs: [{ key: 'item:w1', id: 'w1', kind: 'overdue', headline: 'Send Priya the date', days_late: 3, person: 'Priya' }] },
590
- agent: [{ run_id: 'run-9', kind: 'driver-drafts', question: 'Agent has 2 drafts on Checkout', initiative_id: 'checkout', ws: 'w0' }],
591
- props: { initiative: { checkout: [{ id: 'p1', what: 'problem', at: '2026-10-19T09:00:00Z', data: { text: 'Checkout drops one in five carts at the address step.' } }, { id: 'p2', what: 'evidence', at: '2026-10-19T09:05:00Z', data: { text: 'Funnel export, 30 days.' } }],
592
- search: [{ id: 'p3', what: 'problem', at: '2026-10-19T09:10:00Z', data: { text: 'A draft on another initiative.' } }] } },
593
- };
594
- const CIB = { ...INBOX, count: 2, newCount: 1, items: [INBOX.items[0]] };
595
- const C = await open({ console: CN, inbox: CIB });
596
- const cp = C.page;
597
- await until(() => cp.evaluate(() => document.querySelectorAll('#rank .rr').length === 2 && /^The same paragraph as The brief/.test(document.querySelector('#brief').title || '')));
598
- const want = await cp.evaluate(() => import('/pm/premium-brief.js').then((m) => m.consoleReads().then((r) => ({ brief: m.briefOf(r).parts.map((x) => x.t).join(''), titles: m.needsListOf(r).map((x) => x.title) }))));
599
- const got = await cp.evaluate(() => ({ brief: document.querySelector('#brief').textContent, titles: [...document.querySelectorAll('#rank .rr .rt')].map((t) => t.childNodes[0].textContent), skip: document.querySelectorAll('#rank .rr .skip').length, cap: document.querySelector('#movesCap').textContent, dn: document.querySelector('#dN').textContent, bell: document.querySelector('#pvBdg').textContent, links: document.querySelectorAll('#rank .rr[data-link]').length }));
600
- ok('C1 the hero is the console brief, word for word', got.brief === want.brief && /3 things need you/.test(got.brief), got.brief);
601
- ok('C2 the list is the console\'s Needs you, in its order, without the agent\'s drafts row: that waits in the bell', got.titles.join('|') === want.titles.filter((t) => !/^Agent has/.test(t)).join('|') && got.titles.length === 2 && want.titles.length === 3, JSON.stringify(got.titles));
602
- ok('C3 a console row has no "If you skip" line and no meeting link: no record holds them', got.skip === 0 && got.links === 0, JSON.stringify(got));
603
- ok('C4 the header and the dock count the same two rows, and the bell counts the agent\'s new result', /2 rows left/.test(got.cap) && got.dn === '2' && got.bell === '1', JSON.stringify(got));
604
- const dec = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Pick the launch market/.test(r.textContent)));
605
- await cp.locator('#rank .rr .rhd').nth(dec).click();
606
- await until(() => cp.evaluate(() => __rowOn()));
607
- const dd = await cp.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#dBody').textContent, ask: document.querySelector('#askF').hidden, link: (document.querySelector('#srcLink') || {}).href || '' }));
608
- ok('C5 a decision opens the dialog with what its record says, its source link and its own conversation (premium-popup-context P1)', dd.title === 'Pick the launch market' && /Read from the console Briefing/.test(dd.body) && !dd.ask && /J-7/.test(dd.link), JSON.stringify(dd));
609
- await cp.keyboard.press('Escape');
610
- // premium-agreed-design H2: Home holds My work, so your own item opens on Home itself (premium.js hands its id to premium-work.js)
611
- await cp.evaluate(() => { window.__items = []; document.addEventListener('pmos:item', (e) => window.__items.push(e.detail.id)); });
612
- const own = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Send Priya the date/.test(r.textContent)));
613
- await cp.locator('#rank .rr .rhd').nth(own).click();
614
- const ownGo = await until(() => cp.evaluate(() => (window.__items.length ? { path: location.pathname, items: window.__items } : null)), 6000);
615
- ok('C6 your own item opens on Home, on that item, without leaving the page', ownGo && ownGo.path === '/premium.html' && ownGo.items.join() === 'w1', JSON.stringify(ownGo));
616
- await cp.keyboard.press('Escape');
617
- await cp.click('#pvBell');
618
- await until(() => cp.evaluate(() => !!document.querySelector('#pvList .ib-bun')), 6000);
619
- await cp.locator('#pvList .ib-bun').first().click();
620
- await until(() => cp.evaluate(() => __rowOn() && document.querySelectorAll('#oMain .bd-it').length > 0));
621
- const pd = await cp.evaluate(() => ({ path: location.pathname, title: document.querySelector('#dTitle').textContent, ids: [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id), keep: !!document.querySelector('#oMain [data-bda="pkeep"]'), all: !!document.querySelector('#oMain [data-bda="pall"]') }));
622
- ok('C8 a piece of work in the bell opens Agent proposals on the Briefing with that initiative\'s drafts only', pd.path === '/premium.html' && pd.title === '2 wait for you' && pd.ids.join() === 'p1,p2' && pd.keep && pd.all, JSON.stringify(pd));
623
- await cp.locator('#oMain [data-bda="pall"]').click();
624
- ok('C9 Show all proposals lists every proposal', await until(() => cp.evaluate(() => [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id).sort().join() === 'p1,p2,p3')));
625
- await cp.keyboard.press('Escape');
626
- await until(() => cp.evaluate(() => !__rowOn()));
627
- await cp.click('#pvBell');
628
- await until(() => cp.evaluate(() => !!document.querySelector('#pvList .ib-it [data-ibo="prop:p1"]')), 6000);
629
- await cp.locator('#pvList .ib-it [data-ibo="prop:p1"]').click();
630
- const one = await until(() => cp.evaluate(() => { const ids = [...document.querySelectorAll('#oMain .bd-it')].map((x) => x.dataset.id); return __rowOn() && ids.length ? { ids, back: !!document.querySelector('#oMain [data-bda="pbell"]'), path: location.pathname } : null; }), 6000);
631
- ok('C10 a new proposal in the bell opens that one proposal, with a way back to the bell', one && one.ids.join() === 'p1' && one.back && one.path === '/premium.html', JSON.stringify(one));
632
- await cp.keyboard.press('Escape');
633
- ok('C7 no page error on the console path', C.errors.length === 0, C.errors.join(' | '));
634
- await C.ctx.close();
635
- /* a portfolio documents drafts row opens the draft in the document sheet, on the Briefing (premium-rows-stay-premium) */
636
- const PF = await open({ console: { briefing: { cards: [], needs: [] }, page: { ok: true, today: [], mentions: null, needs: [] },
637
- agent: [{ run_id: 'core-docs-needs:portfolio', kind: 'core-doc-drafts', question: '1 portfolio draft to review', initiative_id: null, board: null, scope: 'portfolio', ws: 'w0', doc: 'pmos/core-docs/portfolio/strategy.draft.md' }] } });
638
- await PF.page.route('**/api/core-docs?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, level: 'portfolio', scope: 'portfolio', docs: [
639
- { key: 'okrs', title: 'OKRs', for: 'What the quarter commits to', st: 'ok', open: { path: 'planning/okrs/q3.md' } },
640
- { key: 'strategy', title: 'Product strategy', for: 'Where the portfolio is going', st: 'draft', open: { path: 'pmos/core-docs/portfolio/strategy.draft.md' }, draft: { slot: 's1', path: 'pmos/core-docs/portfolio/strategy.draft.md' } }] }) }));
641
- await PF.page.route('**/api/doc-sheet/log?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, revisions: [{ rev: 1, at: '2026-10-19T09:00:00Z', by: 'agent' }] }) }));
642
- await PF.page.route('**/api/doc-sheet/at?*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, text: '# Product strategy\n\nWhere the portfolio is going.\n' }) }));
643
- const pp = PF.page;
644
- await until(() => pp.evaluate(() => [...document.querySelectorAll('#rank .rr')].some((r) => /portfolio draft/.test(r.textContent))));
645
- await pp.locator('#rank .rr .rhd').first().click();
646
- await until(() => pp.evaluate(() => __rowOn() && !!document.querySelector('[data-issue-bar="draft"]')));
647
- const pf = await pp.evaluate(() => ({ path: location.pathname, title: document.querySelector('#dTitle').textContent, issue: !!document.querySelector('[data-issue-bar="draft"] [data-ds="issue"]') }));
648
- ok('C10 a portfolio documents row opens its draft in the document sheet with Issue it, on the Briefing', pf.path === '/premium.html' && pf.title === 'Product strategy' && pf.issue, JSON.stringify(pf));
649
- await PF.ctx.close();
650
- }
651
-
652
- /* R8, R11 premium-agreed-design H1/N2: Home has no scroll dock. On a desktop the list is its own panel that scrolls, the page does not, and the
653
- * summary line that heads the list does the dock's job; the old dock stays hidden and out of reach at every scroll position */
654
- const dockOff = () => p.evaluate(() => { const d = document.querySelector('#dock'); return getComputedStyle(d).display === 'none' && d.inert === true; });
655
- await p.evaluate(() => { window.scrollTo(0, 0); document.querySelector('main.stage').scrollTop = 0; });
656
- ok('R11 the old dock is hidden and inert on Home', await dockOff());
657
- const scr = await p.evaluate(() => { const st = document.querySelector('main.stage'); st.scrollTop = 900; window.scrollTo(0, 900); return { list: st.scrollTop, page: Math.round(scrollY), sum: document.querySelector('#hSum').textContent.trim() }; });
658
- ok('R8 the list scrolls in its own panel, the page does not, the summary line heads the list and the dock stays hidden and unreachable', scr.list > 0 && scr.page === 0 && /need you|Nothing needs you/.test(scr.sum) && await dockOff(), JSON.stringify(scr));
659
- ok('R4 hovering the decision lights the meeting that needs it', await (async () => { await p.evaluate(() => { document.querySelector('main.stage').scrollTop = 0; }); await p.locator('#rank .rr[data-link]').first().hover(); return p.evaluate(() => document.querySelector('#tl .ev[data-link]').classList.contains('hl-k')); })());
660
- await sleep(400);
661
- /* R11 floors */
662
- {
663
- const t = await p.evaluate(() => {
664
- const small = [];
665
- for (const s of ['.rr .rhd', '.rr .rpin', '#tl .ev', '#srcChips .fchip', '.fbtn', '#calMore', '.rail .pl', '#srcChip', '#moreBtn', '.rail .pchat .orb', '#theme2']) document.querySelectorAll(s).forEach((e) => { const r = e.getBoundingClientRect(); if (r.width && (r.height < 44 || r.width < 44)) small.push(s + ' ' + Math.round(r.width) + 'x' + Math.round(r.height)); });
666
- return small;
667
- });
668
- ok('R11 every control is at least 44 px', t.length === 0, t.join(' | '));
669
- await p.keyboard.press('Tab');
670
- const ring = await p.evaluate(() => { document.activeElement.focus(); const cs = getComputedStyle(document.activeElement); return cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) >= 2; });
671
- ok('R11 the focus ring is drawn', ring);
672
- const arrows = await p.evaluate(() => { const L = [...document.querySelectorAll('#tl .ev')]; L[0].focus(); L[0].dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true })); return document.activeElement === L[1] || L.length < 2; });
673
- ok('R11 arrow keys move between timeline rows', arrows);
674
- }
675
- {
676
- const R = await open({ ctxOpts: { reducedMotion: 'reduce' } });
677
- ok('R11 reduced motion keeps every row and the hero', await R.page.evaluate(() => document.querySelectorAll('#rank .rr').length === 5 && document.querySelector('#brief').textContent.length > 40));
678
- await R.ctx.close();
679
- }
680
- for (const th of ['light', 'dark']) {
681
- const R = await open({ w: 390, h: 844, theme: th });
682
- const ov = await R.page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
683
- ok(`R11 no sideways scroll at 390 px (${th})`, ov <= 0, String(ov));
684
- await R.page.click('#rank .rhd');
685
- const ph = await until(() => R.page.evaluate(() => __rowOn()), 3000) && await R.page.evaluate(() => ({ inert: ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert), modal: document.querySelector('#dlg').getAttribute('aria-modal'), tab: document.querySelector('#dGrid').dataset.tab, pressed: document.querySelector('#dTabs [data-t="out"]').getAttribute('aria-pressed'), tabsShown: getComputedStyle(document.querySelector('#dTabs')).display !== 'none', paneBtn: getComputedStyle(document.querySelector('#dPane')).display, w: Math.round(document.querySelector('#dlg').getBoundingClientRect().width), l: Math.round(document.querySelector('#dlg').getBoundingClientRect().left), vw: innerWidth, btn: document.querySelector('#dPane').getAttribute('aria-pressed'), ov: document.documentElement.scrollWidth - innerWidth }));
686
- ok(`R11 on a phone the row's dialog is a modal popup and the page behind it is inert (${th})`, ph && ph.inert && ph.modal === 'true', JSON.stringify(ph));
687
- ok(`R4 the row's dialog says what skipping costs (${th})`, await R.page.evaluate(() => /If you skip/.test(document.querySelector('#card').textContent)), await R.page.evaluate(() => document.querySelector('#card').textContent.slice(0, 300)));
688
- ok(`R4 on a phone the dialog opens on Detail, with the mockup's Detail / Conversation switch and no panel button (${th})`, ph && ph.tab === 'out' && ph.pressed === 'true' && ph.tabsShown && ph.paneBtn === 'none' && ph.l === 0 && ph.w === ph.vw && ph.ov <= 0, JSON.stringify(ph));
689
- ok(`0 no page error at 390 px (${th})`, R.errors.length === 0, R.errors.join(' | '));
690
- await R.ctx.close();
691
- }
692
- { // a touch phone: iOS zooms the page in when a text field under 16 px gets focus, and the reply box then runs off the right edge
693
- const R = await open({ w: 390, h: 844, ctxOpts: { isMobile: true, hasTouch: true } });
694
- await R.page.click('#rank .rhd');
695
- await until(() => R.page.evaluate(() => __rowOn() && document.querySelector('#askIn')), 3000);
696
- const fs16 = await R.page.evaluate(() => [...document.querySelectorAll('input,textarea,select')].filter((e) => !/checkbox|radio|range|button|submit|reset|file|color|image|hidden/.test(e.type)).map((e) => (e.id || e.className || e.tagName) + ':' + getComputedStyle(e).fontSize).filter((s) => parseFloat(s.split(':').pop()) < 16));
697
- ok('R11 on a touch phone every text field is at least 16 px, so focus does not zoom the page (the reply box included)', fs16.length === 0 && await R.page.evaluate(() => !!document.querySelector('#askIn')), fs16.join(', '));
698
- await R.ctx.close();
206
+ { const E = await open({ fail: true });
207
+ ok('R9 a page that cannot read the repository says so', !!(await until(() => E.page.evaluate(() => /Home could not read the repository/.test(document.querySelector('#hmList').textContent)))));
208
+ await E.ctx.close(); }
209
+
210
+ /* R8, R11, R12 on a phone, both themes */
211
+ for (const theme of ['light', 'dark']) {
212
+ const P = await open({ w: 390, h: 844, theme, touch: true });
213
+ const top = await until(() => P.page.evaluate(() => { const n = document.querySelector('#hmNeedsN').textContent; return /need/.test(n) ? n : null; }));
214
+ await P.page.click('#hmNeeds');
215
+ const rows = await until(() => P.page.evaluate((sel) => { const l = document.querySelector('#hmList'); return l && getComputedStyle(l).display !== 'none' ? document.querySelectorAll(sel).length : 0; }, NEEDS));
216
+ const needs = await P.page.evaluate(() => { const m = /(\d+) more/.exec((document.querySelector('[data-hm-allneeds]') || {}).textContent || ''); return m ? +m[1] : 0; });
217
+ ok(`R8 (${theme}) the phone's "N need you" equals the Needs-you rows`, !!top && +top.match(/\d+/)[0] === rows + needs, JSON.stringify({ top, rows, needs }));
218
+ const small = await P.page.evaluate(() => [...document.querySelectorAll('#hmTop button, #hmList .hm-rm, #hmFoot button, #hmFoot label')].filter((b) => b.offsetParent !== null).map((b) => b.getBoundingClientRect()).filter((r) => r.height && r.height < 43.5).length);
219
+ ok(`R11 (${theme}) every control on the phone's top bar, sheet and composer is 44 px`, small === 0, String(small));
220
+ const ov = await P.page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
221
+ ok(`R11 no sideways scroll at 390 px (${theme})`, ov <= 0, String(ov));
222
+ const fs16 = await P.page.evaluate(() => [...document.querySelectorAll('textarea, input:not([type=file])')].filter((e) => e.offsetParent !== null && parseFloat(getComputedStyle(e).fontSize) < 16).length);
223
+ ok(`R11 on a touch phone every text field is at least 16 px, so focus does not zoom the page (${theme})`, fs16 === 0, String(fs16));
224
+ ok(`0 no page error at 390 (${theme})`, P.errors.length === 0, P.errors.join(' | '));
225
+ await P.ctx.close();
699
226
  }
700
227
 
701
- /* R12 fidelity, re-pointed to the Agreed design (premium-agreed-design; D60: the new surface's design is the reference the build works from).
702
- * The Agreed design lives on the PM's canvas, not as a page in the repository, so the page is checked against what it fixes: the cozy layer's
703
- * tokens (pm/cozy.css: Nunito, the blue palette, cards and wells, light and dark), the floating place menu (N1: 56 px, bottom left at 36 px on a
704
- * desktop, bottom right on a phone), no rail and no page header on a desktop (N2), and the desktop desk: the list panel, then the docked chat. */
705
- for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
706
- const R = await open({ w, h, theme: th });
707
- await until(() => R.page.evaluate(() => !!document.querySelector('#czFab')), 6000);
708
- await sleep(500);
709
- const g = await R.page.evaluate(() => {
710
- const tok = (v, prop = 'color') => { const e = document.createElement('i'); e.style[prop] = `var(${v})`; document.body.appendChild(e); const c = getComputedStyle(e)[prop]; e.remove(); return c; };
711
- const cs = (s) => { const e = document.querySelector(s); return e ? getComputedStyle(e) : null; }, rect = (s) => { const e = document.querySelector(s); const r = e && e.getClientRects().length ? e.getBoundingClientRect() : null; return r && { l: Math.round(r.left), r: Math.round(innerWidth - r.right), t: Math.round(r.top), b: Math.round(innerHeight - r.bottom), w: Math.round(r.width), h: Math.round(r.height) }; };
712
- const T = { ink: tok('--cz-ink'), ink2: tok('--cz-ink2'), card: tok('--cz-card', 'backgroundColor'), bluebg: tok('--cz-bluebg', 'backgroundColor'), blue: tok('--cz-blue', 'backgroundColor') };
713
- return { T, dark: document.documentElement.dataset.theme === 'dark', font: cs('body').fontFamily, bodyInk: cs('body').color, rowFont: cs('#rank .rr .rt') && cs('#rank .rr .rt').fontFamily, rowInk: cs('#rank .rr .rt') && cs('#rank .rr .rt').color,
714
- dot: cs('#rank .rr .rn') && cs('#rank .rr .rn').backgroundColor, sumBg: cs('.cz-sum').backgroundColor, sumInk: cs('#hSum').color, head: cs('#hInit') && cs('#hInit').color,
715
- fab: rect('#czFab'), fabBg: cs('#czFab').backgroundColor, fabLabel: document.querySelector('#czFab').getAttribute('aria-label'), rail: rect('.rail'), stage: rect('main.stage'), dlg: rect('#dlg'), wide: document.documentElement.scrollWidth > innerWidth + 1 };
228
+ /* R12 fidelity at 1440, light and dark */
229
+ for (const theme of ['light', 'dark']) {
230
+ const D = await open({ theme });
231
+ const f = await D.page.evaluate(() => {
232
+ const desk = document.querySelector('#hmDesk'), list = document.querySelector('#hmList'), cs = getComputedStyle(desk), r = desk.getBoundingClientRect();
233
+ return { inset: Math.round(r.left), radius: cs.borderTopLeftRadius, list: Math.round(list.getBoundingClientRect().width), font: getComputedStyle(document.body).fontFamily, theme: document.documentElement.dataset.theme || '', bg: getComputedStyle(document.body).backgroundColor, rail: !!document.querySelector('nav.rail'), menu: !!document.querySelector('#czMenu, .cz-nav') };
716
234
  });
717
- const diffs = [], want = (n, a, b) => { if (a !== b) diffs.push(`${n} ${a} | ${b}`); };
718
- want('theme', g.dark, th === 'dark');
719
- if (!/^Nunito\b/.test(g.font)) diffs.push('font ' + g.font);
720
- if (!/^Nunito\b/.test(g.rowFont || '')) diffs.push('row font ' + g.rowFont);
721
- want('body ink', g.bodyInk, g.T.ink); want('row ink', g.rowInk, g.T.ink); want('row dot', g.dot, g.T.blue); want('summary ground', g.sumBg, g.T.bluebg); want('summary ink', g.sumInk, g.T.ink); want('group heading', g.head, g.T.ink2);
722
- want('menu button background', g.fabBg, g.T.card);
723
- if (!g.fab || g.fab.w !== 56 || g.fab.h !== 56) diffs.push('menu button size ' + JSON.stringify(g.fab));
724
- else if (w >= 1000 ? g.fab.l !== 36 || g.fab.b !== 36 : g.fab.r !== 18 || g.fab.b !== 24) diffs.push('menu button place ' + JSON.stringify(g.fab));
725
- if (!/Home/.test(g.fabLabel || '')) diffs.push('menu label ' + g.fabLabel);
726
- if (g.rail) diffs.push('rail shown ' + JSON.stringify(g.rail));
727
- if (w >= 1000) { // cozy-home.css: the list panel at 44 px from the left, 316 px wide, from 40 px down; the docked chat from 382 px
728
- if (!g.stage || g.stage.l !== 44 || g.stage.w !== 316 || g.stage.t !== 40) diffs.push('list panel ' + JSON.stringify(g.stage));
729
- if (!g.dlg || g.dlg.l !== 382 || g.dlg.t !== 40) diffs.push('docked chat ' + JSON.stringify(g.dlg));
730
- } else if (!g.stage || g.stage.w < w - 40) diffs.push('phone list ' + JSON.stringify(g.stage));
731
- if (g.wide) diffs.push('sideways scroll');
732
- ok(`R12 Home follows the Agreed design at ${w} px, ${th}: cozy tokens, Nunito, the floating place menu, no rail${w >= 1000 ? ', the list panel and the docked chat' : ''}`, diffs.length === 0, diffs.join(' ; '));
733
- await R.ctx.close();
235
+ ok(`R12 Home follows the Agreed design at 1440 px, ${theme}: the desk at 16 px with a 28 px radius, the 316 px list, Nunito, the floating place menu, no rail`, f.inset === 16 && f.radius === '28px' && f.list === 316 && /Nunito/.test(f.font) && f.menu && !f.rail, JSON.stringify(f));
236
+ await D.ctx.close();
734
237
  }
735
238
  return finish();
736
- })().catch((e) => { console.error(e); finish(1); });
239
+ })();