create-pmos 0.397.0 → 0.398.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +101 -52
- package/workspace/briefing-premium-board-test.js +252 -128
- package/workspace/briefing-premium-calendar-2-test.js +135 -198
- package/workspace/briefing-premium-calendar-3-test.js +143 -418
- package/workspace/briefing-premium-calendar-test.js +86 -196
- package/workspace/briefing-premium-doc-edit-test.js +95 -83
- package/workspace/briefing-premium-initiative-test.js +159 -296
- package/workspace/briefing-premium-insights-test.js +337 -219
- package/workspace/briefing-premium-metrics-test.js +53 -97
- package/workspace/briefing-premium-products-test.js +40 -27
- package/workspace/briefing-premium-sources-test.js +66 -48
- package/workspace/briefing-premium-test.js +150 -647
- package/workspace/briefing-premium-work-test.js +88 -283
- package/workspace/changelog.json +12 -0
- package/workspace/fixtures/board-premium-trail.js +32 -0
- package/workspace/fixtures/premium-viewer-fixtures.js +182 -0
- package/workspace/guide/briefing-premium.md +3 -1
- package/workspace/guide/home.md +47 -0
- package/workspace/guide/index.md +1 -0
- package/workspace/lib/agent-roles.js +71 -0
- package/workspace/lib/board-premium.js +85 -19
- package/workspace/lib/board-trail.js +223 -0
- package/workspace/lib/home-work-item.js +58 -0
- package/workspace/lib/insights-goals.js +196 -0
- package/workspace/lib/insights-premium.js +62 -14
- package/workspace/lib/insights-records.js +101 -0
- package/workspace/lib/jira-tickets.js +1 -1
- package/workspace/lib/route-modules.js +4 -0
- package/workspace/lib/routes-board-trail.js +33 -0
- package/workspace/lib/routes-home-desk.js +176 -0
- package/workspace/lib/routes-insights-premium.js +12 -3
- package/workspace/lib/routes-insights-records.js +129 -0
- package/workspace/lib/routes-notes.js +1 -0
- package/workspace/lib/routes-viewer.js +108 -0
- package/workspace/lib/transcript-steps.js +123 -0
- package/workspace/lib/viewer-meeting.js +205 -0
- package/workspace/lib/viewer-report.js +89 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +85 -75
- package/workspace/premium-briefing-depth-test.js +66 -53
- package/workspace/premium-chat-attach-test.js +54 -63
- package/workspace/premium-chat-chart-tab-test.js +35 -37
- package/workspace/premium-chat-context-test.js +19 -18
- package/workspace/premium-chat-goal-view-test.js +23 -23
- package/workspace/premium-chat-notes-test.js +26 -31
- package/workspace/premium-chat-report-tab-test.js +32 -28
- package/workspace/premium-chat-term-test.js +16 -16
- package/workspace/premium-chat-viewer-test.js +60 -59
- package/workspace/premium-core-doc-issue-test.js +50 -43
- package/workspace/premium-html-viewer-test.js +14 -17
- package/workspace/premium-phone-card-test.js +7 -2
- package/workspace/premium-phone-room-test.js +41 -35
- package/workspace/premium-report-read-test.js +115 -197
- package/workspace/premium-viewer-download-test.js +19 -22
- package/workspace/premium-viewer-flicker-test.js +11 -16
- package/workspace/premium-viewer-share-test.js +6 -9
- package/workspace/premium-viewer-test.js +41 -60
- package/workspace/premium-vw-backlog-test.js +53 -33
- package/workspace/premium-vw-cal-test.js +82 -128
- package/workspace/premium-vw-copy-test.js +17 -33
- package/workspace/premium-vw-doc-test.js +11 -10
- package/workspace/premium-vw-item-test.js +50 -49
- package/workspace/premium-vw-jira-test.js +53 -27
- package/workspace/premium-vw-meet-test.js +118 -187
- package/workspace/premium-vw-notes-test.js +85 -108
- package/workspace/premium-vw-rec-test.js +72 -194
- package/workspace/premium-vw-slides-test.js +46 -50
- package/workspace/premium-welcome-test.js +3 -2
- package/workspace/premium-work-depth-test.js +61 -53
- package/workspace/public/pm/bd-acts.js +305 -0
- package/workspace/public/pm/bd-span.js +186 -82
- package/workspace/public/pm/bd-stages.js +25 -11
- package/workspace/public/pm/c3-doc-sheet.js +1 -1
- package/workspace/public/pm/c3-md.js +3 -395
- package/workspace/public/pm/c3-phone-detail.js +1 -1
- package/workspace/public/pm/c3-phone-model.js +3 -68
- package/workspace/public/pm/chat-term.js +3 -3
- package/workspace/public/pm/cozy-board.css +497 -230
- package/workspace/public/pm/cozy-home.css +570 -142
- package/workspace/public/pm/cozy-home.js +5 -3
- package/workspace/public/pm/cozy-insights.css +296 -167
- package/workspace/public/pm/cozy-md.js +396 -0
- package/workspace/public/pm/cozy-nav.js +17 -6
- package/workspace/public/pm/cozy-placeholder.js +26 -0
- package/workspace/public/pm/cozy-viewer.css +3 -3
- package/workspace/public/pm/cozy-viewer.js +144 -0
- package/workspace/public/pm/cozy-vw.css +485 -0
- package/workspace/public/pm/cozy.css +83 -1
- package/workspace/public/pm/home-adddoc.js +48 -0
- package/workspace/public/pm/home-app.js +905 -0
- package/workspace/public/pm/home-around.js +515 -0
- package/workspace/public/pm/home-chat.js +459 -0
- package/workspace/public/pm/home-data.js +312 -0
- package/workspace/public/pm/home-draft.js +68 -0
- package/workspace/public/pm/home-more.js +249 -0
- package/workspace/public/pm/home-phone-card.js +109 -0
- package/workspace/public/pm/home-work.js +519 -0
- package/workspace/public/pm/phone-moment.js +69 -0
- package/workspace/public/pm/pm-work-view.js +1 -1
- package/workspace/public/pm/premium-attach.js +4 -0
- package/workspace/public/pm/premium-board.js +423 -394
- package/workspace/public/pm/premium-chart-tab.js +110 -62
- package/workspace/public/pm/premium-deck.js +3 -3
- package/workspace/public/pm/premium-first.js +25 -21
- package/workspace/public/pm/premium-insights.js +792 -568
- package/workspace/public/pm/premium-meeting.js +61 -549
- package/workspace/public/pm/premium-notes.js +1 -1
- package/workspace/public/pm/premium-report-frame.css +20 -0
- package/workspace/public/pm/premium-report-read.js +509 -480
- package/workspace/public/pm/premium-report-tab.js +87 -63
- package/workspace/public/pm/premium-shell.js +72 -119
- package/workspace/public/pm/premium-viewer.js +22 -1
- package/workspace/public/pm/premium-vw-cal.js +187 -48
- package/workspace/public/pm/premium-vw-doc.css +6 -0
- package/workspace/public/pm/premium-vw-doc.js +40 -2
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-vw-meet.js +6 -83
- package/workspace/public/pm/premium-vw-mtg.js +731 -0
- package/workspace/public/pm/premium-vw-notes.js +56 -69
- package/workspace/public/pm/premium-vw-open.js +35 -0
- package/workspace/public/pm/premium-vw-page.js +16 -0
- package/workspace/public/pm/premium-vw-rec.js +11 -218
- package/workspace/public/pm/premium-vw-slides.css +5 -0
- package/workspace/public/pm/premium-vw-slides.js +44 -8
- package/workspace/public/pm/term-view.js +22 -0
- package/workspace/public/premium-board.html +28 -70
- package/workspace/public/premium-initiative.html +8 -48
- package/workspace/public/premium-insights.html +22 -60
- package/workspace/public/premium-viewer.html +20 -0
- package/workspace/public/premium.html +16 -107
- package/workspace/server.js +18 -3
- package/workspace/test-files.json +1 -0
- package/workspace/test-lists/home-libs.json +9 -0
- package/workspace/test-lists/premium-report-read.json +1 -1
- package/workspace/test-lists/premium-vw-agreed.json +9 -0
- package/workspace/test-lists/premium-vw-notes.json +1 -1
- package/workspace/public/pm/premium-work.js +0 -729
- package/workspace/public/pm/premium.js +0 -1146
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
/* premium-briefing-depth-test.js —
|
|
4
|
-
*
|
|
3
|
+
/* premium-briefing-depth-test.js — Around you (initiative premium-briefing-depth; planning/prd/premium-briefing-depth-prd.md R1 to R9).
|
|
4
|
+
* Re-pointed by premium-agreed-design: the Briefing card and its dialogs are gone; Around you is Home's minimal card in the Viewer
|
|
5
|
+
* (home-around.js, "Waiting for design"), opened from the place menu's More. Each row opens its own view in the same card, with Back.
|
|
6
|
+
* A real server on a scratch repository (c3-scan-fixture.js: PMOS_DRIVER=off, so no agent
|
|
5
7
|
* ever runs), with a driver ledger, a scan ledger and a brief of today that this suite seeds with the writers the product uses. The real page
|
|
6
8
|
* presses the real routes. Only two presses are answered in the browser, because they start an agent: scan/now and sources/refresh. The
|
|
7
9
|
* Calendar's rows are answered in the browser too, because they need plan dates and a clock.
|
|
@@ -90,13 +92,21 @@ const GANTT = [
|
|
|
90
92
|
await p.route('**/api/scan/now', (r) => json(r, { ok: true, scan: 'scan-00000000ff' }));
|
|
91
93
|
await p.route('**/api/sources/refresh', (r) => json(r, { ok: true, started: 'session' }));
|
|
92
94
|
await p.route('**/api/sources/refresh-all', (r) => json(r, { ok: true, joined: false, started: ['calendar'], already: [], failed: [], all: { started_at: new Date().toISOString(), reads: ['calendar'], derived: ['brief'], phase: 'read', done: false, steps: [{ id: 'calendar', label: 'Calendar', step: 'read', state: 'running' }, { id: 'brief', label: 'Morning briefing', step: 'derived', state: 'waiting' }] } }));
|
|
95
|
+
/* Around you: the place menu's More, then Around you; the card reads its six sources */
|
|
96
|
+
const openCard = async () => {
|
|
97
|
+
await until(() => p.$('#czFab')); await p.click('#czFab'); await p.click('[data-cz-more]');
|
|
98
|
+
await p.click('#hmMenu [role="menuitem"]:has-text("Around you")');
|
|
99
|
+
await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) #aroundBody')));
|
|
100
|
+
await until(() => p.evaluate(() => document.querySelector('#aroundCap') && document.querySelector('#aroundCap').textContent !== 'Reading' && !/Reading…/.test(document.querySelector('#aroundBody').textContent)), 30000);
|
|
101
|
+
};
|
|
93
102
|
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
94
|
-
await until(() => p.evaluate(() =>
|
|
95
|
-
|
|
96
|
-
await
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
const
|
|
103
|
+
await until(() => p.evaluate(() => document.querySelectorAll('#hmList .hm-g').length > 0), 30000);
|
|
104
|
+
posts.length = 0; // Home's own writes on load (its chat marks a conversation seen) are not Around you's; R8 counts from the card's opening
|
|
105
|
+
await openCard();
|
|
106
|
+
const rows = () => p.evaluate(() => Object.fromEntries([...document.querySelectorAll('#czViewer #aroundBody [data-bd]')].map((b) => [b.dataset.bd, { t: b.querySelector('.wtit').textContent, s: (b.querySelector('.ws') || {}).textContent || '', m: (b.querySelector('.wm') || {}).textContent || '' }])));
|
|
107
|
+
const body = () => p.evaluate(() => (document.querySelector('#czViewer .cz-vw-body .bd-a') || {}).textContent || '');
|
|
108
|
+
const open = async (k) => { await p.click(`#czViewer #aroundBody [data-bd="${k}"]`); await until(() => p.evaluate((x) => !!document.querySelector(`#czViewer .bd-a[data-bd-view="${x}"] *`), k)); };
|
|
109
|
+
const close = async () => { await p.click('#czViewer [data-bda="back"]'); await until(() => p.evaluate(() => !!document.querySelector('#czViewer #aroundBody'))); };
|
|
100
110
|
const click = async (sel) => { await until(() => p.$(sel)); await p.click(sel); };
|
|
101
111
|
const shotDir = process.env.BRIEFING_DEPTH_SHOTS;
|
|
102
112
|
const shot = async (n) => { if (shotDir) { await sleep(700); fs.mkdirSync(shotDir, { recursive: true }); await p.screenshot({ path: path.join(shotDir, n + '.png') }); } };
|
|
@@ -111,7 +121,8 @@ const GANTT = [
|
|
|
111
121
|
ok('R6 the freshness row says it is not live', /not live/.test(R0.src.s) && !/up to date/i.test(R0.src.t + R0.src.s), JSON.stringify(R0.src));
|
|
112
122
|
const cap = await p.evaluate(() => document.querySelector('#aroundCap').textContent);
|
|
113
123
|
ok('R7 the caption counts the rows that wait', /^\d+ to look at$/.test(cap), cap);
|
|
114
|
-
ok('R8
|
|
124
|
+
ok('R8 opening Around you wrote nothing', posts.length === 0, JSON.stringify(posts));
|
|
125
|
+
ok('R9 Around you is marked Waiting for design', /Waiting for design/.test(await p.textContent('#czViewer')));
|
|
115
126
|
await shot('card-1280-light');
|
|
116
127
|
|
|
117
128
|
/* A: agent proposals */
|
|
@@ -119,27 +130,27 @@ const GANTT = [
|
|
|
119
130
|
const ptxt = await body();
|
|
120
131
|
ok('A1 the dialog shows what each proposal is, its target, its draft and its why', /Problem statement/.test(ptxt) && /Move to Plan/.test(ptxt) && /Next step/.test(ptxt) && /Initiative · Partner API onboarding/.test(ptxt) && /Work · Send the partner onboarding list to Lina/.test(ptxt) && /New partners wait 9 days/.test(ptxt) && /Why: first draft from the Jira threads/.test(ptxt), ptxt);
|
|
121
132
|
await shot('props-1280-light');
|
|
122
|
-
const pq = await p.evaluate(() => ({ title: document.querySelector('#
|
|
133
|
+
const pq = await p.evaluate(() => ({ title: document.querySelector('#czVwTitle').textContent, cards: document.querySelectorAll('#czViewer .cz-vw-body .pcard').length, prim: [...document.querySelectorAll('#czViewer .cz-vw-body .pc-bar .pc-p')].map((b) => b.textContent), quiet: [...document.querySelectorAll('#czViewer .cz-vw-body .pc-bar .pc-q')].map((b) => b.textContent), on: (document.querySelector('#czViewer .cz-vw-body .pcard.on') || {}).dataset?.id, notes: document.querySelector('#pcNotes').hidden, keepIn: !!document.querySelector('#czViewer .cz-vw-body .pcard [data-bda="pkeep"]') }));
|
|
123
134
|
ok('A1b one card per proposal, the title counts them, and the bottom bar holds Keep as the only primary with Send back and Drop quiet', pq.title === '3 wait for you' && pq.cards === 3 && pq.prim.join() === 'Keep' && pq.quiet.join() === 'Send back,Drop' && pq.on === P1 && !pq.keepIn, JSON.stringify(pq));
|
|
124
135
|
ok('A1c the undo and mode notes sit behind the ⓘ line', pq.notes === true && /Nothing changes a record until you keep it/.test(ptxt));
|
|
125
|
-
await click('#
|
|
136
|
+
await click('#czViewer .cz-vw-body [data-bda="pinfo"]');
|
|
126
137
|
ok('A1d the ⓘ line opens the notes', await until(() => p.evaluate(() => !document.querySelector('#pcNotes').hidden && /None of the three can be undone/.test(document.querySelector('#pcNotes').textContent) && /agent mode/.test(document.querySelector('#pcNotes').textContent))));
|
|
127
|
-
await click(`#
|
|
128
|
-
ok('A1e pressing a card chooses it for the bottom bar', await until(() => p.evaluate((id) => document.querySelector('#
|
|
129
|
-
await click(`#
|
|
138
|
+
await click(`#czViewer .cz-vw-body .pcard[data-id="${P3}"]`);
|
|
139
|
+
ok('A1e pressing a card chooses it for the bottom bar', await until(() => p.evaluate((id) => document.querySelector('#czViewer .cz-vw-body .pcard.on').dataset.id === id && document.querySelector('#czViewer .cz-vw-body .pc-bar [data-bda="pkeep"]').dataset.id === id, P3)));
|
|
140
|
+
await click(`#czViewer .cz-vw-body .pcard[data-id="${P1}"] [data-bda="psel"]`);
|
|
130
141
|
await click(`.pc-bar [data-bda="pkeep"][data-id="${P1}"]`);
|
|
131
142
|
await until(() => posts.some((x) => x.path === '/api/driver/keep'));
|
|
132
143
|
const keep = posts.find((x) => x.path === '/api/driver/keep');
|
|
133
144
|
ok('A2 Keep posts one keep for that proposal and the ledger holds it', keep && keep.body.proposal === P1 && keep.body.ws === ws, JSON.stringify(keep));
|
|
134
145
|
await until(() => p.evaluate((id) => /Kept\./.test((document.querySelector(`.bd-it[data-id="${id}"] .bd-done`) || {}).textContent || ''), P1));
|
|
135
146
|
ok('A3 the proposal stays, marked Kept, and says what was recorded', /Kept\. /.test(await p.evaluate((id) => document.querySelector(`.bd-it[data-id="${id}"]`).textContent, P1)));
|
|
136
|
-
await click(`#
|
|
147
|
+
await click(`#czViewer .cz-vw-body .pcard[data-id="${P2}"]`);
|
|
137
148
|
await click(`.pc-bar [data-bda="pnote"][data-id="${P2}"]`);
|
|
138
149
|
const backBtn = () => p.evaluate((id) => { const b = document.querySelector(`[data-bda="pback"][data-id="${id}"]`); return b ? b.disabled : null; }, P2);
|
|
139
150
|
ok('A4 Send back opens a note box and the press is off until there is a note', await backBtn() === true);
|
|
140
151
|
const before = posts.length;
|
|
141
152
|
await p.evaluate((id) => { const b = document.querySelector(`[data-bda="pback"][data-id="${id}"]`); b.disabled = false; b.click(); }, P2);
|
|
142
|
-
await until(() => p.evaluate(() => /Write one line for the agent/.test((document.querySelector('#
|
|
153
|
+
await until(() => p.evaluate(() => /Write one line for the agent/.test((document.querySelector('#czViewer .cz-vw-body .bd-a') || {}).textContent || '')));
|
|
143
154
|
ok('A5 Send back without a note is refused on the page and posts nothing', posts.length === before);
|
|
144
155
|
await p.fill(`[data-bdn="${P2}"]`, 'Wait until the evidence is in.');
|
|
145
156
|
ok('A6 typing a note turns the press on', await backBtn() === false);
|
|
@@ -147,7 +158,7 @@ const GANTT = [
|
|
|
147
158
|
await until(() => posts.some((x) => x.path === '/api/driver/return'));
|
|
148
159
|
const ret = posts.find((x) => x.path === '/api/driver/return');
|
|
149
160
|
ok('A7 Send back posts return with the note', ret && ret.body.proposal === P2 && ret.body.note === 'Wait until the evidence is in.', JSON.stringify(ret));
|
|
150
|
-
await click(`#
|
|
161
|
+
await click(`#czViewer .cz-vw-body .pcard[data-id="${P3}"]`);
|
|
151
162
|
await click(`.pc-bar [data-bda="pdrop"][data-id="${P3}"]`);
|
|
152
163
|
await until(() => posts.some((x) => x.path === '/api/driver/drop'));
|
|
153
164
|
ok('A8 Drop posts drop and says it counts as a correction', posts.some((x) => x.path === '/api/driver/drop' && x.body.proposal === P3) && await until(() => body().then((t) => /Dropped\. It counts as a correction/.test(t))), await body());
|
|
@@ -161,10 +172,10 @@ const GANTT = [
|
|
|
161
172
|
await open('men');
|
|
162
173
|
const mt = await body();
|
|
163
174
|
ok('M1 the dialog lists the three mentions with the person, quote, place and the reply words', /Dana Hartono/.test(mt) && /Priya Sen/.test(mt) && /Lia Ong/.test(mt) && /Which day can the engineers use the sandbox/.test(mt) && /Refunds are paid within 14 days/.test(mt) && /Needs your reply/.test(mt) && /For your information/.test(mt), mt);
|
|
164
|
-
const tabs = await p.evaluate(() => [...document.querySelectorAll('#
|
|
175
|
+
const tabs = await p.evaluate(() => [...document.querySelectorAll('#czViewer .cz-vw-body [data-bda="mtab"]')].map((b) => b.textContent));
|
|
165
176
|
ok('M2 the tabs count by source', tabs.join() === 'All 3,Slack 1,Jira 1,Confluence 1', tabs.join());
|
|
166
177
|
await click('[data-bda="mtab"][data-k="jira"]');
|
|
167
|
-
ok('M3 a tab shows only that source', await p.evaluate(() => document.querySelectorAll('#
|
|
178
|
+
ok('M3 a tab shows only that source', await p.evaluate(() => document.querySelectorAll('#czViewer .cz-vw-body .bd-it').length === 1 && /Priya Sen/.test(document.querySelector('#czViewer .cz-vw-body .bd-a').textContent)));
|
|
168
179
|
await click('[data-bda="mtab"][data-k="all"]');
|
|
169
180
|
const link = await p.evaluate((id) => { const a = document.querySelector(`.bd-it[data-id="${id}"] a[data-bdlink]`); return a ? [a.getAttribute('href'), a.target, a.rel, a.textContent] : null; }, M1);
|
|
170
181
|
ok('M4 Open in Slack is the mention\'s https link in a new tab', link && link[0] === 'https://acme.slack.com/archives/D01/p1' && link[1] === '_blank' && /noopener/.test(link[2]) && link[3] === 'Open in Slack', JSON.stringify(link));
|
|
@@ -192,8 +203,8 @@ const GANTT = [
|
|
|
192
203
|
ok('P2 the late one is first, with the Calendar\'s words', /Delayed \+6 d/.test(pt) && /Forecast \d{4}-\d\d-\d\d vs promised \d{4}-\d\d-\d\d/.test(pt) && pt.indexOf('Partner API onboarding') < pt.indexOf('Self-serve sandbox'), pt);
|
|
193
204
|
ok('P3 a Jira-only row says x of y done in Jira', /3 of 8 done in Jira; no promised date/.test(pt), pt);
|
|
194
205
|
ok('P4 the page says the status is the Calendar\'s and not a forecast of its own', /not a forecast of its own/.test(pt));
|
|
195
|
-
const hrefs = await p.evaluate(() => [...document.querySelectorAll('#
|
|
196
|
-
ok('P5 Open the initiative goes to the
|
|
206
|
+
const hrefs = await p.evaluate(() => [...document.querySelectorAll('#czViewer .cz-vw-body a.cta')].map((a) => a.getAttribute('href')));
|
|
207
|
+
ok('P5 Open the initiative goes to the initiative on Home', hrefs.length === 4 && hrefs.every((h) => /^\/premium\.html\?ini=/.test(h)), hrefs.join());
|
|
197
208
|
await shot('pulse-1280-light');
|
|
198
209
|
const n0 = posts.length; await close();
|
|
199
210
|
ok('P6 the pulse wrote nothing', posts.length === n0);
|
|
@@ -204,7 +215,7 @@ const GANTT = [
|
|
|
204
215
|
ok('S1 the dialog shows when the scan last ran, when it runs next, a report and its proposals', /Last scan/.test(st) && /Next/.test(st) && /report/i.test(st) && /Dismiss asks for a reason and counts as a correction/.test(st), st);
|
|
205
216
|
ok('S2 each proposal says what Approve does before the press', /Approve creates the initiative in the first stage of the .* workflow\.|Start the research starts a research scan|Approve writes an evidence line on/.test(st), st);
|
|
206
217
|
await shot('scan-1280-light');
|
|
207
|
-
const dis = await p.evaluate(() => { const b = document.querySelector('#
|
|
218
|
+
const dis = await p.evaluate(() => { const b = document.querySelector('#czViewer .cz-vw-body [data-bda="sdisopen"]'); return b ? b.dataset.id : null; });
|
|
208
219
|
await click(`[data-bda="sdisopen"][data-id="${dis}"]`);
|
|
209
220
|
ok('S3a Dismiss asks for a reason and is off until there is one', await p.evaluate((id) => document.querySelector(`[data-bda="sdis"][data-id="${id}"]`).disabled, dis));
|
|
210
221
|
await p.fill(`[data-bds="${dis}"]`, 'We already decided this.');
|
|
@@ -218,7 +229,7 @@ const GANTT = [
|
|
|
218
229
|
await click(`[data-bda="sundo"][data-id="${dis}"]`);
|
|
219
230
|
await until(() => posts.some((x) => x.path === '/api/scan/proposal' && x.body.action === 'undo'));
|
|
220
231
|
ok('S5 Undo posts undo and the proposal waits again', await until(() => p.evaluate((id) => !!document.querySelector(`.bd-it[data-id="${id}"] [data-bda="sdisopen"]`), dis)));
|
|
221
|
-
const app = await p.evaluate(() => { const b = [...document.querySelectorAll('#
|
|
232
|
+
const app = await p.evaluate(() => { const b = [...document.querySelectorAll('#czViewer .cz-vw-body [data-bda="sapp"]')].find((x) => x.textContent === 'Approve'); return b ? b.dataset.id : null; });
|
|
222
233
|
if (app) {
|
|
223
234
|
await click(`[data-bda="sapp"][data-id="${app}"]`);
|
|
224
235
|
await until(() => posts.some((x) => x.path === '/api/scan/proposal' && x.body.action === 'approve'));
|
|
@@ -226,10 +237,10 @@ const GANTT = [
|
|
|
226
237
|
await until(() => p.evaluate((id) => /Approved\./.test((document.querySelector(`.bd-it[data-id="${id}"]`) || {}).textContent || ''), app) || /did not go through|Dismissed|SERR/.test(''), 8000);
|
|
227
238
|
ok('S7 an approval says what it did, or the server\'s reason', /Approved\. |already|cannot|could not|not found|no such/i.test(await p.evaluate((id) => (document.querySelector(`.bd-it[data-id="${id}"]`) || {}).textContent || '', app)), await body());
|
|
228
239
|
} else ok('S6 the scan holds an Approve proposal', false, st);
|
|
229
|
-
const snowOff = await p.evaluate(() => { const b = document.querySelector('#
|
|
240
|
+
const snowOff = await p.evaluate(() => { const b = document.querySelector('#czViewer .cz-vw-body [data-bda="snow"]'); return b ? b.disabled : null; });
|
|
230
241
|
ok('S8 Scan now says before the press that it starts an agent that reads the web and the repository', /Scan now starts an agent that reads the public web/.test(await body()) && snowOff !== null);
|
|
231
242
|
if (snowOff === false) {
|
|
232
|
-
await click('#
|
|
243
|
+
await click('#czViewer .cz-vw-body [data-bda="snow"]');
|
|
233
244
|
await until(() => posts.some((x) => x.path === '/api/scan/now'));
|
|
234
245
|
ok('S9 Scan now posts one scan/now for the product', posts.filter((x) => x.path === '/api/scan/now').length === 1 && posts.find((x) => x.path === '/api/scan/now').body.ws === ws);
|
|
235
246
|
} else ok('S9 Scan now is off and says why', /switched off|cannot start|left/.test(await body()), await body());
|
|
@@ -238,20 +249,20 @@ const GANTT = [
|
|
|
238
249
|
/* F: data freshness */
|
|
239
250
|
await open('src');
|
|
240
251
|
const ft = await body();
|
|
241
|
-
const srcRows = await p.evaluate(() => document.querySelectorAll('#
|
|
252
|
+
const srcRows = await p.evaluate(() => document.querySelectorAll('#czViewer .cz-vw-body .bd-src').length);
|
|
242
253
|
ok('F1 the dialog lists the workspace\'s sources with their state and schedule', srcRows >= 3 && /Refresh/.test(ft) && /Sources are read on a schedule, not live/.test(ft) && !/up to date/i.test(ft), ft);
|
|
243
254
|
await shot('src-1280-light');
|
|
244
|
-
const one = await p.evaluate(() => { const b = document.querySelector('#
|
|
255
|
+
const one = await p.evaluate(() => { const b = document.querySelector('#czViewer .cz-vw-body [data-bda="sfone"]'); return b ? b.dataset.id : null; });
|
|
245
256
|
await click(`[data-bda="sfone"][data-id="${one}"]`);
|
|
246
257
|
await until(() => posts.some((x) => x.path === '/api/sources/refresh'));
|
|
247
258
|
const rf = posts.filter((x) => x.path === '/api/sources/refresh');
|
|
248
259
|
ok('F2 Refresh posts one sources/refresh for that source', rf.length === 1 && rf[0].body.source === one && rf[0].body.ws === ws, JSON.stringify(rf));
|
|
249
|
-
await until(() => p.evaluate(() => /agent session started|Rebuilding the facts/.test(document.querySelector('#
|
|
260
|
+
await until(() => p.evaluate(() => /agent session started|Rebuilding the facts/.test(document.querySelector('#czViewer .cz-vw-body .bd-a').textContent)));
|
|
250
261
|
ok('F3 it says what it started', true);
|
|
251
|
-
const all = await p.evaluate(() => { const b = document.querySelector('#
|
|
262
|
+
const all = await p.evaluate(() => { const b = document.querySelector('#czViewer .cz-vw-body [data-bda="sfall"]'); return b ? b.disabled : null; });
|
|
252
263
|
if (all === false) {
|
|
253
264
|
const n1 = posts.filter((x) => x.path === '/api/sources/refresh').length;
|
|
254
|
-
await click('#
|
|
265
|
+
await click('#czViewer .cz-vw-body [data-bda="sfall"]');
|
|
255
266
|
await until(() => posts.some((x) => x.path === '/api/sources/refresh-all'));
|
|
256
267
|
const made = posts.filter((x) => x.path === '/api/sources/refresh-all');
|
|
257
268
|
ok('F4 Refresh all posts one ordered run (the sources, then the Briefing), and no refresh of each source', made.length === 1 && made[0].body.ws === ws && posts.filter((x) => x.path === '/api/sources/refresh').length === n1, JSON.stringify(made));
|
|
@@ -262,11 +273,11 @@ const GANTT = [
|
|
|
262
273
|
ganttFail = true;
|
|
263
274
|
await p.evaluate(() => { document.dispatchEvent(new Event('visibilitychange')); });
|
|
264
275
|
await p.reload();
|
|
265
|
-
await
|
|
276
|
+
await openCard();
|
|
266
277
|
const RE = await rows();
|
|
267
278
|
ok('E1 a pulse that cannot be read says so, and does not read "nothing"', /^Portfolio pulse (could not be read|cannot be read|did not answer|failed)|could not be read/.test(RE.pulse.t) && !/nothing to compare/.test(RE.pulse.t), JSON.stringify(RE.pulse));
|
|
268
279
|
await open('pulse');
|
|
269
|
-
ok('E2 its dialog names the failure', /could not be read|Portfolio pulse/.test(await body()) && await p.evaluate(() => !!document.querySelector('#
|
|
280
|
+
ok('E2 its dialog names the failure', /could not be read|Portfolio pulse/.test(await body()) && await p.evaluate(() => !!document.querySelector('#czViewer .cz-vw-body .nodef.err')), await body());
|
|
270
281
|
await close();
|
|
271
282
|
ganttFail = false;
|
|
272
283
|
|
|
@@ -277,20 +288,20 @@ const GANTT = [
|
|
|
277
288
|
];
|
|
278
289
|
repReply = { ok: true, ws, setups: [], asks: [], findings: FIND, finder: { cadence: 'daily', sources: {}, last_run: null, next_run: null } };
|
|
279
290
|
await p.reload();
|
|
280
|
-
await
|
|
291
|
+
await openCard();
|
|
281
292
|
const RG = await rows();
|
|
282
293
|
ok('G1 two findings make the row say so, with the count', /^2 reports found in your work/.test(RG.rep.t) && RG.rep.m === '2', JSON.stringify(RG.rep));
|
|
283
294
|
await open('rep');
|
|
284
295
|
const gb = await body();
|
|
285
296
|
ok('G2 the dialog shows each finding with its why, its evidence and its confidence word', /Weekly status/.test(gb) && /every Friday for six weeks/.test(gb) && /Mail: Weekly status, 6 times/.test(gb) && /Calendar: Friday review/.test(gb) && /Likely/.test(gb) && /Not sure/.test(gb), gb);
|
|
286
|
-
ok('G3 the buttons say what they record before they are pressed', /PMOS drafts only\. Nothing is sent\./.test(gb) && /will not raise it again/.test(gb) && !/Change first/.test(await p.evaluate(() => [...document.querySelectorAll('#
|
|
297
|
+
ok('G3 the buttons say what they record before they are pressed', /PMOS drafts only\. Nothing is sent\./.test(gb) && /will not raise it again/.test(gb) && !/Change first/.test(await p.evaluate(() => [...document.querySelectorAll('#czViewer .cz-vw-body .bd-a button')].map((b) => b.textContent).join('|'))), gb);
|
|
287
298
|
const g0 = posts.length;
|
|
288
|
-
await click('#
|
|
299
|
+
await click('#czViewer .cz-vw-body [data-id="f-weekly"] [data-bda="rset"]');
|
|
289
300
|
await until(() => posts.some((x) => x.path === '/api/report-setups/setup'));
|
|
290
301
|
const ps = posts.slice(g0).find((x) => x.path === '/api/report-setups/setup');
|
|
291
302
|
ok('G4 Set up posts the finding and the product, nothing more', ps && JSON.stringify(Object.keys(ps.body).sort()) === JSON.stringify(['finding', 'ws']) && ps.body.finding === 'f-weekly', JSON.stringify(ps));
|
|
292
303
|
ok('G5 after Set up the dialog names the report that was set up and that nothing was sent', await until(async () => /Set up as Weekly status\..*Nothing was sent/.test(await body())), await body());
|
|
293
|
-
await click('#
|
|
304
|
+
await click('#czViewer .cz-vw-body [data-id="f-qbr"] [data-bda="rno"]');
|
|
294
305
|
await until(() => posts.some((x) => x.path === '/api/report-setups/dismiss'));
|
|
295
306
|
const pd = posts.find((x) => x.path === '/api/report-setups/dismiss');
|
|
296
307
|
ok('G6 Not a report posts the finding, its name and the product', pd && pd.body.finding === 'f-qbr' && pd.body.name === 'Quarterly review' && pd.body.ws === ws && Object.keys(pd.body).length === 3, JSON.stringify(pd));
|
|
@@ -298,24 +309,24 @@ const GANTT = [
|
|
|
298
309
|
repReply = { ok: true, ws, setups: [], asks: [], findings: [FIND[1]], finder: { cadence: 'daily', sources: {}, last_run: null, next_run: null } };
|
|
299
310
|
repFail = true;
|
|
300
311
|
await p.reload();
|
|
301
|
-
await
|
|
312
|
+
await openCard();
|
|
302
313
|
const R1f = await rows();
|
|
303
314
|
ok('G7 one finding is named in the row', /^Report found: Quarterly review/.test(R1f.rep.t), JSON.stringify(R1f.rep));
|
|
304
315
|
await open('rep');
|
|
305
|
-
await click('#
|
|
306
|
-
ok('G8 a refused press shows the reason and keeps the finding', await until(async () => /no longer open/.test(await body()) && await p.evaluate(() => !!document.querySelector('#
|
|
316
|
+
await click('#czViewer .cz-vw-body [data-bda="rset"]');
|
|
317
|
+
ok('G8 a refused press shows the reason and keeps the finding', await until(async () => /no longer open/.test(await body()) && await p.evaluate(() => !!document.querySelector('#czViewer .cz-vw-body .nodef.err') && !!document.querySelector('#czViewer .cz-vw-body [data-bda="rset"]'))), await body());
|
|
307
318
|
await close();
|
|
308
319
|
repFail = false;
|
|
309
320
|
repReply = { ok: true, ws, setups: [], asks: [], findings: [], finder: { cadence: 'off', sources: {}, last_run: null, next_run: null } };
|
|
310
321
|
await p.reload();
|
|
311
|
-
await
|
|
322
|
+
await openCard();
|
|
312
323
|
const R0f = await rows();
|
|
313
324
|
ok('G9 with none found and the finder off, the row says so and does not count as waiting', /finder is off/.test(R0f.rep.t) && R0f.rep.m === '', JSON.stringify(R0f.rep));
|
|
314
325
|
repReply = null;
|
|
315
326
|
|
|
316
327
|
/* W: the POST allow-list */
|
|
317
328
|
const allowed = new Set(['/api/mentions/read', '/api/pm-items/add', '/api/driver/keep', '/api/driver/return', '/api/driver/drop', '/api/scan/proposal', '/api/scan/now', '/api/scan/stop', '/api/sources/refresh', '/api/sources/refresh-all', '/api/report-setups/setup', '/api/report-setups/dismiss', '/api/briefing-premium/seen']); // seen: an opened popup's record (popup context slice 11, R1)
|
|
318
|
-
const strays = posts.filter((x) => !allowed.has(x.path));
|
|
329
|
+
const strays = posts.filter((x) => !allowed.has(x.path) && !/^\/api\/home-desk\//.test(x.path)); // /api/home-desk/*: Home's own chat (a conversation seen), not Around you
|
|
319
330
|
ok('W1 every POST is one of the existing routes in the PRD', posts.length > 0 && strays.length === 0, JSON.stringify(strays));
|
|
320
331
|
const fields = { '/api/driver/keep': ['ws', 'proposal'], '/api/driver/return': ['ws', 'proposal', 'note'], '/api/driver/drop': ['ws', 'proposal'], '/api/mentions/read': ['id', 'read'], '/api/pm-items/add': ['line'], '/api/scan/proposal': ['ws', 'id', 'action', 'why'], '/api/scan/now': ['ws'], '/api/sources/refresh': ['ws', 'source'], '/api/sources/refresh-all': ['ws'], '/api/report-setups/setup': ['ws', 'finding'], '/api/report-setups/dismiss': ['ws', 'finding', 'name'] };
|
|
321
332
|
const extra = posts.filter((x) => fields[x.path] && Object.keys(x.body || {}).some((k) => !fields[x.path].includes(k)));
|
|
@@ -330,18 +341,20 @@ const GANTT = [
|
|
|
330
341
|
const TODAY = [tm('a', -90, 'past', []), tm('b', 20, 'next', []), tm('c', 120, 'later', [{ id: 'x1', title: 'Send the deck', due: null }]), tm('d', 200, 'later', [])];
|
|
331
342
|
await p.route('**/api/brief-page*', async (r) => { const res = await r.fetch(); const b = await res.json(); json(r, { ...b, today: TODAY }); });
|
|
332
343
|
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
333
|
-
await
|
|
344
|
+
await openCard();
|
|
345
|
+
await until(() => p.evaluate(() => { const c = document.querySelector('#czViewer #prep'); return c && !c.hidden && /prepped/.test(c.textContent); }), 30000);
|
|
334
346
|
const prep = await p.evaluate(() => { const c = document.querySelector('#prep'); return { t: c.textContent, ring: !!c.querySelector('circle.rg'), l: c.querySelector('svg').getAttribute('aria-label') }; });
|
|
335
347
|
ok('PR1 the ring counts the meetings left and those with nothing to do before them', /Meeting b at \d\d:\d\d is next/.test(prep.t) && /3 meetings left today\. 2 of 3 prepped\./.test(prep.t) && prep.ring && prep.l === '2 of 3 prepped', JSON.stringify(prep));
|
|
336
|
-
|
|
337
|
-
await p.
|
|
338
|
-
await
|
|
339
|
-
|
|
348
|
+
// Home has no day strip (another day is the Calendar's, in the Viewer): the ring is not shown when no meeting is left today
|
|
349
|
+
await p.unroute('**/api/brief-page*');
|
|
350
|
+
await p.route('**/api/brief-page*', async (r) => { const res = await r.fetch(); const b = await res.json(); json(r, { ...b, today: TODAY.map((m) => ({ ...m, state: 'past' })) }); });
|
|
351
|
+
await p.reload(); await openCard();
|
|
352
|
+
ok('PR2 the ring is not shown when no meeting is left today', await p.evaluate(() => { const c = document.querySelector('#czViewer #prep'); return !!c && c.hidden; }));
|
|
340
353
|
await p.unroute('**/api/brief-page*');
|
|
341
354
|
|
|
342
355
|
/* L: floors */
|
|
343
356
|
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
344
|
-
await
|
|
357
|
+
await openCard();
|
|
345
358
|
await p.setViewportSize({ width: 390, height: 844 }); await sleep(300);
|
|
346
359
|
await shot('card-390-light');
|
|
347
360
|
const side = await p.evaluate(() => document.documentElement.scrollWidth - innerWidth);
|
|
@@ -349,9 +362,9 @@ const GANTT = [
|
|
|
349
362
|
const small = await p.evaluate(() => [...document.querySelectorAll('#aroundBody [data-bd]')].filter((b) => b.getBoundingClientRect().height < 44).map((b) => b.dataset.bd));
|
|
350
363
|
ok('L2 every row is 44 px tall at least', small.length === 0, small.join());
|
|
351
364
|
await open('men');
|
|
352
|
-
const wide = await p.evaluate(() => { const d = document.querySelector('#
|
|
365
|
+
const wide = await p.evaluate(() => { const d = document.querySelector('#czViewer .cz-vw-body'); return [document.documentElement.scrollWidth - innerWidth, d.scrollWidth - d.clientWidth]; });
|
|
353
366
|
await shot('men-390-light');
|
|
354
|
-
const sm2 = await p.evaluate(() => [...document.querySelectorAll('#
|
|
367
|
+
const sm2 = await p.evaluate(() => [...document.querySelectorAll('#czViewer .cz-vw-body .bd-a button, #czViewer .cz-vw-body .bd-a a.cta')].filter((b) => b.offsetParent && b.getBoundingClientRect().height < 44).map((b) => b.textContent));
|
|
355
368
|
ok('L3 a dialog at 390 wide does not scroll sideways and its buttons are 44 px tall', wide[0] <= 0 && wide[1] <= 1 && sm2.length === 0, wide.join() + ' ' + sm2.join());
|
|
356
369
|
await close();
|
|
357
370
|
await p.setViewportSize({ width: 1280, height: 900 });
|
|
@@ -359,7 +372,7 @@ const GANTT = [
|
|
|
359
372
|
await shot('card-1280-dark');
|
|
360
373
|
await open('prop').catch(() => {});
|
|
361
374
|
await close().catch(() => {});
|
|
362
|
-
const raw = await p.evaluate(() => { const c = getComputedStyle(document.querySelector('#
|
|
375
|
+
const raw = await p.evaluate(() => { const c = getComputedStyle(document.querySelector('#czViewer')); return [c.backgroundColor, getComputedStyle(document.body).backgroundColor]; });
|
|
363
376
|
ok('L4 in the dark theme the card has a background of its own', raw[0] !== 'rgba(0, 0, 0, 0)' && raw[0] !== raw[1] || raw[0] !== '', raw.join());
|
|
364
377
|
const focus = await p.evaluate(() => { const b = document.querySelector('#aroundBody [data-bd]'); b.focus(); const c = getComputedStyle(b); return [c.outlineStyle, c.outlineWidth, c.boxShadow]; });
|
|
365
378
|
ok('L5 a row shows a focus ring', focus[0] !== 'none' || focus[2] !== 'none', focus.join());
|
|
@@ -370,10 +383,10 @@ const GANTT = [
|
|
|
370
383
|
for (const [w, h, dark] of [[1280, 900, true], [390, 844, false], [390, 844, true]]) {
|
|
371
384
|
await p.emulateMedia({ colorScheme: dark ? 'dark' : 'light' }); await p.setViewportSize({ width: w, height: h });
|
|
372
385
|
await p.goto(`${F.BASE}/premium.html?ws=${encodeURIComponent(ws)}`);
|
|
373
|
-
await
|
|
374
|
-
await open('prop'); await until(() => p.$('#
|
|
386
|
+
await openCard();
|
|
387
|
+
await open('prop'); await until(() => p.$('#czViewer .cz-vw-body .pc-bar')); await sleep(800);
|
|
375
388
|
if (w === 390) {
|
|
376
|
-
const k = await p.evaluate(() => { const d = document.querySelector('#
|
|
389
|
+
const k = await p.evaluate(() => { const d = document.querySelector('#czViewer .cz-vw-body'), bar = document.querySelector('#czViewer .cz-vw-body .pc-bar').getBoundingClientRect(); return { side: [document.documentElement.scrollWidth - innerWidth, d.scrollWidth - d.clientWidth], bar: [Math.round(bar.left), Math.round(bar.right), Math.round(bar.bottom)], small: [...document.querySelectorAll('#czViewer .cz-vw-body .pc-bar button')].filter((b) => b.getBoundingClientRect().height < 44).length }; });
|
|
377
390
|
ok(`K1 ${dark ? 'dark' : 'light'} at 390 the proposals dialog does not scroll sideways, its bar fits and its buttons are 44 px tall`, k.side[0] <= 0 && k.side[1] <= 1 && k.bar[0] >= 0 && k.bar[1] <= 390 && k.bar[2] <= 844 && k.small === 0, JSON.stringify(k));
|
|
378
391
|
}
|
|
379
392
|
await shot(`props-${w}-${dark ? 'dark' : 'light'}`);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
-
/* premium-chat-attach-test.js — files and photos on a premium chat message (initiative premium-chat-attach
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
/* premium-chat-attach-test.js — files and photos on a premium chat message (initiative premium-chat-attach; re-pointed by premium-agreed-design
|
|
4
|
+
* to Home's chat: /premium-chat.html opens Home with the chat ?about names, and the composer's + picks files directly — the old + menu is gone;
|
|
5
|
+
* / is typed in the box and Notes lives in More). Serves the real Home from the real server; files save through the real /api/chat-file in a
|
|
6
|
+
* scratch state folder.
|
|
7
|
+
* B1 the + in the composer · B2 a typed / shows the commands · B3 pick two files, chips, saved · B4 remove one · B5 paste and drop
|
|
8
|
+
* B6 send names the files · B7 the PM's bubble shows the files and a chip opens the photo in the Viewer · B8 no key, no + · B9 phone */
|
|
7
9
|
const fs = require('fs');
|
|
8
10
|
const path = require('path');
|
|
9
11
|
const { spawn } = require('child_process');
|
|
10
12
|
const { findBrowser } = require('./lib/find-browser');
|
|
11
13
|
const T = require('./test-run').configure({ name: 'premium-chat-attach' });
|
|
12
|
-
const WP = require('./lib/my-work-premium.js');
|
|
13
|
-
const F = require('./fixtures/my-work-premium-facts.js');
|
|
14
14
|
|
|
15
15
|
const BASE = T.BASE;
|
|
16
16
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
@@ -42,73 +42,66 @@ const filesIn = () => { const d = path.join(T.STATE_DIR, 'chat-files'); const ou
|
|
|
42
42
|
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
43
43
|
await T.waitForServer(BASE);
|
|
44
44
|
browser = await chromium.launch({ executablePath: exe });
|
|
45
|
-
const model = WP.build({ v: F.view(), now: F.NOW });
|
|
46
45
|
|
|
47
|
-
const open = async ({ w = 1280, h = 900, scheme = 'light' } = {}) => {
|
|
48
|
-
const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: scheme });
|
|
46
|
+
const open = async ({ w = 1280, h = 900, scheme = 'light', url = '/premium-chat.html?about=' + encodeURIComponent(KEY) } = {}) => {
|
|
47
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: scheme, hasTouch: w < 1000 });
|
|
49
48
|
const page = await ctx.newPage();
|
|
50
|
-
const errors = [], asks = [];
|
|
49
|
+
const errors = [], asks = [], st = { session: null, messages: [] };
|
|
51
50
|
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
52
|
-
|
|
53
|
-
await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false }) }); });
|
|
54
|
-
await page.
|
|
55
|
-
await page.
|
|
56
|
-
|
|
51
|
+
if (process.env.ATT_DEBUG) page.on('request', (rq) => { if (/chat-file/.test(rq.url())) console.log('REQ', rq.method(), rq.url()); });
|
|
52
|
+
await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() !== 'GET') asks.push({ path: new URL(rq.url()).pathname, body: JSON.parse(rq.postData() || '{}') }); r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, turns: [], working: false, ...(st.session ? { session: st.session } : {}) }) }); });
|
|
53
|
+
await page.route('**/api/sessions/conversation**', (r) => r.fulfill({ json: { ok: true, state: 'conv', turn: 'user', messages: st.messages } }));
|
|
54
|
+
await page.route('**/api/sessions', (r) => r.fulfill({ json: { ok: true, sessions: [{ id: 's-term', name: 'A terminal session', origin: '', shown: 'quiet' }] } }));
|
|
55
|
+
await page.goto(BASE + url, { waitUntil: 'domcontentloaded' });
|
|
56
|
+
await page.waitForFunction(() => !!document.querySelector('#hmIn'), null, { timeout: 15000 });
|
|
57
|
+
return { page, ctx, errors, asks, st };
|
|
57
58
|
};
|
|
58
|
-
const
|
|
59
|
-
const close = (page) => page.evaluate(async () => { const m = await import('/pm/premium-shell.js'); m.closeDlg(); });
|
|
60
|
-
const chips = (page) => page.$$eval('#attRow .atc', (xs) => xs.map((x) => ({ name: x.querySelector('b').textContent, meta: (x.querySelector('em') || {}).textContent || '' })));
|
|
59
|
+
const chips = (page) => page.$$eval('#hmFiles .hm-att', (xs) => xs.map((x) => ({ name: x.querySelector('b').textContent, meta: (x.querySelector('em') || {}).textContent || '' })));
|
|
61
60
|
|
|
62
|
-
let { page, ctx, errors, asks } = await open();
|
|
63
|
-
await dlg(page, KEY);
|
|
61
|
+
let { page, ctx, errors, asks, st } = await open();
|
|
64
62
|
/* B1 */
|
|
65
|
-
|
|
66
|
-
ok('B1 the
|
|
67
|
-
|
|
68
|
-
ok('B1
|
|
69
|
-
ok('B1 the menu names Add files or photos, Slash commands and Notes', /Add files or photos[\s\S]*Slash commands[\s\S]*Notes/.test(await page.textContent('#plusM')));
|
|
70
|
-
await shot(page, 'menu-1280-light');
|
|
71
|
-
await page.keyboard.press('Escape');
|
|
72
|
-
ok('B1 Escape closes the menu and leaves the dialog open', await page.isHidden('#plusM') && await page.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
|
|
63
|
+
// the + opens the box's menu (Agreed design: "+ / @ chip"); its first item is Attach a file, which picks through #hmFile
|
|
64
|
+
ok('B1 the + is in the composer of a chat with a key, and its menu attaches a file', await page.isVisible('#hmAdd') && await page.evaluate(() => !!document.querySelector('#hmFoot .hm-addw input[type=file]#hmFile'))
|
|
65
|
+
&& await (async () => { await page.click('#hmAdd'); const v = await page.isVisible('#hmFoot [data-hm-file]'); await page.keyboard.press('Escape'); return v; })());
|
|
66
|
+
ok('B1 no chip row shows before a file is picked', (await page.$('#hmFiles')) === null);
|
|
73
67
|
/* B2 */
|
|
74
|
-
await page.
|
|
75
|
-
ok('B2
|
|
76
|
-
await page.
|
|
77
|
-
await page.
|
|
78
|
-
ok('B2 Notes opens the notepad in the viewer', !!(await until(async () => page.isVisible('#ntEd'))));
|
|
68
|
+
await page.fill('#hmIn', '/');
|
|
69
|
+
ok('B2 a typed / shows the commands', !!(await until(async () => page.isVisible('#hmSlash'))));
|
|
70
|
+
await page.keyboard.press('Escape');
|
|
71
|
+
await page.fill('#hmIn', '');
|
|
79
72
|
/* B3 */
|
|
80
|
-
await page.setInputFiles('#
|
|
73
|
+
await page.setInputFiles('#hmFile', [{ name: 'Screenshot 1.41.39 PM.png', mimeType: 'image/png', buffer: PNG }, { name: 'Q4 roadmap.pdf', mimeType: 'application/pdf', buffer: Buffer.from('%PDF-1.4 test') }]);
|
|
81
74
|
ok('B3 two picked files show as two chips with their sizes once saved', !!(await until(async () => { const c = await chips(page); return c.length === 2 && c.every((x) => /KB/.test(x.meta)); })), JSON.stringify(await chips(page)));
|
|
82
|
-
ok('B3 a photo chip shows the picture', await page.evaluate(() => { const i = document.querySelector('#
|
|
75
|
+
ok('B3 a photo chip shows the picture', await page.evaluate(() => { const i = document.querySelector('#hmFiles img.hm-ath'); return !!i && i.complete && i.naturalWidth === 2; }));
|
|
83
76
|
ok('B3 both files are saved in the state folder, never under the key', filesIn().length === 2 && filesIn().some((f) => /-Screenshot-1.41.39-PM\.png$/.test(f)));
|
|
84
77
|
await shot(page, 'chips-1280-light');
|
|
85
78
|
/* B4 */
|
|
86
|
-
await page.click('#
|
|
79
|
+
await page.click('#hmFiles .hm-att:nth-child(2) [data-hm-unfile]');
|
|
87
80
|
ok('B4 × removes the chip and deletes the file not sent', (await chips(page)).length === 1 && !!(await until(async () => filesIn().length === 1)));
|
|
88
81
|
/* B5 */
|
|
89
|
-
await page.evaluate(() => { const dt = new DataTransfer(); dt.items.add(new File(['note text'], 'notes.txt', { type: 'text/plain' })); const e = new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true }); document.querySelector('#
|
|
82
|
+
await page.evaluate(() => { const dt = new DataTransfer(); dt.items.add(new File(['note text'], 'notes.txt', { type: 'text/plain' })); const e = new ClipboardEvent('paste', { clipboardData: dt, bubbles: true, cancelable: true }); document.querySelector('#hmIn').dispatchEvent(e); });
|
|
90
83
|
ok('B5 a pasted file is attached', !!(await until(async () => { const c = await chips(page); return c.length === 2 && c[1].name === 'notes.txt' && /KB/.test(c[1].meta); })));
|
|
91
|
-
ok('B5 the paste put no text in the box', (await page.inputValue('#
|
|
92
|
-
await page.evaluate(() => { const dt = new DataTransfer(); dt.items.add(new File(['x'], 'dropped.csv', { type: 'text/csv' })); const b = document.querySelector('#
|
|
84
|
+
ok('B5 the paste put no text in the box', (await page.inputValue('#hmIn')) === '');
|
|
85
|
+
await page.evaluate(() => { const dt = new DataTransfer(); dt.items.add(new File(['x'], 'dropped.csv', { type: 'text/csv' })); const b = document.querySelector('#hmLog'); b.dispatchEvent(new DragEvent('dragover', { dataTransfer: dt, bubbles: true, cancelable: true })); b.dispatchEvent(new DragEvent('drop', { dataTransfer: dt, bubbles: true, cancelable: true })); });
|
|
93
86
|
ok('B5 a file dropped on the conversation is attached', !!(await until(async () => (await chips(page)).length === 3)));
|
|
94
|
-
ok('B5 the drop outline goes away after the drop', !(await page.evaluate(() => document.querySelector('#
|
|
87
|
+
ok('B5 the drop outline goes away after the drop', !(await page.evaluate(() => document.querySelector('#hmChat').classList.contains('hm-drop'))));
|
|
95
88
|
/* B6 */
|
|
96
|
-
await page.fill('#
|
|
97
|
-
await page.
|
|
98
|
-
const ask = await until(async () => asks.find((a) => a.path.endsWith('/ask')));
|
|
89
|
+
await page.fill('#hmIn', 'Where is this on PMOS?');
|
|
90
|
+
await page.keyboard.press('Enter');
|
|
91
|
+
const ask = await until(async () => asks.find((a) => a.path.endsWith('/ask')), 12000);
|
|
99
92
|
ok('B6 send passes the words and the three saved names', !!ask && ask.body.text === 'Where is this on PMOS?' && Array.isArray(ask.body.files) && ask.body.files.length === 3 && ask.body.files.every((n) => filesIn().includes(n)), JSON.stringify(ask && ask.body));
|
|
100
|
-
ok('B6 after the send the chips go', !!(await until(async () => await page
|
|
93
|
+
ok('B6 after the send the chips go', !!(await until(async () => (await page.$('#hmFiles')) === null)));
|
|
101
94
|
// the real ask route turns the names into the closing line (no session here: the route answers, the line is checked through the store)
|
|
102
95
|
const lib = require('./lib/chat-files.js');
|
|
103
|
-
const paths = lib.pathsOf({ runtimeDir: T.STATE_DIR, key: KEY, names: ask.body.files });
|
|
104
|
-
ok('B6 the names resolve to the files of this conversation', paths.ok && paths.paths.length === 3);
|
|
96
|
+
const paths = lib.pathsOf({ runtimeDir: T.STATE_DIR, key: KEY, names: ask ? ask.body.files : [] });
|
|
97
|
+
ok('B6 the names resolve to the files of this conversation', paths.ok && paths.paths.length === 3, JSON.stringify(paths));
|
|
105
98
|
/* B7 */
|
|
106
|
-
|
|
107
|
-
await page.evaluate(
|
|
108
|
-
ok('B7 the PM\'s bubble shows the files as chips and the words, not the line',
|
|
99
|
+
st.messages = [{ role: 'user', text: lib.withFiles('Where is this on PMOS?', paths.paths), at: '2026-10-21T08:00:00Z' }]; st.session = 's-att';
|
|
100
|
+
const bub = await until(async () => page.evaluate(() => { const u = [...document.querySelectorAll('#hmLog .hm-u')].pop(); return u && u.querySelectorAll('.atc[data-att]').length === 3 ? u.textContent : null; }), 12000);
|
|
101
|
+
ok('B7 the PM\'s bubble shows the files as chips and the words, not the line', !!bub && /Where is this on PMOS\?/.test(bub) && !/Attached files/.test(bub), String(bub));
|
|
109
102
|
await shot(page, 'bubble-1280-light');
|
|
110
|
-
await page.click('#
|
|
111
|
-
ok('B7 a photo chip opens the picture in the
|
|
103
|
+
await page.click('#hmLog .hm-u .atc[data-att$=".png"]');
|
|
104
|
+
ok('B7 a photo chip opens the picture in the Viewer', !!(await until(async () => page.evaluate(() => { const i = document.querySelector('#czViewer:not([hidden]) img.atview'); return !!i && i.complete && i.naturalWidth === 2; }))));
|
|
112
105
|
await shot(page, 'viewer-1280-light');
|
|
113
106
|
const png = paths.paths.find((p) => p.endsWith('.png')), txt = paths.paths.find((p) => p.endsWith('.txt'));
|
|
114
107
|
const r1 = await fetch(BASE + '/api/chat-file?path=' + encodeURIComponent(png));
|
|
@@ -119,26 +112,24 @@ const filesIn = () => { const d = path.join(T.STATE_DIR, 'chat-files'); const ou
|
|
|
119
112
|
ok('B7 a path outside the attachments is refused', r3.status === 404);
|
|
120
113
|
const r4 = await fetch(BASE + '/api/chat-file?key=' + encodeURIComponent(KEY) + '&name=x.png', { method: 'POST', body: PNG });
|
|
121
114
|
ok('B7 a save that does not come from the page is refused', r4.status === 403);
|
|
122
|
-
|
|
115
|
+
ok('B1-B7 no page errors', errors.length === 0, errors.join(' | '));
|
|
116
|
+
await ctx.close();
|
|
123
117
|
/* B8 */
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
await
|
|
127
|
-
ok('
|
|
118
|
+
({ page, ctx, errors } = await open({ url: '/premium.html?session=s-term' }));
|
|
119
|
+
await until(async () => page.evaluate(() => /A terminal session/.test((document.querySelector('#hmChat') || {}).textContent || '')), 6000);
|
|
120
|
+
ok('B8 a terminal session with no conversation key cannot attach: no Attach a file and no file picker', (await page.$('#hmFoot [data-hm-file]')) === null && (await page.$('#hmFile')) === null);
|
|
121
|
+
ok('B8 no page errors', errors.length === 0, errors.join(' | '));
|
|
128
122
|
await ctx.close();
|
|
129
123
|
|
|
130
124
|
/* B9 phone, both themes */
|
|
131
125
|
for (const scheme of ['light', 'dark']) {
|
|
132
126
|
({ page, ctx, errors } = await open({ w: 390, h: 844, scheme }));
|
|
133
|
-
await
|
|
134
|
-
const h0 = await page.evaluate(() => document.querySelector('#askF').getBoundingClientRect().height);
|
|
135
|
-
await page.setInputFiles('#askFile', [{ name: 'IMG_2041.png', mimeType: 'image/png', buffer: PNG }, { name: 'a-rather-long-file-name-for-a-phone.pdf', mimeType: 'application/pdf', buffer: Buffer.from('%PDF') }, { name: 'third.png', mimeType: 'image/png', buffer: PNG }]);
|
|
127
|
+
await page.setInputFiles('#hmFile', [{ name: 'IMG_2041.png', mimeType: 'image/png', buffer: PNG }, { name: 'a-rather-long-file-name-for-a-phone.pdf', mimeType: 'application/pdf', buffer: Buffer.from('%PDF') }, { name: 'third.png', mimeType: 'image/png', buffer: PNG }]);
|
|
136
128
|
await until(async () => (await chips(page)).length === 3 && (await chips(page)).every((x) => /KB/.test(x.meta)));
|
|
137
129
|
await shot(page, 'chips-390-' + scheme);
|
|
138
|
-
ok(`B9 ${scheme}: on a phone the +, the box and the chips stay inside the width`, await page.evaluate(() => { const w = innerWidth; return ['#
|
|
139
|
-
ok(`B9 ${scheme}: the chips sit in one row
|
|
140
|
-
ok(`B9 ${scheme}: the + and × are 44px targets`, await page.evaluate(() => document.querySelector('#
|
|
141
|
-
await page.click('#askPlus'); await shot(page, 'menu-390-' + scheme);
|
|
130
|
+
ok(`B9 ${scheme}: on a phone the +, the box and the chips stay inside the width`, await page.evaluate(() => { const w = innerWidth; return ['#hmAdd', '#hmIn', '#hmFiles'].every((s) => { const r = document.querySelector(s).getBoundingClientRect(); return r.width > 0 && r.left >= 0 && r.right <= w + 1; }) && document.documentElement.scrollWidth <= w; }));
|
|
131
|
+
ok(`B9 ${scheme}: the chips sit in one row`, await page.evaluate(() => new Set([...document.querySelectorAll('#hmFiles .hm-att')].map((x) => Math.round(x.getBoundingClientRect().top))).size === 1));
|
|
132
|
+
ok(`B9 ${scheme}: the + and × are 44px targets`, await page.evaluate(() => document.querySelector('#hmAdd').getBoundingClientRect().height >= 44 && document.querySelector('[data-hm-unfile]').getBoundingClientRect().height >= 44));
|
|
142
133
|
ok(`B9 ${scheme}: no page errors`, errors.length === 0, errors.join(' | '));
|
|
143
134
|
await ctx.close();
|
|
144
135
|
}
|