create-pmos 0.691.0 → 0.693.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 (111) hide show
  1. package/package.json +20 -14
  2. package/payload/KIT-VERSION +1 -1
  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/workspace/adler-moments-test.js +3 -35
  7. package/workspace/adler-seasons-test.js +1 -1
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +1 -1
  10. package/workspace/briefing-premium-doc-edit-test.js +1 -1
  11. package/workspace/briefing-premium-work-test.js +2 -2
  12. package/workspace/changelog.json +19 -0
  13. package/workspace/chat-asks-test.js +1 -1
  14. package/workspace/core-docs-workflow-test.js +1 -1
  15. package/workspace/ev-everywhere-test.js +3 -14
  16. package/workspace/guide/cli.md +3 -1
  17. package/workspace/guide/home.md +1 -1
  18. package/workspace/guide/layout.md +2 -2
  19. package/workspace/guide/settings-and-switches.md +0 -1
  20. package/workspace/impact-screens-test.js +2 -47
  21. package/workspace/ini-workflow-test.js +1 -1
  22. package/workspace/lib/board-premium.js +10 -2
  23. package/workspace/lib/initiative-cli.js +31 -4
  24. package/workspace/lib/initiative-origin.js +131 -0
  25. package/workspace/lib/initiative-writer.js +35 -2
  26. package/workspace/lib/routes-boards.js +4 -1
  27. package/workspace/live-pill-round-test.js +6 -18
  28. package/workspace/milestone-suggest-test.js +4 -28
  29. package/workspace/news-viewers-test.js +3 -29
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/premium-board-actions-test.js +2 -2
  33. package/workspace/premium-briefing-depth-test.js +4 -4
  34. package/workspace/premium-chat-attach-test.js +3 -2
  35. package/workspace/premium-chat-chart-tab-test.js +8 -7
  36. package/workspace/premium-chat-context-test.js +3 -1
  37. package/workspace/premium-chat-goal-view-test.js +3 -1
  38. package/workspace/premium-chat-line-test.js +8 -6
  39. package/workspace/premium-chat-report-tab-test.js +13 -5
  40. package/workspace/premium-chat-term-test.js +2 -2
  41. package/workspace/premium-chat-viewer-test.js +10 -16
  42. package/workspace/premium-core-doc-issue-test.js +7 -2
  43. package/workspace/premium-discuss-landing-test.js +9 -5
  44. package/workspace/premium-html-viewer-test.js +7 -3
  45. package/workspace/premium-link-suggest-test.js +6 -10
  46. package/workspace/premium-phone-card-test.js +2 -2
  47. package/workspace/premium-viewer-download-test.js +1 -1
  48. package/workspace/premium-viewer-flicker-test.js +1 -1
  49. package/workspace/premium-viewer-share-test.js +2 -2
  50. package/workspace/premium-viewer-test.js +1 -1
  51. package/workspace/premium-vw-cal-test.js +1 -1
  52. package/workspace/premium-vw-copy-test.js +3 -3
  53. package/workspace/premium-vw-doc-test.js +1 -1
  54. package/workspace/premium-vw-item-test.js +1 -1
  55. package/workspace/premium-work-depth-test.js +2 -2
  56. package/workspace/program-charter-test.js +1 -12
  57. package/workspace/program-leave-test.js +2 -2
  58. package/workspace/program-order-test.js +3 -65
  59. package/workspace/project-onboard-flow-test.js +5 -5
  60. package/workspace/public/pm/bd-work.js +24 -5
  61. package/workspace/public/pm/cozy-home.css +0 -6
  62. package/workspace/public/pm/cozy-panels.js +2 -6
  63. package/workspace/public/pm/cozy-popup.css +1 -0
  64. package/workspace/public/pm/cozy-popup.js +15 -2
  65. package/workspace/public/pm/cozy-today-page.css +1 -1
  66. package/workspace/public/pm/cozy-today.css +0 -14
  67. package/workspace/public/pm/cozy-viewer.js +14 -38
  68. package/workspace/public/pm/goal-chat.js +2 -2
  69. package/workspace/public/pm/home-app.js +8 -67
  70. package/workspace/public/pm/home-chat.js +1 -1
  71. package/workspace/public/pm/home-ses-name.js +3 -2
  72. package/workspace/public/pm/home-today.js +4 -18
  73. package/workspace/public/premium-intelligence.html +1 -1
  74. package/workspace/public/premium-viewer.html +1 -1
  75. package/workspace/public/premium-workflows.html +1 -1
  76. package/workspace/ready-dash-ui-test.js +1 -1
  77. package/workspace/rename-test.js +2 -2
  78. package/workspace/server.js +11 -12
  79. package/workspace/session-names-test.js +34 -56
  80. package/workspace/sort-order-test.js +2 -71
  81. package/workspace/split-merge-ui-test.js +1 -1
  82. package/workspace/stage-card-tasks-test.js +1 -1
  83. package/workspace/stage-card-test.js +1 -1
  84. package/workspace/task-card-test.js +1 -1
  85. package/workspace/task-press-test.js +1 -1
  86. package/workspace/task-views-test.js +1 -1
  87. package/workspace/test-lists/adler-seasons-art.json +3 -6
  88. package/workspace/test-lists/batch18-asks.json +1 -1
  89. package/workspace/test-lists/briefing-premium.json +1 -11
  90. package/workspace/test-lists/premium-agreed-viewer.json +1 -1
  91. package/workspace/test-lists/who-raised-each-idea.json +5 -0
  92. package/workspace/test-run.js +0 -2
  93. package/workspace/test-timings.json +0 -4
  94. package/workspace/tk-tasks-test.js +3 -17
  95. package/workspace/viewer-trail-test.js +2 -2
  96. package/workspace/workflows-setup-test.js +4 -2
  97. package/workspace/adler-seasons-art-test.js +0 -116
  98. package/workspace/briefing-premium-initiative-test.js +0 -289
  99. package/workspace/briefing-premium-products-test.js +0 -209
  100. package/workspace/briefing-premium-sources-test.js +0 -250
  101. package/workspace/briefing-premium-test.js +0 -282
  102. package/workspace/home-other-product-test.js +0 -197
  103. package/workspace/home-pill-test.js +0 -138
  104. package/workspace/home-railcard-test.js +0 -196
  105. package/workspace/home-rows-test.js +0 -389
  106. package/workspace/panels-test.js +0 -454
  107. package/workspace/public/premium.html +0 -48
  108. package/workspace/test-lists/batch18-panels.json +0 -9
  109. package/workspace/test-lists/home-railcard.json +0 -9
  110. package/workspace/test-lists/home-sessions-pill.json +0 -6
  111. package/workspace/test-lists/viewer-home-rows.json +0 -9
@@ -1,289 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* briefing-premium-initiative-test.js — the initiative (initiative briefing-premium-initiative; planning/prd/briefing-premium-initiative-prd.md I1 to I12),
4
- * re-pointed for premium-agreed-design and again for the Home list fix (canvas HbC): the initiative is a page in Home's Viewer
5
- * (/premium.html?ini=<id>), the list stays the list, and the old /premium-initiative.html?id= link lands there. The page holds the stage card,
6
- * three tasks and the documents that need a look; its + and "Show all N" drill into Tasks, Documents and Stage, with ← back to the page. What moved elsewhere has its own suite:
7
- * a document's page premium-vw-doc-test.js, Add a document briefing-premium-adddoc-test.js, Issue it premium-core-doc-issue-test.js, the record and
8
- * task views premium-vw-item-test.js, the Jira views premium-vw-jira-test.js. The old page's List / By stage / Timeline views, the document filter
9
- * and search and the document sheet's tabs have no place in the Agreed design and are not drawn.
10
- * Serves the real page from the real server. Most checks answer GET /api/initiative-premium with the model lib/initiative-premium.js builds from a
11
- * fixture and GET /api/board-premium with lib/board-premium.js's; the last block reads this repository's own initiative through the real route.
12
- * I1 place · I2 reading · I3 header · I4 overview (Tasks, Documents, Stage: premium-uncovered-features) · I6 tasks · I7 documents · I10 presses · I12 floors and fidelity */
13
- const path = require('path');
14
- const { spawn } = require('child_process');
15
- const { findBrowser } = require('./lib/find-browser');
16
- const { besidePage } = require('./lib/beside-page'); // these checks are about work beside the page, not the popup
17
- const { openMission } = require('./lib/open-mission');
18
- const T = require('./test-run').configure({ name: 'briefing-premium-initiative' });
19
- const IP = require('./lib/initiative-premium.js');
20
- const F = require('./fixtures/initiative-premium-facts.js');
21
- const BP = require('./lib/board-premium.js');
22
- const BF = require('./fixtures/board-premium-facts.js');
23
- const BRP = require('./lib/briefing-premium.js');
24
- const BRF = require('./fixtures/briefing-premium-facts.js');
25
-
26
- const BASE = T.BASE;
27
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
28
- 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); } };
29
- const results = [];
30
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 600) : ''}`); };
31
- let srv = null; let browser = null;
32
- const finish = async (code) => {
33
- if (browser) await browser.close().catch(() => {});
34
- if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
35
- T.killTmux();
36
- const bad = results.filter((x) => !x.cond).length;
37
- console.log(`\n${results.length - bad}/${results.length} briefing-premium-initiative assertions passed`);
38
- process.exit(code !== undefined ? code : (bad ? 1 : 0));
39
- };
40
- process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
41
-
42
- const mk = (o) => IP.build(F.facts(o));
43
- const BOARD = BP.build(BF.facts());
44
- const BRIEF = BRP.build(BRF.facts());
45
- const WRITES = /^\/api\/(?:boards\/(?:move|tasks\/(?:add|state))|lifecycle|core-docs\/draft|task-plans\/propose)$/;
46
-
47
- // the phone design (Ph2_init): a phone shows an initiative as the popup's phone page; the old page is ⋯ › Every part
48
- const everyPart = async (pg) => { await pg.waitForSelector('#czViewer .pw-ph', { state: 'attached', timeout: 20000 }); await pg.evaluate(() => { const r = (window.__czVwMore ? window.__czVwMore(document.body) : []).find((x) => x.label === 'Every part'); if (r) r.go(); }); await pg.waitForTimeout(800); };
49
- (async () => {
50
- const exe = findBrowser();
51
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
52
- let chromium;
53
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
54
- srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
55
- await T.waitForServer(BASE);
56
- browser = besidePage(await chromium.launch({ executablePath: exe }));
57
-
58
- const open = async ({ w = 1280, h = 900, theme = 'light', model = mk(), answers = null, url = '/premium.html?ini=self-serve-v2&ws=w1&board=w1' } = {}) => {
59
- const ctx = await openMission(await browser.newContext({ viewport: { width: w, height: h } }));
60
- const page = await ctx.newPage();
61
- let current = model, calls = 0, answer = { status: 200, body: { ok: true } };
62
- const errors = [], posts = [];
63
- page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
64
- page.on('request', (rq) => { if (rq.method() === 'POST') posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}'), headers: rq.headers() }); });
65
- const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
66
- await page.route('**/api/initiative-premium*', (r) => { calls++; if (answers) { const a = answers(calls, r.request().url()); return json(r, a.body, a.status); } return json(r, { ok: true, state: 'ready', model: current, as_of: Date.now() }); });
67
- await page.route(/\/api\/board-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BOARD, as_of: Date.now() }));
68
- await page.route(/\/api\/briefing-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BRIEF, as_of: Date.now() }));
69
- for (const p of ['**/api/boards/move', '**/api/boards/tasks/**', '**/api/lifecycle', '**/api/core-docs/draft']) await page.route(p, (r) => json(r, answer.body, answer.status));
70
- await page.route('**/api/briefing-premium/**', (r) => json(r, { ok: true, turns: [], working: false }));
71
- await page.goto(BASE + url + (url.includes('?') ? '&' : '?') + 'theme=' + theme);
72
- // ready: the card is drawn and the board's initiatives are read (the switcher and the card's kind line come from them)
73
- const up = await ready(page, !answers);
74
- return { ctx, page, errors, posts, up, calls: () => calls, setModel: (m) => { current = m; }, set: (a) => { answer = a; } };
75
- };
76
- const V = '#czViewer:not([hidden])';
77
- // ready: the initiative's page is open in the Viewer (canvas HbC), its kind line from the board's row (kind · anchor) and, when the
78
- // initiative reads, its card from the record (the ladder). Before the record reads, the page says it is reading.
79
- async function ready(page, full = true) { return until(() => page.evaluate((f) => /·/.test((document.querySelector('#czViewer:not([hidden]) .cz-vw-kind') || {}).textContent || '') && (!f || (!!document.querySelector('#czViewer .iv-mc') && !!((document.querySelector('#czViewer .iv-tel-t .iv-shn b') || {}).textContent || '').trim())), full), 30000); }
80
- const txt = (p, s) => p.evaluate((q) => ((document.querySelector(q) || {}).textContent || '').replace(/\s+/g, ' ').trim(), s);
81
- // batch 11 item 20: the page holds the Tasks (the old All tasks panel is gone); its ⋯ holds Move to a stage and its Documents fold opens
82
- // Documents; the Stage and Documents views hold each other under ⋯; ← goes back to the page. view names the one to show ('tasks' is the page)
83
- const LABEL = { docs: 'Documents', stage: 'Stage' };
84
- const onPage = (p) => p.evaluate((v) => !!document.querySelector(v + ' [data-hi-v="page"]'), V);
85
- const show = async (p, view) => {
86
- if (view === 'tasks') { for (let i = 0; i < 4 && !(await onPage(p)); i++) { await p.click('#czViewer [data-cz-vw="back"]'); await sleep(150); } return until(() => onPage(p)); }
87
- if (await onPage(p) && view === 'docs') await p.click(`${V} [data-iv-docs]`);
88
- else if (await onPage(p)) { // batch 16 item 5c: the page's ⋯ no longer holds the stage; the Stage view sits under Documents' ⋯
89
- await p.click(`${V} [data-iv-docs]`); await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-hi-v="docs"]'), V));
90
- await p.click('#czViewer [data-cz-vw="more"]'); await until(() => p.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu')));
91
- await p.click('#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("Stage"))');
92
- } else {
93
- await p.click('#czViewer [data-cz-vw="more"]'); await until(() => p.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu')));
94
- await p.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${(await onPage(p)) ? 'Move to a stage' : LABEL[view]}"))`);
95
- }
96
- return until(() => p.evaluate((a) => !!document.querySelector(a[0] + ` [data-hi-v="${a[1]}"]`), [V, view])); };
97
- const moreLabels = (p) => p.evaluate(async () => { const b = document.querySelector('#czViewer [data-cz-vw="more"]'); if (!b) return []; b.click(); await new Promise((r) => setTimeout(r, 50)); const m = document.querySelector('#czViewer .cz-vw-menu'); const out = m ? [...m.querySelectorAll('[role="menuitem"] span:first-of-type')].map((x) => x.textContent) : []; b.click(); return out; });
98
- // the initiative's page first (its list row opens it again when something else is shown), then the view asked for
99
- const overview = async (p, view = 'stage') => {
100
- if (!(await p.evaluate((v) => !!document.querySelector(v + ' [data-hi-v="page"]'), V))) {
101
- if (!(await p.evaluate(() => { const b = document.querySelector('#hmList [data-hm-sel="i:self-serve-v2"]'); return !!b && !!b.offsetParent; }))) await p.click('#hmNeeds');
102
- await p.click('#hmList [data-hm-sel="i:self-serve-v2"]');
103
- }
104
- const s = await until(() => p.evaluate((v) => { const o = document.querySelector(v); if (!o) return null; if (o.querySelector('[data-hi-v="page"]')) return 'ok'; return /could not be read/.test(o.textContent) ? 'err' : null; }, V), 30000);
105
- if (s !== 'ok') return !!s;
106
- if (view && view !== 'tasks') await show(p, view);
107
- return true; };
108
- const writes = (X) => X.posts.filter((x) => WRITES.test(x.path));
109
-
110
- const A = await open(), p = A.page;
111
- ok('0 Home opens the initiative\'s page in the Viewer; the list stays the list, with its row selected (HbCDesk)', A.up && await p.evaluate(() => new URLSearchParams(location.search).get('ini') === 'self-serve-v2' && !!document.querySelector('#czViewer .iv-mc') && !document.querySelector('#hmList .iv-mc') && document.querySelector('#hmList [data-hm-sel="i:self-serve-v2"]').getAttribute('aria-current') === 'true'));
112
-
113
- /* I1 place */
114
- {
115
- const R = await open({ url: '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1' });
116
- const u = new URL(R.page.url());
117
- ok('I1 the old initiative link lands on Home with this initiative, its workspace and board kept', R.up && u.pathname === '/premium.html' && u.searchParams.get('ini') === 'self-serve-v2' && u.searchParams.get('ws') === 'w1' && u.searchParams.get('board') === 'w1', R.page.url());
118
- await R.ctx.close();
119
- }
120
- ok('I1 the console is not linked from Home', await p.evaluate(() => ![...document.querySelectorAll('a[href]')].some((a) => /console(\.html)?/.test(a.getAttribute('href')))));
121
- // Home shows only the rows with a call (home-nav-rows-with-a-call): "N more" opens the board's other initiatives in place
122
- await p.evaluate(() => document.querySelectorAll('#hmList .hv-fold[aria-expanded="false"]').forEach((b) => b.click()));
123
- await until(() => p.evaluate(() => !!document.querySelector('#hmList [data-hm-sel="i:partner-rate-limits"]')));
124
- const sib = await p.evaluate(() => [...document.querySelectorAll('#hmList [data-hm-sel^="i:"]')].map((b) => b.dataset.hmSel));
125
- ok('I1 the list keeps the board\'s other initiatives beside the open one', ['i:self-serve-v2', 'i:partner-rate-limits'].every((k) => sib.includes(k)), JSON.stringify(sib));
126
- await p.click('#hmList [data-hm-sel="i:partner-rate-limits"]');
127
- { const u = new URL(p.url()); ok('I1 another initiative\'s name opens its page on the same board', await until(() => p.evaluate(() => new URLSearchParams(location.search).get('ini') === 'partner-rate-limits' && document.querySelector('#czVwTitle').textContent.trim() === 'Partner API rate limits')) && u.searchParams.get('ws') === 'w1' && u.searchParams.get('board') === 'w1', p.url()); }
128
- await p.goBack();
129
- ok('I1 the browser\'s Back closes the page and leads back to all work', await until(() => p.evaluate(() => !new URLSearchParams(location.search).get('ini') && !document.querySelector('#czViewer:not([hidden])') && !document.querySelector('#hmList [aria-current="true"][data-hm-sel^="i:"]'))), p.url());
130
- await p.evaluate(() => { window.__noReload = 1; });
131
- await p.click('#hmList [data-hm-prodopen]');
132
- ok('I1 a product heading\'s name opens the product\'s one page in the Viewer with its goals and its Reports tab, and its own chat (HbCProduct, batch 21 item 2)', await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); return !!v && /Product/.test((v.querySelector('.cz-vw-kind') || {}).textContent || '') && !!v.querySelector('section.hi-pg[aria-label="Goals"]') && !!v.querySelector('[data-pv="tab"][data-k="reports"]') && /^Message PMOS about /.test(document.querySelector('#hmIn').placeholder) && !!document.querySelector('#hmList .hv-prg.sel [data-hm-prodopen]'); })));
133
- if (await p.isVisible('#czFab')) await p.click('#czFab'); await p.click('#czMenu a[aria-current="page"]');
134
- ok('I1 Menu > Today closes the page and clears the selection, without a reload', await until(() => p.evaluate(() => window.__noReload === 1 && !document.querySelector('#czViewer:not([hidden])') && !document.querySelector('#hmList .sel, #hmList [aria-current="true"]') && /^Ask or tell PMOS anything$/.test(document.querySelector('#hmIn').placeholder)))); // chief-of-staff C1: Home's own chat
135
- await p.goto(BASE + '/premium.html?ini=self-serve-v2&ws=w1&board=w1&theme=light'); await ready(p);
136
-
137
- /* I3 header and the ONE view (batch 6 items 1 and 3: the Board's panel draws the same; stage-card-test.js holds the stage card's behaviour) */
138
- await until(() => p.evaluate(() => !!document.querySelector('#czViewer .iv-tel [data-iv-tj] svg')), 15000);
139
- const card = await p.evaluate(() => { const c = document.querySelector('#czViewer .iv-mc'), iv = document.querySelector('#czViewer .iv'); const q = (s, r = c) => ((r.querySelector(s) || {}).textContent || '').replace(/\s+/g, ' ').trim(), d = (s) => ((document.querySelector(s) || {}).textContent || '').trim();
140
- return { kind: d('#czViewer .cz-vw-kind'), title: d('#czVwTitle'), stage: q('.iv-tel-t .iv-shn b'), segs: c.querySelectorAll('.mi-svg .mi-pt').length, now: c.querySelectorAll('.mi-svg .mi-pt:is(.nw, .late, .hold)').length, tail: (c.querySelector('.iv-gx .iv-scgo') || { getAttribute: () => '' }).getAttribute('aria-label') || '', ms: !!c.querySelector('.iv-gx .iv-scgo[data-ms]'),
141
- pri: iv.querySelectorAll('[data-iv-primary]').length, cta: !!iv.querySelector('[data-hm-cta]'), tasks: q('.iv-th', iv), empty: !!iv.querySelector('.iv-empty'), secs: [...iv.querySelectorAll('.iv-ws b')].map((b) => b.textContent), meta: q('.iv-meta', iv) }; });
142
- ok('I3 the page\'s header names the initiative, its workflow and its anchor (D99)', card.title === 'Self-serve onboarding v2' && /^Product feature · \S/.test(card.kind), JSON.stringify(card));
143
- ok('I3 the card shows the stage the workflow engine derives, its stages drawn as the trajectory\'s colours with the current one marked', card.stage === 'Build' && card.segs >= 2 && card.now >= 1, JSON.stringify(card));
144
- ok('I1 the summary leads with at most one primary; the card holds no step list; Tasks is the WBS by stage', card.pri <= 1 && !card.cta && /^Tasks/.test(card.tasks) && (card.secs.length > 0 || card.empty) && !/pull request|builder agent/i.test(card.secs.join(' ')), JSON.stringify(card));
145
- ok('I1 the card\'s → names the next stage', /^Next: ◆ Deliver/.test(card.tail), JSON.stringify(card));
146
- ok('I3 Deliver is a milestone: the next stage carries the ◆ mark (Agreed design AgInitAgents)', card.ms, JSON.stringify(card));
147
- ok('I1 the card wrote nothing on its own', writes(A).length === 0, JSON.stringify(writes(A)));
148
-
149
- /* I7 documents: the page's Documents is a fold row with the count; a press drills into them all (OvIniA) */
150
- ok('I7 the page holds Documents with its count; the list holds no Files or documents group', await until(() => p.evaluate((v) => { const g = document.querySelector(v + ' [data-iv-docs]'); return !!g && /^Documents ?\d+$/.test(g.textContent.replace(/\s+/g, ' ').trim()) && !document.querySelector('#hmList section.hm-g[aria-label="Files"], #hmList [data-iv-docs]'); }, V)));
151
- await p.click(`${V} [data-iv-docs]`);
152
- await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-open="planning/prd/self-serve-v2-prd.md"]'), V), 15000);
153
- await p.click(`${V} [data-ov-open="planning/prd/self-serve-v2-prd.md"]`);
154
- ok('I7 a file opens as its page in the Viewer, not a dialog', await until(() => p.evaluate((v) => !!document.querySelector(v + ' .obody.vw[data-vw="doc:planning/prd/self-serve-v2-prd.md"]') && !(document.querySelector('#dlg') && !!document.querySelector('#dlg.on')), V), 15000));
155
-
156
- /* I4 the Overview */
157
- const i4 = await overview(p, null) && await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-hi-v="page"] .iv-th [data-iv-add]') && !document.querySelector(v + ' [data-hi-view]') && !document.querySelector(v + ' .hx-wait'), V));
158
- ok('I4 the page holds the Tasks with its +, and no All tasks switch (batch 11 item 20), and no Waiting for design marker', !!i4);
159
- ok('I4 the card has no Overview tile: the chat box on the page talks about the initiative (stage card D)', await p.evaluate((v) => !document.querySelector(v + ' .iv [data-hm-ov]') && /^Message PMOS about Self-serve onboarding v2/.test(document.querySelector('#hmIn').placeholder), V));
160
- const pm = await moreLabels(p);
161
- // batch 16 item 5c (FmI1Menu): seven entries at most, Delete last; the rest sits on what it changes (stage-card-test.js holds the stage chip)
162
- ok('I4 the page\'s ⋯ is the short menu: Split, Merge, Program, Open on the Board, Copy, The record, then Delete last (FmI1Menu)', ['Open on the Board', 'Copy', 'The record', 'Delete'].every((l) => pm.includes(l)) && pm.length <= 7 && pm[pm.length - 1] === 'Delete' && !['Move to a stage', 'Moves on by itself', 'Add a stakeholder', 'Put on hold', 'Cancel the initiative', 'Rename', 'All tasks'].some((l) => pm.includes(l)), JSON.stringify(pm));
163
- await show(p, 'stage');
164
- const st = await p.evaluate((v) => { const o = document.querySelector(v); return { moves: [...o.querySelectorAll('[data-ov-move]')].map((b) => b.dataset.ovMove), cur: (o.querySelector('[data-ov-move][aria-pressed="true"]') || {}).textContent, life: [...o.querySelectorAll('[data-ov-life]')].map((b) => b.dataset.ovLife) }; }, V);
165
- await show(p, 'docs');
166
- const ov = await p.evaluate((v) => { const o = document.querySelector(v); return { docs: [...o.querySelectorAll('[data-ov-doc]')].map((d) => d.dataset.ovDoc).sort(), draft: [...o.querySelectorAll('[data-ov-draft], [data-czs-act^="draft:"], [data-ov-none]')].map((b) => b.dataset.ovDraft || b.dataset.ovNone || b.dataset.czsAct.slice(6)).sort(), pri: ((o.querySelector('.czs-pri[data-czs-act^="draft:"]') || {}).dataset || {}).czsAct || '', drafting: [...o.querySelectorAll('[data-ov-doc]')].filter((d) => /Drafting/.test(d.textContent)).map((d) => d.dataset.ovDoc), dread: [...o.querySelectorAll('[data-ov-dread]')].map((b) => b.dataset.ovDread), sum: (o.querySelector('[data-ov-dsum]') || {}).textContent || '' }; }, V);
167
- const M = mk();
168
- ok('I4 the Stage view lists the board\'s stages with the current one pressed, and the lifecycle presses', JSON.stringify(st.moves) === JSON.stringify(M.acts.stages) && st.cur === 'Build' && st.life.join() === 'on-hold', JSON.stringify(st)); // Cancel merged into Won't do (batch 16 item 5c)
169
- ok('I7 the core documents are the non-technical ones, with the engine\'s summary', JSON.stringify(ov.docs) === JSON.stringify(M.docs.rows.filter((d) => !d.tech).map((d) => d.key).sort()) && ov.sum === M.docs.cap, JSON.stringify(ov));
170
- ok('I7 a document not started offers Draft it (the summary\'s one primary drafts the first, the rest offer it from their row); a running one says Drafting and has no press; a draft offers Read', /^draft:(problem|research)$/.test(ov.pri) && [...new Set(ov.draft)].filter((k) => k === 'problem' || k === 'research').sort().join() === 'problem,research' && ov.drafting.join() === 'launch' && ov.dread.length === M.docs.rows.filter((d) => !d.tech && d.st === 'draft' && d.path && d.slot).length, JSON.stringify(ov));
171
-
172
- /* I10 presses */
173
- const mint = await T.nonce(BASE);
174
- const settle = async (fn) => { const c = A.calls(); await fn(); await until(() => A.calls() > c, 10000); await sleep(500); }; // a press that lands reads the initiative again and draws the Overview again
175
- await show(p, 'stage');
176
- // a stage move asks the day it happened first (popup round 3 point 18f): Today keeps the move as it was
177
- await settle(async () => { await p.click(`${V} [data-ov-move="Deliver"]`); await p.click('.hi-pop [data-sw="today"]'); });
178
- const mv = await until(() => A.posts.find((x) => x.path === '/api/boards/move'));
179
- ok('I10 a stage press posts the board, the initiative and the stage to the move route', mv && mv.body.ws === 'w1' && mv.body.board === 'w1' && mv.body.id === 'self-serve-v2' && mv.body.to === 'Deliver', JSON.stringify(mv && mv.body));
180
- await until(() => p.evaluate((v) => !!document.querySelector(v + ' [data-ov-move]'), V));
181
- await p.click(`${V} [data-ov-life="on-hold"]`);
182
- ok('I10 a lifecycle press asks its reason inline before it posts', await until(() => p.evaluate((v) => !!document.querySelector(v + ' #ovWhy'), V)) && !A.posts.some((x) => x.path === '/api/lifecycle'));
183
- await p.fill(`${V} #ovWhy`, 'x'); await p.click(`${V} [data-ov-life-go]`);
184
- ok('I10 a reason too short is refused and nothing is posted', await until(async () => /Say why in a few words/.test(await txt(p, V + ' #ovMsg'))) && !A.posts.some((x) => x.path === '/api/lifecycle'));
185
- await p.fill(`${V} #ovWhy`, 'Waiting on legal'); await settle(() => p.click(`${V} [data-ov-life-go]`));
186
- const lf = await until(() => A.posts.find((x) => x.path === '/api/lifecycle'));
187
- ok('I10 Record posts the state and the reason to the lifecycle route', lf && lf.body.initiative_id === 'self-serve-v2' && lf.body.state === 'on-hold' && lf.body.reason === 'Waiting on legal' && lf.body.ws === 'w1', JSON.stringify(lf && lf.body));
188
- await show(p, 'tasks'); // the page's + opens the add field in Tasks (batch 11 item 20)
189
- await p.click(`${V} [data-iv-add]`);
190
- await until(() => p.evaluate((v) => !!document.querySelector(v + ' #ivAddTask'), V));
191
- await p.press(`${V} #ivAddTask`, 'Enter'); await sleep(200);
192
- ok('I6 Add with no title posts nothing', !A.posts.some((x) => x.path === '/api/boards/tasks/add'));
193
- await p.fill(`${V} #ivAddTask`, 'Release plan'); await settle(() => p.press(`${V} #ivAddTask`, 'Enter'));
194
- const ad = await until(() => A.posts.find((x) => x.path === '/api/task-plans/propose'));
195
- // an initiative with no Live task: the page's add starts a proposal (batch 11 item 8), it never writes the board's tasks directly
196
- ok('I10 Add on a page with no Live task proposes the task: the workspace, this initiative and the title', ad && ad.body.ws === 'w1' && ad.body.initiative === 'self-serve-v2' && ad.body.title === 'Release plan' && !A.posts.some((x) => x.path === '/api/boards/tasks/add'), JSON.stringify(ad && ad.body));
197
- // a task's quick status on the page is covered by task-views-test.js (batch 9 item 5b); this record's page draws no task rows
198
- await show(p, 'docs');
199
- await until(() => p.evaluate((v) => !!document.querySelector(v + ' .czs-pri[data-czs-act^="draft:"]'), V));
200
- const first = await p.evaluate((v) => document.querySelector(v + ' .czs-pri[data-czs-act^="draft:"]').dataset.czsAct.slice(6), V);
201
- await settle(() => p.click(`${V} .czs-pri[data-czs-act^="draft:"]`));
202
- const dr = await until(() => A.posts.find((x) => x.path === '/api/core-docs/draft'));
203
- ok('I10 Draft it posts the workspace, the initiative scope and the key and nothing else', dr && Object.keys(dr.body).sort().join() === 'key,scope,ws' && dr.body.scope === 'initiative:self-serve-v2' && dr.body.key === first, JSON.stringify(dr && dr.body));
204
- A.set({ status: 409, body: { ok: false, error: 'PMOS is already drafting this document.' } });
205
- const other = first === 'problem' ? 'research' : 'problem';
206
- await until(() => p.evaluate((a) => !!document.querySelector(a[0] + ` [data-ov-none="${a[1]}"], ` + a[0] + ` [data-czs-act="draft:${a[1]}"]`), [V, other]));
207
- if (await p.evaluate((a) => !!document.querySelector(a[0] + ` [data-czs-act="draft:${a[1]}"]`), [V, other])) await p.click(`${V} [data-czs-act="draft:${other}"]`);
208
- else {
209
- await p.evaluate((a) => { const n = document.querySelector(a[0] + ` [data-ov-none="${a[1]}"]`); const f = n && !n.offsetParent && n.closest('.czs-sec') && n.closest('.czs-sec').querySelector('[data-czs-fold]'); if (f) f.click(); }, [V, other]); // its group is folded
210
- await p.click(`${V} [data-ov-none="${other}"]`); await until(() => p.evaluate(() => !!document.querySelector('.hi-pop'))); await p.click('.hi-pop button:has-text("Draft it now")'); }
211
- ok('I10 a refused press shows the route\'s reason in the Overview', await until(async () => /already drafting/.test(await txt(p, V + ' #ovMsg'))));
212
- A.set({ status: 200, body: { ok: true } });
213
- ok('I10 every press carried the launch nonce and no writer field', !!mint && writes(A).length >= 5 && writes(A).every((x) => x.headers['x-pmos-nonce'] === mint && !['by', 'via', 'at', 'actor', 'pm', 'nonce'].some((k) => k in x.body)), JSON.stringify(writes(A).map((x) => x.path)));
214
- ok('I10 the Overview posts only to the move, lifecycle, task and draft routes', A.posts.filter((x) => /^\/api\/(boards|lifecycle|core-docs)/.test(x.path)).every((x) => WRITES.test(x.path)));
215
- ok('I1 the old dialog never opened', await p.evaluate(() => { const d = document.querySelector('#dlg'); return !d || !d.classList.contains('on'); }));
216
- ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
217
- await A.ctx.close();
218
-
219
- /* I2 reading and honest states */
220
- {
221
- let n = 0;
222
- const R = await open({ answers: (c) => { n = c; return c <= 2 ? { status: 202, body: { ok: true, state: 'reading' } } : { status: 200, body: { ok: true, state: 'ready', model: mk(), as_of: Date.now() } }; } });
223
- await overview(R.page);
224
- ok('I2 while the initiative is read the Overview says so, then draws when the read ends', await until(() => R.page.evaluate((v) => !!document.querySelector(v + ' [data-ov-move]'), V), 20000) && n >= 3, String(n));
225
- await R.ctx.close();
226
- const E = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'the board could not be read' } }) });
227
- await overview(E.page);
228
- ok('I2 a failed read says so in the Overview and draws no stage or task', await until(() => E.page.evaluate((v) => { const o = document.querySelector(v); return !!o && /could not be read/.test(o.textContent) && !o.querySelector('[data-ov-move], [data-ov-tkrow]'); }, V), 60000));
229
- ok('I2 no page error on a failed read', E.errors.length === 0, E.errors.join(' | '));
230
- await E.ctx.close();
231
- }
232
-
233
- /* I12 floors at 390 */
234
- {
235
- const N = await open({ w: 390, h: 844 });
236
- await everyPart(N.page);
237
- await overview(N.page, null);
238
- ok('I4 a phone draws no Tasks, Documents and Stage switch: the Tasks sit on the page (batch 11 item 20)', await until(() => N.page.evaluate((v) => !!document.querySelector(v + ' [data-hi-v="page"] .iv-th') && !document.querySelector(v + ' [data-hi-view]'), V)));
239
- const fls = [];
240
- for (const view of ['docs', 'stage']) { // the page's own floors (its Tasks too) are the page suites' (tk-tasks-test.js G4)
241
- await show(N.page, view);
242
- fls.push(await N.page.evaluate((a) => { const o = document.querySelector(a[0]); const small = [...o.querySelectorAll('button, select, input')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent.trim().slice(0, 24) || b.id || b.getAttribute('aria-label') || b.tagName); return { view: a[1], over: document.documentElement.scrollWidth - innerWidth, small }; }, [V, view]));
243
- }
244
- ok('I12 at 390 px the Overview\'s Documents and Stage have no sideways scroll and every target is 44 px', fls.every((fl) => fl.over <= 0 && fl.small.length === 0), JSON.stringify(fls));
245
- ok('I12 no page error at 390 px', N.errors.length === 0, N.errors.join(' | '));
246
- await N.ctx.close();
247
- }
248
-
249
- /* the real routes against this repository */
250
- {
251
- const get = async (q) => { for (let i = 0; i < 60; i++) { const r = await fetch(BASE + '/api/initiative-premium' + q); const b = await r.json(); if (r.status !== 202) return { status: r.status, body: b }; await sleep(3000); } return { status: 202, body: null }; };
252
- const r = await get('?id=briefing-premium-board');
253
- const m = r.body && r.body.model;
254
- ok('I1 the real route answers ready with this initiative\'s model', r.status === 200 && r.body.state === 'ready' && m && m.id === 'briefing-premium-board' && m.key === 'init:briefing-premium-board', JSON.stringify(r.body).slice(0, 200));
255
- ok('I6 its PRD requirements are the PRD\'s own (B1 to B13) and no more', m && m.tasks.reqs >= 12 && m.tasks.rows.filter((t) => t.src === 'PRD requirement').every((t) => /^B\d+$/.test(t.ref)));
256
- ok('I7 its core documents come with a scope and counts that add up', m && m.docs.scope === 'initiative:briefing-premium-board' && m.docs.counts.all === m.docs.rows.filter((d) => !d.tech).length);
257
- const miss = await get('?id=no-such-initiative-xyz');
258
- ok('I1 an initiative that is not on a board answers 404 with a reason', miss.status === 404 && miss.body && miss.body.ok === false && /no-such-initiative-xyz/.test(miss.body.error), JSON.stringify(miss.body));
259
- const bad = await fetch(BASE + '/api/initiative-premium?id=../etc/passwd'); ok('I1 an id that is not an id is refused', bad.status === 400);
260
- const post = await fetch(BASE + '/api/initiative-premium?id=x', { method: 'POST' }); ok('I10 the route answers GET only', post.status === 405);
261
- }
262
-
263
- /* I12 fidelity: the Agreed design (premium-agreed-design, Inside one initiative): Plus Jakarta Sans, the cozy card, the CTA in the solid colour, the floating
264
- * menu. The colours are read from the page's own tokens, so each theme is checked against itself. */
265
- for (const [w, h] of [[1440, 900], [390, 844]]) for (const th of ['light', 'dark']) {
266
- const R = await open({ w, h, theme: th });
267
- if (w <= 760) await everyPart(R.page);
268
- const g = await R.page.evaluate(() => {
269
- const tok = (v) => { const x = document.createElement('i'); x.style.setProperty('background-color', 'var(' + v + ')'); document.body.appendChild(x); const c = getComputedStyle(x).backgroundColor; x.remove(); return c; };
270
- const cs = (s) => { const e = document.querySelector(s); return e ? getComputedStyle(e) : null; };
271
- const fab = document.querySelector('#czFab'), fr = fab && fab.getBoundingClientRect(), rl = document.querySelector('#czMenu.ev-rail');
272
- const c = document.querySelector('#czViewer .iv-tel').getBoundingClientRect();
273
- return { font: cs('body').fontFamily, cta: (cs('#czViewer .iv-go') || {}).backgroundColor, ctaAlt: !document.querySelector('#czViewer .iv-go'), solid: tok('--cz-solid'), blue: tok('--cz-blue'), well: tok('--cz-well'), card: tok('--cz-card'), box: cs('#czViewer .iv-mc').backgroundColor, rad: parseFloat(cs(innerWidth <= 760 ? '#czViewer .iv-tel' : '#czViewer .iv-mc').borderTopLeftRadius), fab: fr ? [Math.round(fr.width), Math.round(fr.height)] : null, rail: rl ? Math.round(rl.getBoundingClientRect().width) : 0, over: document.documentElement.scrollWidth - innerWidth, cardW: Math.round(c.width) };
274
- });
275
- const d = [];
276
- if (!/^"?Plus Jakarta Sans/.test(g.font)) d.push('font ' + g.font);
277
- if (!g.ctaAlt && ![g.solid, g.blue].includes(g.cta)) d.push('cta ' + g.cta + ' want ' + g.solid + ' or ' + g.blue);
278
- if (![g.well, g.card].includes(g.box) && !/rgba/.test(g.box)) d.push('card box ' + g.box);
279
- // a phone has no wrapper card (batch 23 item 5, canvas PmA): the mission is the first card there
280
- if (g.rad < 12) d.push('card radius ' + g.rad);
281
- // on a phone the initiative's page is the Viewer, full screen over the list: the floating menu waits under it (HbCPhone)
282
- if (w > 760 && (!g.rail || g.rail !== 72)) d.push('rail ' + JSON.stringify(g.rail)); // a desktop: the rail of places, 72 px (slice 1)
283
- if (g.over > 0) d.push('sideways scroll ' + g.over);
284
- ok(`I12 the initiative follows the Agreed design at ${w} px, ${th}: Plus Jakarta Sans, the cozy card, the CTA, the floating menu`, d.length === 0, d.join(' ; '));
285
- ok(`I12 no page error at ${w} px, ${th}`, R.errors.length === 0, R.errors.join(' | '));
286
- await R.ctx.close();
287
- }
288
- return finish();
289
- })().catch((e) => { console.error(e); finish(1); });
@@ -1,209 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* briefing-premium-products-test.js — the premium Briefing across products (initiative briefing-premium-products; planning/prd/briefing-premium-products-prd.md P1 to P13).
4
- * The real server with two product repositories registered beside the home one (the PMOS checkout the server runs from). Both products hold a
5
- * kill condition KC9 that has passed its date, so each has a "decide" row with the SAME id: the page must keep them apart.
6
- * P1 by default the home workspace is not read
7
- * P2 the product chip on Home (the one picker Home, Board and Insights share, batch 12 item 5) lists every workspace, the home one included
8
- * P3 the ticks are saved when the list closes and survive a reload; All saves every one ('*'); the default ticks save the default (null)
9
- * P4 an unticked product's rows leave the list
10
- * P6 each row carries its product
11
- * P9 deciding a row writes into the owning product's journal and no other
12
- * P10 a message about a merged row starts a Claude Code session in that product
13
- * P12 ?ws= is a one-off view of that product: the chip shows it, and the saved pick stays
14
- * P13 floors: the chip and its rows are 44 px high, reachable by keyboard, no sideways scroll at 390 px, both themes
15
- * Every wait polls the page; no fixed sleep stands in for a state. */
16
- const fs = require('fs');
17
- const os = require('os');
18
- const path = require('path');
19
- const { spawn, spawnSync } = require('child_process');
20
- const { findBrowser } = require('./lib/find-browser');
21
- const T = require('./test-run').configure({ name: 'briefing-premium-products' });
22
-
23
- const BASE = T.BASE;
24
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
25
- /* The product picker is the chip by Good morning (#hmPick, pm/cozy-pick.js; canvas XhpA1Desk): every workspace with a tick box, All products,
26
- * Add a product; the ticks apply when the list (#ppMenu) closes. More > Products is gone. The rows are Home's Needs-you rows. */
27
- const until = async (fn, ms = 15000, step = 150) => { const t0 = Date.now(); for (;;) { let v = null; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
28
- const results = [];
29
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 300) : ''}`); };
30
- let srv = null; let browser = null;
31
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'pmos-bpp-'));
32
- const finish = async (code) => {
33
- if (browser) await browser.close().catch(() => {});
34
- if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
35
- T.killTmux();
36
- try { fs.rmSync(tmp, { recursive: true, force: true }); } catch { /* left for the OS */ }
37
- const bad = results.filter((x) => !x.cond).length;
38
- console.log(`\n${results.length - bad}/${results.length} briefing-premium-products assertions passed`);
39
- process.exit(code !== undefined ? code : (bad ? 1 : 0));
40
- };
41
- process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
42
-
43
- const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
44
- const product = (name, cond) => {
45
- const root = path.join(tmp, name);
46
- fs.mkdirSync(path.join(root, 'planning', 'okrs'), { recursive: true });
47
- fs.writeFileSync(path.join(root, 'AGENTS.md'), '# a\n');
48
- fs.writeFileSync(path.join(root, 'pm-decisions.md'), '# decisions\n');
49
- fs.writeFileSync(path.join(root, 'planning', 'okrs', 'kill-conditions.md'), `| KC9 | ${cond} | stalls by **2020-01-01** | monthly | pauses merges |\n`);
50
- sh(root, ['init', '-q', '-b', 'main']); sh(root, ['config', 'user.email', 't@t']); sh(root, ['config', 'user.name', 't']); sh(root, ['add', '-A']); sh(root, ['commit', '-q', '-m', 'initial']);
51
- return root;
52
- };
53
-
54
- (async () => {
55
- const exe = findBrowser();
56
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the briefing-premium-products suite cannot run'); return finish(1); }
57
- let chromium;
58
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed — the briefing-premium-products suite cannot run'); return finish(1); }
59
- const fakeBin = path.join(tmp, 'bin'); fs.mkdirSync(fakeBin);
60
- fs.writeFileSync(path.join(fakeBin, 'claude'), '#!/bin/sh\nsleep 30\n', { mode: 0o755 });
61
- const rootA = product('idpf-repo', 'IDPF condition'), rootB = product('micro-repo', 'Microsites condition');
62
- srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PATH: fakeBin + path.delimiter + process.env.PATH }) });
63
- await T.waitForServer(BASE);
64
- const json = async (m, p, b, h) => { const res = await fetch(BASE + p, { method: m, headers: { 'content-type': 'application/json', ...(h || {}) }, body: b ? JSON.stringify(b) : undefined }); let j = null; try { j = await res.json(); } catch { /* not json */ } return { status: res.status, body: j }; };
65
- const wA = (await json('POST', '/api/workspaces', { root: rootA, name: 'IDPF', focus: false }, await T.pressHeaders(BASE))).body.workspace;
66
- const wB = (await json('POST', '/api/workspaces', { root: rootB, name: 'microsites', focus: false }, await T.pressHeaders(BASE))).body.workspace;
67
- const all = (await json('GET', '/api/workspaces')).body.workspaces;
68
- const home = all.find((w) => w.home);
69
- ok('P0 the server has a home workspace and the two products', !!home && !!wA && !!wB, JSON.stringify(all.map((w) => [w.name, w.home])));
70
- const model = async () => { const r = await json('GET', '/api/briefing-premium'); return r.status === 200 && r.body.model && !r.body.model.pending ? r.body : null; };
71
- const m0 = await until(model, 90000);
72
- ok('P1 by default only the two products are read: two decide rows, none from the home workspace', m0 && m0.model.list.rows.length === 2 && m0.model.list.rows.every((r) => r.kind === 'decision' && ['IDPF', 'microsites'].includes(r.product)) && m0.model.products.available.find((a) => a.home).on === false, JSON.stringify(m0 && m0.model.list.rows.map((r) => [r.key, r.product])));
73
- ok('P1 the two rows share an id and differ in workspace', m0 && new Set(m0.model.list.rows.map((r) => r.key)).size === 2 && m0.model.list.rows.every((r) => /^decision:KC9:/.test(r.key)));
74
-
75
- browser = await chromium.launch({ executablePath: exe });
76
- { /* this suite checks the records-only rows: the console's Needs you read (premium-brief.js), which replaces them when it answers, is off */
77
- const nc = browser.newContext.bind(browser);
78
- browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
79
- }
80
- const open = async ({ w = 1280, h = 900, theme = 'light', q = '' } = {}) => {
81
- const ctx = await browser.newContext({ viewport: { width: w, height: h } });
82
- await ctx.addInitScript((t) => { try { localStorage.setItem('pmos.premium.theme', t); } catch { /* none */ } }, theme);
83
- const page = await ctx.newPage(); const errors = [];
84
- page.on('pageerror', (e) => errors.push(String(e.message || e)));
85
- await page.goto(BASE + '/premium.html' + q, { waitUntil: 'domcontentloaded' });
86
- await page.waitForSelector('#hmList .hm-pg', { state: 'attached', timeout: 30000 }); // a group of the one list (premium-uncovered-features)
87
- return { ctx, page, errors };
88
- };
89
- // the picker: the chip by Good morning opens the list; ticks reads its tick boxes, close presses Escape (the pick applies then)
90
- // six-place navigation: on a desktop the product choice shows on Work and Goals only, so Today's chip is hidden there. Today still reads the
91
- // one shared pick, and this suite checks that through the same picker: it shows the hidden chip for the test only.
92
- const pick = async (page) => { await page.addStyleTag({ content: 'body.cz-railon.cz-home #hmPick { display: inline-flex !important; }' }); if (!(await page.$('#ppMenu'))) { await page.waitForSelector('#hmPick', { timeout: 20000 }); await page.click('#hmPick'); await page.waitForSelector('#ppMenu', { timeout: 10000 }); } };
93
- const ticks = (page) => page.$$eval('#ppMenu [data-pp]', (els) => els.map((e) => e.dataset.pp + ':' + e.getAttribute('aria-checked')));
94
- const tick = (page, ws) => page.click(`#ppMenu [data-pp="${ws}"]`);
95
- const setting = async () => (await json('GET', '/api/settings')).body.settings.find((x) => x.key === 'ws.briefing.include');
96
- // premium-uncovered-features (canvas HmProducts): another product is a closed group of the one list ("IDPF · 1 your turn"); open it to see its rows
97
- const openGroups = (page) => page.evaluate(() => { document.querySelectorAll('#hmList [data-hm-pg][aria-expanded="false"]').forEach((b) => b.click()); });
98
- const rowsOf = async (page) => { await openGroups(page).catch(() => {}); return rowsOf0(page).then(async (a) => a.concat(await pillRows(page))); };
99
- // a next step of an initiative sits in the pill on its row (batch 12 item 6): open each pill in turn and read the rows behind it
100
- const pillRows = (page) => page.evaluate(async () => {
101
- const out = [], wait = () => new Promise((r) => setTimeout(r, 60));
102
- for (const id of [...document.querySelectorAll('#hmList [data-hm-ses]')].map((b) => b.dataset.hmSes)) {
103
- const b = document.querySelector(`#hmList [data-hm-ses="${CSS.escape(id)}"]`); if (!b) continue;
104
- const tag = (b.closest('section.hm-pg') || b).getAttribute('aria-label') || '';
105
- b.click(); await wait();
106
- for (const e of document.querySelectorAll('#hmList .hv-spp .hm-r[data-id^="n:decision:"]')) if (!out.some((x) => x.key === e.dataset.id.slice(2))) out.push({ key: e.dataset.id.slice(2), tag, title: e.querySelector('.hm-rt b').textContent, ses: id });
107
- const c = document.querySelector(`#hmList [data-hm-ses="${CSS.escape(id)}"]`); if (c && c.getAttribute('aria-expanded') === 'true') { c.click(); await wait(); }
108
- }
109
- return out;
110
- });
111
- const rowsOf0 = (page) => page.$$eval('#hmList .hm-r[data-id^="n:decision:"]:not(.hv-spp .hm-r)', (els) => els.map((e) => ({ key: e.dataset.id.slice(2), tag: (e.closest('section.hm-pg') || e).getAttribute('aria-label') || '', title: e.querySelector('.hm-rt b').textContent })));
112
-
113
- {
114
- const { ctx, page, errors } = await open();
115
- await until(async () => (await rowsOf(page)).length === 2, 20000);
116
- const rows = await rowsOf(page);
117
- ok('P6 each row sits in its product\'s group', rows.length === 2 && rows.map((r) => r.tag).sort().join() === 'IDPF,microsites', JSON.stringify(rows));
118
- await pick(page);
119
- const t0 = await ticks(page);
120
- ok('P2 the chip lists every workspace, the home one included: All products, then each with its tick, then Add a product', t0.length === 4 && t0[0].startsWith('*:') && t0.includes(wA.id + ':true') && t0.includes(wB.id + ':true') && t0.some((x) => x.startsWith(home.id + ':')) && !!(await page.$('#ppMenu [data-pp-add]')), JSON.stringify(t0));
121
- const hs = await page.$$eval('#ppMenu button', (els) => els.map((e) => Math.round(e.getBoundingClientRect().height)));
122
- ok('P13 each row of the list is at least 44 px high', hs.every((h) => h >= 44), JSON.stringify(hs));
123
- // untick the home workspace (it shows as Home's own board) and microsites: the list stays open, the pick applies when it closes
124
- if (t0.includes(home.id + ':true')) await tick(page, home.id);
125
- await tick(page, wB.id);
126
- ok('P2 a press ticks or unticks and the list stays open', !!(await page.$('#ppMenu')) && (await ticks(page)).includes(wB.id + ':false'));
127
- await page.keyboard.press('Escape');
128
- ok('P4 an unticked product\'s row leaves the list', await until(async () => { const r = await rowsOf(page); return r.length === 1 && r[0].tag === 'IDPF'; }, 20000));
129
- const saved = await setting();
130
- ok('P3 the choice is saved as a list of workspace ids', saved && JSON.stringify(saved.value) === JSON.stringify([wA.id]), JSON.stringify(saved));
131
- ok('P2 the chip shows the ticked product\'s tile, its name in words', /IDPF$/.test(await page.getAttribute('#hmPick', 'aria-label')) && (await page.$$('#hmPick .ppk-t')).length === 1, await page.getAttribute('#hmPick', 'aria-label'));
132
- // the keyboard: Enter opens the list, the arrows move, Enter ticks, Escape applies
133
- await page.focus('#hmPick'); await page.keyboard.press('Enter'); await page.waitForSelector('#ppMenu');
134
- ok('P13 keyboard: Enter on the chip opens the list on its first row', await page.evaluate(() => document.activeElement && document.activeElement.dataset.pp === '*'));
135
- await page.focus(`#ppMenu [data-pp="${wB.id}"]`); await page.keyboard.press('Enter');
136
- ok('P13 keyboard: Enter on a row ticks it', (await ticks(page)).includes(wB.id + ':true'));
137
- await page.keyboard.press('ArrowDown');
138
- ok('P13 keyboard: the arrows move in the list', await page.evaluate(() => !!document.activeElement && !!document.activeElement.closest('#ppMenu')));
139
- await page.keyboard.press('Escape');
140
- ok('P13 keyboard: Escape closes the list and applies the ticks', !(await page.$('#ppMenu')) && !!(await until(async () => (await rowsOf(page)).length === 2, 20000)));
141
- ok('P3 the default ticks save the default: the saved choice is gone', (await until(async () => ((await setting()) || {}).changed === false, 10000)), JSON.stringify(await setting()));
142
- // the page reads the saved default back before the list opens again: a list opened on the pick before it would tick from stale state
143
- await until(async () => /all 3$/.test(await page.getAttribute('#hmPick', 'aria-label') || ''), 20000);
144
- await pick(page); if ((await ticks(page)).includes(home.id + ':true')) await tick(page, home.id); await tick(page, wB.id); await page.keyboard.press('Escape');
145
- await until(async () => JSON.stringify(((await setting()) || {}).value) === JSON.stringify([wA.id]), 10000);
146
- ok('P3 the choice survives a reload', await (async () => { await page.reload({ waitUntil: 'domcontentloaded' }); return until(async () => { const r = await rowsOf(page); return r.length === 1 && r[0].tag === 'IDPF' ? 1 : 0; }, 20000); })());
147
- // All products: every workspace, the home one included, is read; saved as '*' so a workspace added later joins
148
- await pick(page); await tick(page, '*'); await page.keyboard.press('Escape');
149
- ok('P3 All products saves every workspace (*) and the home one is read', !!(await until(async () => { const st = await setting(); const m = await json('GET', '/api/briefing-premium'); return st && JSON.stringify(st.value) === '["*"]' && m.body && m.body.model && m.body.model.products.available.every((a) => a.on); }, 20000)), JSON.stringify(await setting()));
150
- ok('P3 with every one ticked the chip says All', /^All/.test(await page.textContent('#hmPick')) && /all 3$/.test(await page.getAttribute('#hmPick', 'aria-label')), await page.getAttribute('#hmPick', 'aria-label'));
151
- // back to the default: tick exactly the two products
152
- await pick(page); await tick(page, home.id); await page.keyboard.press('Escape');
153
- ok('P3 ticking the default again reads every product but the home one, and the saved choice is gone', await until(async () => (await rowsOf(page)).length === 2 && ((await setting()) || {}).changed === false, 20000), JSON.stringify(await setting()));
154
- ok('no page error', errors.length === 0, errors.join(' | '));
155
- await ctx.close();
156
- }
157
-
158
- {
159
- // P9 decide a row of IDPF, from the page
160
- const { ctx, page } = await open();
161
- await until(async () => (await rowsOf(page)).length === 2, 20000);
162
- const row = (await rowsOf(page)).find((r) => r.tag === 'IDPF'), key = row.key;
163
- if (row.ses) await page.click(`#hmList [data-hm-ses="${row.ses}"]`); // the row sits behind its initiative's pill (batch 12 item 6)
164
- await page.click(`#hmList [data-hm-sel="n:${key}"]`);
165
- await page.waitForSelector('#czViewer [data-nv-opt]'); // the decision in the Viewer (batch 18 item 2-A, OvA2Decide)
166
- await page.click('#czViewer [data-nv-opt="extend"]');
167
- await page.fill('#nvWhy', 'IDPF moves the date.');
168
- await page.click('#czViewer [data-nv-rec]');
169
- ok('P9 the press is recorded and the IDPF row leaves, the microsites row stays', await until(async () => { const r = await rowsOf(page); return r.length === 1 && r[0].tag === 'microsites' ? 1 : 0; }, 20000), JSON.stringify(await rowsOf(page)));
170
- const dA = fs.readFileSync(path.join(rootA, 'pm-decisions.md'), 'utf8'), dB = fs.readFileSync(path.join(rootB, 'pm-decisions.md'), 'utf8');
171
- ok('P9 the decision is in IDPF\'s journal and not in the other product\'s or the home one\'s', /KC9/.test(dA) && /IDPF moves the date/.test(dA) && !/KC9/.test(dB) && !/IDPF moves the date/.test(fs.readFileSync(path.join(home.root, 'pm-decisions.md'), 'utf8')));
172
- await ctx.close();
173
- }
174
-
175
- {
176
- // P9/P10 refusals and the agent, over the real routes
177
- const html = await (await fetch(BASE + '/')).text();
178
- const nonce = (/<meta name="pmos-nonce" content="([^"]*)"/.exec(html) || [])[1] || '';
179
- const press = { Origin: BASE, ...(nonce ? { 'x-pmos-nonce': nonce } : {}) };
180
- const homeKey = 'decision:KC9:' + home.id;
181
- const r1 = await json('POST', '/api/briefing-premium/decide', { key: homeKey, choice: 'extend', why: 'Not included.' }, press);
182
- ok('P9 a row of a workspace that is not included is refused', r1.status === 400 && /not included/.test(r1.body.error), JSON.stringify(r1));
183
- const r2 = await json('POST', '/api/briefing-premium/decide', { key: 'decision:KC9:w-nope', choice: 'extend', why: 'Unknown.' }, press);
184
- ok('P9 a row of a workspace that is not registered is refused', r2.status === 400 && /not registered/.test(r2.body.error), JSON.stringify(r2));
185
- const r3 = await json('POST', '/api/briefing-premium/ask', { key: 'decision:KC9:' + wB.id, text: 'Why is this on my list?' }, press);
186
- ok('P10 a message about a merged row starts a Claude Code session in that product', r3.status === 200 && r3.body.ok && r3.body.started === true && ((await json('GET', '/api/sessions')).body.sessions.find((s) => s.id === r3.body.session) || {}).ws === wB.id, JSON.stringify(r3));
187
- const r4 = await json('POST', '/api/briefing-premium/ask', { key: 'decision:KC9:' + wA.id, text: 'Why?' }, press);
188
- ok('P10 a row that is no longer on the page is refused', r4.status === 404, JSON.stringify(r4));
189
- }
190
-
191
- for (const [w, th] of [[390, 'light'], [390, 'dark'], [1280, 'dark']]) {
192
- const { ctx, page } = await open({ w, h: 800, theme: th });
193
- await until(async () => (await rowsOf(page)).length >= 1, 20000);
194
- await pick(page);
195
- const o = await page.evaluate(() => ({ sw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth, chip: Math.round(document.querySelector('#hmPick').getBoundingClientRect().height), sheet: document.querySelector('#ppMenu').classList.contains('sheet'), menu: (() => { const r = document.querySelector('#ppMenu').getBoundingClientRect(); return { l: Math.round(r.left), r: Math.round(r.right) }; })() }));
196
- ok(`P13 at ${w} px, ${th}: no sideways scroll with the list open, the list stays on screen (a sheet on a phone), and the chip is 44 px`, o.sw <= o.cw && o.menu.l >= 0 && o.menu.r <= o.cw && o.sheet === (w < 760) && (w >= 760 || o.chip >= 44), JSON.stringify(o));
197
- await ctx.close();
198
- }
199
-
200
- {
201
- // the narrowed view (P12): the one-workspace page, with a way back
202
- const before = JSON.stringify(((await setting()) || {}).value);
203
- const { ctx, page } = await open({ q: '?ws=' + encodeURIComponent(wB.id) });
204
- await page.waitForSelector('#hmPick', { state: 'attached', timeout: 20000 });
205
- ok('P12 ?ws= shows that one workspace on the chip and leaves the saved pick alone', /Microsites$/.test(await page.getAttribute('#hmPick', 'aria-label')) && JSON.stringify(((await setting()) || {}).value) === before, await page.getAttribute('#hmPick', 'aria-label'));
206
- await ctx.close();
207
- }
208
- return finish();
209
- })().catch((e) => { console.error(e); finish(1); });