create-pmos 0.421.0 → 0.423.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 (112) hide show
  1. package/package.json +25 -25
  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/scripts/anchor-resolve.js +93 -15
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/board-programs-test.js +87 -3
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +13 -11
  10. package/workspace/briefing-premium-initiative-test.js +30 -38
  11. package/workspace/changelog.json +24 -0
  12. package/workspace/fixtures/report-api/draft.json +2 -1
  13. package/workspace/guide/briefing-premium.md +2 -1
  14. package/workspace/guide/home.md +14 -4
  15. package/workspace/guide/programs.md +5 -3
  16. package/workspace/guide/workflows.md +5 -1
  17. package/workspace/home-other-product-test.js +55 -0
  18. package/workspace/ini-workflow-test.js +4 -4
  19. package/workspace/lib/board-premium.js +21 -6
  20. package/workspace/lib/custom-docs.js +65 -3
  21. package/workspace/lib/doc-live-root.js +37 -0
  22. package/workspace/lib/engine/anchor-resolve.js +93 -15
  23. package/workspace/lib/engine/boards.js +30 -2
  24. package/workspace/lib/engine/intake.js +1 -1
  25. package/workspace/lib/hold-spans.js +24 -10
  26. package/workspace/lib/initiative-writer.js +63 -1
  27. package/workspace/lib/kg.js +1 -1
  28. package/workspace/lib/plan-items.js +36 -5
  29. package/workspace/lib/programs.js +11 -3
  30. package/workspace/lib/report-draft.js +3 -0
  31. package/workspace/lib/route-modules.js +2 -0
  32. package/workspace/lib/routes-board-premium.js +28 -0
  33. package/workspace/lib/routes-boards.js +92 -13
  34. package/workspace/lib/routes-doc-sheet.js +29 -1
  35. package/workspace/lib/routes-initiatives.js +12 -0
  36. package/workspace/lib/routes-programs.js +44 -5
  37. package/workspace/lib/routes-task-links.js +329 -0
  38. package/workspace/lib/routes-task-plans.js +333 -0
  39. package/workspace/lib/split-merge-suggest.js +162 -0
  40. package/workspace/lib/split-merge.js +379 -0
  41. package/workspace/lib/task-cli.js +73 -13
  42. package/workspace/lib/task-items.js +15 -3
  43. package/workspace/lib/task-links.js +422 -0
  44. package/workspace/lib/task-plans.js +232 -0
  45. package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
  46. package/workspace/lib/vendor/scripts/intake.js +1 -1
  47. package/workspace/package-lock.json +2 -2
  48. package/workspace/package.json +1 -1
  49. package/workspace/premium-board-actions-test.js +2 -2
  50. package/workspace/premium-core-doc-issue-test.js +2 -2
  51. package/workspace/premium-vw-backlog-test.js +3 -3
  52. package/workspace/premium-vw-doc-test.js +26 -3
  53. package/workspace/premium-vw-item-test.js +3 -3
  54. package/workspace/premium-vw-jira-test.js +6 -6
  55. package/workspace/product-lane-test.js +165 -0
  56. package/workspace/program-leave-test.js +203 -0
  57. package/workspace/program-panel-test.js +1 -1
  58. package/workspace/public/pm/bd-acts.js +5 -2
  59. package/workspace/public/pm/bd-ini-panel.js +32 -9
  60. package/workspace/public/pm/bd-prog-panel.js +22 -7
  61. package/workspace/public/pm/bd-prog.js +6 -1
  62. package/workspace/public/pm/bd-span.js +234 -30
  63. package/workspace/public/pm/bd-views.js +3 -2
  64. package/workspace/public/pm/cozy-board.css +90 -0
  65. package/workspace/public/pm/cozy-home.css +3 -0
  66. package/workspace/public/pm/doc-follow.js +36 -0
  67. package/workspace/public/pm/home-app.js +62 -14
  68. package/workspace/public/pm/home-ini-model.js +0 -34
  69. package/workspace/public/pm/home-ini.js +81 -204
  70. package/workspace/public/pm/home-list.js +2 -2
  71. package/workspace/public/pm/home-today.js +3 -1
  72. package/workspace/public/pm/ini-groups.js +228 -0
  73. package/workspace/public/pm/ini-links.js +561 -0
  74. package/workspace/public/pm/ini-tasks.js +131 -30
  75. package/workspace/public/pm/ini-versions.js +348 -0
  76. package/workspace/public/pm/ini-view-model.js +113 -43
  77. package/workspace/public/pm/ini-view.css +341 -18
  78. package/workspace/public/pm/ini-view.js +153 -38
  79. package/workspace/public/pm/premium-board.js +160 -21
  80. package/workspace/public/pm/premium-report-read.js +20 -1
  81. package/workspace/public/pm/premium-shell.js +29 -4
  82. package/workspace/public/pm/premium-vw-doc.js +46 -11
  83. package/workspace/public/pm/prog-move.js +69 -0
  84. package/workspace/public/pm/split-merge.css +77 -0
  85. package/workspace/public/pm/split-merge.js +265 -0
  86. package/workspace/public/pm/stage-line.js +414 -0
  87. package/workspace/public/pm/task-card.css +3 -0
  88. package/workspace/public/pm/task-card.js +15 -6
  89. package/workspace/public/pm/wf-page.css +2 -0
  90. package/workspace/public/pm/wf-page.js +2 -0
  91. package/workspace/public/pm/wf-stage.js +2 -1
  92. package/workspace/server.js +15 -1
  93. package/workspace/split-merge-ui-test.js +175 -0
  94. package/workspace/stage-card-test.js +12 -11
  95. package/workspace/task-card-test.js +3 -2
  96. package/workspace/task-delete-test.js +126 -0
  97. package/workspace/task-links-test.js +227 -0
  98. package/workspace/task-milestones-test.js +176 -0
  99. package/workspace/task-plans-test.js +181 -0
  100. package/workspace/task-views-test.js +3 -3
  101. package/workspace/test-lists/bd-ini-panel.json +8 -2
  102. package/workspace/test-lists/product-lane.json +6 -0
  103. package/workspace/test-lists/program-leave.json +6 -0
  104. package/workspace/test-lists/split-merge.json +15 -0
  105. package/workspace/test-lists/task-delete.json +5 -0
  106. package/workspace/test-lists/task-links.json +6 -0
  107. package/workspace/test-lists/task-milestones.json +6 -0
  108. package/workspace/test-lists/task-plans.json +6 -0
  109. package/workspace/test-lists/viewer-live-file.json +9 -0
  110. package/workspace/timeline-holds-test.js +61 -4
  111. package/workspace/tk-tasks-test.js +173 -57
  112. package/workspace/workflows-setup-test.js +4 -3
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* task-links-test.js — links between tasks on the real pages (feedback batch 11 item 15; canvas In development, row "Task dependencies":
4
+ * DepA1Timeline, DepA2Drag, DepA3Joint, DepA4Move, DepA5List, DepA6Risk, DepA7Phone, DepA8Suggest, DepA9Adjust). Serves the real Board page
5
+ * from the real server; GET /api/board-premium answers fixtures/board-premium-facts.js with tasks, decorated by lib/task-links.js from a
6
+ * ledger of links, a quiet move and Claude's proposal. The page's clock is the fixture's (17 Oct 2026). The writes are answered here.
7
+ * H the Tasks header: count, the blue ✦ (proposals), the grey ✦ (quiet moves), the late count, in that order
8
+ * T the Timeline: lines hidden but the orange one; dots on linked ends; the orange start edge; the small blue ✦; hover draws the links;
9
+ * the legend's "Waits on" and the foot text
10
+ * J a joint: the type segment, lag ±, unlink and the sentence; a type posts /link
11
+ * S the chips' lists: ✓ posts /accept; the moved list says "Was", Undo all, the quiet switch, and marks them seen
12
+ * D drags: a dot onto another bar's start posts /link fs; a linked bar's move posts /move
13
+ * L List and Kanban: the link icon, the first task it waits on; a press opens Waits on / Then with a search
14
+ * P a phone: a tap on a linked bar opens Waits on / Then as a bottom sheet
15
+ * SHOTS=<dir> writes the screenshots there. */
16
+ const path = require('path');
17
+ const fs = require('fs');
18
+ const { spawn } = require('child_process');
19
+ const { findBrowser } = require('./lib/find-browser');
20
+ const T = require('./test-run').configure({ name: 'task-links-ui' });
21
+ const BP = require('./lib/board-premium.js');
22
+ const F = require('./fixtures/board-premium-facts.js');
23
+ const TL = require('./lib/task-links.js');
24
+
25
+ const BASE = T.BASE;
26
+ const SHOTS = process.env.SHOTS || '';
27
+ const results = [];
28
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
29
+ let srv = null; let browser = null;
30
+ const finish = async (code) => {
31
+ if (browser) await browser.close().catch(() => {});
32
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
33
+ T.killTmux();
34
+ const bad = results.filter((x) => !x.cond).length;
35
+ console.log(`\n${results.length - bad}/${results.length} task-links-ui assertions passed`);
36
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
37
+ };
38
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
39
+
40
+ /* the initiative: the spec is late, the API waits on it, the load test waits on the API; the pilot starts the day after the load test ends */
41
+ const INI = 'partner-rate-limits';
42
+ const task = (uid, title, start, end, status = 'To do') => ({ src: 'pmos', kind: 'Task', ini: INI, uid, title, status, owner: 'Lee', start, end });
43
+ const ITEMS = [
44
+ task('task-a', 'Draft the limits spec', '2026-10-05', '2026-10-15', 'In progress'),
45
+ task('task-b', 'Ship the limits API', '2026-10-21', '2026-11-13'),
46
+ task('task-c', 'Load test at 3x peak', '2026-11-16', '2026-11-20'),
47
+ task('task-f', 'Pilot with 3 partners', '2026-11-23', '2026-11-27'),
48
+ task('task-e', 'Partner FAQ', '2026-10-26', '2026-10-30'),
49
+ ];
50
+ const LINES = [
51
+ { at: '2026-10-12T09:00:00Z', kind: 'link', board: 'w1', ini: INI, from: 'task-a', to: 'task-b', type: 'fs', lag: 0, source: 'you' },
52
+ { at: '2026-10-12T09:01:00Z', kind: 'link', board: 'w1', ini: INI, from: 'task-b', to: 'task-c', type: 'fs', lag: 0, source: 'chat' },
53
+ { at: '2026-10-17T08:00:00Z', kind: 'moved', board: 'w1', ini: INI, batch: 'b-1', via: 'quiet', moves: [{ task: 'task-c', title: 'Load test at 3x peak', from: { start: '2026-11-12', due: '2026-11-18' }, to: { start: '2026-11-16', due: '2026-11-20' }, why: 'waits on Ship the limits API' }] },
54
+ ];
55
+ function model() {
56
+ const m = BP.build(F.facts({ items: ITEMS.map((x) => ({ ...x })) }));
57
+ for (const r of m.rows) if (r.id === INI) { r.start = '2026-10-05'; r.end = '2026-12-15'; }
58
+ TL.decorate(m.rows, TL.fold(LINES), ITEMS, { today: '2026-10-17' });
59
+ return m;
60
+ }
61
+
62
+ (async () => {
63
+ const exe = findBrowser();
64
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
65
+ let chromium;
66
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
67
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
68
+ await T.waitForServer(BASE);
69
+ browser = await chromium.launch({ executablePath: exe });
70
+ const shot = async (page, name, sel) => { if (!SHOTS) return; fs.mkdirSync(SHOTS, { recursive: true }); const p = path.join(SHOTS, name + '.png'); if (sel) await page.locator(sel).first().screenshot({ path: p }); else await page.screenshot({ path: p }); };
71
+
72
+ const open = async (o = {}) => {
73
+ const ctx = await browser.newContext({ viewport: { width: o.w || 1440, height: o.h || 900 } });
74
+ const page = await ctx.newPage();
75
+ const errors = [], posts = [];
76
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
77
+ await page.clock.setFixedTime(new Date(F.NOW));
78
+ await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: model(), as_of: Date.now() }) }));
79
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
80
+ await page.route('**/api/boards/items*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, items: ITEMS.concat([{ src: 'pmos', kind: 'Task', ini: 'usage-billing', uid: 'task-x', title: 'Metering service', start: '2026-11-02', end: '2026-12-18', status: 'To do' }]) }) }));
81
+ await page.route('**/api/task-links/**', (r) => {
82
+ const u = new URL(r.request().url()), body = r.request().method() === 'POST' ? r.request().postDataJSON() : null;
83
+ if (body) posts.push({ route: u.pathname.replace('/api/task-links', ''), body });
84
+ const ans = { ok: true, moved: [], cant: [], linked: [], batch: 'b-x' };
85
+ r.fulfill({ contentType: 'application/json', body: JSON.stringify(ans) });
86
+ });
87
+ await page.addInitScript(([s]) => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); for (const [k, v] of Object.entries(s)) localStorage.setItem(k, v); } } catch { /* none */ } },
88
+ [{ 'pmos.board.view': 'time', 'pmos.board.span': 'half', 'pmos.tasks.view': o.view || 'timeline', 'pmos.tasks.zoom': 'week' }]);
89
+ await page.goto(BASE + '/premium-board.html?ws=w1&board=w1');
90
+ await page.waitForSelector('#ibBody [data-key]', { timeout: 15000 });
91
+ await page.waitForTimeout(400);
92
+ await page.locator(`[data-key="board:${INI}"]`).first().click();
93
+ await page.waitForSelector('#czViewer .iv-th', { timeout: 8000 });
94
+ await page.waitForTimeout(400);
95
+ return { ctx, page, errors, posts };
96
+ };
97
+ const bar = (uid) => `#czViewer [data-ivt-bar="${uid}"]`;
98
+
99
+ {
100
+ const { ctx, page, errors, posts } = await open();
101
+ // ── H: the header
102
+ const H = await page.evaluate(() => {
103
+ const h = document.querySelector('#czViewer .iv-th');
104
+ return { order: [...h.children].map((n) => (n.classList.contains('n') ? 'count' : n.dataset.lkChip || n.className.split(' ')[0])).filter((x) => /count|prop|moved|late|vs-/.test(x)),
105
+ prop: (h.querySelector('[data-lk-chip="prop"]') || {}).textContent || '', moved: (h.querySelector('[data-lk-chip="moved"]') || {}).textContent || '', late: (h.querySelector('[data-lk-chip="late"]') || {}).textContent || '' };
106
+ });
107
+ ok('H1 the header: count, then the blue ✦, the grey ✦ and the late count, in that order', H.order.slice(0, 4).join(',') === 'count,prop,moved,late', JSON.stringify(H));
108
+ ok('H2 the counts: 1 proposal (the pilot starts the day after the load test), 1 quiet move, 2 tasks after a late one', H.prop.trim() === '1' && H.moved.trim() === '1' && H.late.trim() === '2', JSON.stringify(H));
109
+
110
+ // ── T: the Timeline
111
+ const T0 = await page.evaluate(() => {
112
+ const v = document.querySelector('#czViewer'), b = (u) => v.querySelector(`[data-ivt-bar="${u}"]`);
113
+ return { lines: [...v.querySelectorAll('.lk-sv path.lk-ln')].map((p) => p.getAttribute('class')), dotsB: b('task-b').querySelectorAll('.lk-dt.on').length, dotsE: b('task-e').querySelectorAll('.lk-dt.on').length,
114
+ edge: ['task-b', 'task-c', 'task-a'].map((u) => !!b(u).querySelector('.lk-le')), star: !!b('task-c').querySelector('.lk-mv'), legend: (v.querySelector('.ivt-lg') || {}).textContent || '',
115
+ label: b('task-b').getAttribute('aria-label') };
116
+ });
117
+ ok('T1 by default only the late link draws (orange); the others stay hidden', T0.lines.length === 1 && /\bor\b/.test(T0.lines[0]), JSON.stringify(T0.lines));
118
+ ok('T2 a linked bar shows a grey dot at each linked end; an unlinked one shows none', T0.dotsB === 2 && T0.dotsE === 0, JSON.stringify(T0));
119
+ ok('T3 the tasks after the late one carry the orange start edge; the late task keeps its date and no edge', T0.edge.join() === 'true,true,false', JSON.stringify(T0.edge));
120
+ ok('T4 the quietly moved task carries the small blue ✦', T0.star, JSON.stringify(T0));
121
+ ok('T5 the legend says "Waits on" and the foot names the dot', /Waits on/.test(T0.legend) && /a dot to link it/.test(T0.legend), T0.legend);
122
+ ok('T6 the bar\'s label says what it waits on', /waits on Draft the limits spec/.test(T0.label), T0.label);
123
+ await shot(page, 'DepBuild1Timeline', '#czViewer');
124
+ await page.hover(bar('task-b'));
125
+ await page.waitForTimeout(150);
126
+ const T1 = await page.evaluate(() => ({ lines: [...document.querySelectorAll('#czViewer .lk-sv path.lk-ln')].map((p) => p.getAttribute('class')), joints: document.querySelectorAll('#czViewer .lk-jt').length }));
127
+ ok('T7 hovering a bar draws its links (dark), each with a joint', T1.lines.length === 2 && T1.lines.some((c) => /sel/.test(c)) && T1.joints === 2, JSON.stringify(T1));
128
+ await shot(page, 'DepBuild2Hover', '#czViewer .ivt');
129
+
130
+ // ── J: a joint
131
+ await page.locator('#czViewer .lk-jt[data-lk-joint="task-b>task-c"]').click({ force: true });
132
+ await page.waitForSelector('.lk-pop .lk-jc', { timeout: 4000 });
133
+ const J = await page.evaluate(() => { const m = document.querySelector('.lk-pop .lk-jc'); return { seg: m.querySelectorAll('[data-lk-type]').length, on: (m.querySelector('[data-lk-type].on') || {}).dataset.lkType, lag: !!m.querySelector('[data-lk-lag="1"]'), un: !!m.querySelector('[data-lk-unlink]'), say: (m.querySelector('.lk-say') || {}).textContent || '' }; });
134
+ ok('J1 the joint: four types (finish → start on), lag ±, unlink, and the link in one sentence', J.seg === 4 && J.on === 'fs' && J.lag && J.un && /Load test at 3x peak starts when Ship the limits API finishes/.test(J.say), JSON.stringify(J));
135
+ await shot(page, 'DepBuild3Joint');
136
+ await page.locator('.lk-pop [data-lk-type="ss"]').click();
137
+ await page.waitForTimeout(300);
138
+ const pl = posts.filter((p) => p.route === '/link');
139
+ ok('J2 a type posts /link with it', pl.length === 1 && pl[0].body.type === 'ss' && pl[0].body.from === 'task-b' && pl[0].body.to === 'task-c', JSON.stringify(posts));
140
+
141
+ // ── S: the chips' lists
142
+ await page.locator('#czViewer [data-lk-chip="prop"]').click();
143
+ await page.waitForSelector('.lk-pop .lk-m', { timeout: 4000 });
144
+ const S1 = await page.evaluate(() => { const m = document.querySelector('.lk-pop .lk-m'); return { text: m.textContent, yes: m.querySelectorAll('[data-lk-yes]').length, no: m.querySelectorAll('[data-lk-no]').length, dashed: document.querySelectorAll('#czViewer .lk-sv path.lk-ln.pp').length }; });
145
+ ok('S1 the blue ✦ lists the proposal with ✓ and ✕, and draws it dashed blue while open', S1.yes === 1 && S1.no === 1 && /Load test at 3x peak/.test(S1.text) && /Pilot with 3 partners/.test(S1.text) && S1.dashed === 1, JSON.stringify(S1));
146
+ await shot(page, 'DepBuild4Proposals');
147
+ await page.locator('.lk-pop [data-lk-yes]').click();
148
+ await page.waitForTimeout(300);
149
+ const acc = posts.filter((p) => p.route === '/accept');
150
+ ok('S2 ✓ posts /accept with that proposal', acc.length === 1 && acc[0].body.initiative === 'partner-rate-limits' && acc[0].body.ids.length === 1, JSON.stringify(acc));
151
+ await page.locator('#czViewer [data-lk-chip="moved"]').click();
152
+ await page.waitForSelector('.lk-pop .lk-m', { timeout: 4000 });
153
+ const S3 = await page.evaluate(() => { const m = document.querySelector('.lk-pop .lk-m'); return { text: m.textContent, undo: !!m.querySelector('[data-lk-undoall]'), sw: !!m.querySelector('[data-lk-quiet][aria-checked="true"]') }; });
154
+ ok('S3 the grey ✦ lists the move with its new date, "Was …" and why; Undo all; the quiet switch is on', /Load test at 3x peak/.test(S3.text) && /Was Nov 12 → 18/.test(S3.text) && /Waits on Ship the limits API/.test(S3.text) && S3.undo && S3.sw, JSON.stringify(S3));
155
+ await shot(page, 'DepBuild5Moved');
156
+ ok('S4 opening it marks the moves seen', posts.some((p) => p.route === '/seen' && p.body.initiative === 'partner-rate-limits'), JSON.stringify(posts.map((p) => p.route)));
157
+ await page.keyboard.press('Escape');
158
+
159
+ // ── D: drags
160
+ const c = await page.locator(bar('task-c')).boundingBox(), f = await page.locator(bar('task-f')).boundingBox();
161
+ await page.mouse.move(c.x + c.width / 2, c.y + c.height / 2);
162
+ await page.waitForTimeout(100);
163
+ const dot = await page.locator(bar('task-c') + ' .lk-dt.r').boundingBox();
164
+ await page.mouse.move(dot.x + dot.width / 2, dot.y + dot.height / 2);
165
+ await page.mouse.down();
166
+ await page.mouse.move(f.x + 6, f.y + f.height / 2, { steps: 6 });
167
+ await page.waitForTimeout(100);
168
+ const tip = await page.evaluate(() => (document.querySelector('#czViewer .lk-tip') || {}).textContent || '');
169
+ ok('D1 dragging a dot onto another bar\'s start names the link: finish → start, which waits on which', /Finish → start/.test(tip) && /Pilot with 3 partners waits on Load test at 3x peak/.test(tip), tip);
170
+ await shot(page, 'DepBuild6Drag', '#czViewer .ivt');
171
+ await page.mouse.up();
172
+ await page.waitForTimeout(400);
173
+ const ln = posts.filter((p) => p.route === '/link');
174
+ ok('D2 letting go posts /link task-c → task-f, finish → start, and no date picker opens', ln.length === 2 && ln[1].body.from === 'task-c' && ln[1].body.to === 'task-f' && ln[1].body.type === 'fs' && !(await page.$('.tkc.ivq:not(.lk-pop)')), JSON.stringify(ln));
175
+ // bring the bar into view, and out from under the sticky names
176
+ await page.locator(bar('task-b')).scrollIntoViewIfNeeded();
177
+ await page.evaluate(() => { const sc = document.querySelector('#czViewer .ivt-sc'), n = document.querySelector('#czViewer .ivt-n'), x = document.querySelector('#czViewer [data-ivt-bar="task-b"]'); sc.scrollLeft += x.getBoundingClientRect().left - n.getBoundingClientRect().right - 40; });
178
+ await page.waitForTimeout(100);
179
+ const b = await page.locator(bar('task-b')).boundingBox();
180
+ await page.mouse.move(b.x + 30, b.y + b.height / 2);
181
+ await page.mouse.down();
182
+ await page.mouse.move(b.x + 100, b.y + b.height / 2, { steps: 6 });
183
+ await page.mouse.up();
184
+ await page.waitForTimeout(400);
185
+ const mv = posts.filter((p) => p.route === '/move');
186
+ ok('D3 moving a linked bar posts /move (what waits follows, with Undo)', mv.length === 1 && mv[0].body.task === 'task-b' && mv[0].body.start > '2026-10-21', JSON.stringify(mv));
187
+ ok('D4 no page error', errors.length === 0, errors.join(' | '));
188
+ await ctx.close();
189
+ }
190
+
191
+ // ── L: the List and Kanban
192
+ for (const view of ['list', 'kanban']) {
193
+ const { ctx, page, errors } = await open({ view });
194
+ if (view === 'kanban') { await page.locator('#czViewer [data-iv-kstage]').click(); await page.locator('.tkc.ivq [data-ivq-i="1"]').click(); await page.waitForTimeout(300); }
195
+ const m = await page.evaluate(() => [...document.querySelectorAll('#czViewer .lk-mt')].map((x) => x.textContent.trim()));
196
+ ok(`L1 ${view}: the link icon and the first task it waits on`, m.includes('Draft the limits spec') && m.includes('Ship the limits API'), JSON.stringify(m));
197
+ await page.locator('#czViewer .lk-mt[data-lk-meta="task-c"]').first().click();
198
+ await page.waitForSelector('.lk-pop .lk-wt', { timeout: 4000 });
199
+ const W = await page.evaluate(() => { const m = document.querySelector('.lk-pop .lk-wt'); return { text: m.textContent, find: !!m.querySelector('[data-lk-find]') }; });
200
+ ok(`L2 ${view}: a press opens Waits on / Then with a search`, /Waits on/.test(W.text) && /Ship the limits API/.test(W.text) && W.find, JSON.stringify(W));
201
+ if (view === 'list') {
202
+ await page.locator('.lk-pop [data-lk-find]').fill('meter');
203
+ await page.waitForSelector('.lk-pop [data-lk-pick]', { timeout: 4000 });
204
+ const r = await page.locator('.lk-pop [data-lk-pick]').first().textContent();
205
+ ok('L3 the search finds a task in another initiative and says so', /Metering service/.test(r) && /Another initiative/.test(r), r);
206
+ await shot(page, 'DepBuild7List');
207
+ }
208
+ ok(`L4 ${view}: no page error`, errors.length === 0, errors.join(' | '));
209
+ await ctx.close();
210
+ }
211
+
212
+ // ── P: a phone
213
+ {
214
+ const { ctx, page, errors } = await open({ w: 390, h: 844 });
215
+ await page.locator(bar('task-b')).first().click();
216
+ await page.waitForSelector('.lk-pop.sheet', { timeout: 4000 });
217
+ const P = await page.evaluate(() => { const s = document.querySelector('.lk-pop.sheet'), r = s.getBoundingClientRect(); return { bottom: Math.round(r.bottom), w: Math.round(r.width), text: s.textContent, dates: !!s.querySelector('[data-lk-dates]'), lines: document.querySelectorAll('#czViewer .lk-sv path.lk-ln').length, scroll: document.documentElement.scrollWidth }; });
218
+ ok('P1 a tap on a linked bar draws its links and opens Waits on / Then as a bottom sheet, with its dates one row down', P.bottom === 844 && P.w === 390 && /Waits on/.test(P.text) && /Then/.test(P.text) && P.dates && P.lines >= 2 && P.scroll <= 390, JSON.stringify(P));
219
+ await shot(page, 'DepBuild8Phone');
220
+ await page.locator('.lk-pop [data-lk-dates]').click();
221
+ await page.waitForTimeout(300);
222
+ ok('P2 "Change the dates" opens the date picker', !!(await page.$('.tkc.ivq .tkc-pop')), '');
223
+ ok('P3 no page error', errors.length === 0, errors.join(' | '));
224
+ await ctx.close();
225
+ }
226
+ finish();
227
+ })().catch((e) => { console.error(e); finish(1); });
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* task-milestones-test.js — several milestones per initiative on the page (feedback batch 11 item 3; canvas In development, row "Several
4
+ * milestones per initiative": XmlA1Board, XmlA4Hover, XmlA5Phone, XmlA7Spans, XmlA2Flag, XmlA3Viewer, XmlAGrill). Serves the real page from the
5
+ * real server; GET /api/board-premium answers a board built by lib/board-premium.js from rows and work items that carry the ◇ flag. The page's
6
+ * clock is the fixture's (17 Oct 2026). POST /api/boards/tasks/edit is answered here and its bodies are kept.
7
+ * B the Board row: one ◇ per milestone at its due date, filled when done, orange and an orange date when late (the row's dot turns orange
8
+ * too); the Evaluate task IS the end ◇ (said once); the Deliver task keeps its own ◇ with "◆ Deliver" in its name; the legend says Milestone
9
+ * M close ◇s merge into one counted ◇; pressing it lists them under it; a row opens the task card
10
+ * S Quarter puts a date under each ◇; 5 yr none
11
+ * F the status picker: ◇ after a divider; a press writes milestone true; the List shows ◇ after a milestone's title and asks for a due date
12
+ * V the Tasks Timeline: a milestone's bar ends in its ◇ with the date; a dashed guide drops at its date
13
+ * P the phone: no dates; a tap on the row's lane opens a sheet with its milestones
14
+ * SHOTS_3=<dir>: the Board, the counted ◇'s list, the picker, the Tasks Timeline and the phone sheet, into <dir>. */
15
+ const path = require('path');
16
+ const { spawn } = require('child_process');
17
+ const { findBrowser } = require('./lib/find-browser');
18
+ const T = require('./test-run').configure({ name: 'task-milestones' });
19
+ const BP = require('./lib/board-premium.js');
20
+ const F = require('./fixtures/board-premium-facts.js');
21
+
22
+ const BASE = T.BASE;
23
+ const results = [];
24
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
25
+ let srv = null; let browser = null;
26
+ const finish = async (code) => {
27
+ if (browser) await browser.close().catch(() => {});
28
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
29
+ T.killTmux();
30
+ const bad = results.filter((x) => !x.cond).length;
31
+ console.log(`\n${results.length - bad}/${results.length} task-milestones assertions passed`);
32
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
33
+ };
34
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
35
+
36
+ const ROWS = [
37
+ F.row('scarlet', 'Scarlet — ST What’s The News', { owner: 'Wawan', stage: 'Build', start: '2026-11-02', end: '2027-03-31', progress: 30 }),
38
+ F.row('passkey', 'Passkey sign-in', { owner: 'Lee', start: '2026-09-15', end: '2027-02-26', progress: 45 }),
39
+ F.row('recovery', 'Recovery codes', { owner: 'Dara', start: '2026-12-01', end: '2027-04-30', progress: 10 }),
40
+ F.row('email-otp', 'Email OTP', { start: '2026-11-10', end: '2027-06-30', progress: 5 }),
41
+ ];
42
+ const it = (ini, uid, title, o) => ({ uid, key: '', kind: 'Task', src: 'pmos', title, status: 'To do', owner: 'Wawan', ini, start: null, end: null, ref: uid, board: 'w1', milestone: true, ...o });
43
+ const ITEMS = [
44
+ it('scarlet', 'task-pilot', 'Pilot with 2 newsrooms', { status: 'Done', start: '2026-11-02', end: '2026-12-11', section: 'build' }),
45
+ it('scarlet', 'task-api', 'Ship the article summaries API', { status: 'In progress', start: '2026-11-02', end: '2027-01-08', section: 'build', milestone: false }),
46
+ it('scarlet', 'task-feat', 'Feature delivered', { start: '2027-01-18', end: '2027-01-29', section: 'deliver' }),
47
+ it('scarlet', 'task-kpi', 'KPI evaluated', { start: '2027-03-22', end: '2027-03-31', section: 'evaluate' }),
48
+ it('scarlet', 'task-faq', 'Support FAQ', { section: 'evaluate', end: null }),
49
+ it('passkey', 'task-late', 'Beta to staff', { start: '2026-10-01', end: '2026-10-16' }),
50
+ it('passkey', 'task-pk2', 'Rollout 50%', { end: '2026-12-18' }),
51
+ it('recovery', 'task-c1', 'Codes live', { end: '2027-03-02' }),
52
+ it('recovery', 'task-c2', 'Support FAQ live', { end: '2027-03-06' }),
53
+ it('recovery', 'task-wont', 'Dropped', { end: '2027-02-01', status: "Won't do" }),
54
+ ];
55
+
56
+ (async () => {
57
+ const exe = findBrowser();
58
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
59
+ let chromium;
60
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
61
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
62
+ await T.waitForServer(BASE);
63
+ browser = await chromium.launch({ executablePath: exe });
64
+
65
+ /** The Board on the timeline. o: { w, h, span, dark, tasksView } */
66
+ const open = async (o = {}) => {
67
+ const ctx = await browser.newContext({ viewport: { width: o.w || 1440, height: o.h || 900 }, colorScheme: o.dark ? 'dark' : 'light', hasTouch: !!o.phone, isMobile: !!o.phone });
68
+ const page = await ctx.newPage();
69
+ const errors = [], posts = [];
70
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
71
+ await page.clock.setFixedTime(new Date(F.NOW));
72
+ const rows = ROWS.map((r) => ({ ...r }));
73
+ await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(F.facts({ rows, total: rows.length, columns: [], items: ITEMS.map((x) => ({ ...x })) })), as_of: Date.now() }) }));
74
+ await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs: [] }) }));
75
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
76
+ await page.route('**/api/boards/tasks/edit', (r) => { posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, from: { milestone: false } }) }); });
77
+ await page.addInitScript(([s]) => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); for (const [k, v] of Object.entries(s)) localStorage.setItem(k, v); } } catch { /* none */ } }, [{ 'pmos.board.view': 'time', 'pmos.board.pview': 'time', 'pmos.board.span': o.span || 'year', 'pmos.tasks.view': o.tasksView || 'list', 'pmos.tasks.zoom': 'month' }]);
78
+ await page.goto(BASE + '/premium-board.html?ws=w1&board=w1');
79
+ await page.waitForSelector('#ibBody [data-row]', { timeout: 15000 });
80
+ await page.waitForTimeout(500);
81
+ return { ctx, page, errors, posts };
82
+ };
83
+ const shots = process.env.SHOTS_3;
84
+ const shot = async (p, name) => { if (shots) await p.screenshot({ path: path.join(shots, name + '.png') }); };
85
+ const rowOf = (p, key) => p.evaluate((k) => {
86
+ const r = document.querySelector(`#ibBody [data-row="${k}"]`); if (!r) return null;
87
+ return {
88
+ dot: (r.querySelector('.cz-dot') || {}).className || '',
89
+ tm: [...r.querySelectorAll('.tg-tm')].map((x) => x.className + '|' + x.getAttribute('title')),
90
+ tmc: [...r.querySelectorAll('.tg-tmc')].map((x) => x.className + '|' + x.textContent + '|' + x.dataset.msIds),
91
+ tml: [...r.querySelectorAll('.tg-tml')].map((x) => x.className + '|' + x.textContent),
92
+ end: r.querySelector('.tg-end') ? r.querySelector('.tg-end').className + '|' + r.querySelector('.tg-end').getAttribute('title') : '',
93
+ };
94
+ }, key);
95
+
96
+ /* B M — desktop, Year */
97
+ {
98
+ const { ctx, page: p, errors } = await open();
99
+ const sc = await rowOf(p, 'board:scarlet');
100
+ ok('B one ◇ per milestone: the done Pilot filled, Feature delivered open with "◆ Deliver" in its name; no ◇ for a plain task or one with no due date',
101
+ sc && sc.tm.length === 2 && /tg-tm dn\|Pilot with 2 newsrooms · Dec 11 · done/.test(sc.tm[0]) && /^tg-tm\|Feature delivered · Jan 29 · ◆ Deliver$/.test(sc.tm[1]), JSON.stringify(sc));
102
+ ok('B said once: the Evaluate task IS the end ◇ and takes its name; it is not drawn again', sc && /^tg-end\|KPI evaluated · Mar 31 · ◆ Evaluate$/.test(sc.end) && !sc.tm.some((x) => /KPI/.test(x)), JSON.stringify(sc));
103
+ ok('S Year cuts each date to fit and puts it under its ◇', sc && sc.tml.map((x) => x.split('|')[1]).join() === 'Dec 11,Jan 29', JSON.stringify(sc && sc.tml));
104
+ const pk = await rowOf(p, 'board:passkey');
105
+ ok('B a late milestone: an orange outline and an orange date, and the row\'s dot turns orange', pk && /tg-tm late/.test(pk.tm[0]) && /tg-tml late\|Oct 16/.test(pk.tml[0]) && /cz-dot late/.test(pk.dot), JSON.stringify(pk));
106
+ const rc = await rowOf(p, 'board:recovery');
107
+ ok('M two milestones four days apart merge into one counted ◇ with the range under it; Won\'t do is not drawn', rc && rc.tm.length === 0 && rc.tmc.length === 1 && /^tg-tmc\|2\|task-c1 task-c2$/.test(rc.tmc[0]) && rc.tml.join() === 'tg-tml|Mar 2–6', JSON.stringify(rc));
108
+ const lg = await p.evaluate(() => (document.querySelector('#bdChipset .tg-lgd') || document.querySelector('.tg-lgd') || {}).textContent || '');
109
+ ok('B the legend says Milestone, not "Deliver or Evaluate"', /Milestone/.test(lg) && !/Deliver or Evaluate/.test(lg), lg);
110
+ await shot(p, 'milestones-board-1440');
111
+ await p.click('#ibBody [data-row="board:recovery"] .tg-tmc');
112
+ const list = await p.evaluate(() => { const m = document.querySelector('.tg-msp'); return m ? [...m.querySelectorAll('[data-ms-open]')].map((b) => b.textContent) : null; });
113
+ ok('M the counted ◇ lists its milestones right under it: ◇, name, date', list && list.join('|') === 'Codes liveMar 2|Support FAQ liveMar 6', JSON.stringify(list));
114
+ await shot(p, 'milestones-board-list-1440');
115
+ await p.keyboard.press('Escape');
116
+ ok('M Escape closes the list', await p.evaluate(() => !document.querySelector('.tg-msp')));
117
+ ok('the Board threw nothing', !errors.length, errors.join('\n'));
118
+ await ctx.close();
119
+ }
120
+
121
+ /* S — Quarter and 5 yr */
122
+ {
123
+ const { ctx, page: p } = await open({ span: 'quarter' });
124
+ const sc = await rowOf(p, 'board:scarlet');
125
+ ok('S Quarter puts a short date under every ◇', sc && sc.tml.map((x) => x.split('|')[1]).join() === 'Dec 11,Jan 29', JSON.stringify(sc && sc.tml));
126
+ await ctx.close();
127
+ const { ctx: c5, page: p5 } = await open({ span: 'y5' });
128
+ const s5 = await rowOf(p5, 'board:scarlet');
129
+ ok('S 5 yr draws the ◇s with no dates', s5 && !s5.tml.length && (s5.tm.length + s5.tmc.length) >= 1, JSON.stringify(s5));
130
+ await c5.close();
131
+ }
132
+
133
+ /* F V — the initiative panel: the List, the status picker, the Tasks Timeline */
134
+ {
135
+ const { ctx, page: p, errors, posts } = await open();
136
+ await p.click('#ibBody [data-key="board:scarlet"]');
137
+ await p.waitForSelector('.iv-tr', { timeout: 8000 });
138
+ // every stage open, so each task row is drawn
139
+ const unfold = async (sel) => { for (let i = 0; i < 12; i++) { const b = await p.$(sel); if (!b) break; await b.click(); await p.waitForTimeout(80); } };
140
+ await unfold('.iv-ws[data-iv-fold^="sec:"][aria-expanded="false"]');
141
+ const rows = await p.evaluate(() => [...document.querySelectorAll('.iv-tr')].map((r) => ({ t: (r.querySelector('.iv-tt') || {}).textContent, ms: !!r.querySelector('.iv-ms'), ask: (r.querySelector('.iv-dc.ms') || {}).textContent || '' })));
142
+ const by = (t) => rows.find((x) => x.t === t) || {};
143
+ ok('F the List shows a small ◇ after a milestone task\'s title, none after a plain task', by('Feature delivered').ms && by('KPI evaluated').ms && !by('Ship the article summaries API').ms, JSON.stringify(rows));
144
+ ok('F a milestone with no due date asks for it in a dashed chip', by('Support FAQ').ask === 'Set the due date', JSON.stringify(by('Support FAQ')));
145
+ await p.click('.iv-tr:has(.iv-tt:text-is("Ship the article summaries API")) .iv-car');
146
+ const pick = await p.evaluate(() => { const b = document.querySelector('.ivq-st .ivq-ms'); return b ? { lbl: b.getAttribute('aria-label'), tip: b.getAttribute('title'), pressed: b.getAttribute('aria-pressed'), vr: document.querySelectorAll('.ivq-st .vr').length, text: b.textContent } : null; });
147
+ ok('F the status picker holds ◇ after a divider, icon only, its tooltip says what it does', pick && pick.lbl === 'Make it a milestone' && pick.pressed === 'false' && pick.vr === 3 && pick.text === '' && /due date shows as ◇ on the Board and the timeline/.test(pick.tip), JSON.stringify(pick));
148
+ await shot(p, 'milestones-picker-1440');
149
+ await p.click('.ivq-st .ivq-ms'); await p.waitForTimeout(300);
150
+ ok('F pressing ◇ writes milestone true for that task', posts.length === 1 && posts[0].task === 'task-api' && posts[0].milestone === true, JSON.stringify(posts));
151
+ // the Tasks Timeline
152
+ await p.evaluate(() => { const b = document.querySelector('[data-iv-view="timeline"]'); if (b) b.click(); });
153
+ await p.waitForSelector('.ivt', { timeout: 5000 });
154
+ await unfold('.ivt-gh[data-iv-fold^="sec:"][aria-expanded="false"]');
155
+ const tv = await p.evaluate(() => ({ ms: [...document.querySelectorAll('.ivt-ms')].map((x) => x.className + '|' + x.textContent), guides: document.querySelectorAll('.ivt-grid i.ms').length, lg: (document.querySelector('.ivt-lg') || {}).textContent || '' }));
156
+ ok('V a milestone\'s bar ends in its ◇ with the date beside it; a done one filled', tv.ms.some((x) => /^ivt-ms dn\|Dec 11$/.test(x)) && tv.ms.some((x) => /^ivt-ms\|Jan 29$/.test(x)) && tv.ms.some((x) => /^ivt-ms\|Mar 31$/.test(x)), JSON.stringify(tv));
157
+ ok('V a faint dashed guide drops at each milestone date, and the legend names Milestone', tv.guides === 3 && /Milestone/.test(tv.lg), JSON.stringify(tv));
158
+ await shot(p, 'milestones-viewer-timeline-1440');
159
+ ok('the panel threw nothing', !errors.length, errors.join('\n'));
160
+ await ctx.close();
161
+ }
162
+
163
+ /* P — the phone */
164
+ {
165
+ const { ctx, page: p, errors } = await open({ w: 390, h: 844, phone: true });
166
+ const sc = await rowOf(p, 'board:scarlet');
167
+ ok('P the phone draws the ◇s with no dates', sc && sc.tm.length === 2 && !sc.tml.length, JSON.stringify(sc));
168
+ await p.click('#ibBody .tgq-r[data-row="board:scarlet"] > .tg-p', { position: { x: 300, y: 10 } });
169
+ const sh = await p.evaluate(() => { const m = document.querySelector('.tg-msp.sh'); return m ? { h: (m.querySelector('.h') || {}).textContent, rows: [...m.querySelectorAll('[data-ms-open]')].map((b) => b.textContent) } : null; });
170
+ ok('P a tap on the row opens a sheet with its milestones, the end one too', sh && sh.h === 'Scarlet — ST What’s The News' && sh.rows.join('|') === 'Pilot with 2 newsroomsDec 11|Feature deliveredJan 29|KPI evaluatedMar 31', JSON.stringify(sh));
171
+ await shot(p, 'milestones-phone-390');
172
+ ok('the phone threw nothing', !errors.length, errors.join('\n'));
173
+ await ctx.close();
174
+ }
175
+ finish();
176
+ })();
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* task-plans-test.js — planned versus actual on the real pages (feedback batch 11 item 8; canvas In development, row "Planned vs actual":
4
+ * PvaAC1Live, PvaAC2Menu, PvaAC3Draft, PvaAC4Board, PvaAC5Phone). Serves the real Board page from the real server; GET /api/board-premium
5
+ * answers fixtures/board-premium-facts.js with tasks, decorated by lib/task-plans.js from a saved plan and drafts. The page's clock is the
6
+ * fixture's (17 Oct 2026). The writes are answered here: nothing reaches a ledger.
7
+ * B Board timeline: the plan's thin line under the bar, the slip after the end date, a draft-only initiative dashed with its drafts named,
8
+ * the legend's To do, Plan and Draft
9
+ * V the initiative's Tasks timeline: the chip "Live" with the count of drafts, the end slip chip, a plan line only where the dates differ,
10
+ * ⊕ after a task added after the plan, a dropped task keeps only its line
11
+ * M the chip's menu right under it: Show (Live, drafts, New draft from Live), Compare with (plans, Nothing, Save Live as a plan)
12
+ * D a draft: the chip names it in blue, its bars are dashed, the seal "Make … live" shows; its summary, then ✓ posts Make live
13
+ * P a phone: the menu opens as a bottom sheet
14
+ * SHOTS=<dir> writes the screenshots there. */
15
+ const path = require('path');
16
+ const fs = require('fs');
17
+ const { spawn } = require('child_process');
18
+ const { findBrowser } = require('./lib/find-browser');
19
+ const T = require('./test-run').configure({ name: 'task-plans-ui' });
20
+ const BP = require('./lib/board-premium.js');
21
+ const F = require('./fixtures/board-premium-facts.js');
22
+ const TP = require('./lib/task-plans.js');
23
+
24
+ const BASE = T.BASE;
25
+ const SHOTS = process.env.SHOTS || '';
26
+ const results = [];
27
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
28
+ let srv = null; let browser = null;
29
+ const finish = async (code) => {
30
+ if (browser) await browser.close().catch(() => {});
31
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
32
+ T.killTmux();
33
+ const bad = results.filter((x) => !x.cond).length;
34
+ console.log(`\n${results.length - bad}/${results.length} task-plans-ui assertions passed`);
35
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
36
+ };
37
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
38
+
39
+ /* the board: Partner API rate limits runs late against its plan; Usage-based billing has drafts only */
40
+ const task = (ini, uid, title, start, end, status = 'To do', o = {}) => ({ src: 'pmos', kind: 'Task', ini, uid, title, status, owner: 'Lee', start, end, ...o });
41
+ const ITEMS = [
42
+ task('partner-rate-limits', 'task-a', 'Draft the limits spec', '2026-10-05', '2026-10-20', 'In progress'),
43
+ task('partner-rate-limits', 'task-b', 'Ship the limits API', '2026-10-21', '2026-11-30'),
44
+ task('partner-rate-limits', 'task-c', 'Load test at 3x peak', '2026-11-10', '2026-11-20'),
45
+ task('partner-rate-limits', 'task-d', 'Offline docs', '2026-11-01', '2026-11-10', "Won't do"),
46
+ task('partner-rate-limits', 'task-e', 'Partner FAQ', '2026-11-02', '2026-11-06'),
47
+ ];
48
+ const plan = { at: '2026-10-02T10:00:00Z', kind: 'plan', plan: 'plan-1', board: 'w1', initiative: 'partner-rate-limits', name: 'Proposal A · Oct 2', source: 'draft',
49
+ tasks: [{ uid: 'task-a', title: 'Draft the limits spec', start: '2026-10-05', due: '2026-10-16' }, { uid: 'task-b', title: 'Ship the limits API', start: '2026-10-21', due: '2026-11-16' },
50
+ { uid: 'task-d', title: 'Offline docs', start: '2026-11-01', due: '2026-11-10' }, { uid: 'task-e', title: 'Partner FAQ', start: '2026-11-02', due: '2026-11-06' }] };
51
+ const copy = ITEMS.filter((x) => x.status !== "Won't do").map((x, i) => ({ ...TP.taskOfLive(x), k: 'c' + i }));
52
+ const LINES = [plan,
53
+ { at: '2026-10-15T09:00:00Z', kind: 'draft-new', draft: 'draft-c1', board: 'w1', initiative: 'partner-rate-limits', name: 'Change 1 · faster pilot', from: 'live', tasks: copy },
54
+ { at: '2026-10-15T09:01:00Z', kind: 'draft-task', draft: 'draft-c1', k: 'c1', set: { due: '2026-11-23' } },
55
+ { at: '2026-10-10T09:00:00Z', kind: 'draft-new', draft: 'draft-p', board: 'w1', initiative: 'usage-billing', name: 'Proposal A', auto: true, from: 'empty', tasks: [] },
56
+ { at: '2026-10-10T09:01:00Z', kind: 'draft-task', draft: 'draft-p', k: 'p1', add: { title: 'Interview 5 billing leads', start: '2026-10-26', due: '2026-11-06', status: 'To do' } },
57
+ { at: '2026-10-10T09:02:00Z', kind: 'draft-task', draft: 'draft-p', k: 'p2', add: { title: 'Metering service', start: '2026-11-09', due: '2027-01-29', status: 'To do' } },
58
+ { at: '2026-10-11T09:00:00Z', kind: 'draft-new', draft: 'draft-q', board: 'w1', initiative: 'usage-billing', name: 'Proposal B · lean', auto: false, from: 'draft-p', tasks: [{ k: 'q1', src: null, title: 'Metering, lean', start: '2026-11-02', due: '2026-12-18', status: 'To do' }] },
59
+ ];
60
+ function model() {
61
+ const m = BP.build(F.facts({ items: ITEMS.map((x) => ({ ...x })) }));
62
+ TP.decorate(m.rows, TP.fold(LINES));
63
+ for (const r of m.rows) if (r.id === 'partner-rate-limits') { r.start = '2026-10-05'; r.end = '2026-11-30'; }
64
+ return m;
65
+ }
66
+
67
+ (async () => {
68
+ const exe = findBrowser();
69
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
70
+ let chromium;
71
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
72
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
73
+ await T.waitForServer(BASE);
74
+ browser = await chromium.launch({ executablePath: exe });
75
+ const shot = async (page, name, sel) => { if (!SHOTS) return; fs.mkdirSync(SHOTS, { recursive: true }); const p = path.join(SHOTS, name + '.png'); if (sel) await page.locator(sel).first().screenshot({ path: p }); else await page.screenshot({ path: p }); };
76
+
77
+ const open = async (o = {}) => {
78
+ const ctx = await browser.newContext({ viewport: { width: o.w || 1440, height: o.h || 900 } });
79
+ const page = await ctx.newPage();
80
+ const errors = [], posts = [];
81
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
82
+ await page.clock.setFixedTime(new Date(F.NOW));
83
+ await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: model(), as_of: Date.now() }) }));
84
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
85
+ await page.route('**/api/task-plans/preview*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, summary: { added: 0, moved: 1, changed: 1, dropped: 0, conflicts: [], milestones: [], planName: 'Change 1 · faster pilot · Oct 17', notChosen: [] } }) }));
86
+ await page.route('**/api/task-plans/live', (r) => { posts.push({ url: r.request().url(), body: r.request().postDataJSON() }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, plan: 'plan-2', name: 'Change 1 · faster pilot', summary: {}, versions: null }) }); });
87
+ await page.addInitScript(([s]) => { try { if (!sessionStorage.getItem('set')) { sessionStorage.setItem('set', '1'); for (const [k, v] of Object.entries(s)) localStorage.setItem(k, v); } } catch { /* none */ } },
88
+ [{ 'pmos.board.view': 'time', 'pmos.board.span': o.span || 'half', 'pmos.tasks.view': 'timeline', 'pmos.tasks.zoom': 'month', ...(o.store || {}) }]);
89
+ await page.goto(BASE + '/premium-board.html?ws=w1&board=w1');
90
+ await page.waitForSelector('#ibBody [data-key]', { timeout: 15000 });
91
+ await page.waitForTimeout(500);
92
+ return { ctx, page, errors, posts };
93
+ };
94
+
95
+ // ── B: the Board timeline
96
+ {
97
+ const { ctx, page, errors, posts } = await open();
98
+ const B = await page.evaluate(() => {
99
+ const row = (k) => document.querySelector(`.tg-r[data-row="${k}"]`);
100
+ const pr = row('board:partner-rate-limits'), ub = row('board:usage-billing');
101
+ const lg = document.querySelector('.tg-lgd');
102
+ return { line: !!(pr && pr.querySelector('.tg-pl')), slip: pr ? (pr.querySelector('.tg-slip') || {}).textContent || '' : '', lineTip: pr && pr.querySelector('.tg-pl') ? pr.querySelector('.tg-pl').getAttribute('title') : '',
103
+ draft: !!(ub && ub.querySelector('.tg-bar.tg-dr')), draftTip: ub && ub.querySelector('.tg-dr') ? ub.querySelector('.tg-dr').getAttribute('title') : '',
104
+ others: [...document.querySelectorAll('.tg-r[data-row]')].filter((r) => r !== pr && r.querySelector('.tg-pl')).length, legend: lg ? lg.textContent : '' };
105
+ });
106
+ ok('B1 the plan\'s thin line sits under the bar of the initiative that has a saved plan, named on hover', B.line && /Plan · Proposal A/.test(B.lineTip), JSON.stringify(B));
107
+ ok('B2 the slip after the end date: +14d (late)', B.slip === '+14d', JSON.stringify(B));
108
+ ok('B3 an initiative with drafts only draws its newest draft dashed, and its title names both drafts', B.draft && /Proposal B · lean/.test(B.draftTip) && /Newest: Proposal B · lean|Newest: Proposal A/.test(B.draftTip), JSON.stringify(B));
109
+ ok('B4 no plan line where no plan is saved (zero is silence)', B.others === 0, JSON.stringify(B));
110
+ ok('B5 the legend: "Planned" is "To do"; Plan and Draft show while they are drawn', /To do/.test(B.legend) && !/Planned/.test(B.legend) && /Plan/.test(B.legend) && /Draft/.test(B.legend), B.legend);
111
+ await shot(page, 'PvaBuild1Board');
112
+
113
+ // ── V: the initiative's Tasks timeline
114
+ await page.locator('.tg-n[data-key="board:partner-rate-limits"]').first().click();
115
+ await page.waitForSelector('#czViewer .iv-th', { timeout: 8000 });
116
+ await page.waitForTimeout(300);
117
+ const V = await page.evaluate(() => {
118
+ const v = document.querySelector('#czViewer');
119
+ const chip = v.querySelector('[data-vs-chip]'), rows = [...v.querySelectorAll('.ivt-r.k')];
120
+ const by = (t) => rows.find((r) => r.querySelector('.iv-tt') && r.querySelector('.iv-tt').textContent === t);
121
+ const has = (t, s) => { const r = by(t); return !!(r && r.querySelector(s)); };
122
+ return { chip: chip ? chip.textContent.trim() : '', chipDr: chip ? chip.classList.contains('dr') : null, slip: (v.querySelector('.vs-slip') || {}).textContent || '',
123
+ lineA: has('Draft the limits spec', '.ivt-pl'), lineFaq: has('Partner FAQ', '.ivt-pl'), addC: has('Load test at 3x peak', '.vs-add'), slipB: (by('Ship the limits API') && (by('Ship the limits API').querySelector('.ivt-sl') || {}).textContent) || '',
124
+ legend: (v.querySelector('.ivt-lg') || {}).textContent || '', seal: !!v.querySelector('[data-vs-live]') };
125
+ });
126
+ ok('V1 the chip says Live with 1 draft, grey; the header sums the end slip (+14d)', /^Live\s*1/.test(V.chip) && V.chipDr === false && V.slip === '+14d', JSON.stringify(V));
127
+ ok('V2 a plan line where the dates differ, none where they match', V.lineA && !V.lineFaq, JSON.stringify(V));
128
+ ok('V3 ⊕ after a task added after the plan; the slip after a late date', V.addC && /\+14d/.test(V.slipB), JSON.stringify(V));
129
+ ok('V4 the legend names the plan; no seal on Live', /Plan · Proposal A/.test(V.legend) && !V.seal, JSON.stringify(V));
130
+ await shot(page, 'PvaBuild2Live', '#czViewer');
131
+
132
+ // ── M: the chip's menu
133
+ await page.locator('#czViewer [data-vs-chip]').click();
134
+ await page.waitForSelector('.vs-pop .vs-m', { timeout: 4000 });
135
+ const M = await page.evaluate(() => { const m = document.querySelector('.vs-pop .vs-m'); return { text: m.textContent, show: [...m.querySelectorAll('[data-vs-show]')].length, cmp: [...m.querySelectorAll('[data-vs-cmp]')].length, save: !!m.querySelector('[data-vs-save]'), nw: !!m.querySelector('[data-vs-new]'), checked: [...m.querySelectorAll('[aria-checked="true"]')].map((b) => b.textContent.trim()) }; });
136
+ ok('M1 the menu: Show (Live, the draft), New draft from Live; Compare with (the plan, the draft, Nothing), Save Live as a plan', M.show === 2 && M.cmp === 3 && M.save && M.nw && /Show/.test(M.text) && /Compare with/.test(M.text), JSON.stringify(M));
137
+ ok('M2 Live and the plan are the ones picked', M.checked.length === 2 && /^Live/.test(M.checked[0]) && /Proposal A/.test(M.checked[1]), JSON.stringify(M.checked));
138
+ await shot(page, 'PvaBuild3Menu');
139
+
140
+ // ── D: a draft
141
+ await page.locator('.vs-pop [data-vs-show="draft-c1"]').click();
142
+ await page.waitForTimeout(300);
143
+ const D = await page.evaluate(() => { const v = document.querySelector('#czViewer'), chip = v.querySelector('[data-vs-chip]'); return { chip: chip.textContent.trim(), dr: chip.classList.contains('dr'), dashed: v.querySelectorAll('.ivt-b.dr').length, seal: !!v.querySelector('[data-vs-live]'), count: (v.querySelector('.iv-th .n') || {}).textContent || '' }; });
144
+ ok('D1 the chip names the draft in blue; every bar is dashed; the seal shows', /Change 1/.test(D.chip) && D.dr && D.dashed >= 3 && D.seal, JSON.stringify(D));
145
+ const wide = await page.evaluate(() => { const b = document.querySelector('#czViewer .cz-vw-body'), h = document.querySelector('#czViewer .iv-th'); return { body: b.scrollWidth - b.clientWidth, head: h.scrollWidth - Math.round(h.getBoundingClientRect().width) }; });
146
+ ok('D5 a long draft name wraps the head; the Viewer never scrolls sideways', wide.body <= 0 && wide.head <= 1, JSON.stringify(wide));
147
+ ok('D2 the count says how many tasks the draft holds, without its name again (the chip says it)', /^4 tasks$/.test(D.count.trim()), D.count);
148
+ await page.locator('#czViewer [data-vs-live]').click();
149
+ await page.waitForSelector('.vs-pop .vs-cf', { timeout: 4000 });
150
+ const cf = await page.locator('.vs-pop .vs-cf').textContent();
151
+ ok('D3 Make live shows what changes right under the seal: 1 date moved, the plan it saves', /1 date moved/.test(cf) && /Saved as the plan/.test(cf), cf);
152
+ await shot(page, 'PvaBuild4Draft');
153
+ await page.locator('.vs-pop [data-vs-cf="yes"]').click();
154
+ await page.waitForTimeout(400);
155
+ ok('D4 ✓ posts Make live for that draft', posts.length === 1 && posts[0].body.draft === 'draft-c1', JSON.stringify(posts));
156
+ ok('B6 no page error', errors.length === 0, errors.join(' | '));
157
+ await ctx.close();
158
+ }
159
+
160
+ // ── P: a phone, the chip's menu as a bottom sheet
161
+ {
162
+ const { ctx, page, errors } = await open({ w: 390, h: 844 });
163
+ const n = page.locator('[data-key="board:partner-rate-limits"]').first();
164
+ await n.click();
165
+ await page.waitForSelector('#czViewer [data-vs-chip]', { timeout: 8000 });
166
+ await page.locator('#czViewer [data-vs-chip]').click();
167
+ await page.waitForSelector('.vs-pop.sheet', { timeout: 4000 });
168
+ const P = await page.evaluate(() => { const r = document.querySelector('.vs-pop.sheet').getBoundingClientRect(); return { bottom: Math.round(r.bottom), w: Math.round(r.width), scroll: document.documentElement.scrollWidth }; });
169
+ ok('P1 on a phone the menu is a bottom sheet the width of the screen; no sideways scroll', P.bottom === 844 && P.w === 390 && P.scroll <= 390, JSON.stringify(P));
170
+ // batch 11 item 20: the 390 px Tasks header holds the group icon, the view switch, + and a draft's Make live, all in the Viewer
171
+ await page.locator('.vs-pop [data-vs-show="draft-c1"]').click();
172
+ await page.waitForSelector('#czViewer [data-vs-live]', { timeout: 4000 });
173
+ const H = await page.evaluate(() => { const v = document.querySelector('#czViewer'), b = v.querySelector('.cz-vw-body').getBoundingClientRect(), h = v.querySelector('.iv-th'); const ins = (s) => { const e = h.querySelector(s); if (!e) return 'none'; const r = e.getBoundingClientRect(); return r.width > 0 && r.left >= b.left && r.right <= b.right + 0.5 ? 'in' : 'out'; }; return { by: ins('[data-ig-by]'), view: ins('.ivx-seg'), seal: ins('[data-vs-live]'), add: h.querySelector('[data-iv-add]') ? ins('[data-iv-add]') : 'in', head: h.scrollWidth - Math.round(h.getBoundingClientRect().width), scroll: document.documentElement.scrollWidth }; });
174
+ ok('P3 on a phone the Tasks header fits the group icon, the view switch, + and Make live', H.by === 'in' && H.view === 'in' && H.seal === 'in' && H.add === 'in' && H.head <= 1 && H.scroll <= 390, JSON.stringify(H));
175
+ await shot(page, 'PvaBuild6PhoneDraft', '#czViewer .iv-th');
176
+ ok('P2 no page error', errors.length === 0, errors.join(' | '));
177
+ await shot(page, 'PvaBuild5Phone');
178
+ await ctx.close();
179
+ }
180
+ finish();
181
+ })().catch((e) => { console.error(e); finish(1); });