create-pmos 0.422.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 (79) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/board-programs-test.js +28 -0
  7. package/workspace/briefing-premium-adddoc-test.js +1 -1
  8. package/workspace/briefing-premium-board-test.js +12 -10
  9. package/workspace/briefing-premium-initiative-test.js +30 -38
  10. package/workspace/changelog.json +12 -0
  11. package/workspace/guide/briefing-premium.md +1 -1
  12. package/workspace/guide/home.md +9 -2
  13. package/workspace/guide/programs.md +1 -0
  14. package/workspace/guide/workflows.md +5 -1
  15. package/workspace/ini-workflow-test.js +4 -4
  16. package/workspace/lib/board-premium.js +3 -2
  17. package/workspace/lib/custom-docs.js +65 -3
  18. package/workspace/lib/engine/boards.js +25 -2
  19. package/workspace/lib/initiative-writer.js +63 -1
  20. package/workspace/lib/plan-items.js +36 -5
  21. package/workspace/lib/programs.js +11 -3
  22. package/workspace/lib/route-modules.js +1 -0
  23. package/workspace/lib/routes-board-premium.js +22 -0
  24. package/workspace/lib/routes-boards.js +50 -10
  25. package/workspace/lib/routes-initiatives.js +12 -0
  26. package/workspace/lib/routes-task-links.js +329 -0
  27. package/workspace/lib/split-merge-suggest.js +162 -0
  28. package/workspace/lib/split-merge.js +379 -0
  29. package/workspace/lib/task-cli.js +58 -5
  30. package/workspace/lib/task-items.js +14 -2
  31. package/workspace/lib/task-links.js +422 -0
  32. package/workspace/package-lock.json +2 -2
  33. package/workspace/package.json +1 -1
  34. package/workspace/premium-board-actions-test.js +2 -2
  35. package/workspace/premium-core-doc-issue-test.js +2 -2
  36. package/workspace/premium-vw-backlog-test.js +3 -3
  37. package/workspace/premium-vw-item-test.js +3 -3
  38. package/workspace/premium-vw-jira-test.js +6 -6
  39. package/workspace/product-lane-test.js +165 -0
  40. package/workspace/program-panel-test.js +1 -1
  41. package/workspace/public/pm/bd-ini-panel.js +16 -6
  42. package/workspace/public/pm/bd-prog.js +6 -1
  43. package/workspace/public/pm/bd-span.js +69 -15
  44. package/workspace/public/pm/bd-views.js +3 -2
  45. package/workspace/public/pm/cozy-board.css +10 -0
  46. package/workspace/public/pm/home-app.js +25 -8
  47. package/workspace/public/pm/home-ini-model.js +0 -34
  48. package/workspace/public/pm/home-ini.js +72 -204
  49. package/workspace/public/pm/ini-groups.js +228 -0
  50. package/workspace/public/pm/ini-links.js +561 -0
  51. package/workspace/public/pm/ini-tasks.js +58 -22
  52. package/workspace/public/pm/ini-versions.js +14 -9
  53. package/workspace/public/pm/ini-view-model.js +88 -4
  54. package/workspace/public/pm/ini-view.css +259 -18
  55. package/workspace/public/pm/ini-view.js +140 -32
  56. package/workspace/public/pm/premium-board.js +54 -6
  57. package/workspace/public/pm/split-merge.css +77 -0
  58. package/workspace/public/pm/split-merge.js +265 -0
  59. package/workspace/public/pm/stage-line.js +414 -0
  60. package/workspace/public/pm/task-card.js +5 -3
  61. package/workspace/public/pm/wf-page.css +2 -0
  62. package/workspace/public/pm/wf-page.js +2 -0
  63. package/workspace/public/pm/wf-stage.js +2 -1
  64. package/workspace/server.js +15 -1
  65. package/workspace/split-merge-ui-test.js +175 -0
  66. package/workspace/stage-card-test.js +12 -11
  67. package/workspace/task-card-test.js +3 -2
  68. package/workspace/task-delete-test.js +126 -0
  69. package/workspace/task-links-test.js +227 -0
  70. package/workspace/task-milestones-test.js +1 -1
  71. package/workspace/task-plans-test.js +6 -0
  72. package/workspace/task-views-test.js +1 -1
  73. package/workspace/test-lists/bd-ini-panel.json +8 -2
  74. package/workspace/test-lists/product-lane.json +6 -0
  75. package/workspace/test-lists/split-merge.json +15 -0
  76. package/workspace/test-lists/task-delete.json +5 -0
  77. package/workspace/test-lists/task-links.json +6 -0
  78. package/workspace/tk-tasks-test.js +173 -57
  79. package/workspace/workflows-setup-test.js +4 -3
@@ -0,0 +1,175 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* split-merge-ui-test.js — split one initiative in two, or merge two, on the real pages over a real server (feedback batch 11 item 14, option
4
+ * A grilled 2026-10-26; canvas In development, row "Split or merge initiatives": XsmA1Suggest, XsmA1Menu, XsmA2Split, XsmA3SplitDone,
5
+ * XsmA5MergeCheck, XsmA7Closed). The synthetic `team` repository of plan-test-repos.js; the tasks are made through the real routes.
6
+ * B Board: the purple dot after the name; the card under the summary with ✕ ✎ ✓; ✎ opens the split editor with Claude's picks ticked and
7
+ * ✕ comes back; ✓ splits, the toast says what moved with Undo, and the new row is open; Undo puts it back; ⋯ holds Split into a new
8
+ * initiative and Merge into ›; the merge check shows the one that closes over the one that stays with the reason; the merge lands with
9
+ * Undo; ✕ Not now on the card hides it and the dot
10
+ * H Home: the merged one leads with "Merged · <day>" and a link to the one that stays
11
+ * P phone: the card in the full-screen Viewer
12
+ * SHOTS=<dir> saves the screenshots. */
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { spawn } = require('child_process');
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ const T = require('./test-run').configure({ name: 'split-merge-ui' });
18
+ const { makeRepos, codeRepo, write, git } = require('./plan-test-repos');
19
+
20
+ const BASE = T.BASE;
21
+ const SHOTS = process.env.SHOTS || '';
22
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
23
+ const until = async (fn, ms = 15000, step = 150) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
24
+ const results = [];
25
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 700) : ''}`); };
26
+ const R = makeRepos('split-merge-ui');
27
+ const team = codeRepo(path.join(R.base, 'team'));
28
+ fs.mkdirSync(path.join(team, 'pmos', 'state'), { recursive: true });
29
+ // names the PM would read: the fixture calls every initiative x
30
+ for (const [id, title] of [['fx-full', 'Decommission — retire old IdP'], ['fx-bare', 'Migration — move from old IdP'], ['fx.v2', 'Tender new CIAM']]) {
31
+ const f = path.join(team, 'planning/initiatives', id + '.md');
32
+ if (fs.existsSync(f)) write(team, 'planning/initiatives/' + id + '.md', fs.readFileSync(f, 'utf8').replace(/^title: x$/m, 'title: ' + title));
33
+ }
34
+ git(team, ['add', '-A']); git(team, ['commit', '-q', '-m', 'titles']);
35
+ let srv = null; let browser = null;
36
+ const finish = async (code) => {
37
+ if (browser) await browser.close().catch(() => {});
38
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
39
+ T.killTmux();
40
+ R.cleanup();
41
+ const bad = results.filter((x) => !x.cond).length;
42
+ console.log(`\n${results.length - bad}/${results.length} split-merge-ui assertions passed`);
43
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
44
+ };
45
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
46
+ const shot = (p, name) => (SHOTS ? p.screenshot({ path: path.join(SHOTS, name) }) : null);
47
+
48
+ (async () => {
49
+ const exe = findBrowser();
50
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
51
+ let chromium;
52
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
53
+ if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
54
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: R.base, PMOS_NO_OPEN: '1' }) });
55
+ await T.waitForServer(BASE);
56
+ const press = await T.pressHeaders(BASE);
57
+ const post = async (p, body) => { const r = await fetch(BASE + p, { method: 'POST', headers: press, body: JSON.stringify(body) }); return r.json().catch(() => null); };
58
+ const ws = (await post('/api/workspaces', { root: team, focus: false })).workspace.id;
59
+ // the board derives its rows first: a task added before that has no row to land on
60
+ await until(async () => { const r = await fetch(`${BASE}/api/boards/backlog?ws=${ws}&board=${ws}&view=all`); const j = await r.json().catch(() => null); return r.status === 200 && j && !j.pending; }, 90000, 300);
61
+ // fx-full: the PRD and the plan now; the cutover two months later, with its own owner — Claude suggests splitting the cutover off
62
+ for (const [title, start, due, owner] of [['Write the PRD problem', '2026-11-02', '2026-11-06', ''], ['List apps still on the old IdP', '2026-11-04', '2026-11-12', ''],
63
+ ['Plan the cutover window', '2027-01-04', '2027-01-08', 'Ana'], ['Switch traffic to the new IdP', '2027-01-11', '2027-01-20', 'Ana']]) {
64
+ const a = await post('/api/boards/tasks/add', { ws, board: ws, initiative: 'fx-full', title, start, due });
65
+ if (owner && a && a.item) await post('/api/boards/tasks/edit', { ws, board: ws, task: a.item.uid, owner });
66
+ }
67
+ await until(async () => { const r = await (await fetch(`${BASE}/api/board-premium?ws=${ws}&board=${ws}`)).json(); return r.state === 'ready' && (r.model.initiatives.list.rows.find((x) => x.id === 'fx-full') || {}).suggest; }, 90000, 500);
68
+
69
+ browser = await chromium.launch({ executablePath: exe });
70
+ const open = async (o = {}) => {
71
+ const ctx = await browser.newContext({ viewport: { width: o.w || 1440, height: o.h || 900 } });
72
+ const page = await ctx.newPage();
73
+ const errors = [];
74
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
75
+ await page.goto(`${BASE}/premium-board.html?ws=${ws}&board=${ws}`);
76
+ await page.waitForSelector('#ibBody [data-key]', { timeout: 30000 });
77
+ await page.waitForTimeout(500);
78
+ return { ctx, page, errors };
79
+ };
80
+ const rowBtn = (p, title) => p.locator('#ibBody [data-key]', { hasText: title }).first();
81
+ const toast = (p) => p.evaluate(() => { const t = document.querySelector('#bdToast'); return t && !t.hidden ? t.textContent : ''; });
82
+ const vTitle = (p) => p.evaluate(() => { const v = document.querySelector('#czViewer'); return v && !v.hidden ? (v.querySelector('.cz-vw-tt, .cz-vw-title, h2') || {}).textContent || '' : ''; });
83
+ const menu = async (p) => { await p.click('#czViewer [data-cz-vw="more"]'); await p.waitForTimeout(100); return p.evaluate(() => [...document.querySelectorAll('.cz-vw-menu [role="menuitem"]')].map((b) => b.textContent.trim())); };
84
+
85
+ /* B — the Board */
86
+ {
87
+ const { ctx, page: p, errors } = await open();
88
+ ok('B the purple dot after the name of the one Claude has a suggestion for', await p.evaluate(() => { const r = [...document.querySelectorAll('#ibBody [data-key]')].find((x) => /Decommission/.test(x.textContent)); return !!(r && r.querySelector('.sm-dot')); }), await p.evaluate(() => [...document.querySelectorAll('#ibBody [data-key]')].slice(0, 8).map((x) => x.className + ':' + x.textContent.slice(0, 50)).join(' / ')));
89
+ if (!(await p.evaluate(() => !!document.querySelector('#ibBody .sm-dot')))) return finish(1);
90
+ const key = await p.evaluate(() => { const d = document.querySelector('#ibBody .sm-dot'); const b = d && d.closest('[data-key]'); return b ? b.dataset.key : null; });
91
+ await p.click(`#ibBody [data-key="${key}"]`);
92
+ const card = await until(() => p.evaluate(() => { const c = document.querySelector('#czViewer .sm-card'); return c ? { title: c.querySelector('.sm-h b').textContent, btns: [...c.querySelectorAll('[data-sm]')].map((b) => b.getAttribute('aria-label')), after: !!(c.previousElementSibling && c.previousElementSibling.classList.contains('iv-sum')) } : null; }));
93
+ ok('B the card under the summary: the spark title and ✕ Not now, ✎ Change it first, ✓ Split as suggested', card && /^Split off .+\?$/.test(card.title) && card.btns.join('|') === 'Not now|Change it first|Split as suggested' && card.after, JSON.stringify(card));
94
+ await shot(p, 'board-suggest.png');
95
+ await p.click('#czViewer [data-sm="edit"]');
96
+ const ed = await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer [data-sm-v="split"]'); if (!v) return null; const docs = !v.querySelector('.sm-q'); return docs && { name: v.querySelector('#smName').value, on: [...v.querySelectorAll('.sm-pk.on .sm-t b')].map((b) => b.textContent), keep: v.querySelector('.sm-keep').textContent, cnt: v.querySelector('.sm-cnt').textContent }; }));
97
+ ok('B ✎ opens the split editor with Claude\'s picks ticked: the cutover\'s two tasks, its name, what it keeps', ed && ed.on.length === 2 && ed.on.every((t) => /cutover|traffic/i.test(t)) && ed.name && /starts at/.test(ed.keep) && /2 tasks/.test(ed.cnt), JSON.stringify(ed));
98
+ await shot(p, 'board-split-editor.png');
99
+ await p.click('#czViewer [data-sm-x]');
100
+ ok('B ✕ in the editor goes back to the initiative', await until(() => p.evaluate(() => !!document.querySelector('#czViewer .sm-card'))));
101
+ await p.click('#czViewer [data-sm="yes"]');
102
+ const t = await until(async () => { const x = await toast(p); return /^Split off/.test(x) ? x : null; }, 20000);
103
+ ok('B ✓ splits: the toast says what moved, with Undo', /^Split off .+ · 2 tasks/.test(t) && /Undo/.test(t), t);
104
+ const newOpen = await until(async () => { const v = await vTitle(p); return v && !/Decommission/.test(v) && /cutover|traffic/i.test(v) ? v : null; }, 20000);
105
+ ok('B the new initiative is selected and open', !!newOpen, await vTitle(p));
106
+ // it is placed right after the old one on the Roadmap; the Board still lists late and at-risk rows first
107
+ ok('B its row is on the Board\'s list', await p.evaluate(() => [...document.querySelectorAll('#ibBody [data-key]')].some((x) => /cutover|traffic/i.test(x.textContent))), await p.evaluate(() => [...document.querySelectorAll('#ibBody [data-key]')].map((x) => x.textContent.slice(0, 30)).join(' / ')));
108
+ await shot(p, 'board-split-done.png');
109
+ await p.click('#bdToast .bd-undo');
110
+ ok('B Undo puts it back', !!(await until(async () => /Undone/.test(await toast(p)), 15000)), await toast(p));
111
+ await p.waitForTimeout(1500);
112
+
113
+ // ⋯ holds Split into a new initiative and Merge into ›
114
+ await until(async () => { await p.click(`#ibBody [data-key="${key}"]`).catch(() => {}); return p.evaluate(() => !!document.querySelector('#czViewer:not([hidden])')); });
115
+ const m = await menu(p);
116
+ ok('B ⋯ holds Split into a new initiative and Merge into', m.includes('Split into a new initiative') && m.some((x) => /^Merge into/.test(x)), JSON.stringify(m));
117
+ await shot(p, 'board-menu.png');
118
+ await p.click('.cz-vw-menu [role="menuitem"] >> text=Merge into');
119
+ const list = await until(() => p.evaluate(() => { const h = document.querySelector('#bdPop'); return h && !h.hidden ? [...h.querySelectorAll('[data-pm-to]')].map((b) => b.textContent.trim()) : null; }));
120
+ ok('B Merge into › lists the other initiatives of the board', !!list && list.length >= 1, JSON.stringify(list));
121
+ const bare = await p.evaluate(() => [...document.querySelectorAll('#bdPop [data-pm-to]')].findIndex((b) => /Migration/.test(b.textContent)));
122
+ await p.click(`#bdPop [data-pm-to="${Math.max(0, bare)}"]`);
123
+ const mc = await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer [data-sm-v="merge"]'); return v ? { gone: v.querySelector('.sm-mc.gone b').textContent, stay: v.querySelector('.sm-mc.stay b').textContent, why: v.querySelector('.sm-r').textContent } : null; }));
124
+ ok('B the merge check: the one that closes over the one that stays, with the reason', mc && /Decommission/.test(mc.gone) && /Migration/.test(mc.stay) && /^Stays: /.test(mc.why), JSON.stringify(mc));
125
+ await shot(p, 'board-merge-check.png');
126
+ await p.click('#czViewer [data-sm-go]');
127
+ const mt = await until(async () => { const x = await toast(p); return /^Merged into/.test(x) ? x : null; }, 20000);
128
+ ok('B the merge lands: the toast says so, with Undo', /^Merged into /.test(mt) && /Undo/.test(mt), mt);
129
+ await shot(p, 'board-merge-done.png');
130
+ ok('B no page error', !errors.length, errors.join(' | '));
131
+ await ctx.close();
132
+ }
133
+
134
+ /* H — the merged one on Home */
135
+ {
136
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
137
+ const p = await ctx.newPage();
138
+ const errors = [];
139
+ p.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
140
+ await p.goto(`${BASE}/premium.html?theme=light&ws=${ws}&ini=fx-full`);
141
+ const g = await until(() => p.evaluate(() => { const s = document.querySelector('#czViewer .sm-gone'); return s ? s.textContent : null; }), 30000);
142
+ ok('H the merged one leads with Merged · <day> and where its work went', !!g && /^Merged · /.test(g.trim()) && /are now in /.test(g), g);
143
+ await shot(p, 'home-merged.png');
144
+ ok('H the merged one draws no stage card and no tasks: they moved', await p.evaluate(() => !document.querySelector('#czViewer .iv-stg, #czViewer [aria-label="Tasks"]') || !!document.querySelector('#czViewer .sm-gone')));
145
+ await p.click('#czViewer .sm-gone .sm-lk');
146
+ ok('H its link opens the one that stays', !!(await until(() => p.evaluate(() => { const v = document.querySelector('#czViewer'); return v && /Migration/.test((v.querySelector('.cz-vw-head, header') || v).textContent.slice(0, 200)) && !v.querySelector('.sm-gone'); }), 15000)));
147
+ ok('H no page error', !errors.length, errors.join(' | '));
148
+ await ctx.close();
149
+ }
150
+
151
+ /* undo the merge for the phone and the dismiss */
152
+ {
153
+ const lines = fs.readFileSync(path.join(team, 'pmos/state/boards.jsonl'), 'utf8').trim().split('\n').map((l) => JSON.parse(l));
154
+ const op = lines.filter((l) => l.kind === 'ini-merge').pop().op;
155
+ await post('/api/initiatives/sm-undo', { ws, undo: op });
156
+ await until(async () => { const r = await (await fetch(`${BASE}/api/board-premium?ws=${ws}&board=${ws}`)).json(); return r.state === 'ready' && (r.model.initiatives.list.rows.find((x) => x.id === 'fx-full') || {}).suggest; }, 60000, 500);
157
+ }
158
+
159
+ /* P — the phone */
160
+ {
161
+ const { ctx, page: p, errors } = await open({ w: 390, h: 844 });
162
+ const key = await p.evaluate(() => { const d = document.querySelector('#ibBody .sm-dot'); const b = d && d.closest('[data-key]'); return b ? b.dataset.key : null; });
163
+ ok('P phone: the dot on the row', !!key);
164
+ if (key) await p.click(`#ibBody [data-key="${key}"]`);
165
+ ok('P phone: the card in the full-screen Viewer', await until(() => p.evaluate(() => !!document.querySelector('#czViewer .sm-card'))));
166
+ await shot(p, 'phone-suggest.png');
167
+ await p.click('#czViewer [data-sm="no"]');
168
+ const t = await until(async () => { const x = await toast(p); return /^Not now/.test(x) ? x : null; });
169
+ ok('P ✕ Not now: the toast says Claude asks again when the tasks change', /^Not now/.test(t || ''), t);
170
+ ok('P ✕ Not now hides the card and the dot', await until(() => p.evaluate(() => !document.querySelector('#czViewer .sm-card') && !document.querySelector('#ibBody .sm-dot')), 20000));
171
+ ok('P no page error', !errors.length, errors.join(' | '));
172
+ await ctx.close();
173
+ }
174
+ finish();
175
+ })();
@@ -119,13 +119,14 @@ async function pure() {
119
119
  };
120
120
  const V = '#czViewer [data-hi-v="page"]';
121
121
  const shot = async (p, name, sel) => { if (!SHOTS) return; await sleep(300); await (sel ? p.locator(sel).first() : p).screenshot({ path: path.join(SHOTS, name + '.png') }); };
122
- /* re-pointed (batch 6 items 1 and 3, the one view): the page's stage card is the one the Board draws. It says where the stage is (the
123
- * ladder, n of m), how much of its section is done, the day clock, the dates line and the next stage; the steps are said once, in Tasks */
122
+ /* re-pointed (batch 11 item 21, the stage card as a timeline): the header says the stage, "N of M done", the day clock and → the next
123
+ * stage; under it one line holds a part a stage (a press shows it in Tasks), the ◇ milestones and Today. The steps are said once, in Tasks */
124
124
  const card = (p) => p.evaluate((v) => {
125
125
  const c = document.querySelector(v + ' .iv-sc'); const t = (n) => (n ? n.textContent.replace(/\s+/g, ' ').trim() : '');
126
- return { head: t(c.querySelector('.iv-sch')), stage: t(c.querySelector('.iv-sch > b')), where: t(c.querySelector('.iv-sch .iv-r')), bars: c.querySelectorAll('.iv-lad i').length, now: c.querySelectorAll('.iv-lad i.now').length,
127
- titles: [...c.querySelectorAll('.iv-lad i')].map((i) => i.title), steps: document.querySelectorAll(v + ' .cz-sl').length, pri: document.querySelectorAll(v + ' [data-iv-primary]').length,
128
- cta: !!document.querySelector(v + ' [data-hm-cta]'), ov: !!document.querySelector(v + ' [data-hm-ov]'), sw: !!c.querySelector('.hi-sw'), tail: t(c.querySelector('.iv-nx')), next: !!c.querySelector('[data-iv-next]'), ms: !!c.querySelector('.iv-nx .iv-nd.ms'), kr: t(c.querySelector('.iv-nx .iv-kr')) };
126
+ const parts = [...c.querySelectorAll('.iv-tl .iv-tlp')], keys = [...new Set(parts.map((x) => x.dataset.ivStage))], go = c.querySelector('.iv-scgo');
127
+ return { head: t(c.querySelector('.iv-sch')), stage: t(c.querySelector('.iv-sch > b')), bars: keys.length + c.querySelectorAll('.iv-tl .iv-tl-sk').length, now: new Set(parts.filter((x) => x.classList.contains('now')).map((x) => x.dataset.ivStage)).size,
128
+ titles: keys.map((k) => parts.find((x) => x.dataset.ivStage === k).title), steps: document.querySelectorAll(v + ' .cz-sl').length, pri: document.querySelectorAll(v + ' [data-iv-primary]').length,
129
+ cta: !!document.querySelector(v + ' [data-hm-cta]'), ov: !!document.querySelector(v + ' [data-hm-ov]'), sw: !!c.querySelector('.hi-sw'), tail: go ? go.getAttribute('aria-label') : '', next: !!c.querySelector('[data-iv-next]'), ms: !!(go && go.dataset.ms), ready: !!(go && go.classList.contains('on')), clock: t(c.querySelector('.iv-clk')), late: !!c.querySelector('.iv-clk.w') };
129
130
  }, V);
130
131
 
131
132
  /* D1 a desktop: the Build stage of the fixture (the contract waits for you, a Jira ticket open, Deliver next) */
@@ -134,10 +135,10 @@ async function pure() {
134
135
  ok('D1 the initiative\'s page draws the one view\'s stage card', A.up);
135
136
  const c = await card(p);
136
137
  ok('D1 the header names the stage', c.stage === 'Build', JSON.stringify(c));
137
- ok('D1 one bar a stage of the workflow, the current one marked', c.bars === 8 && c.now === 1, JSON.stringify(c));
138
- ok('D1 every bar names its stage on hover (the current one says now)', c.titles.length === 8 && c.titles.every(Boolean) && c.titles.some((x) => /^Build · now$/.test(x)), JSON.stringify(c.titles));
138
+ ok('D1 the line holds one part a stage of the workflow, the current one marked', c.bars === 8 && c.now === 1, JSON.stringify(c));
139
+ ok('D1 every part names its stage on hover (the current one says now)', c.titles.length >= 7 && c.titles.every(Boolean) && c.titles.some((x) => /^Build · .*now$/.test(x)), JSON.stringify(c.titles));
139
140
  ok('D1 the old CTA button, the C overview tile, the switch and the step list are gone from the card; at most one primary on the page', !c.cta && !c.ov && !c.sw && c.steps === 0 && c.pri <= 1, JSON.stringify(c));
140
- ok('D1 the last line is ◆ Deliver, with the KR it moves, by the board\'s name', c.next && /^Deliver/.test(c.tail) && c.ms && c.kr === 'KR 1.1', c.tail);
141
+ ok('D1 the → names ◆ Deliver, the next stage', c.next && /^Next: ◆ Deliver\. Move to Deliver$/.test(c.tail) && c.ms, c.tail);
141
142
  await shot(p, 'desk-build', V + ' .iv-sc');
142
143
  // the move popover opens under the next-stage line
143
144
  await p.click(V + ' [data-iv-next]');
@@ -167,8 +168,8 @@ async function pure() {
167
168
  const A = await open({ w: 390, h: 844, theme: 'dark', model: SCEN.discover(), board: DB, sessions, trail }), p = A.page;
168
169
  ok('D3 the phone draws the same card', A.up);
169
170
  const c = await card(p);
170
- ok('D3 the clock: "day 9 of ~7", amber when over', await p.evaluate((v) => { const t = document.querySelector(v + ' .iv-sch .iv-r span.w'); return !!t && /^day 9 of ~7$/.test(t.textContent); }, V), c.head);
171
- ok('D3 the last line is Plan, the next stage', /^Plan/.test(c.tail) && c.next && !c.ms, c.tail);
171
+ ok('D3 the clock: "9 of ~7 days", amber when over', c.clock === '9 of ~7 days' && c.late, c.head);
172
+ ok('D3 the → names Plan, the next stage', /^Next: Plan/.test(c.tail) && c.next && !c.ms, c.tail);
172
173
  await shot(p, 'phone-discover');
173
174
  await p.click(V + ' [data-iv-next]');
174
175
  const sh = await until(() => p.evaluate(() => { const el = document.querySelector('.hi-pop'); if (!el) return null; const s = el.querySelector('[data-hi-auto]'); const r = s && s.getBoundingClientRect(), tr = s && getComputedStyle(s, '::before');
@@ -209,7 +210,7 @@ async function pure() {
209
210
  {
210
211
  const A = await open({ model: SCEN.ready() }), p = A.page;
211
212
  const c = await card(p);
212
- ok('D5 every step done: the last line is ◆ Deliver', A.up && /^Deliver/.test(c.tail) && c.ms, JSON.stringify(c));
213
+ ok('D5 every step done: the → names ◆ Deliver', A.up && /^Next: ◆ Deliver/.test(c.tail) && c.ms, JSON.stringify(c));
213
214
  await shot(p, 'desk-ready', V + ' .iv-sc');
214
215
  await p.click(V + ' [data-iv-next]');
215
216
  await until(() => p.evaluate(() => !!document.querySelector('.hi-pop [data-hi-go]')));
@@ -118,9 +118,10 @@ async function pure() {
118
118
  const dc = []; let closed = 0, undo = null;
119
119
  const del = C.deleteEntry({ ws: 'w1', board: 'b1', t, post: async (p, b) => { dc.push([p, b]); return { ok: true }; }, toast: (m, u) => { undo = u; }, done: () => { closed++; } });
120
120
  await del.on(); await undo();
121
- ok('P10 Delete: red, the delete route, the Viewer closes, Undo restores; none for a Jira ticket or a breakdown item', del.label === 'Delete' && del.danger === true
121
+ ok('P10 Delete: red, the delete route, the Viewer closes, Undo restores; a breakdown item too (batch 11 item 16), never a Jira ticket', del.label === 'Delete' && del.danger === true
122
122
  && dc.map((c) => c[0]).join() === '/api/boards/tasks/delete,/api/boards/tasks/restore' && dc[0][1].task === 'task-1' && closed === 2
123
- && C.deleteEntry({ t: { ...t, jira: { key: 'CIAM-214' } }, post }) === null && C.deleteEntry({ t: { ...t, uid: 'fx-bare.abcdefghij' }, post }) === null, JSON.stringify(dc));
123
+ && C.deleteEntry({ t: { ...t, jira: { key: 'CIAM-214' } }, post }) === null && !!C.deleteEntry({ t: { ...t, uid: 'fx-bare.abcdefghij' }, post })
124
+ && C.deleteEntry({ t: { ...t, uid: 'CIAM-214' }, post }) === null, JSON.stringify(dc));
124
125
  }
125
126
 
126
127
  (async () => {
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* task-delete-test.js — a Delete for every PMOS task, where it sits (feedback batch 11 item 16; Wawan: "I should be able to delete the task
4
+ * (not Jira)"). Serves the real page from the real server; GET /api/board-premium answers a board built by lib/board-premium.js. The delete
5
+ * and restore routes are answered here and their bodies are kept.
6
+ * D the status picker under a task's caret ends in a trash, icon only, after its own divider: a press deletes the task at once (no confirm),
7
+ * the toast says "Deleted · <title>." with Undo, and Undo restores it
8
+ * I a breakdown item (<initiative>.<10 characters>) gets the same trash; a Jira ticket draws no caret, so it has none
9
+ * P the phone: a long press on the box opens the same picker, with the trash
10
+ * SHOTS_16=<dir>: the picker with the trash, the toast, and the phone, into <dir>. */
11
+ const path = require('path');
12
+ const { spawn } = require('child_process');
13
+ const { findBrowser } = require('./lib/find-browser');
14
+ const T = require('./test-run').configure({ name: 'task-delete' });
15
+ const BP = require('./lib/board-premium.js');
16
+ const F = require('./fixtures/board-premium-facts.js');
17
+
18
+ const BASE = T.BASE;
19
+ const results = [];
20
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
21
+ let srv = null; let browser = null;
22
+ const finish = async (code) => {
23
+ if (browser) await browser.close().catch(() => {});
24
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
25
+ T.killTmux();
26
+ const bad = results.filter((x) => !x.cond).length;
27
+ console.log(`\n${results.length - bad}/${results.length} task-delete assertions passed`);
28
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
29
+ };
30
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
31
+
32
+ const ROWS = [F.row('scarlet', 'Scarlet — ST What’s The News', { owner: 'Wawan', stage: 'Build', start: '2026-11-02', end: '2027-03-31', progress: 30 })];
33
+ const it = (uid, title, o) => ({ uid, key: '', kind: 'Task', src: 'pmos', title, status: 'To do', owner: 'Wawan', ini: 'scarlet', start: null, end: null, ref: uid, board: 'w1', section: 'build', ...o });
34
+ const ITEMS = [
35
+ it('task-api', 'Ship the article summaries API', { status: 'In progress', start: '2026-11-02', end: '2027-01-08' }),
36
+ it('scarlet.a1b2c3d4e5', 'WP2 Newsroom pilot plan', { store: 'item', end: '2026-12-11' }),
37
+ ];
38
+
39
+ (async () => {
40
+ const exe = findBrowser();
41
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
42
+ let chromium;
43
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
44
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
45
+ await T.waitForServer(BASE);
46
+ browser = await chromium.launch({ executablePath: exe });
47
+
48
+ /** The Board on the timeline, with the initiative panel open on Scarlet's Tasks. o: { w, h, phone, dark } */
49
+ const open = async (o = {}) => {
50
+ 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 });
51
+ const page = await ctx.newPage();
52
+ const errors = [], posts = [];
53
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
54
+ await page.clock.setFixedTime(new Date(F.NOW));
55
+ let gone = new Set();
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({ rows: ROWS.map((x) => ({ ...x })), total: 1, columns: [], items: ITEMS.filter((x) => !gone.has(x.uid)).map((x) => ({ ...x })) })), as_of: Date.now() }) }));
57
+ await page.route('**/api/programs', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, programs: [] }) }));
58
+ await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'not in this check' }) }));
59
+ await page.route('**/api/boards/tasks/delete', (r) => { const b = JSON.parse(r.request().postData() || '{}'); posts.push(['delete', b]); gone.add(b.task); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, task: b.task }) }); });
60
+ await page.route('**/api/boards/tasks/restore', (r) => { const b = JSON.parse(r.request().postData() || '{}'); posts.push(['restore', b]); gone = new Set([...gone].filter((x) => x !== b.task)); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, task: b.task }) }); });
61
+ 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': 'year', 'pmos.tasks.view': 'list' }]);
62
+ await page.goto(BASE + '/premium-board.html?ws=w1&board=w1');
63
+ await page.waitForSelector('#ibBody [data-row]', { timeout: 15000 });
64
+ await page.waitForTimeout(400);
65
+ return { ctx, page, errors, posts };
66
+ };
67
+ const shots = process.env.SHOTS_16;
68
+ const shot = async (p, name) => { if (shots) await p.screenshot({ path: path.join(shots, name + '.png') }); };
69
+ const unfold = async (p) => { for (let i = 0; i < 12; i++) { const b = await p.$('.iv-ws[data-iv-fold^="sec:"][aria-expanded="false"]'); if (!b) break; await b.click(); await p.waitForTimeout(80); } };
70
+ const picker = (p) => p.evaluate(() => {
71
+ const pop = document.querySelector('.ivq-st'); if (!pop) return null;
72
+ const kids = [...pop.children].map((x) => x.className || x.tagName);
73
+ const b = pop.querySelector('.ivq-del');
74
+ return { kids, del: b ? { lbl: b.getAttribute('aria-label'), tip: b.getAttribute('title'), text: b.textContent, last: pop.lastElementChild === b, afterVr: !!(b.previousElementSibling && b.previousElementSibling.classList.contains('vr')) } : null };
75
+ });
76
+
77
+ /* D I — desktop, the initiative panel */
78
+ {
79
+ const { ctx, page: p, errors, posts } = await open();
80
+ await p.click('#ibBody [data-key="board:scarlet"]');
81
+ await p.waitForSelector('.iv-tr', { timeout: 8000 });
82
+ await unfold(p);
83
+ await p.click('.iv-tr:has(.iv-tt:text-is("Ship the article summaries API")) .iv-car');
84
+ const pk = await picker(p);
85
+ ok('D the status picker ends in a trash, icon only, after its own divider, named "Delete task"', pk && pk.del && pk.del.lbl === 'Delete task' && pk.del.tip === 'Delete task' && pk.del.text === '' && pk.del.last && pk.del.afterVr, JSON.stringify(pk));
86
+ await shot(p, 'delete-picker-1440');
87
+ await p.click('.ivq-st .ivq-del'); await p.waitForTimeout(400);
88
+ const after = await p.evaluate(() => ({ toast: (document.getElementById('bdToast') || {}).textContent || '', undo: !!document.querySelector('#bdToast .bd-undo'), dialog: !!document.querySelector('[role="alertdialog"], dialog[open]'), rows: [...document.querySelectorAll('.iv-tr .iv-tt')].map((x) => x.textContent) }));
89
+ ok('D a press deletes it at once, no confirm: the delete route, and the row is gone', posts.length === 1 && posts[0][0] === 'delete' && posts[0][1].task === 'task-api' && posts[0][1].board === 'w1' && !after.dialog && !after.rows.includes('Ship the article summaries API'), JSON.stringify({ posts, after }));
90
+ ok('D the toast says "Deleted · <title>." with Undo', /^Deleted · Ship the article summaries API\.\s*Undo$/.test(after.toast.trim()) && after.undo, after.toast);
91
+ await shot(p, 'delete-toast-1440');
92
+ await p.click('#bdToast .bd-undo'); await p.waitForTimeout(500);
93
+ const back = await p.evaluate(() => [...document.querySelectorAll('.iv-tr .iv-tt')].map((x) => x.textContent));
94
+ ok('D Undo restores it: the restore route, and the row is back', posts.length === 2 && posts[1][0] === 'restore' && posts[1][1].task === 'task-api' && back.includes('Ship the article summaries API'), JSON.stringify({ posts, back }));
95
+ await unfold(p);
96
+ await p.click('.iv-tr:has(.iv-tt:text-is("WP2 Newsroom pilot plan")) .iv-car');
97
+ const pi = await picker(p);
98
+ ok('I a breakdown item gets the same trash, and a press deletes it', pi && pi.del && pi.del.lbl === 'Delete task', JSON.stringify(pi));
99
+ await p.click('.ivq-st .ivq-del'); await p.waitForTimeout(300);
100
+ ok('I the delete route takes the item id', posts.length === 3 && posts[2][1].task === 'scarlet.a1b2c3d4e5', JSON.stringify(posts));
101
+ const T2 = await p.evaluate(async () => { const m = await import('/pm/ini-tasks.js'); return [m.deletable('task-1'), m.deletable('scarlet.a1b2c3d4e5'), m.deletable('dt:d1:k'), m.deletable('CIAM-214'), m.deletable('')]; });
102
+ ok('I a Board task, a breakdown item and a draft\'s task can be deleted; a Jira key never', T2.join() === 'true,true,true,false,false', JSON.stringify(T2));
103
+ ok('the panel threw nothing', !errors.length, errors.join('\n'));
104
+ await ctx.close();
105
+ }
106
+
107
+ /* P — the phone: a long press on the box opens the picker, with the trash */
108
+ {
109
+ const { ctx, page: p, errors } = await open({ w: 390, h: 844, phone: true });
110
+ const opened = await p.evaluate(() => { const r = document.querySelector('#ibBody [data-key="board:scarlet"], #ibBody [data-row="board:scarlet"] .tg-n'); if (r) r.click(); return !!r; });
111
+ await p.waitForSelector('.iv-tr', { timeout: 8000 }).catch(() => {});
112
+ await unfold(p);
113
+ const box = await p.$('.iv-tr:has(.iv-tt:text-is("Ship the article summaries API")) .iv-cb');
114
+ if (box) {
115
+ const bb = await box.boundingBox();
116
+ await p.mouse.move(bb.x + bb.width / 2, bb.y + bb.height / 2); await p.mouse.down(); await p.waitForTimeout(650); await p.mouse.up();
117
+ await p.waitForTimeout(200);
118
+ }
119
+ const pk = await picker(p);
120
+ ok('P a long press on the box opens the picker, with the trash last', opened && pk && pk.del && pk.del.last, JSON.stringify({ opened, pk }));
121
+ await shot(p, 'delete-picker-390');
122
+ ok('the phone threw nothing', !errors.length, errors.join('\n'));
123
+ await ctx.close();
124
+ }
125
+ finish();
126
+ })();