create-pmos 0.692.0 → 0.694.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 (110) hide show
  1. package/package.json +22 -16
  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 +21 -2
  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/home.md +2 -2
  17. package/workspace/guide/layout.md +2 -2
  18. package/workspace/guide/settings-and-switches.md +0 -1
  19. package/workspace/impact-screens-test.js +2 -47
  20. package/workspace/ini-workflow-test.js +1 -1
  21. package/workspace/lib/board-grill.js +17 -24
  22. package/workspace/lib/discovery-questions.js +36 -0
  23. package/workspace/lib/routes-board-grill.js +31 -3
  24. package/workspace/live-pill-round-test.js +6 -18
  25. package/workspace/milestone-suggest-test.js +4 -28
  26. package/workspace/news-viewers-test.js +3 -29
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/premium-board-actions-test.js +3 -3
  30. package/workspace/premium-briefing-depth-test.js +4 -4
  31. package/workspace/premium-chat-attach-test.js +3 -2
  32. package/workspace/premium-chat-chart-tab-test.js +8 -7
  33. package/workspace/premium-chat-context-test.js +3 -1
  34. package/workspace/premium-chat-goal-view-test.js +3 -1
  35. package/workspace/premium-chat-line-test.js +8 -6
  36. package/workspace/premium-chat-report-tab-test.js +13 -5
  37. package/workspace/premium-chat-term-test.js +2 -2
  38. package/workspace/premium-chat-viewer-test.js +10 -16
  39. package/workspace/premium-core-doc-issue-test.js +7 -2
  40. package/workspace/premium-discuss-landing-test.js +9 -5
  41. package/workspace/premium-html-viewer-test.js +7 -3
  42. package/workspace/premium-link-suggest-test.js +6 -10
  43. package/workspace/premium-phone-card-test.js +2 -2
  44. package/workspace/premium-viewer-download-test.js +1 -1
  45. package/workspace/premium-viewer-flicker-test.js +1 -1
  46. package/workspace/premium-viewer-share-test.js +2 -2
  47. package/workspace/premium-viewer-test.js +1 -1
  48. package/workspace/premium-vw-cal-test.js +1 -1
  49. package/workspace/premium-vw-copy-test.js +3 -3
  50. package/workspace/premium-vw-doc-test.js +1 -1
  51. package/workspace/premium-vw-item-test.js +1 -1
  52. package/workspace/premium-work-depth-test.js +2 -2
  53. package/workspace/program-charter-test.js +1 -12
  54. package/workspace/program-leave-test.js +2 -2
  55. package/workspace/program-order-test.js +3 -65
  56. package/workspace/project-onboard-flow-test.js +5 -5
  57. package/workspace/public/pm/bd-asks.js +6 -5
  58. package/workspace/public/pm/cozy-home.css +0 -6
  59. package/workspace/public/pm/cozy-panels.js +2 -6
  60. package/workspace/public/pm/cozy-popup.css +1 -0
  61. package/workspace/public/pm/cozy-popup.js +15 -2
  62. package/workspace/public/pm/cozy-today-page.css +1 -1
  63. package/workspace/public/pm/cozy-today.css +0 -14
  64. package/workspace/public/pm/cozy-viewer.js +14 -38
  65. package/workspace/public/pm/goal-chat.js +2 -2
  66. package/workspace/public/pm/home-app.js +8 -67
  67. package/workspace/public/pm/home-chat.js +1 -1
  68. package/workspace/public/pm/home-ses-name.js +3 -2
  69. package/workspace/public/pm/home-today.js +4 -18
  70. package/workspace/public/pm/ini-view-model.js +2 -2
  71. package/workspace/public/pm/premium-board.js +1 -1
  72. package/workspace/public/premium-intelligence.html +1 -1
  73. package/workspace/public/premium-viewer.html +1 -1
  74. package/workspace/public/premium-workflows.html +1 -1
  75. package/workspace/ready-dash-ui-test.js +1 -1
  76. package/workspace/rename-test.js +2 -2
  77. package/workspace/server.js +11 -12
  78. package/workspace/session-names-test.js +34 -56
  79. package/workspace/sort-order-test.js +2 -71
  80. package/workspace/split-merge-ui-test.js +1 -1
  81. package/workspace/stage-card-tasks-test.js +1 -1
  82. package/workspace/stage-card-test.js +1 -1
  83. package/workspace/task-card-test.js +1 -1
  84. package/workspace/task-press-test.js +1 -1
  85. package/workspace/task-views-test.js +1 -1
  86. package/workspace/test-lists/adler-seasons-art.json +3 -6
  87. package/workspace/test-lists/batch18-asks.json +1 -1
  88. package/workspace/test-lists/briefing-premium.json +1 -11
  89. package/workspace/test-lists/discovery-three-questions.json +5 -0
  90. package/workspace/test-lists/premium-agreed-viewer.json +1 -1
  91. package/workspace/test-run.js +0 -2
  92. package/workspace/test-timings.json +0 -4
  93. package/workspace/tk-tasks-test.js +3 -17
  94. package/workspace/viewer-trail-test.js +2 -2
  95. package/workspace/workflows-setup-test.js +4 -2
  96. package/workspace/adler-seasons-art-test.js +0 -116
  97. package/workspace/briefing-premium-initiative-test.js +0 -289
  98. package/workspace/briefing-premium-products-test.js +0 -209
  99. package/workspace/briefing-premium-sources-test.js +0 -250
  100. package/workspace/briefing-premium-test.js +0 -282
  101. package/workspace/home-other-product-test.js +0 -197
  102. package/workspace/home-pill-test.js +0 -138
  103. package/workspace/home-railcard-test.js +0 -196
  104. package/workspace/home-rows-test.js +0 -389
  105. package/workspace/panels-test.js +0 -454
  106. package/workspace/public/premium.html +0 -48
  107. package/workspace/test-lists/batch18-panels.json +0 -9
  108. package/workspace/test-lists/home-railcard.json +0 -9
  109. package/workspace/test-lists/home-sessions-pill.json +0 -6
  110. package/workspace/test-lists/viewer-home-rows.json +0 -9
@@ -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); });
@@ -1,250 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* briefing-premium-sources-test.js — mail, Jira and Confluence on the premium Briefing (initiative briefing-premium-sources; planning/prd/briefing-premium-sources-prd.md S1 to S11).
4
- * The real server with one product repository and a made-up morning brief written to <state>/briefs/<today>.json. Nothing here touches the PM's real briefs.
5
- * S1/S8 no brief for today: the header says so S2/S5 the rows, each tagged Across products (the brief names no included initiative)
6
- * S3 the dialog opens an https link and records nothing S7 the digests in Today S9 the writes refuse a source key; the agent answers
7
- * S11 the source row and the digest are drawn in the Agreed design's tokens at 1280 and 390 px, light and dark; no sideways scroll
8
- * (re-pointed by premium-agreed-design: rows are Home's Needs-you rows; by premium-uncovered-features: the digests are in New for you and
9
- * the read lines in Sources; by feedback batch 16 item 5: New for you opens from Your day's fold, and Sources is Settings › Connectors)
10
- * Every wait polls the page; no fixed sleep stands in for a state. */
11
- const fs = require('fs');
12
- const os = require('os');
13
- const path = require('path');
14
- const { spawn, spawnSync } = require('child_process');
15
- const { findBrowser } = require('./lib/find-browser');
16
- const T = require('./test-run').configure({ name: 'briefing-premium-sources' });
17
-
18
- const BASE = T.BASE;
19
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
20
- /* premium-agreed-design: the Briefing's ranked list, its dialog, its Today timeline and its cards are gone. A source row is a Needs-you row on
21
- * Home (its hint leads with the product, then the source and sender, then the prepared line) and opens in the Viewer.
22
- * premium-uncovered-features: Around you is gone. Today's digests are in New for you, and the read lines and the background line are in
23
- * Sources; both open from the place menu (cozy-nav.js). */
24
- /* feedback batch 16 item 5: New for you is a fold of Your day (its digests row opens the whole list), and Sources is Settings › Connectors. */
25
- const moreItem = async (pg, label, sel) => {
26
- if (await pg.isVisible('#czViewer')) { await pg.keyboard.press('Escape'); }
27
- if (label === 'Sources') {
28
- if (await pg.isVisible('#czFab')) await pg.click('#czFab'); await pg.click('#czMenu [data-cz-settings]'); await pg.waitForSelector('#evSettings:not([hidden])');
29
- if (!(await pg.$('#evSettings [data-ev-sec="connectors"][aria-current="page"]'))) await pg.click('#evSettings [data-ev-sec="connectors"]');
30
- await pg.waitForSelector('#evSettings ' + sel, { timeout: 15000 });
31
- return;
32
- }
33
- await pg.click('#hmList [data-hm-day]'); await pg.waitForSelector('#czViewer [data-yd="news-all"]', { timeout: 15000 });
34
- await pg.click('#czViewer [data-yd="news-all"] >> nth=-1');
35
- await pg.waitForSelector('#czViewer ' + sel, { timeout: 15000 });
36
- };
37
- const srcRowsOf = (pg) => pg.$$eval('#hmList .hm-r[data-id^="n:src:"]', (els) => els.map((e) => ({ key: e.dataset.id.slice(2), title: e.querySelector('.hm-rt b').textContent, line2: (e.querySelector('.hm-rt em') || {}).textContent || (e.querySelector('.hm-rm') || { title: '' }).title || '' }))); // Home A + C (HvAC): a row is one line; the second line is the row's title (its tooltip)
38
- const allNeeds = async (pg) => { for (let i = 0; i < 20; i++) { const t = await pg.textContent('#hmList [data-hm-allneeds]').catch(() => null); if (t === null || !/Show$/.test(t.trim())) return; await pg.click('#hmList [data-hm-allneeds]', { timeout: 2000 }).catch(() => {}); await sleep(150); } };
39
- 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); } };
40
- const results = [];
41
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 300) : ''}`); };
42
- let srv = null; let browser = null;
43
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'pmos-bps-'));
44
- const finish = async (code) => {
45
- if (browser) await browser.close().catch(() => {});
46
- if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
47
- T.killTmux();
48
- try { fs.rmSync(tmp, { recursive: true, force: true }); } catch { /* left for the OS */ }
49
- const bad = results.filter((x) => !x.cond).length;
50
- console.log(`\n${results.length - bad}/${results.length} briefing-premium-sources assertions passed`);
51
- process.exit(code !== undefined ? code : (bad ? 1 : 0));
52
- };
53
- process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
54
-
55
- const pad = (n) => String(n).padStart(2, '0');
56
- const TODAY = (() => { const d = new Date(); return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; })();
57
- const item = (id, o = {}) => ({ id, title: 'Item ' + id, why_now: 'Why ' + id, evidence: '', source: 'mail', initiative_id: null, owner: 'pm', effort: 'minutes', confidence: 0.9, worth_asking: false, kind: 'you', ...o });
58
- const BRIEF = {
59
- date: TODAY, generated_at: new Date(Date.now() - 60000).toISOString(), sources: { mail: 'read', jira: 'read', confluence: 'read', slack: 'read' }, calendar: [],
60
- priorities: [
61
- item('aaaaaaaaaaa1', { title: 'Confirm the Thursday review', who: 'Anna Lee', verb: 'reply', todo: 'Confirm Thursday', link: 'https://mail.example/t/1', ask: 'Can you confirm?' }),
62
- item('aaaaaaaaaaa2', { title: 'Sign off the vendor terms', source: 'confluence', who: 'Budi Santoso', verb: 'sign-off', link: 'https://wiki.example/p/2' }),
63
- item('aaaaaaaaaaa3', { title: 'Look at the failing ticket', source: 'jira', who: 'Chen', verb: 'review', todo: 'Check the repro', link: 'https://jira.example/browse/AB-3' }),
64
- ],
65
- worth_asking: [item('bbbbbbbbbbb1', { title: 'A thread that may be for you', who: 'Dewi', confidence: 0.3, worth_asking: true })],
66
- digests: [{ source: 'slack', name: '#launch', link: 'https://slack.example/c/1', decisions: ['Ship on Friday'], open: ['Who owns QA'], goals: [] }],
67
- places: [], resolved: [],
68
- };
69
- const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
70
-
71
- (async () => {
72
- const exe = findBrowser();
73
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the briefing-premium-sources suite cannot run'); return finish(1); }
74
- let chromium;
75
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed — the briefing-premium-sources suite cannot run'); return finish(1); }
76
- const fakeBin = path.join(tmp, 'bin'); fs.mkdirSync(fakeBin);
77
- fs.writeFileSync(path.join(fakeBin, 'claude'), '#!/bin/sh\nsleep 30\n', { mode: 0o755 });
78
- const root = path.join(tmp, 'idpf-repo');
79
- fs.mkdirSync(root, { recursive: true }); fs.writeFileSync(path.join(root, 'AGENTS.md'), '# a\n');
80
- 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']);
81
- 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 }) });
82
- await T.waitForServer(BASE);
83
- 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 { j = null; } return { status: res.status, body: j }; };
84
- const added = await json('POST', '/api/workspaces', { root, name: 'IDPF', focus: false }, await T.pressHeaders(BASE));
85
- ok('S0 the product is registered', !!(added.body && added.body.workspace));
86
- 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; };
87
- const m0 = await until(model, 90000);
88
- ok('S1 with no brief for today there are no source rows and the header says so', m0 && !m0.model.list.rows.some((r) => r.kind === 'source') && /no morning brief for today/.test(m0.model.header.text), m0 && m0.model.header.text);
89
-
90
- // the brief is written where the workspace reads it: <state>/briefs/<today>.json
91
- fs.mkdirSync(path.join(T.STATE_DIR, 'briefs'), { recursive: true });
92
- fs.writeFileSync(path.join(T.STATE_DIR, 'briefs', TODAY + '.json'), JSON.stringify(BRIEF));
93
- const m1 = (await json('GET', '/api/briefing-premium')).body.model;
94
- const srcRows = m1.list.rows.filter((r) => r.kind === 'source');
95
- ok('S2 four rows come from the brief: three priorities and one worth asking, in the brief\'s order', srcRows.length === 4 && srcRows[0].title === 'Confirm the Thursday review' && srcRows[3].title === 'A thread that may be for you', JSON.stringify(srcRows.map((r) => r.title)));
96
- ok('S5 every row reads Across products, because the brief names no initiative of an included product', srcRows.every((r) => r.product === 'Across products'));
97
- ok('S8 the header no longer says there is no brief', !/no morning brief/.test(m1.header.text), m1.header.text);
98
-
99
- browser = await chromium.launch({ executablePath: exe });
100
- { /* this suite checks the records-only rows: the console's Needs you read (premium-brief.js), which replaces them when it answers, is off */
101
- const nc = browser.newContext.bind(browser);
102
- 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; };
103
- }
104
- const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
105
- const ctx = await browser.newContext({ viewport: { width: w, height: h } });
106
- const page = await ctx.newPage(); const errors = [];
107
- page.on('pageerror', (e) => errors.push(String(e.message || e)));
108
- // the greeting is a morning card (the evening shows the day's recap instead): the page reads a fixed morning clock
109
- const am = new Date(); am.setHours(10, 0, 0, 0); await page.clock.setFixedTime(am);
110
- await page.goto(BASE + '/premium.html?theme=' + theme, { waitUntil: 'domcontentloaded' });
111
- // the list is drawn: on a phone "Not in an initiative" starts folded (Home A + C, HvAC), so its folded line stands for its rows there
112
- await page.waitForSelector(w > 760 ? '#hmList .hm-r[data-id^="n:src:"]' : '#hmList .hv-lh', { state: 'attached', timeout: 60000 });
113
- return { ctx, page, errors };
114
- };
115
-
116
- {
117
- const { ctx, page, errors } = await open();
118
- await allNeeds(page);
119
- const rows = await srcRowsOf(page);
120
- ok('S2 the first row is its title, with the product, the source and sender · the verb and the prepared line as its detail', rows[0] && rows[0].title === 'Confirm the Thursday review' && rows[0].line2 === 'Across products · Mail · Anna Lee · Reply: Confirm Thursday', JSON.stringify(rows[0]));
121
- ok('S2 a row with a verb and no prepared line shows the verb alone', rows[1] && /Confluence · Budi Santoso · Sign off$/.test(rows[1].line2), JSON.stringify(rows[1]));
122
- // premium-uncovered-features (canvas HmMyWork): no Needs you group; the greeting counts the next steps that are yours, the source rows among them
123
- // chief-of-staff delete list: no "N are yours" line; the source rows are still among the next steps
124
- const allRows = await page.$$eval('#hmList .hm-r[data-id^="n:"]', (els) => els.length);
125
- ok('S6 the four source rows are among the next steps of the list', rows.length === 4 && allRows >= 4, String(allRows));
126
- await page.click(`#hmList [data-hm-sel="n:${rows[0].key}"]`);
127
- await page.waitForSelector('#czViewer #srcLink');
128
- const link = await page.$eval('#czViewer #srcLink', (a) => ({ href: a.href, target: a.target, rel: a.rel, h: Math.round(a.getBoundingClientRect().height) }));
129
- ok('S3 the Viewer opens the item\'s https link in a new tab', link.href === 'https://mail.example/t/1' && link.target === '_blank' && /noopener/.test(link.rel), JSON.stringify(link));
130
- ok('S2 the row\'s why now is in its Viewer card', /Why now:\s*Why aaaaaaaaaaa1/.test(await page.textContent('#czViewer')), await page.textContent('#czViewer'));
131
- ok('S3 the card offers nothing that records or sends', (await page.$('#czViewer [data-hv-rec]')) === null && (await page.$('#czViewer [data-hv-later], #czViewer [data-hv-until]')) === null && (await page.$('#czViewer [data-hv-opt]')) === null);
132
- ok('S11 the link is the shell\'s primary: at least 40 px high on a desk (44 on a phone or a touch screen, cozy-vw-shell.css)', link.h >= 40, String(link.h));
133
- await page.keyboard.press('Escape');
134
- await moreItem(page, 'New for you', '#aroundDig');
135
- const dig = await page.$eval('#czViewer #aroundDig', (e) => ({ h: e.querySelector('.ev-lbl').textContent, t: e.textContent, href: (e.querySelector('a.srcLink') || {}).href || '' }));
136
- ok('S7 New for you lists Digests with their count', dig.h === 'Digests 1', dig.h);
137
- ok('S7 the digest holds its lines and its link', /Decision: Ship on Friday/.test(dig.t) && /Open: Who owns QA/.test(dig.t) && dig.href === 'https://slack.example/c/1', JSON.stringify(dig).slice(0, 300));
138
- ok('no page error', errors.length === 0, errors.join(' | '));
139
- await ctx.close();
140
- }
141
-
142
- { /* harness-health: the background line at the top of Settings › Connectors (was Sources), and the chip's dot takes its level */
143
- const api = (await json('GET', '/api/sources')).body;
144
- const h = api && api.health;
145
- ok('H1 GET /api/sources carries the background health: a level, a line and the issues', h && ['ok', 'warn', 'bad'].includes(h.level) && typeof h.line === 'string' && h.line.length > 10 && Array.isArray(h.issues), JSON.stringify(h));
146
- const shot = process.env.PMOS_SHOT_DIR || '';
147
- for (const theme of ['light', 'dark']) {
148
- const { ctx, page, errors } = await open({ theme, w: 1280, h: 844 }); // Connectors are in the computer's Settings: a phone's Settings is one screen (phone design, Ph2_more)
149
- // premium-agreed-design (shared foundation): the design draws no Sources chip, so there is no dot on the page; the level is still read (GET /api/sources)
150
- const dot = await page.evaluate(() => (document.querySelector('#srcDot, #srcChip') ? 'drawn' : 'none'));
151
- await moreItem(page, 'Sources', '.ev-reads');
152
- // batch 28 item 1 (canvas CnA): one list, trouble first. The background issues are rows of the list (trouble rows, the amber dot);
153
- // all well is silence: no background line, no Today/Needs you footer, no count on the Connectors tab
154
- let list = null;
155
- for (let k = 0; k < 25 && !(list && list.w > 0); k++) {
156
- if (k) await page.waitForTimeout(200);
157
- list = await page.evaluate(() => { const r = document.querySelector('#evSettings .ev-reads'); const rows = [...document.querySelectorAll('#evSettings .ev-reads .ev-fr')];
158
- return r ? { w: Math.round(r.getBoundingClientRect().width), sw: document.documentElement.scrollWidth, rows: rows.length, trouble: rows.filter((x) => x.classList.contains('ev-fr-t')).length,
159
- firstQuiet: rows.findIndex((x) => !x.classList.contains('ev-fr-t')), lastTrouble: rows.map((x) => x.classList.contains('ev-fr-t')).lastIndexOf(true),
160
- line: !!document.querySelector('#evSettings #srcHealth'), footer: !!document.querySelector('#evSettings [data-reads]'), count: !!document.querySelector('#evSettings [data-ev-sec="connectors"] .ev-k') } : null; });
161
- }
162
- if (theme === 'light') {
163
- ok('H2 Settings › Connectors: background issues are trouble rows, before every quiet row; all well draws no background line', list && !list.line && (h.level === 'ok' ? true : list.trouble >= 1) && (list.lastTrouble < 0 || list.firstQuiet < 0 || list.lastTrouble < list.firstQuiet), JSON.stringify(list));
164
- ok('H5 the Today/Needs you footer and the tab count are gone (CnA)', list && !list.footer && !list.count, JSON.stringify(list));
165
- ok('H3 no Sources chip and no dot are drawn on the page (premium-agreed-design)', dot === 'none', dot);
166
- if (shot) await page.screenshot({ path: path.join(shot, 'cards-reads-light.png'), fullPage: true });
167
- } else ok('H4 in dark the list fits: no sideways scroll', list && list.sw <= 1280 && list.w > 0, JSON.stringify(list));
168
- if (shot) { await sleep(1200); await page.screenshot({ path: path.join(shot, 'sources-health-' + theme + '.png') }); }
169
- ok('H no page error (' + theme + ')', errors.length === 0, errors.join(' | '));
170
- await ctx.close();
171
- }
172
- }
173
-
174
- {
175
- const html = await (await fetch(BASE + '/')).text();
176
- const nonce = (/<meta name="pmos-nonce" content="([^"]*)"/.exec(html) || [])[1] || '';
177
- const press = { Origin: BASE, ...(nonce ? { 'x-pmos-nonce': nonce } : {}) };
178
- const r1 = await json('POST', '/api/briefing-premium/put-off', { key: 'src:aaaaaaaaaaa1', until: 'later' }, press);
179
- ok('S9 a source row cannot be put off', r1.status === 400, JSON.stringify(r1));
180
- const r2 = await json('POST', '/api/briefing-premium/decide', { key: 'src:aaaaaaaaaaa1', choice: 'extend', why: 'No.' }, press);
181
- ok('S9 a source row cannot be decided', r2.status >= 400, JSON.stringify(r2));
182
- const r3 = await json('POST', '/api/briefing-premium/ask', { key: 'src:aaaaaaaaaaa1', text: 'Why is this on my list?' }, press);
183
- ok('S9 a message about a source row starts a Claude Code session', r3.status === 200 && r3.body.ok && r3.body.started === true, JSON.stringify(r3));
184
- }
185
-
186
- /* S11 fidelity: the source row and the digest are drawn in the Agreed design's own type and colours.
187
- * Re-pointed for premium-agreed-design: the reference was the old mockup (prototype/premium-ux-concept/briefing-artifact.html: Space Grotesk,
188
- * ember, a numbered rank). The Agreed design replaced that look on purpose, so each property is now pinned to the cozy token the design names
189
- * (cozy.css, cozy-home.css), resolved in the page itself for the theme under test; the row and the digest still fill their column, and still
190
- * nothing scrolls sideways. A source row that drifted off the design's tokens fails here as it failed against the mockup. */
191
- {
192
- // re-pointed again for the Agreed design's Home: the source row is a Needs-you row of Home's list, and the digest is a row of New for you.
193
- // Re-pointed for Home A + C (HvAC, HvACDesk): a row is one line, its mark and its title; the subject moved to the row's tooltip and
194
- // accessible name, and the title is the row title role, 15 px at 600 (feedback batch 26 item 6)
195
- const ROWS = [['row', '.hm-rm'], ['number', '.hv-d'], ['title', '.hm-rt b']];
196
- const DIGS = [['event', ''], ['eventTime', '.ev-tx .ev-mut'], ['eventTitle', '.ev-tx b']];
197
- const SANS = 'var(--cz-sans)';
198
- /* The design's values, as the tokens name them (a value that starts var( is resolved in the page; anything else is literal) */
199
- const WANT = {
200
- row: { fontFamily: SANS, color: 'var(--cz-ink)', backgroundColor: 'transparent' },
201
- number: { backgroundColor: 'var(--cz-blue)', borderRadius: '50%', width: '8px', height: '8px' }, // the row's dot is blue: it waits on you (HvAC .d)
202
- title: { fontFamily: SANS, fontSize: 'var(--fs-row)', fontWeight: 'var(--fw-strong)', color: 'var(--cz-ink)' }, // the row title role (batch 26 item 6), desktop and phone
203
- event: { fontFamily: SANS, color: 'var(--cz-ink)', backgroundColor: 'transparent' }, // a row of New for you's table (cozy-ev.css)
204
- eventTime: { fontSize: 'var(--fs-meta)', color: 'var(--cz-ink3)' },
205
- eventTitle: { fontFamily: SANS, fontSize: 'var(--fs-row)', fontWeight: 'var(--fw-strong)', color: 'var(--cz-ink)' },
206
- };
207
- const grab = (pg, pairs, base, col) => pg.evaluate(([pairs, want, base, col]) => {
208
- const o = {};
209
- const probe = document.createElement('div'); document.body.appendChild(probe);
210
- const resolve = (k, v) => { if (!/^var\(/.test(v) && v !== 'transparent') return v; probe.removeAttribute('style'); probe.style.position = 'absolute'; probe.style.visibility = 'hidden'; probe.style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), v); return getComputedStyle(probe)[k]; };
211
- const root = document.querySelectorAll(base)[base.includes('n:src:') ? 1 : 0];
212
- for (const [n, s] of pairs) {
213
- const e = !root ? null : s ? root.querySelector(s) : root;
214
- if (!e) { o[n] = null; continue; }
215
- const cs = getComputedStyle(e), v = {};
216
- for (const [k, w] of Object.entries(want[n])) v[k] = [resolve(k, w), cs[k]];
217
- o[n] = v;
218
- }
219
- probe.remove();
220
- const c = root && root.closest(col);
221
- o.fit = [c ? Math.round(c.getBoundingClientRect().width) : null, root ? Math.round(root.getBoundingClientRect().width) : null];
222
- return o;
223
- }, [pairs, WANT, base, col]);
224
- const diff = (c, pairs, slack) => {
225
- const d = [];
226
- for (const [n] of pairs) { if (!c[n]) { d.push(n + ' missing'); continue; } for (const [k, [want, got]] of Object.entries(c[n])) if (want !== got) d.push(`${n}.${k} ${want} | ${got}`); }
227
- const [col, got] = c.fit; if (col == null || got == null || got < col - slack || got > col + 2) d.push(`width fills ${col} | ${got}`);
228
- return d;
229
- };
230
- for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
231
- const R = await open({ w, h, theme: th });
232
- // on a phone the list is the page (canvas HmPhone)
233
- await allNeeds(R.page);
234
- // on a phone "Not in an initiative" starts folded (HvAC): open it to reach the source row
235
- if (w === 390) { const lh = await R.page.$('#hmList .hv-lh[aria-expanded="false"]'); if (lh) await lh.click(); }
236
- await sleep(500);
237
- const rowSel = '#hmList .hm-r[data-id^="n:src:"]';
238
- const diffs = diff(await grab(R.page, ROWS, rowSel, '.hm-pg'), ROWS, 4); // the row fills its group (the group's own inset aside)
239
- if (w === 390) await R.page.keyboard.press('Escape');
240
- await moreItem(R.page, 'New for you', '#aroundDig');
241
- await sleep(300);
242
- diffs.push(...diff(await grab(R.page, DIGS, '#czViewer #aroundDig .ev-trow', '#aroundDig'), DIGS, 2));
243
- ok(`S11 the source row and the digest look like the Agreed design's at ${w} px, ${th}`, diffs.length === 0, diffs.join(' ; '));
244
- const ov = await R.page.evaluate(() => document.documentElement.scrollWidth - innerWidth);
245
- ok(`S11 no sideways scroll at ${w} px, ${th}`, ov <= 0, String(ov));
246
- await R.ctx.close();
247
- }
248
- }
249
- return finish();
250
- })().catch((e) => { console.error(e); finish(1); });