create-pmos 0.397.0 → 0.398.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-adddoc-test.js +101 -52
  8. package/workspace/briefing-premium-board-test.js +252 -128
  9. package/workspace/briefing-premium-calendar-2-test.js +135 -198
  10. package/workspace/briefing-premium-calendar-3-test.js +143 -418
  11. package/workspace/briefing-premium-calendar-test.js +86 -196
  12. package/workspace/briefing-premium-doc-edit-test.js +95 -83
  13. package/workspace/briefing-premium-initiative-test.js +159 -296
  14. package/workspace/briefing-premium-insights-test.js +337 -219
  15. package/workspace/briefing-premium-metrics-test.js +53 -97
  16. package/workspace/briefing-premium-products-test.js +40 -27
  17. package/workspace/briefing-premium-sources-test.js +66 -48
  18. package/workspace/briefing-premium-test.js +150 -647
  19. package/workspace/briefing-premium-work-test.js +88 -283
  20. package/workspace/changelog.json +12 -0
  21. package/workspace/fixtures/board-premium-trail.js +32 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
  23. package/workspace/guide/briefing-premium.md +3 -1
  24. package/workspace/guide/home.md +47 -0
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/lib/agent-roles.js +71 -0
  27. package/workspace/lib/board-premium.js +85 -19
  28. package/workspace/lib/board-trail.js +223 -0
  29. package/workspace/lib/home-work-item.js +58 -0
  30. package/workspace/lib/insights-goals.js +196 -0
  31. package/workspace/lib/insights-premium.js +62 -14
  32. package/workspace/lib/insights-records.js +101 -0
  33. package/workspace/lib/jira-tickets.js +1 -1
  34. package/workspace/lib/route-modules.js +4 -0
  35. package/workspace/lib/routes-board-trail.js +33 -0
  36. package/workspace/lib/routes-home-desk.js +176 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +129 -0
  39. package/workspace/lib/routes-notes.js +1 -0
  40. package/workspace/lib/routes-viewer.js +108 -0
  41. package/workspace/lib/transcript-steps.js +123 -0
  42. package/workspace/lib/viewer-meeting.js +205 -0
  43. package/workspace/lib/viewer-report.js +89 -0
  44. package/workspace/package-lock.json +2 -2
  45. package/workspace/package.json +1 -1
  46. package/workspace/premium-board-actions-test.js +85 -75
  47. package/workspace/premium-briefing-depth-test.js +66 -53
  48. package/workspace/premium-chat-attach-test.js +54 -63
  49. package/workspace/premium-chat-chart-tab-test.js +35 -37
  50. package/workspace/premium-chat-context-test.js +19 -18
  51. package/workspace/premium-chat-goal-view-test.js +23 -23
  52. package/workspace/premium-chat-notes-test.js +26 -31
  53. package/workspace/premium-chat-report-tab-test.js +32 -28
  54. package/workspace/premium-chat-term-test.js +16 -16
  55. package/workspace/premium-chat-viewer-test.js +60 -59
  56. package/workspace/premium-core-doc-issue-test.js +50 -43
  57. package/workspace/premium-html-viewer-test.js +14 -17
  58. package/workspace/premium-phone-card-test.js +7 -2
  59. package/workspace/premium-phone-room-test.js +41 -35
  60. package/workspace/premium-report-read-test.js +115 -197
  61. package/workspace/premium-viewer-download-test.js +19 -22
  62. package/workspace/premium-viewer-flicker-test.js +11 -16
  63. package/workspace/premium-viewer-share-test.js +6 -9
  64. package/workspace/premium-viewer-test.js +41 -60
  65. package/workspace/premium-vw-backlog-test.js +53 -33
  66. package/workspace/premium-vw-cal-test.js +82 -128
  67. package/workspace/premium-vw-copy-test.js +17 -33
  68. package/workspace/premium-vw-doc-test.js +11 -10
  69. package/workspace/premium-vw-item-test.js +50 -49
  70. package/workspace/premium-vw-jira-test.js +53 -27
  71. package/workspace/premium-vw-meet-test.js +118 -187
  72. package/workspace/premium-vw-notes-test.js +85 -108
  73. package/workspace/premium-vw-rec-test.js +72 -194
  74. package/workspace/premium-vw-slides-test.js +46 -50
  75. package/workspace/premium-welcome-test.js +3 -2
  76. package/workspace/premium-work-depth-test.js +61 -53
  77. package/workspace/public/pm/bd-acts.js +305 -0
  78. package/workspace/public/pm/bd-span.js +186 -82
  79. package/workspace/public/pm/bd-stages.js +25 -11
  80. package/workspace/public/pm/c3-doc-sheet.js +1 -1
  81. package/workspace/public/pm/c3-md.js +3 -395
  82. package/workspace/public/pm/c3-phone-detail.js +1 -1
  83. package/workspace/public/pm/c3-phone-model.js +3 -68
  84. package/workspace/public/pm/chat-term.js +3 -3
  85. package/workspace/public/pm/cozy-board.css +497 -230
  86. package/workspace/public/pm/cozy-home.css +570 -142
  87. package/workspace/public/pm/cozy-home.js +5 -3
  88. package/workspace/public/pm/cozy-insights.css +296 -167
  89. package/workspace/public/pm/cozy-md.js +396 -0
  90. package/workspace/public/pm/cozy-nav.js +17 -6
  91. package/workspace/public/pm/cozy-placeholder.js +26 -0
  92. package/workspace/public/pm/cozy-viewer.css +3 -3
  93. package/workspace/public/pm/cozy-viewer.js +144 -0
  94. package/workspace/public/pm/cozy-vw.css +485 -0
  95. package/workspace/public/pm/cozy.css +83 -1
  96. package/workspace/public/pm/home-adddoc.js +48 -0
  97. package/workspace/public/pm/home-app.js +905 -0
  98. package/workspace/public/pm/home-around.js +515 -0
  99. package/workspace/public/pm/home-chat.js +459 -0
  100. package/workspace/public/pm/home-data.js +312 -0
  101. package/workspace/public/pm/home-draft.js +68 -0
  102. package/workspace/public/pm/home-more.js +249 -0
  103. package/workspace/public/pm/home-phone-card.js +109 -0
  104. package/workspace/public/pm/home-work.js +519 -0
  105. package/workspace/public/pm/phone-moment.js +69 -0
  106. package/workspace/public/pm/pm-work-view.js +1 -1
  107. package/workspace/public/pm/premium-attach.js +4 -0
  108. package/workspace/public/pm/premium-board.js +423 -394
  109. package/workspace/public/pm/premium-chart-tab.js +110 -62
  110. package/workspace/public/pm/premium-deck.js +3 -3
  111. package/workspace/public/pm/premium-first.js +25 -21
  112. package/workspace/public/pm/premium-insights.js +792 -568
  113. package/workspace/public/pm/premium-meeting.js +61 -549
  114. package/workspace/public/pm/premium-notes.js +1 -1
  115. package/workspace/public/pm/premium-report-frame.css +20 -0
  116. package/workspace/public/pm/premium-report-read.js +509 -480
  117. package/workspace/public/pm/premium-report-tab.js +87 -63
  118. package/workspace/public/pm/premium-shell.js +72 -119
  119. package/workspace/public/pm/premium-viewer.js +22 -1
  120. package/workspace/public/pm/premium-vw-cal.js +187 -48
  121. package/workspace/public/pm/premium-vw-doc.css +6 -0
  122. package/workspace/public/pm/premium-vw-doc.js +40 -2
  123. package/workspace/public/pm/premium-vw-file.js +2 -2
  124. package/workspace/public/pm/premium-vw-meet.js +6 -83
  125. package/workspace/public/pm/premium-vw-mtg.js +731 -0
  126. package/workspace/public/pm/premium-vw-notes.js +56 -69
  127. package/workspace/public/pm/premium-vw-open.js +35 -0
  128. package/workspace/public/pm/premium-vw-page.js +16 -0
  129. package/workspace/public/pm/premium-vw-rec.js +11 -218
  130. package/workspace/public/pm/premium-vw-slides.css +5 -0
  131. package/workspace/public/pm/premium-vw-slides.js +44 -8
  132. package/workspace/public/pm/term-view.js +22 -0
  133. package/workspace/public/premium-board.html +28 -70
  134. package/workspace/public/premium-initiative.html +8 -48
  135. package/workspace/public/premium-insights.html +22 -60
  136. package/workspace/public/premium-viewer.html +20 -0
  137. package/workspace/public/premium.html +16 -107
  138. package/workspace/server.js +18 -3
  139. package/workspace/test-files.json +1 -0
  140. package/workspace/test-lists/home-libs.json +9 -0
  141. package/workspace/test-lists/premium-report-read.json +1 -1
  142. package/workspace/test-lists/premium-vw-agreed.json +9 -0
  143. package/workspace/test-lists/premium-vw-notes.json +1 -1
  144. package/workspace/public/pm/premium-work.js +0 -729
  145. package/workspace/public/pm/premium.js +0 -1146
@@ -3,7 +3,11 @@
3
3
  /* briefing-premium-metrics-test.js — the Metrics card of the premium Board (initiative briefing-premium-metrics; planning/prd/briefing-premium-metrics-prd.md M1 to M10).
4
4
  * Serves the real page from the real server. The Board's answer and the card's answer are served from fixtures (the card's model is built by
5
5
  * lib/board-metrics-premium.js from made-up runs, commits and initiatives); the last blocks ask the real route and compare the card with the mockup.
6
- * C1 place and absence · C2 tiles · C3 reading a week · C4 dialog and agent · C5 pending and failure · C6 floors · C7 the real route · C8 fidelity · C9 targets on the Board · C10 the Insights twin */
6
+ * C1 place · C2 tiles · C4 definition and values by week · C5 pending and failure · C6 floors · C7 the real route · C9 targets on the Board · C10 the Insights twin
7
+ * Re-pointed for the Agreed Board (premium-agreed-design): the Agreed design has no Metrics frame, so the Board keeps the card's function as a plain
8
+ * panel (pm/bd-acts.js), tagged "Waiting for design", opened from the quiet Metrics link under the stage track. The charts, the week reader (C3), the
9
+ * dialog with its agent (C4) and the card's geometry (C8) were parts of the retired card: the definition and the values by week stay, in a fold;
10
+ * charts, targets and longer ranges live on Insights (Delivery trends), which C10 checks. */
7
11
  const fs = require('fs');
8
12
  const path = require('path');
9
13
  const { spawn } = require('child_process');
@@ -44,161 +48,113 @@ const ready = (model) => ({ status: 200, body: { ok: true, state: 'ready', model
44
48
  await T.waitForServer(BASE);
45
49
  browser = await chromium.launch({ executablePath: exe });
46
50
 
47
- const open = async ({ w = 1280, h = 900, theme = 'light', answers = null } = {}) => {
51
+ const open = async ({ w = 1280, h = 900, theme = 'light', answers = null, url = '/premium-board.html' } = {}) => {
48
52
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
49
- await ctx.addInitScript(() => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); } catch { /* none */ } });
50
53
  const page = await ctx.newPage();
51
- const errors = [], posts = []; let calls = 0; let thread = { ok: true, turns: [], working: false };
54
+ const errors = []; let calls = 0;
52
55
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
53
56
  await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.facts()), as_of: Date.now() }) }));
57
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: '{"ok":false}' }));
54
58
  await page.route('**/api/board-metrics-premium*', (r) => { calls++; const a = answers ? answers(calls) : ready(metrics()); return r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
55
- await page.route('**/api/core-docs/**', (r) => r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }));
56
- await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() === 'GET') return r.fulfill({ contentType: 'application/json', body: JSON.stringify(thread) }); posts.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); return r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }); });
57
- await page.goto(BASE + '/premium-board.html?theme=' + theme);
59
+ await page.goto(BASE + url + (url.includes('?') ? '&' : '?') + 'theme=' + theme);
58
60
  await until(() => page.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 20000);
59
- await page.evaluate(() => { const m = document.querySelector('#miMet'); if (m) m.click(); }); // the Agreed design opens the Metrics card from the ⋯ menu (premium-agreed-design)
60
- return { ctx, page, errors, posts, calls: () => calls, setThread: (t) => { thread = t; } };
61
+ if (await page.isVisible('#moreBtn')) { await page.click('#moreBtn'); await page.click('#bdMetrics'); } else await page.click('#ibBody [data-open="metrics"]'); // re-pointed: Metrics is in the ⋯ menu (desktop) or the phone's plain row
62
+ return { ctx, page, errors, calls: () => calls };
61
63
  };
64
+ const tilesOf = (pg) => pg.evaluate(() => [...document.querySelectorAll('#peek .bd-met')].map((t) => ({ k: t.dataset.met, s: [...t.querySelector('summary').children].map((c) => c.textContent), look: t.classList.contains('look') })));
62
65
 
63
66
  /* C1 */
64
67
  const A = await open(), p = A.page;
65
- const shown = await until(() => p.evaluate(() => !document.querySelector('#cMet').hidden && document.querySelectorAll('#metBody .mt1').length === 4));
66
- ok('C1 a tenant board draws the Metrics card with four tiles', shown);
68
+ const shown = await until(async () => { const t = await tilesOf(p); return t.length === 4 ? t : null; });
69
+ ok('C1 the Metrics link under the track opens the board\'s four measures in the side panel', !!shown);
67
70
  if (!shown) return finish(1);
68
- const place = await p.evaluate(() => ({ above: !document.querySelector('#popMet').hidden && !!document.querySelector('#popMet #cMet'), cap: document.querySelector('#metCap').textContent, h: document.querySelector('#hMet').textContent }));
69
- ok('C1 the card opens from the ⋯ menu (Agreed design; it sat above the Initiatives card before) and says which repository it counts', place.above && place.cap === 'counted from idpf' && place.h === 'Metrics', JSON.stringify(place));
71
+ const place = await p.evaluate(() => ({ t: document.querySelector('#pkTitle').textContent, tag: (document.querySelector('#peek .bd-wtag') || {}).textContent, cap: document.querySelector('#metW .bd-amut').textContent, ins: (document.querySelector('#metW a[href^="/premium-insights.html"]') || {}).textContent, dlg: !!document.querySelector('#dlg.on') }));
72
+ ok('C1 it is a plain panel tagged "Waiting for design", says which repository it counts and links to Insights; no old dialog', place.t === 'Metrics' && place.tag === 'Waiting for design' && /^counted from idpf/.test(place.cap) && /Targets and longer ranges are on Insights/.test(place.ins || '') && !place.dlg, JSON.stringify(place));
70
73
 
71
74
  /* C2 */
72
- const tiles = await p.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((t) => ({ l: t.querySelector('span').textContent, v: t.querySelector('.mval').textContent, c: t.querySelector('.mwk').textContent, chart: !!t.querySelector('svg'), cls: t.className, chg: (t.querySelector('.mchg') || {}).textContent || '' })));
73
- ok('C2 the first tile is the latest week with its run count, and how it changed', tiles[0].l === 'Corrections per 100 runs' && tiles[0].v === '10.0' && /^week to .+, 10 runs$/.test(tiles[0].c) && tiles[0].chg === '▼ Down 15.0 vs last week' && tiles[0].chart && /\bok\b/.test(tiles[0].cls), JSON.stringify(tiles[0]));
74
- ok('C2 merges, blocked and idle are counted; blocked and idle chart from today and say plainly that their history starts today', tiles[1].v === '3' && tiles[1].chart && tiles[2].v === '1' && tiles[2].c === 'of 3 open · history starts today' && tiles[2].chart && tiles[3].v === '1' && tiles[3].c === 'of 3 open · history starts today' && tiles[3].chart && /\bbad\b/.test(tiles[2].cls) && /\bwarn\b/.test(tiles[3].cls), JSON.stringify(tiles));
75
- const per = await p.evaluate(() => [...document.querySelectorAll('#perTabs button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed') + ':' + (b.getAttribute('aria-disabled') || '')).join('|'));
76
- ok('C2 only Week is available; Day and Month are disabled', per === 'Day:false:true|Week:true:|Month:false:true', per);
77
- ok('C2 Day and Month hold no count, so only Week shows, as one quiet chip (premium-calmer-first-screen)', await p.evaluate(() => [...document.querySelectorAll('#perTabs button')].filter((b) => getComputedStyle(b).display !== 'none').map((b) => b.textContent).join() === 'Week'));
78
- ok('C2 no target, on-target chip, dashed line or demo label is drawn; the lead line says no measure has a target', await p.evaluate(() => !document.querySelector('#cMet .mchip.ok, #cMet .tg, #cMet .tgl') && !/on target|demo|dashed/i.test(document.querySelector('#metBody').textContent) && /No measure here has a target/.test(document.querySelector('#metHint').textContent)));
79
- const look = await p.evaluate(() => ({ chips: [...document.querySelectorAll('#metBody .mt1')].map((t) => (t.querySelector('.mchip') || {}).textContent || ''), off: [...document.querySelectorAll('#metBody .mt1')].map((t) => t.classList.contains('off')), lead: (document.querySelector('#metHint .mflag') || {}).textContent || '', ins: (document.querySelector('#metHint a#metIns') || {}).getAttribute ? document.querySelector('#metHint a#metIns').getAttribute('href') : '' }));
80
- ok('C2 the tiles that need a look carry the chip and the orange outline; the lead line counts them and links to Insights', JSON.stringify(look.off) === JSON.stringify(tiles.map((t) => /\b(warn|bad)\b/.test(t.cls))) && look.chips.every((c, i) => (c === 'Needs a look') === look.off[i]) && look.lead === look.off.filter(Boolean).length + ' of 4 need a look.' && /^\/premium-insights\.html\?ws=/.test(look.ins), JSON.stringify(look));
75
+ const t0 = shown;
76
+ ok('C2 the first tile is the latest week with its run count, and how it changed', t0[0].k === 'corrections' && t0[0].s[0] === 'Corrections per 100 runs' && t0[0].s[1] === '10.0' && /^week to .+, 10 runs$/.test(t0[0].s[2]) && t0[0].s[3] === 'Down 15.0 vs last week', JSON.stringify(t0[0]));
77
+ ok('C2 merges, blocked and idle are counted; blocked and idle say plainly that their history starts today', t0[1].s[1] === '3' && t0[2].s[1] === '1' && t0[2].s[2] === 'of 3 open · history starts today' && t0[3].s[1] === '1' && t0[3].s[2] === 'of 3 open · history starts today', JSON.stringify(t0));
78
+ ok('C2 no target and no on-target chip is drawn when none is set; a measure that needs a look says so', !t0.some((x) => x.s.some((y) => /target/i.test(y))) && t0.filter((x) => x.look).every((x) => x.s.includes('Needs a look')), JSON.stringify(t0));
81
79
  {
82
- const gap = metrics({ runs: null, commits: null, inits: null });
83
- const R = await open({ answers: () => ready(gap) });
84
- const t = await until(async () => { const a = await R.page.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((x) => x.querySelector('.mval').textContent + '/' + x.querySelector('.mwk').textContent)); return a.length ? a : null; }) || [];
85
- ok('C2 a source that cannot be read says Not read and why, with no number and no chart', t.length === 4 && t.every((x) => x.startsWith('Not read/')) && /agent-runs\.jsonl could not be read in idpf/.test(t[0]) && !(await R.page.evaluate(() => document.querySelector('#metBody svg'))), JSON.stringify(t));
80
+ const R = await open({ answers: () => ready(metrics({ runs: null, commits: null, inits: null })) });
81
+ const t = await until(async () => { const a = await tilesOf(R.page); return a.length === 4 ? a : null; }) || [];
82
+ ok('C2 a source that cannot be read says Not read and why, with no number', t.length === 4 && t.every((x) => x.s[1] === 'Not read') && /agent-runs\.jsonl could not be read in idpf/.test(t[0].s[2]), JSON.stringify(t));
86
83
  await R.ctx.close();
87
84
  }
88
85
 
89
- /* C3 */
90
- const box = await p.locator('#metBody .mch').first().locator('svg').boundingBox();
91
- const at = async (frac) => { await p.mouse.move(box.x + box.width * frac, box.y + box.height / 2); await sleep(150); return p.evaluate(() => ({ v: document.querySelector('#metBody .mch .mval').textContent, c: document.querySelector('#metBody .mch .mwk').textContent, hv: document.querySelector('#metBody .mch').classList.contains('hv') })); };
92
- const first = await at(0.02);
93
- ok('C3 moving over the first week reads "No runs" for a week without enough runs', first.v === 'No runs' && /^Week to /.test(first.c) && first.hv, JSON.stringify(first));
94
- const mid = await at(0.841);
95
- ok('C3 moving over a counted week reads its value and run count', /^\d+\.\d$/.test(mid.v) && / · 12 runs$/.test(mid.c), JSON.stringify(mid));
96
- await p.mouse.move(5, 5); await sleep(200);
97
- const back = await p.evaluate(() => ({ v: document.querySelector('#metBody .mch .mval').textContent, hv: document.querySelector('#metBody .mch').classList.contains('hv') }));
98
- ok('C3 leaving the chart returns to the latest week', back.v === '10.0' && !back.hv, JSON.stringify(back));
99
- await p.locator('#metBody .mch').first().focus(); await p.keyboard.press('ArrowLeft'); await sleep(100);
100
- ok('C3 the arrow keys read the week before', await p.evaluate(() => document.querySelector('#metBody .mch .mval').textContent === '25.0' || /^\d+\.\d$/.test(document.querySelector('#metBody .mch .mval').textContent)));
101
- await p.locator('#metBody .mch').first().blur();
102
-
103
- /* C4 */
104
- await p.locator('#metBody .mt1').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
105
- const dlg = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, sub: document.querySelector('#dSub').textContent, grid: [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'), vals: document.querySelectorAll('#oMain .vtb div').length, def: document.querySelector('#oMain .lede').textContent, ask: document.querySelector('#askF').hidden }));
106
- ok('C4 a tile opens its definition, its values by week and the repository it counted, with the read-only agent beside it', dlg.title === 'Corrections per 100 runs' && dlg.sub === 'idpf' && /Now\|10\.0/.test(dlg.grid) && /Better when\|Lower/.test(dlg.grid) && /Source\|idpf/.test(dlg.grid) && dlg.vals === 8 && /per 100 agent runs/.test(dlg.def) && dlg.ask === false, JSON.stringify(dlg));
107
- ok('C4 the dialog holds no press that records anything', await p.evaluate(() => !document.querySelector('#oMain button, #oMain .dmcta')));
108
- A.setThread({ ok: true, working: false, turns: [] }); await p.fill('#askIn', 'Why did it fall?'); const n0 = A.posts.length; await p.press('#askIn', 'Enter');
109
- ok('C4 a question posts the metric\'s key and the text', await until(() => A.posts.length > n0 && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'board:metric-corrections' && A.posts[A.posts.length - 1].body.text === 'Why did it fall?'), JSON.stringify(A.posts.slice(-1)));
110
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
111
- await p.evaluate(() => { if (document.querySelector('#popMet').hidden) document.querySelector('#miMet').click(); }); // the dialog's close leaves the Metrics popover shut
112
- await p.locator('#metBody .mt1').nth(2).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
113
- ok('C4 Blocked opens its definition, and the weeks before its history started read Not kept yet', await p.evaluate(() => { const v = [...document.querySelectorAll('#oMain .vtb div b')].map((b) => b.textContent); return document.querySelector('#dTitle').textContent === 'Blocked' && /blocked step/.test(document.querySelector('#oMain .lede').textContent) && v.length === 8 && v.slice(0, 7).every((x) => x === 'Not kept yet') && v[7] === '1'; }));
114
- await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
115
- await p.$eval('#perTabs [data-per="day"]', (b) => b.click()); ok('C4 a disabled period says why and changes nothing', await until(() => p.evaluate(() => /by week only/.test(document.querySelector('#toast').textContent))) && await p.evaluate(() => document.querySelector('#perTabs [data-per="week"]').getAttribute('aria-pressed') === 'true'));
86
+ /* C4 the definition and the values by week */
87
+ await p.click('#peek .bd-met[data-met="corrections"] summary');
88
+ const d = await p.evaluate(() => { const t = document.querySelector('#peek .bd-met[data-met="corrections"]'); return { open: t.open, def: t.querySelector(':scope > .bd-amut').textContent, wk: t.querySelectorAll('.bd-kv b').length, vals: [...t.querySelectorAll('.bd-kv b')].map((b) => b.textContent) }; });
89
+ ok('C4 a measure opens its definition and its values by week; a week with too few runs is not kept', d.open && /per 100 agent runs/.test(d.def) && d.wk === 8 && d.vals[7] === '10' && d.vals[0] === 'Not kept yet', JSON.stringify(d));
90
+ ok('C4 the panel holds no press that records anything', await p.evaluate(() => !document.querySelector('#peek form, #peek [data-act]')));
116
91
  ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
117
92
  await A.ctx.close();
118
93
 
119
94
  /* C5 */
120
95
  {
121
96
  const R = await open({ answers: (c) => (c < 2 ? ready(metrics({ inits: null, initsPending: true })) : ready(metrics())) });
122
- const idle = () => R.page.evaluate(() => { const t = document.querySelectorAll('#metBody .mt1')[2]; return t ? t.querySelector('.mval').textContent : ''; });
123
- ok('C5 while the workflow is derived Blocked and Idle say Reading, and the page asks again until they are filled', await until(async () => /^Reading/.test(await idle())) && await until(async () => (await idle()) === '1', 9000) && R.calls() >= 2, String(R.calls()));
97
+ const idle = async () => { const t = await tilesOf(R.page); return t[2] ? t[2].s[1] : ''; };
98
+ ok('C5 while the workflow is derived Blocked says Reading, and the panel asks again until it is filled', await until(async () => /^Reading/.test(await idle())) && await until(async () => (await idle()) === '1', 9000) && R.calls() >= 2, String(R.calls()));
124
99
  await R.ctx.close();
125
100
  const F2 = await open({ answers: () => ({ status: 500, body: { ok: false, state: 'error', error: 'the repository could not be read' } }) });
126
- ok('C5 a failed read says why and draws no tile', await until(() => F2.page.evaluate(() => !document.querySelector('#cMet').hidden && /The reason: the repository could not be read/.test(document.querySelector('#metHint').textContent) && document.querySelectorAll('#metBody .mt1').length === 0)));
101
+ ok('C5 a failed read says why and draws no tile', await until(() => F2.page.evaluate(() => /The reason: the repository could not be read/.test((document.querySelector('#metW') || {}).textContent || '') && !document.querySelector('#peek .bd-met'))));
127
102
  await F2.ctx.close();
128
103
  }
129
104
 
130
105
  /* C6 */
131
106
  for (const theme of ['light', 'dark']) {
132
107
  const R = await open({ w: 390, h: 844, theme }), q = R.page;
133
- await until(() => q.evaluate(() => document.querySelectorAll('#metBody .mt1').length === 4));
134
- const m = await q.evaluate(() => ({ over: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#metBody .mt1')].filter((b) => b.getBoundingClientRect().height < 44).length }));
135
- ok(`C6 at 390 px (${theme}) the card does not scroll sideways and every tile is 44 px or more`, !m.over && m.small === 0, JSON.stringify(m));
108
+ await until(async () => (await tilesOf(q)).length === 4);
109
+ const m = await q.evaluate(() => ({ over: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#peek .bd-met summary')].filter((b) => b.getBoundingClientRect().height < 44).length }));
110
+ ok(`C6 at 390 px (${theme}) the panel does not scroll sideways and every measure is 44 px or more`, !m.over && m.small === 0, JSON.stringify(m));
111
+ ok(`C6 no page error at 390 px (${theme})`, R.errors.length === 0, R.errors.join(' | '));
136
112
  await R.ctx.close();
137
113
  }
138
114
 
139
115
  /* C7 the real route */
140
116
  {
141
117
  const home = await fetch(BASE + '/api/board-metrics-premium').then((r) => r.json());
142
- ok('C7 the real route gives the home workspace the card too', home.ok === true && home.state === 'ready', JSON.stringify(home));
118
+ ok('C7 the real route gives the home workspace its measures', home.ok === true && home.state === 'ready', JSON.stringify(home).slice(0, 300));
143
119
  const post = await fetch(BASE + '/api/board-metrics-premium', { method: 'POST', headers: await T.pressHeaders(BASE), body: '{}' }).then((r) => r.status);
144
120
  ok('C7 the route is read-only', post === 405, String(post));
145
121
  const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
146
122
  pg.on('pageerror', (e) => errs.push(String(e)));
147
123
  await pg.goto(BASE + '/premium-board.html');
148
- await until(() => pg.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 40000); await sleep(1500);
149
- ok('C7 the real PMOS board draws the Metrics card and no script error', await pg.evaluate(() => !document.querySelector('#cMet').hidden) && errs.length === 0, errs.join(' | '));
124
+ await until(() => pg.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 40000); await sleep(800);
125
+ await pg.click('#moreBtn'); await pg.click('#bdMetrics');
126
+ ok('C7 the real PMOS board opens its Metrics panel with four measures and no script error', await until(() => pg.evaluate(() => document.querySelectorAll('#peek .bd-met').length === 4), 30000) && errs.length === 0, errs.join(' | '));
150
127
  await ctx.close();
151
128
  }
152
129
 
153
- /* C9 a target set on Insights draws on the Board */
130
+ /* C9 a target set on Insights shows on the Board */
154
131
  {
155
132
  const R = await open({ answers: () => ready(metrics({ targets: { corrections: { target: 12 }, merges: { target: 5 } } })) }), q = R.page;
156
- await until(() => q.evaluate(() => document.querySelectorAll('#metBody .mt1').length === 4));
157
- const t = await q.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((x) => ({ chip: (x.querySelector('.mchip') || {}).textContent || '', cls: (x.querySelector('.mchip') || {}).className || '', tg: !!x.querySelector('svg .tg'), tgl: !!x.querySelector('.tgl'), tgt: (x.querySelector('.mtg') || {}).textContent || '', off: x.classList.contains('off') })));
158
- ok('C9 a measure on target carries the On target chip, its target and the dashed line, with no outline', t[0].chip === 'On target' && /\bok\b/.test(t[0].cls) && t[0].tg && t[0].tgl && t[0].tgt === 'target 12.0' && !t[0].off, JSON.stringify(t[0]));
159
- ok('C9 a measure off target carries its gap, the dashed line and the orange outline', t[1].chip === '2 short' && /\bwarn\b/.test(t[1].cls) && t[1].tg && t[1].tgt === 'target 5' && t[1].off, JSON.stringify(t[1]));
160
- ok('C9 a measure with no target draws no dashed line, and the lead line says the line is the target set on Insights', !t[2].tg && !t[3].tg && await q.evaluate(() => /The dashed line is the target set on Insights/.test(document.querySelector('#metHint').textContent)), JSON.stringify(t.slice(2)));
161
- await q.locator('#metBody .mt1').first().click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(300);
162
- ok('C9 the dialog names the target and the gap', await q.evaluate(() => { const g = [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'); return /Target\|12\.0/.test(g) && /Gap\|On target/.test(g); }));
133
+ const t = await until(async () => { const a = await tilesOf(q); return a.length === 4 ? a : null; }) || [];
134
+ ok('C9 a measure on target says On target with its target', t[0] && t[0].s.includes('On target · target 12.0') && !t[0].look, JSON.stringify(t[0]));
135
+ ok('C9 a measure off target says its gap and is outlined', t[1] && t[1].s.includes('2 short · target 5') && t[1].look, JSON.stringify(t[1]));
136
+ ok('C9 a measure with no target shows none', t[2] && !t[2].s.some((y) => /target/.test(y)) && !t[3].s.some((y) => /target/.test(y)), JSON.stringify(t.slice(2)));
163
137
  ok('C9 no page error', R.errors.length === 0, R.errors.join(' | '));
164
138
  await R.ctx.close();
165
139
  }
166
140
 
167
- /* C10 the Insights page shows the same measures, and a target saved there is sent for the Board */
141
+ /* C10 the Insights page shows the same measures (Delivery trends), and a target saved there is sent for the Board */
168
142
  {
169
143
  const IP = require('./lib/insights-premium.js'), IF = require('./fixtures/insights-premium-facts.js');
170
- const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), q = await ctx.newPage(), errs = [], saves = [], asked = [];
171
- let tg = {};
144
+ const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), q = await ctx.newPage(), errs = [], saves = [];
172
145
  q.on('pageerror', (e) => errs.push(String((e && e.message) || e)));
173
146
  await q.route('**/api/insights-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(IF.facts()), as_of: 1 }) }));
174
- await q.route('**/api/board-metrics-premium*', (r) => { asked.push(new URL(r.request().url()).searchParams.get('weeks')); return r.fulfill({ contentType: 'application/json', body: JSON.stringify(ready(metrics({ targets: tg, trunk: { ref: 'origin/main', fetched_at: '2026-10-14T07:00:00Z' } })).body) }); });
175
- await q.route('**/api/board-metric-targets/save', (r) => { const b = JSON.parse(r.request().postData() || '{}'); saves.push(b); tg = b.target == null ? {} : { [b.key]: { target: Number(b.target) } }; return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, targets: tg }) }); });
147
+ await q.route('**/api/board-metrics-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(ready(metrics()).body) }));
148
+ await q.route('**/api/board-metric-targets/save', (r) => { saves.push(JSON.parse(r.request().postData() || '{}')); return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, targets: {} }) }); });
176
149
  await q.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: '{"ok":true,"turns":[],"working":false}' }));
177
150
  await q.goto(BASE + '/premium-insights.html');
178
- const up = await until(() => q.evaluate(() => !document.querySelector('#cBm').hidden && document.querySelectorAll('#bmBody .mt1').length === 4), 20000);
179
- ok('C10 Insights draws the Board measures card with the same four tiles as the Board', up && await q.evaluate(() => [...document.querySelectorAll('#bmBody .mt1 .mval')].map((v) => v.textContent).join('|') === '10.0|3|1|1' && /counted from idpf/.test(document.querySelector('#bmCap').textContent)));
180
- ok('C10 Blocked and Idle say plainly on their charts that history starts today', await q.evaluate(() => [...document.querySelectorAll('#bmBody .mt1')].slice(2).every((t) => !!t.querySelector('svg') && t.querySelector('.mwk').textContent === 'of 3 open · history starts today')));
181
- await q.locator('#bmRange [data-w="26"]').click();
182
- ok('C10 a longer range asks for 26 weeks', await until(() => asked.includes('26')) && await until(() => q.evaluate(() => document.querySelector('#bmRange [data-w="26"]').getAttribute('aria-pressed') === 'true')), JSON.stringify(asked));
183
- await q.locator('#bmBody .mt1').nth(1).click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(300);
184
- ok('C10 the measure popup reads its numbers first and says when the trunk was fetched', await q.evaluate(() => { const say = document.querySelector('#dBody .stream').textContent, g = [...document.querySelectorAll('#oMain .kv2 span')].map((x) => x.textContent).join('|'); return /Merged a week is 3, to the trunk, week to \d+ \w+\. Up 1 vs last week\. origin\/main was last fetched 14 Oct \d\d:00\./.test(say) && /No target is set/.test(say) && /Trunk read\|origin\/main, fetched 14 Oct \d\d:00/.test(g); }));
185
- await q.fill('#bmT', '5'); await q.click('#bmGo');
186
- ok('C10 Save target sends the measure and the number for this board', await until(() => saves.length === 1) && saves[0].ws === 'w1' && saves[0].key === 'merges' && saves[0].target === '5', JSON.stringify(saves));
187
- ok('C10 the card redraws with the target: its gap chip, dashed line and outline', await until(() => q.evaluate(() => { const t = document.querySelectorAll('#bmBody .mt1')[1]; return t && (t.querySelector('.mchip') || {}).textContent === '2 short' && !!t.querySelector('svg .tg') && t.classList.contains('off'); })));
151
+ const v = await until(async () => { const x = await q.evaluate(() => Object.fromEntries([...document.querySelectorAll('#bmBody [data-tile]')].map((e) => [e.dataset.tile, e.querySelector('.v').textContent]))); return x.corrections && x.corrections !== 'Reading' ? x : null; }, 20000);
152
+ ok('C10 Insights\' Delivery trends show the Board\'s measures with the same values', !!v && v.corrections === '10.0' && v.merges === '3' && v.idle === '1', JSON.stringify(v));
153
+ await q.click('#bmBody [data-tile="merges"]'); await until(() => q.evaluate(() => !!document.querySelector('#czViewer [data-tgf]')));
154
+ await q.fill('#czViewer [data-tgf] [name="tg"]', '5'); await q.click('#czViewer [data-tgf] button[type="submit"]');
155
+ ok('C10 a target saved on Insights goes to the Board\'s target route, for this board', await until(() => saves.length === 1) && saves[0].key === 'merges' && saves[0].target === 5, JSON.stringify(saves));
188
156
  ok('C10 no page error', errs.length === 0, errs.join(' | '));
189
157
  await ctx.close();
190
158
  }
191
-
192
- /* C8 the card keeps every part of the mockup's card, in the Agreed design's type (premium-agreed-design: the Board is drawn to the AgBoard frames,
193
- so the card no longer copies the retired briefing mockup's geometry and type; the same parts are checked, each drawn and visible) */
194
- {
195
- const SEL = [['card', '#cMet'], ['heading', '#hMet'], ['hint', '#cMet .mhint'], ['note', '#cMet .note'], ['t1', '#cMet .mt1:nth-child(1)'], ['t1val', '#cMet .mt1:nth-child(1) .mval'], ['t1cap', '#cMet .mt1:nth-child(1) .mwk'], ['t1chg', '#cMet .mt1:nth-child(1) .mchg'], ['t1svg', '#cMet .mt1:nth-child(1) svg'], ['t1line', '#cMet .mt1:nth-child(1) .ln2'], ['t1dot', '#cMet .mt1:nth-child(1) .dt'], ['t1foot', '#cMet .mt1:nth-child(1) .mfoot'], ['t3', '#cMet .mt1:nth-child(3)']];
196
- for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
197
- const R = await open({ w, h, theme: th }); await until(() => R.page.evaluate(() => document.querySelectorAll('#metBody .mt1').length === 4)); await sleep(500);
198
- const c = await R.page.evaluate((pairs) => { const miss = []; for (const [n, q] of pairs) { const e = document.querySelector(q); const r = e && e.getBoundingClientRect(); if (!e || ((!r.width || !r.height) && !e.closest('#metFold'))) miss.push(n); } /* the hint and the note sit in the card's info fold (premium-calmer-first-screen) */ return { miss, font: getComputedStyle(document.querySelector('#cMet')).fontFamily, over: document.documentElement.scrollWidth > innerWidth + 1 }; }, SEL);
199
- ok(`C8 the Metrics card draws every part, in Nunito, with no sideways scroll at ${w} px, ${th}`, c.miss.length === 0 && /Nunito/.test(c.font) && !c.over, JSON.stringify(c));
200
- await R.ctx.close();
201
- }
202
- }
203
159
  return finish();
204
160
  })().catch((e) => { console.error(e); finish(1); });
@@ -21,6 +21,9 @@ const T = require('./test-run').configure({ name: 'briefing-premium-products' })
21
21
 
22
22
  const BASE = T.BASE;
23
23
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
24
+ /* premium-agreed-design: Home has no header line and no picker chip. The product picker is Home's minimal Products card in the Viewer
25
+ * (home-more.js openProducts, "Waiting for design"), opened from the place menu's More; it holds the header's line (#hxSnap), the count
26
+ * (#hxCount), one switch per workspace and Back to the default. The rows are Home's Needs-you rows; a row's product leads its hint. */
24
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); } };
25
28
  const results = [];
26
29
  const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 300) : ''}`); };
@@ -80,43 +83,52 @@ const product = (name, cond) => {
80
83
  const page = await ctx.newPage(); const errors = [];
81
84
  page.on('pageerror', (e) => errors.push(String(e.message || e)));
82
85
  await page.goto(BASE + '/premium.html' + q, { waitUntil: 'domcontentloaded' });
83
- await page.waitForSelector('#rank .rr, #calm:not([hidden]), #pkw:not([hidden])', { state: 'attached', timeout: 30000 }); // the picker is parked for the Sources dialog (premium-topbar), so attached, not visible
86
+ await page.waitForSelector('#hmList .hm-g', { state: 'attached', timeout: 30000 });
84
87
  return { ctx, page, errors };
85
88
  };
86
- // premium-topbar: the picker lives in the Sources dialog (the chip, or the ⋯ menu at phone width)
89
+ // the picker: the place menu's More, then Products; the card opens in the Viewer and reads the products
87
90
  const pick = async (page) => {
88
- if (!(await page.isVisible('#pick'))) { if (await page.isVisible('#srcChip')) await page.click('#srcChip'); else { await page.click('#moreBtn'); await page.click('#srcItem'); } await page.waitForSelector('#pick', { state: 'visible', timeout: 10000 }); }
89
- await page.click('#pick');
91
+ if (!(await page.isVisible('#czViewer #hxCount'))) {
92
+ await page.click('#czFab'); await page.click('[data-cz-more]');
93
+ await page.click('#hmMenu [role="menuitem"]:has-text("Products")');
94
+ await page.waitForSelector('#czViewer #hxCount', { state: 'visible', timeout: 10000 });
95
+ }
90
96
  };
91
- const rowsOf = (page) => page.$$eval('#rank .rr', (els) => els.map((e) => ({ key: e.dataset.key, tag: (e.querySelector('.pn') || {}).textContent || '', title: e.querySelector('.rt').textContent })));
97
+ const pickText = (page) => page.textContent('#czViewer #hxCount');
98
+ const rowsOf = (page) => page.$$eval('#hmList .hm-r[data-id^="n:decision:"]', (els) => els.map((e) => ({ key: e.dataset.id.slice(2), tag: ((e.querySelector('.hm-rt em') || {}).textContent || '').split(' · ')[0], title: e.querySelector('.hm-rt b').textContent })));
92
99
 
93
100
  {
94
101
  const { ctx, page, errors } = await open();
95
102
  await until(async () => (await rowsOf(page)).length === 2, 20000);
96
103
  const rows = await rowsOf(page);
97
104
  ok('P6 each row carries its product', rows.length === 2 && rows.map((r) => r.tag).sort().join() === 'IDPF,microsites', JSON.stringify(rows));
98
- const snap = await page.textContent('#snap');
99
- ok('P1 the header names what is read and what is not', /IDPF and microsites/.test(snap) && /not included/.test(snap) && /\b[Pp][Mm][Oo][Ss]\b|pmos/i.test(snap), snap);
100
- ok('P2 the picker says how many of the workspaces are on', (await page.textContent('#pick')).replace(/\s+/g, '') === 'Products2of3', await page.textContent('#pick'));
101
105
  await pick(page);
102
- const items = await page.$$eval('#pickMenu [role="menuitemcheckbox"]', (els) => els.map((e) => ({ name: e.textContent.trim(), on: e.getAttribute('aria-checked'), h: Math.round(e.getBoundingClientRect().height) })));
103
- ok('P2 the menu lists every workspace, the home one included, unticked', items.length === 3 && items.filter((i) => i.on === 'true').length === 2 && items.some((i) => i.on === 'false' && /home/.test(i.name)), JSON.stringify(items));
104
- const pickH = await page.$eval('#pick', (e) => Math.round(e.getBoundingClientRect().height));
105
- ok('P13 the picker and its items are at least 42 px high (the crumb menu\'s own height)', pickH >= 42 && items.every((i) => i.h >= 42), pickH + ' ' + JSON.stringify(items.map((i) => i.h)));
106
+ const snap = await until(async () => { const t = await page.textContent('#czViewer #hxSnap').catch(() => ''); return t || null; }, 10000) || '';
107
+ ok('P1 the Products card names what is read and what is not', /IDPF and microsites/.test(snap) && /not included/.test(snap) && /\b[Pp][Mm][Oo][Ss]\b|pmos/i.test(snap), snap);
108
+ ok('P1 the Products card is marked Waiting for design', /Waiting for design/.test(await page.textContent('#czViewer')));
109
+ ok('P2 the picker says how many of the workspaces are on', (await pickText(page)).replace(/\s+/g, '') === 'Products2of3', await pickText(page));
110
+ const items = await page.$$eval('#czViewer .hx-sw[data-ws]', (els) => els.map((e) => ({ name: e.getAttribute('aria-label'), on: e.getAttribute('aria-checked'), h: Math.round(e.closest('.hx-row').getBoundingClientRect().height) })));
111
+ ok('P2 the card lists every workspace, the home one included, switched off', items.length === 3 && items.filter((i) => i.on === 'true').length === 2 && items.some((i) => i.on === 'false' && /home/.test(i.name)), JSON.stringify(items));
112
+ ok('P13 each workspace\'s line is at least 42 px high', items.every((i) => i.h >= 42), JSON.stringify(items.map((i) => i.h)));
106
113
  // untick microsites: its row leaves, the setting is saved
107
- await page.click(`#pickMenu [data-ws="${wB.id}"]`);
114
+ await page.click(`#czViewer .hx-sw[data-ws="${wB.id}"]`);
108
115
  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));
109
116
  const saved = (await json('GET', '/api/settings')).body.settings.find((s) => s.key === 'ws.briefing.include');
110
117
  ok('P3 the choice is saved as a list of workspace ids', saved && JSON.stringify(saved.value) === JSON.stringify([wA.id]), JSON.stringify(saved));
111
- ok('P2 the count in the picker follows', (await page.textContent('#pick')).replace(/\s+/g, '') === 'Products1of3');
112
- ok('P13 keyboard: the menu stays open on the ticked item and Escape closes it', await page.evaluate((id) => document.activeElement && document.activeElement.dataset.ws === id, wB.id) && (await page.keyboard.press('Escape'), await until(async () => await page.$eval('#pickMenu', (e) => e.hidden), 3000)));
118
+ ok('P2 the count in the picker follows', !!(await until(async () => (await pickText(page)).replace(/\s+/g, '') === 'Products1of3', 10000)), await pickText(page));
119
+ await page.focus(`#czViewer .hx-sw[data-ws="${wA.id}"]`); await page.keyboard.press('Enter');
120
+ ok('P13 keyboard: Enter on a switch flips it', !!(await until(async () => (await page.getAttribute(`#czViewer .hx-sw[data-ws="${wA.id}"]`, 'aria-checked')) === 'false', 10000)));
121
+ await page.focus(`#czViewer .hx-sw[data-ws="${wA.id}"]`).catch(() => {}); await page.keyboard.press('Enter');
122
+ await until(async () => (await page.getAttribute(`#czViewer .hx-sw[data-ws="${wA.id}"]`, 'aria-checked')) === 'true', 10000);
123
+ await page.keyboard.press('Escape');
124
+ ok('P13 keyboard: Escape closes the card', !!(await until(() => page.evaluate(() => !window.czViewer.isOpen()), 3000)));
113
125
  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); })());
114
126
  // tick the home workspace
115
- await pick(page); await page.click(`#pickMenu [data-ws="${home.id}"]`);
116
- ok('P3 ticking the home workspace reads it', await until(async () => (await page.getAttribute(`#pickMenu [data-ws="${home.id}"]`, 'aria-checked')) === 'true' && new RegExp(home.name + ' and IDPF|IDPF and ' + home.name, 'i').test(await page.textContent('#snap')), 20000), await page.textContent('#snap'));
127
+ await pick(page); await page.click(`#czViewer .hx-sw[data-ws="${home.id}"]`);
128
+ ok('P3 switching the home workspace on reads it', await until(async () => (await page.getAttribute(`#czViewer .hx-sw[data-ws="${home.id}"]`, 'aria-checked')) === 'true' && new RegExp(home.name + ' and IDPF|IDPF and ' + home.name, 'i').test(await page.textContent('#czViewer #hxSnap')), 20000), await page.textContent('#czViewer #hxSnap').catch(() => ''));
117
129
  // back to the default
118
- await page.click('#pickMenu [data-reset]');
119
- ok('P3 Back to the default reads every product but the home one again', await until(async () => (await rowsOf(page)).length === 2, 20000) && (await page.textContent('#pick')).replace(/\s+/g, '') === 'Products2of3');
130
+ await page.click('#czViewer [data-reset]');
131
+ ok('P3 Back to the default reads every product but the home one again', await until(async () => (await rowsOf(page)).length === 2 && (await pickText(page)).replace(/\s+/g, '') === 'Products2of3', 20000), await pickText(page));
120
132
  ok('P3 and the saved choice is gone', (await json('GET', '/api/settings')).body.settings.find((s) => s.key === 'ws.briefing.include').changed === false);
121
133
  ok('no page error', errors.length === 0, errors.join(' | '));
122
134
  await ctx.close();
@@ -127,11 +139,11 @@ const product = (name, cond) => {
127
139
  const { ctx, page } = await open();
128
140
  await until(async () => (await rowsOf(page)).length === 2, 20000);
129
141
  const key = (await rowsOf(page)).find((r) => r.tag === 'IDPF').key;
130
- await page.click(`#rank .rr[data-key="${key}"] .rhd`);
131
- await page.waitForSelector('#dBody [data-op]');
132
- await page.click('#dBody [data-op="extend"]');
133
- await page.fill('#why', 'IDPF moves the date.');
134
- await page.click('#recBtn');
142
+ await page.click(`#hmList [data-hm-sel="n:${key}"]`);
143
+ await page.waitForSelector('#czViewer [data-hv-opt]');
144
+ await page.click('#czViewer [data-hv-opt="extend"]');
145
+ await page.fill('#hvWhy', 'IDPF moves the date.');
146
+ await page.click('#czViewer [data-hv-rec]');
135
147
  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)));
136
148
  const dA = fs.readFileSync(path.join(rootA, 'pm-decisions.md'), 'utf8'), dB = fs.readFileSync(path.join(rootB, 'pm-decisions.md'), 'utf8');
137
149
  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')));
@@ -158,15 +170,16 @@ const product = (name, cond) => {
158
170
  const { ctx, page } = await open({ w, h: 800, theme: th });
159
171
  await until(async () => (await rowsOf(page)).length >= 1, 20000);
160
172
  await pick(page);
161
- const o = await page.evaluate(() => ({ sw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth, menu: (() => { const r = document.querySelector('#pickMenu').getBoundingClientRect(); return { l: Math.round(r.left), r: Math.round(r.right) }; })() }));
162
- ok(`P13 at ${w} px, ${th}: no sideways scroll with the menu open, and the menu stays on screen`, o.sw <= o.cw && o.menu.l >= 0 && o.menu.r <= o.cw, JSON.stringify(o));
173
+ const o = await page.evaluate(() => ({ sw: document.documentElement.scrollWidth, cw: document.documentElement.clientWidth, menu: (() => { const r = document.querySelector('#czViewer').getBoundingClientRect(); return { l: Math.round(r.left), r: Math.round(r.right) }; })() }));
174
+ ok(`P13 at ${w} px, ${th}: no sideways scroll with the Products card open, and the card stays on screen`, o.sw <= o.cw && o.menu.l >= 0 && o.menu.r <= o.cw, JSON.stringify(o));
163
175
  await ctx.close();
164
176
  }
165
177
 
166
178
  {
167
179
  // the narrowed view (P12): the one-workspace page, with a way back
168
180
  const { ctx, page } = await open({ q: '?ws=' + encodeURIComponent(wB.id) });
169
- ok('P12 ?ws= shows that one workspace and a link back to the picked products', await until(async () => (await page.$('#pickAll')) !== null, 20000) && (await page.getAttribute('#pickAll', 'href')) === '/premium.html');
181
+ await pick(page);
182
+ ok('P12 ?ws= shows that one workspace and a link back to the picked products', await until(async () => (await page.$('#czViewer #pickAll')) !== null, 20000) && (await page.getAttribute('#czViewer #pickAll', 'href')) === '/premium.html');
170
183
  await ctx.close();
171
184
  }
172
185
  return finish();