create-pmos 0.401.0 → 0.403.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 (127) hide show
  1. package/package.json +25 -30
  2. package/payload/KIT-VERSION +2 -2
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +227 -0
  8. package/workspace/board-shot.js +54 -0
  9. package/workspace/briefing-premium-adddoc-test.js +28 -22
  10. package/workspace/briefing-premium-board-test.js +107 -82
  11. package/workspace/briefing-premium-calendar-2-test.js +23 -10
  12. package/workspace/briefing-premium-calendar-3-test.js +23 -19
  13. package/workspace/briefing-premium-calendar-test.js +20 -15
  14. package/workspace/briefing-premium-initiative-test.js +25 -12
  15. package/workspace/briefing-premium-insights-test.js +31 -18
  16. package/workspace/briefing-premium-metrics-test.js +8 -8
  17. package/workspace/briefing-premium-sources-test.js +15 -10
  18. package/workspace/briefing-premium-test.js +39 -16
  19. package/workspace/changelog.json +24 -0
  20. package/workspace/fixtures/board-premium-facts.js +20 -3
  21. package/workspace/fixtures/briefing-premium-facts.js +18 -2
  22. package/workspace/fixtures/premium-viewer-fixtures.js +24 -2
  23. package/workspace/fixtures/program-ascent.js +101 -0
  24. package/workspace/guide/home.md +11 -7
  25. package/workspace/guide/index.md +1 -0
  26. package/workspace/guide/jira.md +38 -6
  27. package/workspace/guide/programs.md +37 -0
  28. package/workspace/home-rows-test.js +184 -0
  29. package/workspace/lib/briefing-premium-products.js +4 -4
  30. package/workspace/lib/briefing-premium.js +2 -2
  31. package/workspace/lib/calendar-layers.js +8 -4
  32. package/workspace/lib/initiative-layout.js +4 -3
  33. package/workspace/lib/jira-cli.js +17 -12
  34. package/workspace/lib/jira-status.js +1 -1
  35. package/workspace/lib/jira-tickets.js +126 -24
  36. package/workspace/lib/meeting-files.js +58 -0
  37. package/workspace/lib/meeting-learn.js +139 -0
  38. package/workspace/lib/meeting-material.js +12 -5
  39. package/workspace/lib/notes.js +3 -0
  40. package/workspace/lib/programs.js +129 -0
  41. package/workspace/lib/route-modules.js +1 -0
  42. package/workspace/lib/routes-brief-page.js +8 -1
  43. package/workspace/lib/routes-briefing-premium.js +1 -1
  44. package/workspace/lib/routes-calendar-views.js +24 -3
  45. package/workspace/lib/routes-meeting-material.js +38 -0
  46. package/workspace/lib/routes-meeting-points.js +23 -3
  47. package/workspace/lib/routes-programs.js +122 -0
  48. package/workspace/package-lock.json +2 -2
  49. package/workspace/package.json +1 -1
  50. package/workspace/premium-board-actions-test.js +31 -25
  51. package/workspace/premium-chat-context-test.js +1 -1
  52. package/workspace/premium-chat-goal-view-test.js +1 -1
  53. package/workspace/premium-chat-viewer-test.js +1 -1
  54. package/workspace/premium-core-doc-issue-test.js +13 -7
  55. package/workspace/premium-discuss-landing-test.js +83 -0
  56. package/workspace/premium-link-suggest-test.js +103 -0
  57. package/workspace/premium-report-read-test.js +86 -82
  58. package/workspace/premium-vw-backlog-test.js +6 -5
  59. package/workspace/premium-vw-cal-test.js +45 -19
  60. package/workspace/premium-vw-item-test.js +8 -6
  61. package/workspace/premium-vw-jira-test.js +3 -2
  62. package/workspace/premium-vw-meet-test.js +122 -66
  63. package/workspace/premium-vw-notes-test.js +7 -6
  64. package/workspace/premium-vw-rec-test.js +14 -13
  65. package/workspace/premium-vw-slides-test.js +11 -5
  66. package/workspace/program-panel-test.js +152 -0
  67. package/workspace/public/pm/bd-acts.js +24 -15
  68. package/workspace/public/pm/bd-asks.js +111 -30
  69. package/workspace/public/pm/bd-ini-panel.js +229 -0
  70. package/workspace/public/pm/bd-pop.js +2 -2
  71. package/workspace/public/pm/bd-prog-panel.js +436 -0
  72. package/workspace/public/pm/bd-prog.js +191 -0
  73. package/workspace/public/pm/bd-span.js +98 -15
  74. package/workspace/public/pm/bd-views.js +93 -29
  75. package/workspace/public/pm/cozy-board.css +214 -20
  76. package/workspace/public/pm/cozy-evui.js +4 -2
  77. package/workspace/public/pm/cozy-home-rows.css +54 -0
  78. package/workspace/public/pm/cozy-home.css +35 -0
  79. package/workspace/public/pm/cozy-insights.css +1 -2
  80. package/workspace/public/pm/cozy-mtg-present.css +160 -0
  81. package/workspace/public/pm/cozy-panel.css +155 -0
  82. package/workspace/public/pm/cozy-rec-pill.css +12 -0
  83. package/workspace/public/pm/cozy-rec-pill.js +46 -0
  84. package/workspace/public/pm/cozy-today.css +189 -0
  85. package/workspace/public/pm/cozy-viewer.js +307 -43
  86. package/workspace/public/pm/cozy-vw-mtg.css +96 -94
  87. package/workspace/public/pm/cozy-vw-rp.css +40 -25
  88. package/workspace/public/pm/cozy-vw-shell.css +127 -0
  89. package/workspace/public/pm/cozy-xv.css +51 -0
  90. package/workspace/public/pm/cozy-xv.js +34 -0
  91. package/workspace/public/pm/home-app.js +192 -72
  92. package/workspace/public/pm/home-chat.js +17 -4
  93. package/workspace/public/pm/home-data.js +1 -1
  94. package/workspace/public/pm/home-day.js +64 -0
  95. package/workspace/public/pm/home-ini-model.js +1 -1
  96. package/workspace/public/pm/home-ini.js +197 -54
  97. package/workspace/public/pm/home-list.js +100 -27
  98. package/workspace/public/pm/home-mentions.js +187 -0
  99. package/workspace/public/pm/home-rec-row.js +67 -0
  100. package/workspace/public/pm/home-review.js +20 -10
  101. package/workspace/public/pm/home-task.js +19 -18
  102. package/workspace/public/pm/home-today.js +137 -59
  103. package/workspace/public/pm/premium-board.js +294 -288
  104. package/workspace/public/pm/premium-insights.js +118 -82
  105. package/workspace/public/pm/premium-mtg-present.js +408 -100
  106. package/workspace/public/pm/premium-mtg-replay.js +70 -10
  107. package/workspace/public/pm/premium-report-read.js +118 -63
  108. package/workspace/public/pm/premium-vw-cal.js +62 -34
  109. package/workspace/public/pm/premium-vw-mtg.js +348 -192
  110. package/workspace/public/pm/program-model.js +192 -0
  111. package/workspace/public/pm/rec-state.js +63 -0
  112. package/workspace/public/pm/rp-parts.js +33 -8
  113. package/workspace/public/pm/tk-draft.js +107 -0
  114. package/workspace/public/pm/tk-model.js +134 -0
  115. package/workspace/public/pm/tk-send.js +124 -0
  116. package/workspace/public/pm/tk-tasks.css +120 -0
  117. package/workspace/public/premium-board.html +4 -2
  118. package/workspace/server.js +4 -2
  119. package/workspace/skills/jira-push.skill +3 -3
  120. package/workspace/test-lists/board-programs.json +9 -0
  121. package/workspace/test-lists/prd-to-jira.json +6 -0
  122. package/workspace/test-lists/program-hierarchy.json +11 -0
  123. package/workspace/test-lists/program-panel.json +9 -0
  124. package/workspace/test-lists/viewer-home-rows.json +9 -0
  125. package/workspace/test-lists/viewer-meetings.json +9 -0
  126. package/workspace/test-lists/viewer-shell-a.json +15 -0
  127. package/workspace/tk-tasks-test.js +199 -0
@@ -81,11 +81,13 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
81
81
  // BdAsks, BdActions); New initiative and Cancelled and archived are side panels; the toast is #bdToast with its Undo; the old dialog never opens.
82
82
  const listed = (id) => p.evaluate((x) => [...document.querySelectorAll('#ibBody .ini2')].some((b) => b.dataset.key === 'board:' + x), id);
83
83
  const toastIs = (re) => until(() => p.evaluate((s) => { const t = document.querySelector('#bdToast'); return t && !t.hidden && new RegExp(s).test(t.textContent) ? t.textContent : null; }, re.source));
84
- const peekOn = (title) => until(() => p.evaluate((t) => { const k = document.querySelector('#peek'); return k && !k.hidden && (document.querySelector('#pkTitle') || {}).textContent === t && !k.querySelector('.bd-wtag'); }, title));
84
+ const peekOn = (title) => until(() => p.evaluate((t) => { const k = document.querySelector('#czViewer'); return k && !k.hidden && (document.querySelector('#czViewer .cz-vw-title') || {}).textContent === t && !k.querySelector('.bd-wtag'); }, title));
85
85
  const popOn = (re) => until(() => p.evaluate((s) => { const k = document.querySelector('#bdPop'); return k && !k.hidden && new RegExp(s).test(k.textContent) ? k.textContent : null; }, re.source));
86
86
  const noDlg = () => p.evaluate(() => !document.querySelector('#dlg.on'));
87
- const acts = async (id) => { await until(() => listed(id), 30000); await p.click(`#ibBody .ini2[data-key="board:${id}"]`); await until(() => p.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await p.click('#peek [data-pk="acts"]'); return until(() => p.evaluate(() => { const m = document.querySelector('#bdPop'); return !!m && !m.hidden && m.getAttribute('role') === 'menu'; })); };
88
- const closeAll = async () => { for (let i = 0; i < 3; i++) { if (await p.evaluate(() => document.querySelector('#peek').hidden && (!document.querySelector('#bdPop') || document.querySelector('#bdPop').hidden))) return; await p.keyboard.press('Escape'); await sleep(100); } };
87
+ /* re-pointed (viewer-shell-a, XvABoard): the initiative opens in the Viewer, and its ⋯ holds "Move, hold, cancel or archive" */
88
+ const vwActs = async (pg) => { await until(() => pg.evaluate(() => { const v = document.querySelector('#czViewer'), c = window.czViewer && window.czViewer.current(); return !!v && !v.hidden && !!c && c.kind === 'Initiative' && !!v.querySelector('[data-cz-vw="more"]'); })); await pg.click('#czViewer [data-cz-vw="more"]'); await pg.waitForSelector('.cz-vw-menu [role="menuitem"]'); const i = await pg.evaluate(() => [...document.querySelectorAll('.cz-vw-menu [role="menuitem"]')].findIndex((b) => b.textContent.trim() === 'Move, hold, cancel or archive')); await pg.locator('.cz-vw-menu [role="menuitem"]').nth(i).click(); };
89
+ const acts = async (id) => { await until(() => listed(id), 30000); await p.click(`#ibBody .ini2[data-key="board:${id}"]`); await vwActs(p); return until(() => p.evaluate(() => { const m = document.querySelector('#bdPop'); return !!m && !m.hidden && m.getAttribute('role') === 'menu'; })); };
90
+ const closeAll = async () => { for (let i = 0; i < 4; i++) { if (await p.evaluate(() => (!document.querySelector('#czViewer') || document.querySelector('#czViewer').hidden) && (!document.querySelector('#bdPop') || document.querySelector('#bdPop').hidden))) return; await p.keyboard.press('Escape'); await sleep(100); } };
89
91
  await until(() => p.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 30000);
90
92
  await p.click('#chAsks');
91
93
  ok('A2 the New asks popover lists both asks with Accept and Decline (BdAsks)', await until(() => p.evaluate(() => document.querySelectorAll('#bdPop .bd-acard[data-ask]').length === 2 && document.querySelectorAll('#bdPop [data-askact="accept"]').length === 2 && document.querySelectorAll('#bdPop [data-askact="decline"]').length === 2)), await p.evaluate(() => (document.querySelector('#bdPop') || {}).textContent));
@@ -93,20 +95,20 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
93
95
 
94
96
  /* T triage */
95
97
  await p.click(`#bdPop [data-askact="accept"][data-id="${a1.body.ask.id}"]`); await peekOn('Accept ask');
96
- const anc = await until(() => p.evaluate(() => { const s = document.querySelector('#peek select[name="anchor"]'); return s && !s.disabled ? [...s.options].map((o) => o.value) : null; }));
97
- ok('T1 Accept of an ask with no goal opens New initiative with the anchors the board declares, and no lane field', !!anc && anc.includes('health:tech') && await p.evaluate(() => !document.querySelector('#peek [name="lane"]')), JSON.stringify(anc));
98
- await p.fill('#peek input[name="title"]', ''); await p.click('#peek form[data-form="new2"] [type="submit"]');
98
+ const anc = await until(() => p.evaluate(() => { const s = document.querySelector('#czViewer select[name="anchor"]'); return s && !s.disabled ? [...s.options].map((o) => o.value) : null; }));
99
+ ok('T1 Accept of an ask with no goal opens New initiative with the anchors the board declares, and no lane field', !!anc && anc.includes('health:tech') && await p.evaluate(() => !document.querySelector('#czViewer [name="lane"]')), JSON.stringify(anc));
100
+ await p.fill('#czViewer input[name="title"]', ''); await p.click('#czViewer form[data-form="new2"] [type="submit"]');
99
101
  ok('T2 an empty name is refused on the page, before any press', await p.evaluate(() => /Give it a name/.test(document.querySelector('#formM').textContent)) && !P.posts.some((x) => x.path === '/api/boards/asks/accept'));
100
- await p.fill('#peek input[name="title"]', 'Daily CSV of failed payouts'); await p.selectOption('#peek select[name="anchor"]', 'health:tech');
101
- await p.click('#peek [data-newact="link"]'); await p.fill('#nwLink input', 'https://slack.example.com/archives/finance'); await p.click('#peek [data-newact="addlink"]');
102
+ await p.fill('#czViewer input[name="title"]', 'Daily CSV of failed payouts'); await p.selectOption('#czViewer select[name="anchor"]', 'health:tech');
103
+ await p.click('#czViewer [data-newact="link"]'); await p.fill('#nwLink input', 'https://slack.example.com/archives/finance'); await p.click('#czViewer [data-newact="addlink"]');
102
104
  ok('T2 a pasted link shows as material', await p.evaluate(() => /slack\.example\.com/.test(document.querySelector('#nwMat').textContent)));
103
- await p.click('#peek form[data-form="new2"] [type="submit"]');
105
+ await p.click('#czViewer form[data-form="new2"] [type="submit"]');
104
106
  ok('T3 Accept records the accept line and a new initiative, and says so', !!(await toastIs(/accepted in/)) && lines('boards.jsonl').some((l) => l.kind === 'ask-accept' && l.ask === a1.body.ask.id), JSON.stringify(lines('boards.jsonl').map((l) => l.kind)));
105
107
  const g0 = await until(() => lines('triage-answers.jsonl').find((l) => l.kind === 'start'));
106
- ok('T3 the Why and the link start its first questions (BdGrill): one start line, and the questions open in the same panel', !!g0 && /Finance wants a CSV/.test(g0.why) && g0.links.length === 1 && !!(await until(() => p.evaluate(() => !!document.querySelector('#peek .bd-qc.on') && /questions? before the BRD/.test(document.querySelector('#peek').textContent)))), JSON.stringify(g0));
107
- await p.click('#peek .bd-qc.on [data-qchip]'); await p.click('#peek [data-grill="next"]');
108
+ ok('T3 the Why and the link start its first questions (BdGrill): one start line, and the questions open in the same panel', !!g0 && /Finance wants a CSV/.test(g0.why) && g0.links.length === 1 && !!(await until(() => p.evaluate(() => !!document.querySelector('#czViewer .bd-qc.on') && /questions? before the BRD/.test(document.querySelector('#czViewer').textContent)))), JSON.stringify(g0));
109
+ await p.click('#czViewer .bd-qc.on [data-qchip]'); await p.click('#czViewer [data-grill="next"]');
108
110
  ok('T3 an answer is kept per question', await until(() => lines('triage-answers.jsonl').some((l) => l.kind === 'answer' && l.answer)));
109
- await p.click('#peek [data-grill="later"]');
111
+ await p.click('#czViewer [data-grill="later"]');
110
112
  ok('T3 Later keeps the open questions as the next step', await until(() => lines('triage-answers.jsonl').some((l) => l.kind === 'later')) && !!(await toastIs(/Kept as the next step/)));
111
113
  await until(() => p.evaluate(() => document.querySelector('#chAsks') && /\b1\b/.test(document.querySelector('#chAsks').textContent)), 30000);
112
114
  await p.click('#chAsks');
@@ -122,23 +124,26 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
122
124
 
123
125
  /* N New initiative */
124
126
  ok('N1 New initiative is offered on a team board', await p.evaluate(() => !document.querySelector('#newIni').hidden));
125
- await p.click('#newIni'); await peekOn('New initiative');
126
- await until(() => p.evaluate(() => { const s = document.querySelector('#peek select[name="anchor"]'); return s && !s.disabled; }));
127
- await p.fill('#peek input[name="title"]', 'Partner usage per key'); await p.click('#peek form[data-form="new2"] [type="submit"]');
127
+ await p.click('#newIni'); await p.click('#bdPop [data-newmenu="ini"]'); await peekOn('New initiative');
128
+ await until(() => p.evaluate(() => { const s = document.querySelector('#czViewer select[name="anchor"]'); return s && !s.disabled; }));
129
+ await p.fill('#czViewer input[name="title"]', 'Partner usage per key'); await p.click('#czViewer form[data-form="new2"] [type="submit"]');
128
130
  ok('N2 an unanchored create is refused on the page', await p.evaluate(() => /Choose what it counts toward/.test(document.querySelector('#formM').textContent)));
129
- await p.selectOption('#peek select[name="anchor"]', 'health:tech'); await p.click('#peek form[data-form="new2"] [type="submit"]');
131
+ await p.selectOption('#czViewer select[name="anchor"]', 'health:tech'); await p.click('#czViewer form[data-form="new2"] [type="submit"]');
130
132
  const made = await toastIs(/created in/);
131
133
  const recs = fs.readdirSync(path.join(team, 'planning', 'initiatives'));
132
134
  ok('N3 Create writes an ask, its accept and a new initiative record, as the console does', !!made && recs.some((f) => /partner-usage/.test(f)) && lines('boards.jsonl').some((l) => l.kind === 'ask' && l.line === 'Partner usage per key'), made + ' / ' + recs.join());
133
- await until(() => p.evaluate(() => !!document.querySelector('#peek .bd-qc')));
135
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer .bd-qc')));
136
+ const later0 = lines('triage-answers.jsonl').filter((l) => l.kind === 'later').length;
134
137
  await closeAll();
138
+ // the questions sit in the Viewer's shell now: its Close (Escape, ×) does what Later does, so no question is dropped by closing
139
+ ok('N4 closing the questions with the shell\'s Close keeps the open ones as the next step, as Later does', await until(() => lines('triage-answers.jsonl').filter((l) => l.kind === 'later').length > later0) && !!(await toastIs(/Kept as the next step of Partner usage per key/)));
135
140
 
136
141
  /* M move and Undo, from the panel's ⋯ (BdActions) */
137
142
  ok('M1 the row menu offers the next stage with how much is ready, hold, cancel and archive', await acts('pa-one') && await p.evaluate(() => { const L = [...document.querySelectorAll('#bdPop [data-rowact] span:first-of-type')].map((b) => b.textContent); return /^Move to /.test(L[0]) && L.includes('Hold') && L.includes('Cancel') && L.includes('Archive'); }), await p.evaluate(() => document.querySelector('#bdPop').textContent));
138
143
  await p.keyboard.press('Escape');
139
- ok('M2 Escape closes the menu and gives the focus back to the ⋯ button', await until(() => p.evaluate(() => document.querySelector('#bdPop').hidden && document.activeElement.dataset.pk === 'acts')));
144
+ ok('M2 Escape closes the menu and gives the focus back to the Viewer\'s ⋯ button', await until(() => p.evaluate(() => document.querySelector('#bdPop').hidden && document.activeElement.dataset.czVw === 'more')), await p.evaluate(() => document.activeElement.outerHTML.slice(0, 120)));
140
145
  await p.keyboard.press('Escape');
141
- ok('M2 a second Escape closes the panel and gives the focus back to the row', await until(() => p.evaluate(() => document.querySelector('#peek').hidden && !!document.activeElement.closest('#ibBody'))));
146
+ ok('M2 a second Escape closes the Viewer and gives the focus back to the row', await until(() => p.evaluate(() => document.querySelector('#czViewer').hidden && !!document.activeElement.closest('#ibBody'))));
142
147
  const from = ready.model.initiatives.list.rows.find((r) => r.id === 'pa-one').acts.stage;
143
148
  await acts('pa-one'); await p.click('#bdPop [data-rowact^="mv:"]');
144
149
  const mv = await toastIs(/^Moved to/);
@@ -166,8 +171,8 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
166
171
  ok('L5 the row leaves the track and the ⋯ menu\'s Cancelled and archived item counts it', await until(() => p.evaluate(() => !document.querySelector('#ibBody .bt-l[data-row="board:pa-one"]') && /1 cancelled/.test((document.querySelector('#bdGone') || {}).textContent || '')), 30000));
167
172
  await closeAll();
168
173
  await p.click('#moreBtn'); await p.click('#bdGone'); await peekOn('Cancelled and archived');
169
- ok('L6 a cancelled initiative offers Reopen only', await p.evaluate(() => [...document.querySelectorAll('#peek .bd-gr [data-rowact]')].map((b) => b.dataset.rowact).join() === 'reopen'));
170
- await p.click('#peek .bd-gr [data-rowact="reopen"]');
174
+ ok('L6 a cancelled initiative offers Reopen only', await p.evaluate(() => [...document.querySelectorAll('#czViewer .bd-gr [data-rowact]')].map((b) => b.dataset.rowact).join() === 'reopen'));
175
+ await p.click('#czViewer .bd-gr [data-rowact="reopen"]');
171
176
  ok('L6 Reopen records an active line', await until(() => { const L = lines('lifecycle.jsonl').filter((l) => l.initiative_id === 'pa-one'); return L[L.length - 1].state === 'active'; }));
172
177
  await closeAll();
173
178
  await until(() => listed('pa-one'), 30000);
@@ -182,11 +187,12 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
182
187
  Stage view; the card moves a stage with Move and Back (premium-uncovered-features, canvas InStage) */
183
188
  const I = await open('/premium-initiative.html?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id));
184
189
  const ip = I.page;
190
+ const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
185
191
  const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('.hm-card [data-hm-ov]'); }), 60000);
186
192
  ok('I0 the expand link lands on Home with the initiative selected, ws and board kept', !!landed, await ip.evaluate(() => location.href));
187
193
  await ip.click('.hm-card [data-hm-ov]');
188
- await until(() => ip.evaluate(() => !!document.querySelector('#czViewer [data-hi-view="stage"]')), 60000);
189
- await ip.click('#czViewer [data-hi-view="stage"]');
194
+ await until(() => ip.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 60000);
195
+ await (async (pg) => { if (await pg.$('#czViewer [data-hi-view="stage"]')) await pg.click('#czViewer [data-hi-view="stage"]'); else await viaMore(pg, 'Stage'); })(ip);
190
196
  const bar = await until(() => ip.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); if (!v || !v.querySelector('[data-ov-move]')) return null; const cur = v.querySelector('[data-ov-move][aria-pressed="true"]'); return { moves: [...v.querySelectorAll('[data-ov-move]')].map((x) => x.dataset.ovMove), cur: cur ? cur.dataset.ovMove : '', life: [...v.querySelectorAll('[data-ov-life]')].map((x) => x.dataset.ovLife) }; }), 60000);
191
197
  ok('I1 the Overview offers the stages, the current one pressed, and the lifecycle presses', !!bar && bar.moves.length > 1 && !!bar.cur && bar.moves.indexOf(bar.cur) < bar.moves.length - 1 && bar.life.join() === 'on-hold,cancelled', JSON.stringify(bar) + ' ' + (await ip.evaluate(() => (document.querySelector('#czViewer .cz-vw-body') || {}).innerText || 'no Viewer')).slice(0, 400));
192
198
  const n0 = lines('boards.jsonl').filter((l) => l.kind === 'move').length;
@@ -227,7 +233,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
227
233
  await S.page.click('#chAsks');
228
234
  ok('S1 the PMOS-self board names the router in its asks popover and hides New initiative', await until(() => S.page.evaluate(() => /pmos-router/.test((document.querySelector('#bdPop') || {}).textContent || '') && document.querySelector('#newIni').hidden)));
229
235
  await S.page.keyboard.press('Escape');
230
- await S.page.click('#ibBody .ini2'); await until(() => S.page.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await S.page.click('#peek [data-pk="acts"]');
236
+ await S.page.click('#ibBody .ini2'); await vwActs(S.page);
231
237
  ok('S2 its actions have no move', await until(() => S.page.evaluate(() => { const x = document.querySelector('#bdPop'); return x && !x.hidden && !x.querySelector('[data-rowact^="mv:"]') && !!x.querySelector('[data-rowact="hold"]'); })));
232
238
  await S.ctx.close();
233
239
  }
@@ -247,7 +253,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
247
253
  await until(() => S.page.evaluate(() => document.querySelectorAll('#ibBody .ini2').length > 0), 30000);
248
254
  const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#ibBody .ini2, #chAsks, #newIni')].filter((b) => b.offsetParent && (b.getBoundingClientRect().width < 44 || b.getBoundingClientRect().height < 44)).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().width) + 'x' + Math.round(b.getBoundingClientRect().height)) }));
249
255
  ok('F1 at 390 px there is no sideways scroll and every new control is at least 44 px', !f.wide && !f.small.length, JSON.stringify(f));
250
- await S.page.click('#ibBody .ini2'); await until(() => S.page.evaluate(() => !!document.querySelector('#peek [data-pk="acts"]'))); await S.page.click('#peek [data-pk="acts"]');
256
+ await S.page.click('#ibBody .ini2'); await vwActs(S.page);
251
257
  const mi = await until(() => S.page.evaluate(() => { const L = [...document.querySelectorAll('#bdPop.sheet:not([hidden]) .bd-mi')]; return L.length ? L.every((b) => b.getBoundingClientRect().height >= 44) && document.documentElement.scrollWidth <= innerWidth + 1 : null; }));
252
258
  ok('F2 the action rows are 44 px tall and the open sheet adds no sideways scroll', !!mi);
253
259
  await S.ctx.close();
@@ -114,7 +114,7 @@ const second = (k) => [
114
114
  await p.click('#hmPeek');
115
115
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'out' && v.tabs.length ? v : null; }) || await p.evaluate(look);
116
116
  ok(`C5 at 390 (${scheme}) the bar's press opens the file in the Viewer over the chat and the bar goes`, s1.tab === 'out' && s1.out >= 340 && JSON.stringify(s1.tabs) === JSON.stringify(['signup-plan2.md']) && !s1.peek, JSON.stringify(s1));
117
- await p.click('#czViewer [data-cz-vw="close"]'); // closing the Viewer goes back to the chat
117
+ await p.click('#czViewer [data-cz-vw="back"]'); // on a phone the Viewer's ← (shell A: no × there) goes back to the chat
118
118
  const s2 = await p.evaluate(look);
119
119
  ok(`C6 at 390 (${scheme}) every chip is at least 44 px and nothing scrolls sideways`, s2.minH >= 44 && !s2.wide, JSON.stringify(s2));
120
120
  ok(`C6 no page error at 390 (${scheme})`, errs.length === 0, errs.join(' | '));
@@ -117,7 +117,7 @@ const look = () => {
117
117
  const s1 = await until(async () => { const v = await p.evaluate(look); return v.tab === 'out' && v.pane ? v : null; }) || await p.evaluate(look);
118
118
  ok(`G5 (${scheme}) the chip shows the Goal tab on the popup's Detail tab, the popup's full width`, s1.tab === 'out' && s1.out >= 340 && /1 of 3 done points met/.test(s1.pane || ''), JSON.stringify(s1));
119
119
  if (shots) await p.screenshot({ path: `${shots}/goal-390-${scheme}.png` });
120
- await p.click('#czViewer [data-cz-vw="close"]'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])')));
120
+ await p.click('#czViewer [data-cz-vw="back"]'); await until(() => p.evaluate(() => !document.querySelector('#czViewer:not([hidden])'))); // the popup is phone-wide here: shell A shows ← there, no ×
121
121
  st.goal = goalOf('waiting', { met: [DRAFT.done[0]] });
122
122
  const s2 = await until(async () => { const v = await p.evaluate(look); return v.peek ? v : null; }) || await p.evaluate(look);
123
123
  ok(`G5 (${scheme}) a change offers the goal in the bar over the box, without covering the conversation`, /Needs you/.test(s2.peek || '') && !s2.layer && s2.tab === 'chat', JSON.stringify(s2));
@@ -66,7 +66,7 @@ const look = () => {
66
66
  return { p, ctx, errs };
67
67
  };
68
68
  const many = (p) => p.evaluate(async () => { const v = await import('/pm/premium-viewer.js'); for (const n of ['funnel-export.csv', 'support-tickets.md', 'pricing-notes.md', 'a-longer-quarterly-plan.md']) v.vwOpen({ id: 'x:' + n, title: n, html: '<article class="paper doc"><p>' + n + '</p></article>' }); });
69
- const closeVw = (p) => p.click('#czViewer [data-cz-vw="close"]');
69
+ const closeVw = (p) => p.click('#czViewer [data-cz-vw="close"], #czViewer [data-cz-vw="back"]'); // shell A: × on a desk, ← on a phone
70
70
 
71
71
  { const { p, ctx, errs } = await open(1280);
72
72
  const s0 = await p.evaluate(look);
@@ -96,28 +96,32 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
96
96
  ok('B1 a board document is a row whose title opens the reader', await until(() => p.evaluate((k) => !!document.querySelector(`#docBody [data-opendoc="core:${k}"]`), bkey), 60000));
97
97
  ok('B1 every document row has a title that opens it', await p.evaluate(() => [...document.querySelectorAll('#docBody .bd-dt[data-docrow]')].every((r) => !!r.querySelector('[data-opendoc]'))));
98
98
  await p.click(`#docBody [data-opendoc="core:${bkey}"]`);
99
- ok('B2 the reader shows the file\'s text and path, and the bar says nothing is sent', await until(() => p.evaluate((pt) => { const o = document.querySelector('#peek'); return !o.hidden && /Why this board exists/.test(o.textContent) && o.textContent.includes(pt) && !!o.querySelector('[data-issue-bar="draft"]') && /Nothing is sent/.test(o.querySelector('[data-issue-bar]').textContent) && !!o.querySelector('[data-act="issue"]'); }, d1.path)), await p.evaluate(() => document.querySelector('#peek').textContent));
99
+ ok('B2 the reader shows the file\'s text and path, and the bar says nothing is sent', await until(() => p.evaluate((pt) => { const o = document.querySelector('#czViewer'); return !o.hidden && /Why this board exists/.test(o.textContent) && o.textContent.includes(pt) && !!o.querySelector('[data-issue-bar="draft"]') && /Nothing is sent/.test(o.querySelector('[data-issue-bar]').textContent) && !!o.querySelector('[data-act="issue"]'); }, d1.path)), await p.evaluate(() => document.querySelector('#czViewer').textContent));
100
100
  ok('B2 no old dialog opens', await p.evaluate(() => !!!document.querySelector('#dlg.on')));
101
101
  const n0 = ledger().filter((l) => l.ev === 'issue').length;
102
- await p.click('#peek [data-act="issue"]');
102
+ await p.click('#czViewer [data-act="issue"]');
103
103
  ok('B3 Issue it says it sent nothing', !!(await bToast(p, /Issued\. Nothing was sent to anyone/)));
104
104
  const sent = P.posts.filter((x) => x.path === '/api/core-docs/issue');
105
105
  ok('B4 it posted the workspace, the scope, the key and the slot, and nothing else, with the launch nonce', sent.length === 1 && Object.keys(sent[0].body).sort().join() === 'key,scope,slot,ws' && sent[0].body.scope === bscope && sent[0].body.key === bkey && sent[0].body.slot === d1.slot && sent[0].body.ws === B.ws && sent[0].headers['x-pmos-nonce'] === nonce && !!nonce, JSON.stringify(sent));
106
106
  const il = ledger().filter((l) => l.ev === 'issue');
107
107
  ok('B5 the ledger has one new issue line for that draft, written by the PM', il.length === n0 + 1 && il[il.length - 1].slot === d1.slot && il[il.length - 1].scope === bscope && /pm/.test(String(il[il.length - 1].by)), JSON.stringify(il));
108
108
  ok('B5 the file now says state: issued', /^state: issued$/m.test(fs.readFileSync(path.join(team, d1.path), 'utf8')));
109
- ok('B6 the reader says it is issued, the Issue it press is gone, and the row reads Up to date', await until(() => p.evaluate(() => { const o = document.querySelector('#peek'); return !o.hidden && !!o.querySelector('[data-issue-bar="done"]') && !o.querySelector('[data-act="issue"]'); }), 30000) && await until(() => p.evaluate((k) => { const r = document.querySelector(`#docBody [data-docrow="core:${k}"]`); return r && /Up to date/.test(r.textContent); }, bkey), 30000), await p.evaluate(() => document.querySelector('#peek').textContent + ' // ' + document.querySelector('#docBody').textContent));
109
+ ok('B6 the reader says it is issued, the Issue it press is gone, and the row reads Up to date', await until(() => p.evaluate(() => { const o = document.querySelector('#czViewer'); return !o.hidden && !!o.querySelector('[data-issue-bar="done"]') && !o.querySelector('[data-act="issue"]'); }), 30000) && await until(() => p.evaluate((k) => { const r = document.querySelector(`#docBody [data-docrow="core:${k}"]`); return r && /Up to date/.test(r.textContent); }, bkey), 30000), await p.evaluate(() => document.querySelector('#czViewer').textContent + ' // ' + document.querySelector('#docBody').textContent));
110
110
  await p.screenshot({ path: path.join(R.base, 'board-issued.png') });
111
111
  await P.ctx.close();
112
112
 
113
113
  /* I the initiative: a layout inside Home (premium-agreed-design). The Board's expand link lands there; the card's Overview lists the core documents (its Documents view),
114
114
  and a draft opens a minimal reader in the Viewer (Waiting for design) with the Issue it bar, Read and Edit */
115
+ // Documents is shell A (XvADocs): its groups after the first are folded, so a row is unfolded before it is pressed
116
+ const unfold = (p, sel) => p.evaluate((q) => { const n = document.querySelector(q); const f = n && !n.offsetParent && n.closest('.czs-sec') && n.closest('.czs-sec').querySelector('[data-czs-fold]'); if (f) f.click(); }, sel);
117
+ const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
115
118
  const ovOpen = async (p) => { await until(() => p.evaluate(() => !!document.querySelector('.hm-card [data-hm-ov]')), 60000); await p.click('.hm-card [data-hm-ov]');
116
119
  // the Overview opens on Tasks; the core documents are its Documents view (premium-uncovered-features, canvas InDocs)
117
- if (await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-hi-view="docs"]')), 30000)) await p.click('#czViewer [data-hi-view="docs"]'); };
120
+ if (await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 30000)) await (async (pg) => { if (await pg.$('#czViewer [data-hi-view="docs"]')) await pg.click('#czViewer [data-hi-view="docs"]'); else await viaMore(pg, 'Documents'); })(p); };
118
121
  const I = await open('/premium-initiative.html' + iq), ip = I.page;
119
122
  await ovOpen(ip);
120
123
  await until(() => ip.evaluate((k) => !!document.querySelector(`#czViewer [data-ov-dread="${k}"]`), ikey), 60000);
124
+ await unfold(ip, `#czViewer [data-ov-dread="${ikey}"]`);
121
125
  await ip.click(`#czViewer [data-ov-dread="${ikey}"]`);
122
126
  ok('I1 the reader of a draft has the Issue it bar above the text', await until(() => ip.evaluate(() => { const o = document.querySelector('#czViewer:not([hidden])'); const b = o && o.querySelector('[data-issue-bar="draft"]'); const t = o && o.querySelector('.dsbody'); return !!b && !!t && /Nothing is sent/.test(b.textContent) && /Why this board exists/.test(t.textContent) && !!(b.compareDocumentPosition(t) & Node.DOCUMENT_POSITION_FOLLOWING); }), 30000));
123
127
  ok('I1 no old dialog opens', await ip.evaluate(() => { const d = document.querySelector('#dlg'); return !d || !d.classList.contains('on'); }));
@@ -143,12 +147,14 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
143
147
  const k3 = d3.path.split('/').slice(-2)[0];
144
148
  await ovOpen(jp);
145
149
  await until(() => jp.evaluate((k) => !!document.querySelector(`#czViewer [data-ov-dread="${k}"]`), k3), 60000);
150
+ await unfold(jp, `#czViewer [data-ov-dread="${k3}"]`);
146
151
  await jp.click(`#czViewer [data-ov-dread="${k3}"]`);
147
152
  await until(() => jp.evaluate(() => !!document.querySelector('#czViewer [data-ds="issue"]')));
148
153
  await jp.click('#czViewer [data-ds="issue"]');
149
154
  const issued = !!(await toastIs(jp, /Issued\. Nothing was sent to anyone/)) && await until(() => jp.evaluate(() => !!document.querySelector('#czViewer [data-issue-bar="done"]') && !document.querySelector('#czViewer [data-ds="issue"]')));
150
155
  await sleep(1500); await ovOpen(jp);
151
- ok('I4 Issue it works from the reader: the toast, the issued bar, and the Overview row reads Up to date', issued && await until(() => jp.evaluate((k) => /Up to date/.test((document.querySelector(`#czViewer [data-ov-doc="${k}"]`) || {}).textContent || ''), k3), 30000));
156
+ // shell A (XvADocs): an up-to-date document says nothing about its state (zero is silence); it is a plain Open press, not the draft reader
157
+ ok('I4 Issue it works from the reader: the toast, the issued bar, and the Overview row is a plain open, no longer a draft', issued && await until(() => jp.evaluate((k) => { const r = document.querySelector(`#czViewer [data-ov-doc="${k}"]`); return !!r && !!r.querySelector('[data-ov-open]') && !r.querySelector('[data-ov-dread]'); }, k3), 30000), JSON.stringify({ issued, row: await jp.evaluate((k) => ((document.querySelector(`#czViewer [data-ov-doc="${k}"]`) || {}).outerHTML || 'none').replace(/<svg.*?<\/svg>/g, '').slice(0, 400), k3) }));
152
158
  ok('I4 the file says state: issued and the ledger has its issue line', /^state: issued$/m.test(fs.readFileSync(path.join(team, d3.path), 'utf8')) && ledger().some((l) => l.ev === 'issue' && l.slot === d3.slot && l.scope === iscope));
153
159
  await jp.screenshot({ path: path.join(R.base, 'ini-issued.png') });
154
160
 
@@ -174,8 +180,8 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
174
180
  await S.page.click(w <= 720 ? '#chDocs' : '#tabDocs');
175
181
  await until(() => S.page.evaluate((k) => !!document.querySelector(`#docBody [data-opendoc="core:${k}"]`), k4), 60000);
176
182
  await S.page.click(`#docBody [data-opendoc="core:${k4}"]`);
177
- await until(() => S.page.evaluate(() => !!document.querySelector('#peek [data-act="issue"]')));
178
- const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#peek [data-act="issue"]')].filter((b) => b.getBoundingClientRect().height < (innerWidth <= 720 ? 44 : 34)).map((b) => b.textContent) }));
183
+ await until(() => S.page.evaluate(() => !!document.querySelector('#czViewer [data-act="issue"]')));
184
+ const f = await S.page.evaluate(() => ({ wide: document.documentElement.scrollWidth > innerWidth + 1, small: [...document.querySelectorAll('#czViewer [data-act="issue"]')].filter((b) => b.getBoundingClientRect().height < (innerWidth <= 720 ? 44 : 34)).map((b) => b.textContent) }));
179
185
  ok(`F1 ${w} px ${theme}: no sideways scroll and the bar's button is 44 px on a phone`, !f.wide && !f.small.length, JSON.stringify(f));
180
186
  await S.page.screenshot({ path: path.join(R.base, `bar-${w}-${theme}.png`) });
181
187
  await S.ctx.close();
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-discuss-landing-test.js — Discuss in chat from another page lands on Home (Viewer kit, frame XvABoardChat): the chat about the item
4
+ * opens, and the item opens in the Viewer beside it when Home has a view for it.
5
+ * D1 the shell's Discuss in chat names the item: ?about=<prefix>:<id>, ?label, ?vk, ?vid · D2 an initiative lands on its layout, chat and
6
+ * overview · D3 a document lands on its chat with the document open · D4 a kind Home has no view for is the chat alone · D5 no page error */
7
+ const path = require('path');
8
+ const { spawn } = require('child_process');
9
+ const { findBrowser } = require('./lib/find-browser');
10
+ const T = require('./test-run').configure({ name: 'premium-discuss-landing' });
11
+ const BP = require('./lib/board-premium.js');
12
+ const BF = require('./fixtures/board-premium-facts.js');
13
+ const BRP = require('./lib/briefing-premium.js');
14
+ const BRF = require('./fixtures/briefing-premium-facts.js');
15
+
16
+ const BASE = T.BASE;
17
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
18
+ const until = async (fn, ms = 6000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
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} premium-discuss-landing 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 BOARD = BP.build(BF.facts());
33
+ const BRIEF = BRP.build(BRF.facts());
34
+ const json = (r, body, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(body) });
35
+
36
+ (async () => {
37
+ const exe = findBrowser();
38
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
39
+ let chromium;
40
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
41
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
42
+ await T.waitForServer(BASE);
43
+ browser = await chromium.launch({ executablePath: exe });
44
+ const errors = [];
45
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
46
+ await ctx.route(/\/api\/board-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BOARD, as_of: Date.now() }));
47
+ await ctx.route(/\/api\/briefing-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BRIEF, as_of: Date.now() }));
48
+ await ctx.route('**/api/briefing-premium/**', (r) => json(r, { ok: true, turns: [], working: false }));
49
+ const page = await ctx.newPage();
50
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
51
+
52
+ // the Discuss press of an item on a page with no chat beside it (the Viewer floats there), read as the address it goes to
53
+ const discussFrom = async (item) => {
54
+ await page.goto(BASE + '/premium-viewer.html?theme=light');
55
+ await page.waitForFunction(() => !!window.czViewer, null, { timeout: 15000 });
56
+ await page.evaluate((it) => window.czViewer.open({ ...it, discuss: true, html: '<p>The item</p>' }), item);
57
+ await page.click('#czViewer [data-cz-vw="discuss"]');
58
+ await page.waitForURL(/\/premium\.html\?/, { timeout: 15000 });
59
+ return new URL(page.url());
60
+ };
61
+ const state = () => page.evaluate(() => ({
62
+ vw: !!document.querySelector('#czViewer:not([hidden])'), vwTitle: ((document.querySelector('#czViewer .cz-vw-hd') || {}).textContent || '').replace(/\s+/g, ' ').trim(),
63
+ top: document.querySelector('#hmTopTitle').textContent, url: location.search,
64
+ }));
65
+
66
+ let u = await discussFrom({ kind: 'Initiative', id: 'usage-billing', title: 'Usage-based billing' });
67
+ ok('D1 an initiative\'s Discuss names it: about=init:<id>, its title, its kind and id', u.searchParams.get('about') === 'init:usage-billing' && u.searchParams.get('label') === 'Usage-based billing' && u.searchParams.get('vk') === 'initiative' && u.searchParams.get('vid') === 'usage-billing', u.search);
68
+ let s = await until(async () => { const v = await state(); return v.vw && /Usage-based billing/.test(v.vwTitle) ? v : null; }, 15000) || await state();
69
+ ok('D2 an initiative lands on its layout, with its chat and its overview in the Viewer beside it', s.top === 'Usage-based billing' && s.vw && /Usage-based billing/.test(s.vwTitle) && /ini=usage-billing/.test(s.url), JSON.stringify(s));
70
+
71
+ if (process.env.DL_SHOTS) await page.screenshot({ path: path.join(process.env.DL_SHOTS, 'discuss-landing-1440.png') }); // a folder: a review shot
72
+ u = await discussFrom({ kind: 'PRD', id: 'planning/prd/usage-billing.md', title: 'Usage billing PRD' });
73
+ ok('D1 a document\'s Discuss keeps its path for Home: about=doc:…, vid=<path>', /^doc:planning-prd-usage-billing\.md$/.test(u.searchParams.get('about') || '') && u.searchParams.get('vid') === 'planning/prd/usage-billing.md', u.search);
74
+ s = await until(async () => { const v = await state(); return v.vw && /usage-billing|Usage billing PRD/i.test(v.vwTitle) ? v : null; }, 15000) || await state();
75
+ ok('D3 a document lands on the chat about it, with the document open in the Viewer', s.top === 'Usage billing PRD' && s.vw && /usage-billing|Usage billing PRD/i.test(s.vwTitle), JSON.stringify(s));
76
+
77
+ u = await discussFrom({ kind: 'Person', id: 'ana', title: 'Ana Lim' });
78
+ ok('D1 a kind Home has no key for is a chat key: about=chat:<id>', u.searchParams.get('about') === 'chat:ana', u.search);
79
+ await sleep(2500); s = await state();
80
+ ok('D4 a kind Home has no view for is the chat alone, named by its label', s.top === 'Ana Lim' && !s.vw, JSON.stringify(s));
81
+ ok('D5 no page error', errors.length === 0, errors.join(' | '));
82
+ finish();
83
+ })();
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* premium-link-suggest-test.js — a loose chat's guess at its initiative (Viewer kit, frame XvALinkSuggest). A loose session whose title shares
4
+ * words with one initiative's title shows one quiet chip at the chat's top: "Looks like <initiative> · Link it ×". Link it links the session
5
+ * through the real route's contract (POST /api/session/initiative); × hides the chip for that chat and it stays hidden after a reload.
6
+ * L1 the chip names the matching initiative · L2 a chat with no match shows no chip · L3 Link it posts the link · L4 × hides it and it stays
7
+ * hidden · L5 a phone keeps 44 px targets · L6 no page error */
8
+ const path = require('path');
9
+ const { spawn } = require('child_process');
10
+ const { findBrowser } = require('./lib/find-browser');
11
+ const T = require('./test-run').configure({ name: 'premium-link-suggest' });
12
+ const BP = require('./lib/board-premium.js');
13
+ const BF = require('./fixtures/board-premium-facts.js');
14
+ const BRP = require('./lib/briefing-premium.js');
15
+ const BRF = require('./fixtures/briefing-premium-facts.js');
16
+
17
+ const BASE = T.BASE;
18
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
+ const until = async (fn, ms = 6000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
20
+ const results = [];
21
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
22
+ let srv = null; let browser = null;
23
+ const finish = async (code) => {
24
+ if (browser) await browser.close().catch(() => {});
25
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
26
+ T.killTmux();
27
+ const bad = results.filter((x) => !x.cond).length;
28
+ console.log(`\n${results.length - bad}/${results.length} premium-link-suggest assertions passed`);
29
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
30
+ };
31
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
32
+
33
+ const BOARD = BP.build(BF.facts());
34
+ const BRIEF = BRP.build(BRF.facts());
35
+ const SESSIONS = [
36
+ { id: 's-meter', name: 'Fix the usage meter on billing', origin: '', shown: 'quiet' },
37
+ { id: 's-lunch', name: 'Lunch plans for Friday', origin: '', shown: 'quiet' },
38
+ ];
39
+ const json = (r, body, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(body) });
40
+
41
+ (async () => {
42
+ const exe = findBrowser();
43
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
44
+ let chromium;
45
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
46
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
47
+ await T.waitForServer(BASE);
48
+ browser = await chromium.launch({ executablePath: exe });
49
+
50
+ const errors = [];
51
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
52
+ const setup = async (page, posts) => {
53
+ page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
54
+ await page.route(/\/api\/board-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BOARD, as_of: Date.now() }));
55
+ await page.route(/\/api\/briefing-premium(\?.*)?$/, (r) => json(r, { ok: true, state: 'ready', model: BRIEF, as_of: Date.now() }));
56
+ await page.route('**/api/briefing-premium/**', (r) => json(r, { ok: true, turns: [], working: false }));
57
+ await page.route('**/api/sessions', (r) => json(r, { ok: true, sessions: SESSIONS }));
58
+ await page.route('**/api/sessions/conversation**', (r) => json(r, { ok: true, state: 'conv', turn: 'user', messages: [{ role: 'user', text: 'The meter double counts', at: Date.now() - 60000 }] }));
59
+ await page.route('**/api/session/initiative', (r) => { posts.push(JSON.parse(r.request().postData() || '{}')); return json(r, { ok: true }); });
60
+ };
61
+ const openSession = async (page, name) => {
62
+ const row = await until(async () => page.$(`#hmList button:has-text("${name}")`), 10000);
63
+ if (!row) return false;
64
+ await row.click(); await sleep(600); return true;
65
+ };
66
+ const chip = (page) => page.evaluate(() => { const s = document.querySelector('#hmSug'); return s && !s.hidden ? s.textContent.replace(/\s+/g, ' ').trim() : ''; });
67
+
68
+ const posts = [];
69
+ let page = await ctx.newPage(); await setup(page, posts);
70
+ await page.goto(BASE + '/premium.html?theme=light');
71
+ const opened = await openSession(page, 'Fix the usage meter on billing');
72
+ ok('L1 the loose session opens from the list', opened);
73
+ ok('L1 the chip names the matching initiative, once, with Link it', /^Looks like Usage-based billing\s*Link it$/.test(await until(() => chip(page))), await chip(page));
74
+ await openSession(page, 'Lunch plans for Friday');
75
+ ok('L2 a loose chat that matches no initiative shows no chip', (await chip(page)) === '');
76
+ await openSession(page, 'Fix the usage meter on billing');
77
+ await page.click('#hmSug [data-hm-sug="link"]');
78
+ ok('L3 Link it links this session to the guessed initiative', !!(await until(async () => posts.length === 1)) && posts[0].id === 's-meter' && posts[0].initiative === 'usage-billing', JSON.stringify(posts));
79
+ await page.close();
80
+
81
+ page = await ctx.newPage(); await setup(page, posts);
82
+ await page.goto(BASE + '/premium.html?theme=light');
83
+ await openSession(page, 'Fix the usage meter on billing');
84
+ await until(() => chip(page));
85
+ await page.click('#hmSug [data-hm-sug="x"]');
86
+ ok('L4 × hides the chip', (await chip(page)) === '');
87
+ await page.reload(); await openSession(page, 'Fix the usage meter on billing'); await sleep(800);
88
+ ok('L4 a dismissed guess stays hidden for that chat after a reload', (await chip(page)) === '');
89
+ await page.close(); await ctx.close();
90
+
91
+ const pctx = await browser.newContext({ viewport: { width: 390, height: 844 }, hasTouch: true });
92
+ page = await pctx.newPage(); await setup(page, []);
93
+ await page.goto(BASE + '/premium.html?theme=light');
94
+ const loose = await until(async () => page.$('#hmList button:has-text("Not in an initiative")'), 10000); // the phone folds loose chats into one row
95
+ if (loose) { await loose.click(); await sleep(500); }
96
+ const popen = await openSession(page, 'Fix the usage meter on billing');
97
+ if (process.env.LS_DEBUG) { console.log('phone open', popen); await page.screenshot({ path: process.env.LS_DEBUG }); }
98
+ const sz = await until(() => page.evaluate(() => { const b = document.querySelector('#hmSug:not([hidden]) [data-hm-sug="link"]'); if (!b) return null; const r = b.getBoundingClientRect(); return r.width && { w: r.width, h: r.height }; }));
99
+ ok('L5 on a phone the chip shows and Link it is a 44 px target', !!sz && sz.h >= 44 && sz.w >= 44, JSON.stringify(sz));
100
+ await pctx.close();
101
+ ok('L6 no page error', errors.length === 0, errors.join(' | '));
102
+ finish();
103
+ })();