create-pmos 0.324.0 → 0.326.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.
- package/package.json +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-calendar-2-test.js +8 -6
- package/workspace/briefing-premium-calendar-3-test.js +7 -4
- package/workspace/briefing-premium-calendar-test.js +4 -2
- package/workspace/guide/briefing-premium.md +23 -2
- package/workspace/lib/engine/boards.js +28 -1
- package/workspace/lib/routes-boards.js +2 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-vw-backlog-test.js +127 -0
- package/workspace/premium-vw-doc-test.js +3 -1
- package/workspace/premium-vw-item-test.js +128 -0
- package/workspace/premium-vw-meet-test.js +210 -0
- package/workspace/premium-vw-notes-test.js +161 -0
- package/workspace/premium-vw-rec-test.js +209 -0
- package/workspace/public/pm/premium-board.js +13 -1
- package/workspace/public/pm/premium-initiative.js +7 -2
- package/workspace/public/pm/premium-meeting.js +106 -32
- package/workspace/public/pm/premium-shell.js +8 -2
- package/workspace/public/pm/premium-vw-backlog.css +30 -0
- package/workspace/public/pm/premium-vw-backlog.js +91 -0
- package/workspace/public/pm/premium-vw-doc-model.js +3 -2
- package/workspace/public/pm/premium-vw-doc.css +1 -0
- package/workspace/public/pm/premium-vw-doc.js +7 -4
- package/workspace/public/pm/premium-vw-item-model.js +58 -0
- package/workspace/public/pm/premium-vw-item.css +25 -0
- package/workspace/public/pm/premium-vw-item.js +66 -0
- package/workspace/public/pm/premium-vw-jira.js +3 -1
- package/workspace/public/pm/premium-vw-meet.css +87 -0
- package/workspace/public/pm/premium-vw-meet.js +322 -0
- package/workspace/public/pm/premium-vw-notes.css +43 -0
- package/workspace/public/pm/premium-vw-notes.js +188 -0
- package/workspace/public/pm/premium-vw-rec.css +75 -0
- package/workspace/public/pm/premium-vw-rec.js +257 -0
- package/workspace/public/pm/premium.js +2 -0
- package/workspace/test-files.json +2 -0
- package/workspace/test-lists/premium-viewer.json +4 -2
- package/workspace/test-lists/premium-vw-backlog.json +13 -0
- package/workspace/test-lists/premium-vw-item.json +13 -0
- package/workspace/test-lists/premium-vw-meet.json +13 -0
- package/workspace/test-lists/premium-vw-notes.json +13 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-item-test.js — an initiative and its tasks as tabs of the premium dialog's viewer (initiative premium-viewer, S7; planning/prd/premium-viewer-prd.md R9, R6, R7).
|
|
4
|
+
* Serves the real initiative and Board pages from the real server with /api/initiative-premium and /api/board-premium answered by stand-ins built
|
|
5
|
+
* from the libraries' own fixtures. Opens the dialog, presses Open the full record, then a task inside the tab and the initiative link inside the task.
|
|
6
|
+
* Every wait polls the page; no fixed sleep stands in for a state. */
|
|
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-vw-item' });
|
|
11
|
+
const IP = require('./lib/initiative-premium.js');
|
|
12
|
+
const F = require('./fixtures/initiative-premium-facts.js');
|
|
13
|
+
const BP = require('./lib/board-premium.js');
|
|
14
|
+
const BF = require('./fixtures/board-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 = 10000, 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-vw-item assertions passed`);
|
|
28
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
29
|
+
};
|
|
30
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
31
|
+
|
|
32
|
+
(async () => {
|
|
33
|
+
const exe = findBrowser();
|
|
34
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
35
|
+
let chromium;
|
|
36
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
37
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
38
|
+
await T.waitForServer(BASE);
|
|
39
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
40
|
+
const MODEL = IP.build(F.facts());
|
|
41
|
+
|
|
42
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', answer = null } = {}) => {
|
|
43
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
44
|
+
const page = await ctx.newPage();
|
|
45
|
+
const S = { errors: [], gets: [] };
|
|
46
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
47
|
+
await page.route('**/api/initiative-premium*', (r) => { S.gets.push(r.request().url()); const a = answer ? answer(S.gets.length) : { status: 200, body: { ok: true, state: 'ready', model: MODEL, as_of: Date.now() } }; r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); });
|
|
48
|
+
await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
|
|
49
|
+
await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
|
|
50
|
+
S.up = await until(() => page.evaluate(() => !!document.querySelector('#cIniTk') && !!window.__premiumViewer), 20000);
|
|
51
|
+
return { page, ctx, S };
|
|
52
|
+
};
|
|
53
|
+
const st = (page) => page.evaluate(() => ({ ...window.__premiumViewer.vwState(), tabs: [...document.querySelectorAll('#vTabs .vtab')].map((x) => x.textContent.trim()) }));
|
|
54
|
+
const paneTxt = (page, id) => page.evaluate((k) => { const p = document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(k)}"]`); return p ? p.textContent.replace(/\s+/g, ' ') : ''; }, id);
|
|
55
|
+
const INI = 'item:ini:self-serve-v2';
|
|
56
|
+
|
|
57
|
+
/* R9 on the initiative page, at 1280 */
|
|
58
|
+
{
|
|
59
|
+
const { page, ctx, S } = await open();
|
|
60
|
+
ok('R9 the initiative page loads with the viewer', S.up);
|
|
61
|
+
await page.locator('#cIniTk .tkq', { hasText: 'UAT with five partners' }).click(); await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
62
|
+
const n0 = S.gets.length; // the page's own read
|
|
63
|
+
ok('R9 a task dialog offers Open the initiative', await page.evaluate(() => /Open the initiative/.test((document.querySelector('#oMain [data-vwopen]') || {}).textContent || '')));
|
|
64
|
+
await page.click('#oMain [data-vwopen]');
|
|
65
|
+
await until(async () => /Checks/.test(await paneTxt(page, INI)));
|
|
66
|
+
let s = await st(page), t = await paneTxt(page, INI);
|
|
67
|
+
ok('R9 the initiative opens as a tab beside the task\'s own detail', JSON.stringify(s.ids) === JSON.stringify([INI]) && s.on === INI && s.tabs.length === 2, JSON.stringify(s));
|
|
68
|
+
ok('R9 the tab holds the record, next step, checks, tasks and links', ['planning/initiatives/self-serve-v2.md', 'q3-2026:o1:kr1', 'Dara', '30 Oct', 'Next: contract', 'Checks', 'Sandbox key step', 'UAT with five partners', 'planning/evals/self-serve-v2-eval-rubric.md'].every((x) => t.includes(x)), t.slice(0, 500));
|
|
69
|
+
ok('R9 the tab loads its own stylesheet', await page.evaluate(() => !!document.querySelector('link[data-vw-css="item"]')));
|
|
70
|
+
await page.click(`#dOut .obody.vw[data-vw="${INI}"] [data-vwtask="task:t1"]`);
|
|
71
|
+
const TK = 'item:task:self-serve-v2:task:t1';
|
|
72
|
+
await until(async () => /UAT with five partners/.test(await paneTxt(page, TK)));
|
|
73
|
+
s = await st(page); t = await paneTxt(page, TK);
|
|
74
|
+
ok('R9 a task inside the tab opens its own tab, named by the task', JSON.stringify(s.ids) === JSON.stringify([INI, TK]) && s.on === TK && s.tabs[2] === 'UAT with five partners', JSON.stringify(s));
|
|
75
|
+
ok('R9 the task tab shows owner, start, due and status', ['Dara', '20 Oct', '27 Oct', 'To do', 'PMOS task'].every((x) => t.includes(x)), t);
|
|
76
|
+
ok('R9 two tabs of one initiative read the route once', S.gets.length - n0 === 1, String(S.gets.length - n0));
|
|
77
|
+
await page.click(`#dOut .obody.vw[data-vw="${TK}"] [data-vwini]`);
|
|
78
|
+
s = await st(page);
|
|
79
|
+
ok('R9 the initiative link brings the open initiative tab forward, not a second one', s.on === INI && s.ids.length === 2, JSON.stringify(s));
|
|
80
|
+
await page.keyboard.press('Escape'); await until(() => page.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
81
|
+
await page.click('#crAsk'); await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
82
|
+
s = await st(page);
|
|
83
|
+
ok('R9 a new dialog starts with no extra tab; the initiative\'s own dialog offers Open the full record', s.ids.length === 0 && await page.evaluate(() => /Open the full record/.test((document.querySelector('#oMain [data-vwopen]') || {}).textContent || '')), JSON.stringify(s));
|
|
84
|
+
ok('R9 no page error', S.errors.length === 0, S.errors.join(' | '));
|
|
85
|
+
await ctx.close();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* R6 a route that is reading, then fails */
|
|
89
|
+
{
|
|
90
|
+
const { page, ctx, S } = await open({ answer: (n) => (n === 1 ? { status: 200, body: { ok: true, state: 'ready', model: MODEL } } : n <= 3 ? { status: 202, body: { ok: true, state: 'reading' } } : { status: 500, body: { ok: false, state: 'error', error: 'the board could not be read' } }) });
|
|
91
|
+
await page.click('#crAsk'); await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
92
|
+
await page.evaluate(() => window.__premiumWorkItem.openWorkItem({ kind: 'initiative', id: 'other-two', title: 'Other' }));
|
|
93
|
+
ok('R6 while the route reads, the tab says so', await until(async () => /Reading the initiative/.test(await paneTxt(page, 'item:ini:other-two')), 3000));
|
|
94
|
+
ok('R6 a failed read says what failed and invents nothing', await until(async () => /could not be read: the board could not be read/.test(await paneTxt(page, 'item:ini:other-two')), 8000), await paneTxt(page, 'item:ini:other-two'));
|
|
95
|
+
await ctx.close();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* R9 from the Board's initiative dialog (Popup), and R7 floors at 390 in dark */
|
|
99
|
+
{
|
|
100
|
+
const ctx = await browser.newContext({ viewport: { width: 390, height: 844 } });
|
|
101
|
+
const page = await ctx.newPage(); const errors = [];
|
|
102
|
+
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
103
|
+
await page.addInitScript(() => { try { localStorage.setItem('pmos.premium.openAs', 'popup'); } catch { /* none */ } });
|
|
104
|
+
await page.route('**/api/board-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: BP.build(BF.facts()), as_of: Date.now() }) }));
|
|
105
|
+
await page.route('**/api/initiative-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: MODEL, as_of: Date.now() }) }));
|
|
106
|
+
await page.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }));
|
|
107
|
+
await page.goto(BASE + '/premium-board.html?theme=dark');
|
|
108
|
+
const up = await until(() => page.evaluate(() => document.querySelectorAll('#ibBody [data-key]').length > 0), 20000);
|
|
109
|
+
ok('R9 the Board loads', up);
|
|
110
|
+
const opened = await page.evaluate(() => { const b = document.querySelector('#ibBody [data-key]'); if (b) b.click(); return !!b; });
|
|
111
|
+
await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
112
|
+
ok('R9 an initiative row opens the Board dialog with Open the full record', opened && await until(() => page.evaluate(() => !!document.querySelector('#oMain [data-vwopen]')), 3000));
|
|
113
|
+
await page.evaluate(() => document.querySelector('#oMain [data-vwopen]').click());
|
|
114
|
+
const id = await until(() => page.evaluate(() => window.__premiumViewer.vwState().ids[0]), 3000);
|
|
115
|
+
ok('R9 the Board dialog opens the record as a tab', /^item:ini:/.test(id || ''), String(id));
|
|
116
|
+
await until(async () => /Checks/.test(await paneTxt(page, id)));
|
|
117
|
+
const fl = await page.evaluate((k) => {
|
|
118
|
+
const p = document.querySelector(`#dOut .obody.vw[data-vw="${CSS.escape(k)}"]`);
|
|
119
|
+
const small = [...p.querySelectorAll('button, a')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent.trim().slice(0, 30));
|
|
120
|
+
return { wide: document.documentElement.scrollWidth <= 390, small, bg: getComputedStyle(p.querySelector('.vwi-l') || p).backgroundColor };
|
|
121
|
+
}, id);
|
|
122
|
+
ok('R7 at 390px in dark: no sideways scroll, every press at least 44px', fl.wide && fl.small.length === 0, JSON.stringify(fl));
|
|
123
|
+
ok('R7 dark theme cards are dark', /rgba?\((\d+), (\d+), (\d+)/.test(fl.bg) && +RegExp.$1 < 80, fl.bg);
|
|
124
|
+
ok('R9 no page error on the Board', errors.length === 0, errors.join(' | '));
|
|
125
|
+
await ctx.close();
|
|
126
|
+
}
|
|
127
|
+
finish();
|
|
128
|
+
})();
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-meet-test.js — the meeting detail laid out as the console's note sheet (initiative premium-viewer, R3, slice S3; planning/prd/premium-viewer-prd.md).
|
|
4
|
+
* Serves the real Briefing from the real server. The Briefing model, the calendar, the notes and the note (GET /api/notes/one) are answered by stand-ins,
|
|
5
|
+
* so each press can be read off the request the page sent. The routes' own behaviour is in their own suites; the pure half is in premium-vw-meet.test.js.
|
|
6
|
+
* S1 stage · S2 head · S3 After · S4 Make task · S5 Before · S6 During · S7 series membership · S8 no note · S9 writes · S10 floors
|
|
7
|
+
* Every wait polls the page; no fixed sleep stands in for a state. */
|
|
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-vw-meet' });
|
|
12
|
+
const B = require('./lib/briefing-premium.js');
|
|
13
|
+
const F = require('./fixtures/briefing-premium-facts.js');
|
|
14
|
+
|
|
15
|
+
const BASE = T.BASE;
|
|
16
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
const until = async (fn, ms = 10000, 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); } };
|
|
18
|
+
const results = [];
|
|
19
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
20
|
+
let srv = null; let browser = null;
|
|
21
|
+
const finish = async (code) => {
|
|
22
|
+
if (browser) await browser.close().catch(() => {});
|
|
23
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
24
|
+
T.killTmux();
|
|
25
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
26
|
+
console.log(`\n${results.length - bad}/${results.length} premium-vw-meet assertions passed`);
|
|
27
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
28
|
+
};
|
|
29
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
30
|
+
|
|
31
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
32
|
+
const dayKey = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
33
|
+
const iso = (d) => { const off = -d.getTimezoneOffset(), a = Math.abs(off); return `${dayKey(d)}T${pad(d.getHours())}:${pad(d.getMinutes())}:00${off >= 0 ? '+' : '-'}${pad(Math.floor(a / 60))}:${pad(a % 60)}`; };
|
|
34
|
+
const NOW = new Date();
|
|
35
|
+
const midnight = new Date(NOW.getFullYear(), NOW.getMonth(), NOW.getDate());
|
|
36
|
+
const monday = () => { const d = new Date(midnight); d.setDate(d.getDate() - ((d.getDay() + 6) % 7)); return d; };
|
|
37
|
+
/* "Weekly sync" started at most 10 minutes ago (never before midnight), so it is a Today row; START is in whole minutes, as the calendar answer holds it */
|
|
38
|
+
const START = new Date(Math.max(midnight.getTime(), Math.floor((NOW.getTime() - 10 * 60000) / 60000) * 60000)), END = new Date(START.getTime() + 45 * 60000);
|
|
39
|
+
const weekAnswer = () => {
|
|
40
|
+
const m = monday(), cells = [];
|
|
41
|
+
for (let i = 0; i < 7; i++) { const d = new Date(m.getFullYear(), m.getMonth(), m.getDate() + i); cells.push({ key: dayKey(d), start: dayKey(d), end: dayKey(d), events: [] }); }
|
|
42
|
+
cells.find((c) => c.key === dayKey(START)).events.push({ id: 'ev-sync', at: iso(START), end: iso(END), title: 'Weekly sync', attendees: ['Dara', 'Sam'] });
|
|
43
|
+
return { ok: true, view: 'week', range: { start: cells[0].key, end: cells[6].key }, cells, events_source: 'calendar-memory', today: dayKey(NOW), context: {}, link_boards: [], gantt: [] };
|
|
44
|
+
};
|
|
45
|
+
const ROW = { id: 'n1', title: 'Weekly sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', event_id: 'ev-sync', start: iso(START), title: 'Weekly sync' }, series: { key: 'weekly-sync' } };
|
|
46
|
+
const NOTE = { ...ROW, meeting_ms: 32 * 60000,
|
|
47
|
+
meeting: { ...ROW.meeting, end: iso(END), context: { with: 'Dara and Sam', purpose: 'Agree what blocks the release.', agenda: ['Migration check status', 'Hiring loop'], links: [{ label: 'Release PRD', url: 'https://x.example/prd' }] } },
|
|
48
|
+
initiative: { id: 'premium-ux', ws: 'w1', title: 'Premium UX' }, board: { id: 'b1', ws: 'w1', title: 'Growth' },
|
|
49
|
+
final_notes: { overview: 'The team reviewed the migration check.', decisions: [{ text: 'Keep the new copy', why: 'Completion rose six points.' }], actions: [{ text: 'Start the migration check', owner: 'Sam', due: '2026-10-22' }], questions: [{ text: 'Do old workspaces need a manual step?' }] },
|
|
50
|
+
final: { segments: [{ t: 61000, spk: 'meeting', text: 'The migration check status is not started.' }, { t: 125000, spk: 'mic', text: 'Then we keep the copy.' }] }, speakers: { meeting: 'Dara' } };
|
|
51
|
+
const PLACE = { key: 'weekly-sync', title: 'Weekly sync', pos: 2, count: 3, by: 'calendar', prev: { id: 'n0', at: '2026-10-06T10:00:00Z', overview: 'The copy test plan.' }, next: { id: 'n2', at: '2026-10-20T10:00:00Z' },
|
|
52
|
+
since: { at: '2026-10-06T10:00:00Z', items: [{ text: 'Write the runbook', owner: 'Sam', state: 'done' }, { text: 'Book the readout', owner: 'Dara', state: 'again' }], fresh: [{ text: 'Start the migration check', owner: 'Sam' }] },
|
|
53
|
+
carried_in: [{ text: 'Book the readout', owner: 'Dara' }], carried: {} };
|
|
54
|
+
const PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==', 'base64');
|
|
55
|
+
|
|
56
|
+
(async () => {
|
|
57
|
+
const exe = findBrowser();
|
|
58
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
59
|
+
let chromium;
|
|
60
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
61
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
62
|
+
await T.waitForServer(BASE);
|
|
63
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
64
|
+
|
|
65
|
+
const facts = () => { const f = F.facts(); f.meetings = [{ start: START.getTime(), end: END.getTime(), title: 'Weekly sync', with: 'Dara, Sam', initiative: null }]; return f; };
|
|
66
|
+
const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
67
|
+
const SESS = [];
|
|
68
|
+
/* opts: notes (the rows GET /api/notes holds), note (the note GET /api/notes/one answers) */
|
|
69
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', notes = [ROW], note = NOTE } = {}) => {
|
|
70
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
71
|
+
const page = await ctx.newPage();
|
|
72
|
+
const S = { errors: [], reqs: [], planPosts: [], memberPosts: [], oneGets: [], out: false };
|
|
73
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
74
|
+
page.on('request', (r) => { if (r.url().startsWith(BASE)) S.reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
|
|
75
|
+
await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(facts()), as_of: Date.now() }));
|
|
76
|
+
await page.route('**/api/calendar-views*', (r) => json(r, weekAnswer()));
|
|
77
|
+
await page.route('**/api/meeting-replay*', (r) => json(r, { ok: false, error: 'no note' }, 404));
|
|
78
|
+
await page.route('**/api/meeting-material*', (r) => json(r, { ok: true, key: 'k', items: [] }));
|
|
79
|
+
await page.route('**/api/notes/recording*', (r) => r.fulfill({ status: 200, contentType: 'audio/wav', body: Buffer.alloc(0) }));
|
|
80
|
+
await page.route('**/api/notes/screen*', (r) => r.fulfill({ status: 200, contentType: 'image/png', body: PNG }));
|
|
81
|
+
await page.route('**/api/notes/series?*', (r) => json(r, { ok: true, series: { key: 'weekly-sync', meetings: [] } }));
|
|
82
|
+
await page.route('**/api/notes/one*', (r) => {
|
|
83
|
+
const id = new URL(r.request().url()).searchParams.get('id'); S.oneGets.push(id);
|
|
84
|
+
const n = S.out ? { ...note, series_pm: 'off' } : note;
|
|
85
|
+
return json(r, { ok: true, note: n, recording: { bytes: 64 }, screen: { frames: [{ t: 120000, why: 'A slide with the plan' }] }, place: S.out ? null : PLACE });
|
|
86
|
+
});
|
|
87
|
+
await page.route('**/api/notes/series-member', (r) => { const b = JSON.parse(r.request().postData() || '{}'); S.memberPosts.push(b); S.out = b.key === 'off'; return json(r, { ok: true }); });
|
|
88
|
+
await page.route(/\/api\/notes$/, (r) => json(r, { ok: true, notes }));
|
|
89
|
+
await page.route('**/api/plan-items*', (r) => {
|
|
90
|
+
const req = r.request();
|
|
91
|
+
if (req.method() === 'POST') { const b = JSON.parse(req.postData() || '{}'); S.planPosts.push(b); return json(r, { ok: true, written: [{ item: 'item-9' }] }); }
|
|
92
|
+
return json(r, { ok: true, stages: [{ id: 'st1', label: 'Intake' }] });
|
|
93
|
+
});
|
|
94
|
+
await page.goto(BASE + '/premium.html?theme=' + theme);
|
|
95
|
+
S.up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 && document.querySelectorAll('#tl .ev').length > 0), 20000);
|
|
96
|
+
await until(() => page.evaluate(() => document.querySelectorAll('#wkStrip [data-day]').length === 5));
|
|
97
|
+
await page.evaluate(() => { const r = [...document.querySelectorAll('#tl .ev')].find((e) => e.querySelector('b').textContent === 'Weekly sync'); r.click(); });
|
|
98
|
+
S.dlg = await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && !!document.querySelector('#oMain .vm-ph')));
|
|
99
|
+
SESS.push(S);
|
|
100
|
+
return Object.assign(S, { ctx, page });
|
|
101
|
+
};
|
|
102
|
+
const part = (p, k) => p.evaluate((x) => { const e = document.querySelector(`#oMain .vm-body[data-part="${x}"]`); return e ? { shown: !e.hidden, text: e.textContent } : null; }, k);
|
|
103
|
+
const stage = async (p, k) => { await p.click(`#oMain [data-ph="${k}"]`); await until(async () => ((await part(p, k)) || {}).shown); };
|
|
104
|
+
|
|
105
|
+
const A = await open();
|
|
106
|
+
ok('0 the meeting dialog opens with Before, During and After', A.up && A.dlg);
|
|
107
|
+
if (!A.up || !A.dlg) return finish(1);
|
|
108
|
+
const p = A.page;
|
|
109
|
+
|
|
110
|
+
/* S1 the stage */
|
|
111
|
+
const st = await until(() => p.evaluate(() => { const b = [...document.querySelectorAll('#oMain .vm-ph [data-ph]')]; return b.length === 3 && b.find((x) => x.getAttribute('aria-pressed') === 'true') && /migration check/.test(document.querySelector('#oMain').textContent) ? b.map((x) => x.dataset.ph + ':' + x.getAttribute('aria-pressed')).join() : null; }));
|
|
112
|
+
ok('S1 a meeting with notes opens on After, and only one stage is pressed', st === 'before:false,during:false,after:true', String(st));
|
|
113
|
+
ok('S1 the note was read from GET /api/notes/one for the meeting\'s note', A.oneGets[0] === 'n1', JSON.stringify(A.oneGets));
|
|
114
|
+
|
|
115
|
+
/* S2 the head */
|
|
116
|
+
const head = await p.evaluate(() => ({ lines: [...document.querySelectorAll('#oMain .vm-ln')].map((x) => x.textContent), ser: (document.querySelector('#oMain .vm-ser') || {}).textContent || '', prev: (document.querySelector('#oMain [data-vm="prev"]') || {}).dataset, next: !!document.querySelector('#oMain [data-vm="next"][data-id="n2"]'), sel: !!document.querySelector('#mtgSel') }));
|
|
117
|
+
ok('S2 the head says when the meeting is and what it is about, with Change', head.lines.length >= 2 && head.lines.some((l) => / to /.test(l)) && head.lines.some((l) => /Not linked yet|It is about/.test(l)) && head.sel, JSON.stringify(head.lines));
|
|
118
|
+
ok('S2 the series line says N of M and pages to the meeting before and after', /Weekly sync · 2 of 3/.test(head.ser) && head.prev && head.prev.id === 'n0' && head.next && /Not part of this series/.test(head.ser), head.ser);
|
|
119
|
+
|
|
120
|
+
/* S3 After */
|
|
121
|
+
const af = (await part(p, 'after')).text;
|
|
122
|
+
ok('S3 Since the last one lists the step done, raised again and the new one', /Since the last one, /.test(af) && /Write the runbook/.test(af) && /Done/.test(af) && /Raised again/.test(af) && /New/.test(af));
|
|
123
|
+
ok('S3 the summary, the Decision and Why table and the open question come from the final notes', /The team reviewed the migration check\./.test(af) && /Keep the new copy/.test(af) && /Completion rose six points\./.test(af) && /Do old workspaces need a manual step\?/.test(af));
|
|
124
|
+
const tb = await p.evaluate(() => ({ dec: [...document.querySelectorAll('#oMain [data-vm-t="decisions"] th')].map((x) => x.textContent).join('|'), act: [...document.querySelectorAll('#oMain [data-vm-t="actions"] tbody td')].slice(0, 3).map((x) => x.textContent).join('|'),
|
|
125
|
+
img: !!document.querySelector('#oMain .vm-shots img[src*="/api/notes/screen?id=n1"]'), aud: (document.querySelector('#oMain audio.vm-aud') || {}).src || '', fold: (document.querySelector('#oMain details.vm-fold summary') || {}).textContent || '' }));
|
|
126
|
+
ok('S3 the tables have Decision and Why, and Next step with owner and due', tb.dec === 'Decision|Why' && tb.act === 'Start the migration check|Sam|2026-10-22', JSON.stringify(tb));
|
|
127
|
+
ok('S3 the screenshot, the kept audio and the folded transcript are shown', tb.img && /\/api\/notes\/recording\?id=n1&b=64/.test(tb.aud) && /Transcript · 2 lines/.test(tb.fold), JSON.stringify(tb));
|
|
128
|
+
|
|
129
|
+
/* S4 Make task */
|
|
130
|
+
await p.click('#oMain .mtg-task');
|
|
131
|
+
await until(() => A.planPosts.length === 1);
|
|
132
|
+
const pp = A.planPosts[0];
|
|
133
|
+
ok('S4 Make task posts one planned event to the note\'s initiative with the owner and due', pp && pp.ws === 'w1' && pp.events[0].ev === 'planned' && pp.events[0].initiative === 'premium-ux' && pp.events[0].owner === 'person:Sam' && pp.events[0].due === '2026-10-22' && pp.events[0].stage === 'st1', JSON.stringify(pp));
|
|
134
|
+
ok('S4 the step says Task made and the status says where it went', await until(() => p.evaluate(() => /Added to Premium UX, under Intake\./.test(document.querySelector('#mtgStatus').textContent) && document.querySelector('#oMain .mtg-task').textContent === 'Task made')));
|
|
135
|
+
await p.click('#mtgUndo'); await until(() => A.planPosts.length === 2);
|
|
136
|
+
ok('S4 Undo withdraws the item', A.planPosts[1].events[0].ev === 'withdrawn' && A.planPosts[1].events[0].item === 'item-9');
|
|
137
|
+
|
|
138
|
+
/* S5 Before */
|
|
139
|
+
await stage(p, 'before');
|
|
140
|
+
const bf = (await part(p, 'before')).text;
|
|
141
|
+
ok('S5 Before shows what was carried in, the agenda with what was heard, and what it is for', /Carried in from/.test(bf) && /Book the readout/.test(bf) && /1 of 2 heard/.test(bf) && /What it is for/.test(bf) && /Release PRD/.test(bf), bf.slice(0, 300));
|
|
142
|
+
ok('S5 Before keeps Prepared for you and Material', /Prepared for you/.test(bf) && /Material/.test(bf) && await p.evaluate(() => !!document.querySelector('#mmAdd') && !!document.querySelector('#mmAdd').offsetParent));
|
|
143
|
+
ok('S1 pressing a stage shows it, hides the others and moves the pressed state', await p.evaluate(() => document.querySelector('#oMain [data-ph="before"]').getAttribute('aria-pressed') === 'true' && document.querySelector('#oMain .vm-body[data-part="after"]').hidden));
|
|
144
|
+
|
|
145
|
+
/* S6 During */
|
|
146
|
+
await stage(p, 'during');
|
|
147
|
+
const du = (await part(p, 'during')).text;
|
|
148
|
+
ok('S6 During lists the transcript with times and the speakers the note names', /01:01/.test(du) && /Dara/.test(du) && /The migration check status is not started\./.test(du) && /You/.test(du), du.slice(0, 200));
|
|
149
|
+
ok('S6 the Record and Focus presses stay in the head on every stage', await p.evaluate(() => !!document.querySelector('#oMain [data-m3="focus"]').offsetParent));
|
|
150
|
+
|
|
151
|
+
/* S7 series membership */
|
|
152
|
+
await p.click('#oMain [data-vm="serout"]');
|
|
153
|
+
await until(() => A.memberPosts.length === 1);
|
|
154
|
+
ok('S7 Not part of this series posts the note with key off', A.memberPosts[0].id === 'n1' && A.memberPosts[0].key === 'off', JSON.stringify(A.memberPosts));
|
|
155
|
+
ok('S7 the note is read again and the line offers Put it back', await until(() => p.evaluate(() => /Taken out of its series/.test(document.querySelector('#oMain').textContent) && !!document.querySelector('#oMain [data-vm="serback"]'))));
|
|
156
|
+
await p.click('#oMain [data-vm="serback"]'); await until(() => A.memberPosts.length === 2);
|
|
157
|
+
ok('S7 Put it back posts the note with no key', A.memberPosts[1].key === null, JSON.stringify(A.memberPosts[1]));
|
|
158
|
+
|
|
159
|
+
/* S2 a meeting of the series opens beside this one as a viewer tab (the frame, premium-viewer S1) */
|
|
160
|
+
await until(() => p.evaluate(() => !!document.querySelector('#oMain [data-vm="prev"][data-id="n0"]')));
|
|
161
|
+
await p.click('#oMain [data-vm="prev"]');
|
|
162
|
+
const tab = await until(() => p.evaluate(() => { const t = document.querySelector('#vTabs'), pane = document.querySelector('#dOut .obody.vw[data-vw="meet-note"]'); return t && !t.hidden && pane && !pane.hidden && /Since the last one/.test(pane.textContent) ? { tabs: [...t.querySelectorAll('.vtab')].map((x) => x.textContent.trim()), main: document.querySelector('#oMain').hidden, ph: [...pane.querySelectorAll('[data-ph]')].length } : null; }));
|
|
163
|
+
ok('S2 the meeting before opens as a viewer tab beside the meeting, with its own Before, During and After', tab && tab.tabs.length === 2 && tab.main && tab.ph === 3 && A.oneGets.includes('n0'), JSON.stringify([tab, A.oneGets]));
|
|
164
|
+
await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-vm="next"]');
|
|
165
|
+
ok('S2 paging in the tab reads the next meeting into the same tab', await until(() => A.oneGets.includes('n2')) && await p.evaluate(() => document.querySelectorAll('#vTabs .vtab').length === 2));
|
|
166
|
+
await p.click('#vTabs .vx');
|
|
167
|
+
ok('S2 closing the tab shows the meeting again', await until(() => p.evaluate(() => !document.querySelector('#oMain').hidden && document.querySelector('#vTabs').hidden)));
|
|
168
|
+
|
|
169
|
+
/* S8 a meeting with no note */
|
|
170
|
+
const Z = await open({ notes: [], note: null });
|
|
171
|
+
const zst = await until(() => Z.page.evaluate(() => { const b = document.querySelector('#oMain [data-ph="before"]'); return b && b.getAttribute('aria-pressed') === 'true' && /No notes for this meeting\./.test(document.querySelector('#oMain').textContent); }));
|
|
172
|
+
ok('S8 with no note the detail opens on Before and After says there are no notes', zst);
|
|
173
|
+
ok('S8 with no note During says nothing was transcribed, and no note was asked for', /Nothing was transcribed/.test((await part(Z.page, 'during')).text) && Z.oneGets.length === 0 && !(await Z.page.evaluate(() => !!document.querySelector('#oMain .vm-ser'))));
|
|
174
|
+
|
|
175
|
+
/* S9 writes */
|
|
176
|
+
const posts = [...new Set([].concat(A.reqs, Z.reqs).filter((r) => /^POST /.test(r)))].sort();
|
|
177
|
+
ok('S9 the only writes are Make task and the series membership', posts.join() === 'POST /api/notes/series-member,POST /api/plan-items', posts.join());
|
|
178
|
+
for (const [pth, body] of [['/api/notes/series-member', { id: 'n-nothing', key: 'off' }]]) {
|
|
179
|
+
const res = await fetch(BASE + pth, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
|
|
180
|
+
ok(`S9 ${pth} without the launch nonce is refused`, res.status === 403, String(res.status));
|
|
181
|
+
}
|
|
182
|
+
await A.ctx.close(); await Z.ctx.close();
|
|
183
|
+
|
|
184
|
+
/* S10 floors (PMOS_SHOTS=<dir> also saves a picture of each stage) */
|
|
185
|
+
const shotDir = process.env.PMOS_SHOTS || '';
|
|
186
|
+
for (const [w, h, th] of [[1280, 900, 'light'], [1280, 900, 'dark']]) {
|
|
187
|
+
if (!shotDir) break;
|
|
188
|
+
const P = await open({ w, h, theme: th });
|
|
189
|
+
await until(() => P.page.evaluate(() => /migration check/.test(document.querySelector('#oMain').textContent)));
|
|
190
|
+
for (const k of ['after', 'before', 'during']) { await stage(P.page, k); await P.page.screenshot({ path: path.join(shotDir, `${k}-${w}-${th}.png`) }); }
|
|
191
|
+
await P.ctx.close();
|
|
192
|
+
}
|
|
193
|
+
for (const th of ['light', 'dark']) {
|
|
194
|
+
const P = await open({ w: 390, h: 844, theme: th });
|
|
195
|
+
await until(() => P.page.evaluate(() => /migration check/.test(document.querySelector('#oMain').textContent)));
|
|
196
|
+
/* measure once the meeting stylesheet has loaded and the dialog's presses are live, not on the first unstyled frame */
|
|
197
|
+
await until(() => P.page.evaluate(() => document.querySelector('#oMain').dataset.ready === 'meeting' && [...document.styleSheets].some((x) => /premium-vw-meet\.css/.test(x.href || '') && x.cssRules.length > 0)));
|
|
198
|
+
const fl = () => P.page.evaluate(() => ({ scroll: document.documentElement.scrollWidth <= innerWidth + 1 && document.querySelector('#oMain').scrollWidth <= document.querySelector('#oMain').clientWidth + 1,
|
|
199
|
+
btn: [...document.querySelectorAll('#oMain .vm-ph button, #oMain .vm-ib, #oMain .vm-lk, #oMain .mtg-task')].filter((b) => b.getClientRects().length).map((b) => Math.round(Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height))) }));
|
|
200
|
+
const f0 = await fl();
|
|
201
|
+
if (shotDir) await P.page.screenshot({ path: path.join(shotDir, `after-390-${th}.png`) });
|
|
202
|
+
await P.page.click('#oMain [data-ph="before"]'); const f1 = await fl();
|
|
203
|
+
ok(`S10 at 390 px (${th}) the detail has no sideways scroll and every press is at least 44 px`, f0.scroll && f1.scroll && f0.btn.length > 3 && [...f0.btn, ...f1.btn].every((n) => n >= 44), JSON.stringify([f0, f1]));
|
|
204
|
+
const contrast = await P.page.evaluate(() => { const b = document.querySelector('#oMain .vm-ph [aria-pressed="true"]'); const c = getComputedStyle(b); return c.color !== c.backgroundColor; });
|
|
205
|
+
ok(`S10 (${th}) the pressed stage is drawn apart from its label`, contrast);
|
|
206
|
+
await P.ctx.close();
|
|
207
|
+
}
|
|
208
|
+
ok('S9 no page error in any run', SESS.every((x) => x.errors.length === 0), JSON.stringify(SESS.map((x) => x.errors).filter((e) => e.length)));
|
|
209
|
+
return finish();
|
|
210
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* premium-vw-notes-test.js — the Notes list and a note opened beside it (initiative premium-viewer, R9; planning/prd/premium-viewer-prd.md).
|
|
4
|
+
* Serves the real Briefing from the real server. The Briefing model, the calendar, the notes, the boards, the search and the note are answered by stand-ins,
|
|
5
|
+
* so each press can be read off the request the page sent. The routes' own behaviour is in their own suites; the pure half is in premium-vw-notes.test.js.
|
|
6
|
+
* N1 open · N2 groups · N3 series · N4 search · N5 the note tab · N6 Change what it is about · N7 writes · N8 floors
|
|
7
|
+
* Every wait polls the page; no fixed sleep stands in for a state. */
|
|
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-vw-notes' });
|
|
12
|
+
const B = require('./lib/briefing-premium.js');
|
|
13
|
+
const F = require('./fixtures/briefing-premium-facts.js');
|
|
14
|
+
|
|
15
|
+
const BASE = T.BASE;
|
|
16
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
17
|
+
const until = async (fn, ms = 10000, 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); } };
|
|
18
|
+
const results = [];
|
|
19
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
20
|
+
let srv = null; let browser = null;
|
|
21
|
+
const finish = async (code) => {
|
|
22
|
+
if (browser) await browser.close().catch(() => {});
|
|
23
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
24
|
+
T.killTmux();
|
|
25
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
26
|
+
console.log(`\n${results.length - bad}/${results.length} premium-vw-notes assertions passed`);
|
|
27
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
28
|
+
};
|
|
29
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
30
|
+
|
|
31
|
+
const NOW = new Date();
|
|
32
|
+
const ROWS = [
|
|
33
|
+
{ id: 'n1', title: 'Weekly sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', title: 'Weekly sync', start: '2026-10-19T10:00:00+07:00' }, board: { id: 'b1', ws: 'w1', title: 'Growth' }, initiative: { id: 'ux', ws: 'w1', title: 'Premium UX' }, series: { key: 'wk', by: 'calendar' }, meeting_ms: 32 * 60000, summary_lines: ['The copy test was agreed.'] },
|
|
34
|
+
{ id: 'n0', title: 'Weekly sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', title: 'Weekly sync', start: '2026-10-12T10:00:00+07:00' }, board: { id: 'b1', ws: 'w1', title: 'Growth' }, series: { key: 'wk', by: 'calendar' }, summary_lines: ['The runbook was asked for.'] },
|
|
35
|
+
{ id: 'n2', title: 'Exec sync', state: 'ended', updated_at: NOW.toISOString(), meeting: { kind: 'event', title: 'Exec sync', start: '2026-10-16T10:00:00+07:00' }, portfolio: true, meeting_ms: 28 * 60000 },
|
|
36
|
+
{ id: 'n3', title: 'Call with a partner', state: 'ended', updated_at: NOW.toISOString(), created_at: '2026-10-15T08:00:00Z', meeting: null, summary_lines: ['They want SSO before they move 40 seats.'] },
|
|
37
|
+
];
|
|
38
|
+
const NOTE = { id: 'n3', title: 'Call with a partner', state: 'ended', meeting: null, meeting_ms: 22 * 60000, final_notes: { overview: 'The partner wants SSO first.', decisions: [{ text: 'Price SSO in the team plan', why: 'Two partners asked.' }], actions: [{ text: 'Send the SSO plan', owner: 'Ana', due: '2026-10-24' }], questions: [] } };
|
|
39
|
+
|
|
40
|
+
(async () => {
|
|
41
|
+
const exe = findBrowser();
|
|
42
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
43
|
+
let chromium;
|
|
44
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
45
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
46
|
+
await T.waitForServer(BASE);
|
|
47
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
48
|
+
|
|
49
|
+
const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
|
|
50
|
+
const SESS = [];
|
|
51
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', notes = ROWS } = {}) => {
|
|
52
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
53
|
+
const page = await ctx.newPage();
|
|
54
|
+
const S = { errors: [], reqs: [], linkPosts: [], oneGets: [], searches: [], note: { ...NOTE } };
|
|
55
|
+
page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
|
|
56
|
+
page.on('request', (r) => { if (r.url().startsWith(BASE)) S.reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
|
|
57
|
+
await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }));
|
|
58
|
+
await page.route('**/api/calendar-views*', (r) => json(r, { ok: true, view: 'week', cells: [], events_source: 'calendar-memory', context: {}, link_boards: [], gantt: [] }));
|
|
59
|
+
await page.route('**/api/notes/search*', (r) => { const q = new URL(r.request().url()).searchParams.get('q'); S.searches.push(q); return json(r, { ok: true, ids: /runbook|said/.test(q) ? ['n0'] : [] }); });
|
|
60
|
+
await page.route('**/api/notes/one*', (r) => { const id = new URL(r.request().url()).searchParams.get('id'); S.oneGets.push(id);
|
|
61
|
+
const n = id === 'n3' ? S.note : { ...ROWS.find((x) => x.id === id), final_notes: { overview: 'Notes of ' + id, decisions: [], actions: [], questions: [] } };
|
|
62
|
+
return json(r, { ok: true, note: n, place: id === 'n3' ? null : { key: 'wk', title: 'Weekly sync', pos: id === 'n1' ? 2 : 1, count: 2, prev: id === 'n1' ? { id: 'n0', at: '2026-10-12T03:00:00Z' } : null, next: id === 'n0' ? { id: 'n1', at: '2026-10-19T03:00:00Z' } : null } }); });
|
|
63
|
+
await page.route('**/api/notes/link', (r) => { const b = JSON.parse(r.request().postData() || '{}'); S.linkPosts.push(b); if (b.initiative) S.note = { ...S.note, board: b.board, initiative: b.initiative }; return json(r, { ok: true }); });
|
|
64
|
+
await page.route(/\/api\/notes(\?.*)?$/, (r) => json(r, { ok: true, notes, series_open: { wk: { open: 2, carried: false } } }));
|
|
65
|
+
await page.route(/\/api\/boards(\?.*)?$/, (r) => json(r, { ok: true, boards: [{ id: 'b1', ws: 'w1', name: 'Growth' }] }));
|
|
66
|
+
await page.route('**/api/boards/backlog*', (r) => json(r, { ok: true, rows: [{ id: 'ux', title: 'Premium UX' }, { id: 'sso', title: 'SSO for teams' }] }));
|
|
67
|
+
await page.goto(BASE + '/premium.html?theme=' + theme);
|
|
68
|
+
S.up = await until(() => page.evaluate(() => !!document.querySelector('#vnOpen') && !!document.querySelector('#vnOpenFoot') && document.querySelectorAll('#rank .rr').length > 0), 20000);
|
|
69
|
+
if (S.up) { if (w <= 600 && await page.evaluate(() => document.querySelector('#todayCard').classList.contains('calhid'))) await page.click('#todayCard .foldb'); await page.click(w <= 600 ? '#vnOpenFoot' : '#vnOpen'); S.dlg = await until(() => page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && document.querySelectorAll('#vnBody .vn-g').length > 0)); }
|
|
70
|
+
SESS.push(S);
|
|
71
|
+
return Object.assign(S, { ctx, page });
|
|
72
|
+
};
|
|
73
|
+
const A = await open();
|
|
74
|
+
ok('N1 the Calendar card has a Notes button that opens the dialog with the list', A.up && A.dlg && await A.page.evaluate(() => document.querySelector('#dTitle').textContent === 'Notes'));
|
|
75
|
+
if (!A.up || !A.dlg) return finish(1);
|
|
76
|
+
const p = A.page;
|
|
77
|
+
|
|
78
|
+
/* N2 groups */
|
|
79
|
+
const g = await p.evaluate(() => ({ groups: [...document.querySelectorAll('#vnBody .vn-g h4')].map((x) => x.firstChild.textContent), count: document.querySelector('#vnCount').textContent }));
|
|
80
|
+
ok('N2 the notes are grouped: Portfolio, the board, then Not linked, with a count', g.groups.join('|') === 'Portfolio|Growth|Not linked' && g.count === '4 notes', JSON.stringify(g));
|
|
81
|
+
const r3 = await p.evaluate(() => document.querySelector('[data-vn-note="n3"]').textContent);
|
|
82
|
+
ok('N2 a note with no meeting is tagged no meeting; the Portfolio note shows its length', /no meeting/.test(r3) && /28 min/.test(await p.evaluate(() => document.querySelector('[data-vn-note="n2"]').textContent)), r3);
|
|
83
|
+
|
|
84
|
+
/* N3 series */
|
|
85
|
+
const ser = await p.evaluate(() => document.querySelector('[data-vn-series="wk"]').textContent);
|
|
86
|
+
ok('N3 the two notes of the series are one entry with 2 meetings, series and 2 open', /2 meetings/.test(ser) && /series/.test(ser) && /2 open/.test(ser), ser);
|
|
87
|
+
await p.click('[data-vn-fold="wk"]');
|
|
88
|
+
ok('N3 folding the series open lists its notes with their first summary line', await until(() => p.evaluate(() => !!document.querySelector('.vn-sub [data-vn-note="n0"]') && /The runbook was asked for\./.test(document.querySelector('#vnBody').textContent) && document.querySelector('[data-vn-fold="wk"]').getAttribute('aria-expanded') === 'true')));
|
|
89
|
+
|
|
90
|
+
/* N4 search */
|
|
91
|
+
await p.fill('#vnQ', 'sso');
|
|
92
|
+
ok('N4 typing filters the list at once and the count says N of M', await until(() => p.evaluate(() => document.querySelectorAll('#vnBody [data-vn-note]').length === 1 && !!document.querySelector('[data-vn-note="n3"]') && document.querySelector('#vnCount').textContent === '1 of 4 notes')));
|
|
93
|
+
await p.fill('#vnQ', 'what was said');
|
|
94
|
+
ok('N4 a note found by the server search in what was said is listed', await until(() => p.evaluate(() => !!document.querySelector('[data-vn-note="n0"]'))) && A.searches.includes('what was said'), JSON.stringify(A.searches));
|
|
95
|
+
await p.fill('#vnQ', 'zzz');
|
|
96
|
+
ok('N4 no match says so', await until(() => p.evaluate(() => /No note matches “zzz”/.test(document.querySelector('#vnBody').textContent))));
|
|
97
|
+
ok('N4 the search field keeps focus while typing', await p.evaluate(() => document.activeElement && document.activeElement.id === 'vnQ'));
|
|
98
|
+
await p.fill('#vnQ', '');
|
|
99
|
+
|
|
100
|
+
/* N5 the note tab */
|
|
101
|
+
await until(() => p.evaluate(() => !!document.querySelector('[data-vn-note="n3"]')));
|
|
102
|
+
await p.click('[data-vn-note="n3"]');
|
|
103
|
+
const tab = await until(() => p.evaluate(() => { const t = document.querySelector('#vTabs'), pane = document.querySelector('#dOut .obody.vw[data-vw="meet-note"]'); return t && !t.hidden && pane && !pane.hidden && /Price SSO in the team plan/.test(pane.textContent) ? { tabs: [...t.querySelectorAll('.vtab')].map((x) => x.textContent.trim()), ph: [...pane.querySelectorAll('.vm-ph [data-ph]')].map((b) => b.dataset.ph + ':' + b.getAttribute('aria-pressed')).join(), text: pane.textContent } : null; }));
|
|
104
|
+
ok('N5 a note opens as a viewer tab beside the list, on After', tab && tab.tabs.length === 2 && /Notes/.test(tab.tabs[0]) && /Call with a partner/.test(tab.tabs[1]) && tab.ph === 'before:false,during:false,after:true', JSON.stringify(tab && { tabs: tab.tabs, ph: tab.ph }));
|
|
105
|
+
ok('N5 the tab has the summary, the Decision and Why table and the next step table from the note', tab && /The partner wants SSO first\./.test(tab.text) && /Two partners asked\./.test(tab.text) && /Send the SSO plan/.test(tab.text) && /Ana/.test(tab.text) && /No meeting/.test(tab.text));
|
|
106
|
+
await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-ph="before"]');
|
|
107
|
+
ok('N5 Before says the note has no calendar event', await until(() => p.evaluate(() => { const b = document.querySelector('#dOut .obody.vw[data-vw="meet-note"] .vm-body[data-part="before"]'); return b && !b.hidden && /not linked to a calendar event/.test(b.textContent); })));
|
|
108
|
+
await p.click('#vTabs .vtab[data-vw="main"]');
|
|
109
|
+
await p.click('[data-vn-series="wk"]');
|
|
110
|
+
ok('N5 pressing a series opens its newest note, which says N of M', await until(() => p.evaluate(() => /Weekly sync · 2 of 2/.test((document.querySelector('#dOut .obody.vw[data-vw="meet-note"] .vm-ser') || {}).textContent || ''))) && A.oneGets.includes('n1'));
|
|
111
|
+
await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-vm="prev"]');
|
|
112
|
+
ok('N5 paging reads the meeting before into the same tab', await until(() => A.oneGets.includes('n0')) && await p.evaluate(() => document.querySelectorAll('#vTabs .vtab').length === 2));
|
|
113
|
+
|
|
114
|
+
/* N6 Change what it is about */
|
|
115
|
+
await p.click('#vTabs .vtab[data-vw="main"]');
|
|
116
|
+
await p.click('[data-vn-note="n3"]');
|
|
117
|
+
await until(() => p.evaluate(() => /Call with a partner/.test((document.querySelector('#dOut .obody.vw[data-vw="meet-note"] h3') || {}).textContent || '')));
|
|
118
|
+
await p.click('#dOut .obody.vw[data-vw="meet-note"] [data-vm="nabout"]');
|
|
119
|
+
const opts = await until(() => p.evaluate(() => { const s = document.querySelector('#dOut .vm-nabout select'); return s ? [...s.options].map((o) => o.textContent) : null; }));
|
|
120
|
+
ok('N6 Choose what it is about lists Portfolio, the board and its initiatives', opts && opts.join('|') === 'Choose what it is about|Portfolio|Board: Growth|Initiative: Premium UX|Initiative: SSO for teams', JSON.stringify(opts));
|
|
121
|
+
await p.selectOption('#dOut .vm-nabout select', 'i:w1/sso');
|
|
122
|
+
await p.click('#dOut [data-vm="nsave"]');
|
|
123
|
+
await until(() => A.linkPosts.length === 1);
|
|
124
|
+
ok('N6 Save posts the console\'s link body for the note', JSON.stringify(A.linkPosts[0]) === JSON.stringify({ id: 'n3', board: { id: 'b1', ws: 'w1', title: 'Growth' }, initiative: { id: 'sso', ws: 'w1', title: 'SSO for teams' } }), JSON.stringify(A.linkPosts));
|
|
125
|
+
ok('N6 the note is read again and its head names the initiative, with Change', await until(() => p.evaluate(() => { const pn = document.querySelector('#dOut .obody.vw[data-vw="meet-note"]'); return /Growth › SSO for teams/.test(pn.textContent) && /Change/.test(pn.querySelector('[data-vm="nabout"]').textContent) && !pn.querySelector('.vm-nabout'); })));
|
|
126
|
+
|
|
127
|
+
/* N7 writes */
|
|
128
|
+
const posts = [...new Set(A.reqs.filter((r) => /^POST /.test(r)))].sort();
|
|
129
|
+
ok('N7 the only write is the note\'s link', posts.join() === 'POST /api/notes/link', posts.join());
|
|
130
|
+
const res = await fetch(BASE + '/api/notes/link', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id: 'n-nothing', portfolio: true }) });
|
|
131
|
+
ok('N7 /api/notes/link without the launch nonce is refused', res.status === 403, String(res.status));
|
|
132
|
+
await A.ctx.close();
|
|
133
|
+
|
|
134
|
+
/* an empty store says so */
|
|
135
|
+
const Z = await open({ notes: [] });
|
|
136
|
+
ok('N2 with no notes the list says notes you record show here', Z.up && await until(() => Z.page.evaluate(() => document.querySelector('#dlg').classList.contains('on') && /No notes yet/.test((document.querySelector('#vnBody') || {}).textContent || ''))));
|
|
137
|
+
await Z.ctx.close();
|
|
138
|
+
|
|
139
|
+
/* N8 floors (PMOS_SHOTS=<dir> also saves pictures) */
|
|
140
|
+
const shotDir = process.env.PMOS_SHOTS || '';
|
|
141
|
+
for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
|
|
142
|
+
if (w === 1280 && !shotDir) continue;
|
|
143
|
+
const P = await open({ w, h, theme: th });
|
|
144
|
+
if (!P.dlg) { ok(`N8 ${w} ${th} opens`, false); await P.ctx.close(); continue; }
|
|
145
|
+
await P.page.click('[data-vn-fold="wk"]');
|
|
146
|
+
const fl = () => P.page.evaluate(() => { const pane = [...document.querySelectorAll('#oMain, #dOut .obody.vw')].find((x) => !x.hidden) || document.querySelector('#oMain');
|
|
147
|
+
return { scroll: document.documentElement.scrollWidth <= innerWidth + 1 && pane.scrollWidth <= pane.clientWidth + 1,
|
|
148
|
+
btn: [...pane.querySelectorAll('.vn-o, .vn-x, .vn-q, .vm-ph button, .vm-lk')].filter((b) => b.getClientRects().length).map((b) => Math.round(Math.min(b.getBoundingClientRect().width, b.getBoundingClientRect().height))) }; });
|
|
149
|
+
const f0 = await fl();
|
|
150
|
+
if (w === 390) ok(`N8 at 390 px (${th}) the Calendar card header keeps one line and Notes sits under the day`, await P.page.evaluate(() => { const h = document.querySelector('#todayCard .ch'), r = (e) => e.getBoundingClientRect(); const bs = [...h.querySelectorAll('button')].filter((b) => b.getClientRects().length); return !document.querySelector('#vnOpen').getClientRects().length && bs.every((b) => Math.abs(r(b).top - r(bs[0]).top) < 4) && r(document.querySelector('#vnOpenFoot')).height >= 44; }));
|
|
151
|
+
if (shotDir) await P.page.screenshot({ path: path.join(shotDir, `list-${w}-${th}.png`) });
|
|
152
|
+
await P.page.click('[data-vn-note="n3"]');
|
|
153
|
+
await until(() => P.page.evaluate(() => /Price SSO/.test((document.querySelector('#dOut .obody.vw[data-vw="meet-note"]') || {}).textContent || '')));
|
|
154
|
+
const f1 = await fl();
|
|
155
|
+
if (shotDir) await P.page.screenshot({ path: path.join(shotDir, `note-${w}-${th}.png`) });
|
|
156
|
+
if (w === 390) ok(`N8 at 390 px (${th}) the list and the note have no sideways scroll and every press is at least 44 px`, f0.scroll && f1.scroll && f0.btn.length > 3 && [...f0.btn, ...f1.btn].every((n) => n >= 44), JSON.stringify([f0, f1]));
|
|
157
|
+
await P.ctx.close();
|
|
158
|
+
}
|
|
159
|
+
ok('N7 no page error in any run', SESS.every((x) => x.errors.length === 0), JSON.stringify(SESS.map((x) => x.errors).filter((e) => e.length)));
|
|
160
|
+
return finish();
|
|
161
|
+
})().catch((e) => { console.error(e); finish(1); });
|