create-pmos 0.474.0 → 0.475.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +5 -3
  2. package/bin/create-pmos.js +23 -1
  3. package/install.ps1 +2 -1
  4. package/install.sh +6 -1
  5. package/package.json +14 -14
  6. package/payload/KIT-VERSION +1 -1
  7. package/payload/planning/evals/eval-calibration.md +1 -1
  8. package/payload/planning/okrs/health-budgets.md +1 -1
  9. package/payload/state/discoveries.md +1 -1
  10. package/workspace/README.md +1 -1
  11. package/workspace/bin/pmos.js +1 -1
  12. package/workspace/changelog.json +13 -0
  13. package/workspace/fixtures/fake-claude-onboard.js +48 -0
  14. package/workspace/guide/briefing-premium.md +2 -7
  15. package/workspace/guide/index.md +2 -2
  16. package/workspace/guide/launcher.md +14 -32
  17. package/workspace/guide/layout.md +1 -1
  18. package/workspace/guide/settings.md +3 -3
  19. package/workspace/guide/welcome.md +64 -21
  20. package/workspace/lib/claude-readiness.js +143 -0
  21. package/workspace/lib/engine/calendar-import.js +5 -0
  22. package/workspace/lib/freshness.js +5 -3
  23. package/workspace/lib/launcher-cli.js +83 -8
  24. package/workspace/lib/onboarding-progress.js +36 -0
  25. package/workspace/lib/project-onboard.js +363 -0
  26. package/workspace/lib/route-modules.js +2 -0
  27. package/workspace/lib/routes-onboard.js +188 -0
  28. package/workspace/lib/routes-onboarding.js +5 -4
  29. package/workspace/lib/routes-setup.js +88 -0
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/project-onboard-flow-test.js +135 -0
  33. package/workspace/public/pm/cozy-claude-setup.js +90 -0
  34. package/workspace/public/pm/cozy-onboard.css +60 -0
  35. package/workspace/public/pm/cozy-onboard.js +226 -0
  36. package/workspace/public/pm/cozy-settings.js +8 -2
  37. package/workspace/public/pm/home-app.js +10 -0
  38. package/workspace/public/pm/premium-first.js +1 -1
  39. package/workspace/public/pm/premium-welcome-model.js +1 -1
  40. package/workspace/public/pm/premium-welcome.js +107 -62
  41. package/workspace/public/pm/premium.css +16 -0
  42. package/workspace/public/pm/setup-checklist.js +22 -0
  43. package/workspace/public/premium.html +1 -0
  44. package/workspace/server.js +28 -6
  45. package/workspace/skills/calendar-sync.skill +1 -1
  46. package/workspace/test-files.json +6 -3
  47. package/workspace/test-lists/briefing-premium.json +1 -3
  48. package/workspace/test-lists/claude-onboarding-build.json +9 -0
  49. package/workspace/premium-welcome-test.js +0 -219
@@ -1,219 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- /* premium-welcome-test.js — the premium Welcome page and the first-Briefing card (initiative premium-welcome; planning/prd/premium-welcome-prd.md R1 to R11).
4
- * Serves the real pages from the real server. The onboarding routes, the proactive settings and the source routes are answered by stand-ins, so each press can be
5
- * read off the request the page sent. The routes' own behaviour is in their own suites (pm-welcome-test.js, the onboarding suites).
6
- * R1 own address · R2 About you · R3 sources · R4 found · R5 defaults · R6 import · R7 first card · R8 not now · R9 already imported · R10 writes · R11 floors and fidelity
7
- * Every wait polls the page; no fixed sleep stands in for a state. */
8
- const fs = require('fs');
9
- const os = require('os');
10
- const path = require('path');
11
- const { spawn, spawnSync } = require('child_process');
12
- const { findBrowser } = require('./lib/find-browser');
13
- const CT = require('./lib/premium-console-type'); // the mockup is read with the console's type (PM, 2026-10-19), as premium.css is
14
- const CT_VENDOR = 'file://' + path.join(__dirname, 'public', 'vendor') + '/';
15
- const T = require('./test-run').configure({ name: 'premium-welcome' });
16
- const B = require('./lib/briefing-premium.js');
17
- const F = require('./fixtures/briefing-premium-facts.js');
18
-
19
- const BASE = T.BASE;
20
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
21
- 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); } };
22
- const results = [];
23
- const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
24
- let srv = null; let browser = null;
25
- const finish = async (code) => {
26
- if (browser) await browser.close().catch(() => {});
27
- if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
28
- T.killTmux();
29
- const bad = results.filter((x) => !x.cond).length;
30
- console.log(`\n${results.length - bad}/${results.length} premium-welcome browser assertions passed`);
31
- process.exit(code !== undefined ? code : (bad ? 1 : 0));
32
- };
33
- process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
34
-
35
- const mockupFile = path.join(os.tmpdir(), `premium-welcome-mockup-${process.pid}.html`);
36
- const built = spawnSync('python3', [path.join(__dirname, '..', 'prototype', 'premium-welcome', 'build.py'), mockupFile], { encoding: 'utf8' });
37
-
38
- const STRUCT = {
39
- ok: true,
40
- boards: [
41
- { key: 'payments', name: 'Payments', unsorted: [{}, {}, {}], initiatives: [
42
- { proposal_id: 'p1', title: 'Refund reason codes', lane: 'feature', anchor: null, stage: 'Specified', checked: true, docs: [{ file: 'payments/refund-codes-prd.md' }, { file: 'payments/x.md' }] },
43
- { proposal_id: 'p3', title: 'Card vault migration', lane: 'feature', anchor: 'KR-P1', stage: 'Done', checked: false, docs: [{ file: 'a.md' }] }] },
44
- { key: 'growth', name: 'Growth', unsorted: [], initiatives: [{ proposal_id: 'g1', title: 'Win-back emails', lane: 'feature', anchor: 'KR-G1', stage: 'Building', checked: true, docs: [] }] }],
45
- questions: [{ id: 'anchor', text: 'Anchor for the ones with none', default: 'per-board', options: [{ value: 'per-board', label: 'Each board’s domain anchor' }, { value: 'health:upkeep', label: 'health:upkeep for all' }] },
46
- { id: 'fiscal', text: 'Fiscal year starts', default: 'January' }],
47
- };
48
- const LOOK = { sentence: '214 files read. 3 initiatives on 2 boards, 41 documents.', findings: [
49
- { title: 'Deadline 30 Oct has no owner', why: 'A date within 30 days names no owner.', evidence: [{ file: 'payments/refund-codes-prd.md', line: 14 }] },
50
- { title: '<img src=x onerror="window.__pwn=1">', why: '<b>bold</b>', evidence: [{ file: 'growth/pricing.md' }] }] };
51
- const BRIEFING = { ok: true, items: [{ title: 'Refund reason codes needs an anchor you confirm', why: 'It had no anchor.', evidence: [{ file: 'payments/refund-codes-prd.md', line: 1 }], initiative: { title: 'Refund reason codes', board: 'payments' } }] };
52
-
53
- (async () => {
54
- const exe = findBrowser();
55
- if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
56
- let chromium;
57
- try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
58
- srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
59
- await T.waitForServer(BASE);
60
- browser = await chromium.launch({ executablePath: exe });
61
- const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
62
-
63
- /* opts: status (the onboarding status answer), applyError, toolError, briefing, structure, w, h, theme, touch, url, tools (the sessionStorage record the first card reads) */
64
- const open = async ({ url = '/premium-welcome.html?ws=w1', w = 1280, h = 900, theme = 'light', touch = false, status = { ok: true, state: 'new', first_run: true, imports: [] }, applyError = null, toolError = null, briefing = BRIEFING, structure = STRUCT, tools = null } = {}) => {
65
- const ctx = await browser.newContext({ viewport: { width: w, height: h }, hasTouch: touch, isMobile: touch });
66
- const page = await ctx.newPage();
67
- const S = { errors: [], reqs: [], posts: [], headers: [], dismissed: 0, undone: [], settings: { name: 'Dana', about: { role: 'Senior PM', work: '', duties: '' } }, applied: [] };
68
- page.on('pageerror', (e) => S.errors.push(String((e && e.message) || e)));
69
- page.on('request', (r) => { if (r.url().startsWith(BASE)) { const u = new URL(r.url()); if (u.pathname.startsWith('/api/')) S.reqs.push(r.method() + ' ' + u.pathname); if (r.method() === 'POST') S.headers.push(r.headers()['x-pmos-nonce'] || ''); } });
70
- const body = (r) => JSON.parse(r.request().postData() || '{}');
71
- await page.route('**/api/workspaces', (r) => (r.request().method() === 'GET' ? json(r, { workspaces: [{ id: 'w1', name: 'checkout-team', root: '/home/u/checkout-team' }, { id: 'w2', name: 'growth-notes', root: '/home/u/growth-notes' }] }) : (S.posts.push(['workspaces', body(r)]), json(r, { workspace: { id: 'w2', name: 'growth-notes', root: '/home/u/growth-notes' } }))));
72
- await page.route('**/api/pick-folder', (r) => { S.posts.push(['pick-folder', body(r)]); return json(r, { ok: true, root: '/home/u/growth-notes' }); });
73
- await page.route('**/api/proactive/settings', (r) => { if (r.request().method() === 'GET') return json(r, { ok: true, settings: S.settings }); const b = body(r); S.posts.push(['settings', b]); return json(r, { ok: true }); });
74
- await page.route('**/api/proactive/goals/plan', (r) => { S.posts.push(['plan', body(r)]); return json(r, { ok: true }); });
75
- await page.route('**/api/sources/refresh', (r) => { const b = body(r); S.posts.push(['refresh', b]); return toolError && b.source === toolError.source ? json(r, { ok: false, error: toolError.error }, 409) : json(r, { ok: true }); });
76
- await page.route('**/api/onboarding/status*', (r) => json(r, status));
77
- await page.route('**/api/onboarding/scan', (r) => { S.posts.push(['scan', body(r)]); return json(r, { ok: true, scan_id: 's1', first_look: LOOK }); });
78
- await page.route('**/api/onboarding/structure*', (r) => json(r, structure));
79
- await page.route('**/api/onboarding/apply', (r) => { const b = body(r); S.posts.push(['apply', b]); S.applied.push(b); return applyError ? json(r, { ok: false, error: applyError }, 400) : json(r, { ok: true, import_id: 'imp1', boards: 2, initiatives: b.include.length }); });
80
- await page.route('**/api/onboarding/briefing*', (r) => json(r, briefing));
81
- await page.route('**/api/onboarding/dismiss', (r) => { S.dismissed++; S.posts.push(['dismiss', body(r)]); return json(r, { ok: true }); });
82
- await page.route('**/api/onboarding/undo', (r) => { S.undone.push(body(r)); S.posts.push(['undo', body(r)]); return json(r, { ok: true, retracted: 1 }); });
83
- await page.route('**/api/briefing-premium*', (r) => json(r, { ok: true, state: 'ready', model: B.build(F.facts()), as_of: Date.now() }));
84
- if (tools) await page.addInitScript((t) => { try { sessionStorage.setItem('pmos.welcome.tools', t); } catch { /* none */ } }, JSON.stringify(tools));
85
- await page.goto(BASE + url + (url.includes('?') ? '&' : '?') + 'theme=' + theme);
86
- return { ctx, page, S };
87
- };
88
- const text = (page, sel) => page.evaluate((s) => { const e = document.querySelector(s); return e ? e.textContent.replace(/\s+/g, ' ').trim() : null; }, sel);
89
- const heading = (page, re) => until(() => page.evaluate((src) => new RegExp(src).test((document.querySelector('#wlH') || {}).textContent || ''), re.source));
90
- const click = (page, sel) => page.evaluate((s) => document.querySelector(s).click(), sel);
91
- const fillIn = async (page, sel, v) => { await page.fill(sel, v); };
92
-
93
- if (built.status !== 0) { ok('the mockup builds (prototype/premium-welcome/build.py)', false, built.stderr); return finish(1); }
94
-
95
- /* ── the whole flow ──────────────────────────────────────────────────────────────────────── */
96
- const P = await open();
97
- ok('R1 the page is served at its own address with the launch nonce', await until(() => P.page.evaluate(() => (document.querySelector('meta[name="pmos-nonce"]').content || '').length > 8)));
98
- ok('R2 About you opens on its heading and is prefilled from the proactive settings', await heading(P.page, /Welcome to PMOS/) && await P.page.inputValue('[data-f=name]') === 'Dana' && await P.page.inputValue('[data-f=role]') === 'Senior PM');
99
- ok('R2 the step bar and count say step 1 of 3', /step 1 of 3/.test(await text(P.page, '#wlCount')) && (await P.page.$$('#wlSteps li')).length === 3);
100
- await fillIn(P.page, '[data-f=work]', 'I run checkout'); await fillIn(P.page, '[data-f=name]', 'Dana K');
101
- await click(P.page, '[data-w=about]');
102
- ok('R2 Continue saves the four fields through the proactive settings and moves on', await heading(P.page, /Where does your work live/) && JSON.stringify(P.S.posts.find((p) => p[0] === 'settings')[1]) === JSON.stringify({ name: 'Dana K', about: { role: 'Senior PM', work: 'I run checkout', duties: '' } }));
103
- ok('R3 the folder being set up is listed, and each tool is Off until ticked', /checkout-team/.test(await text(P.page, '#wlCard')) && await P.page.evaluate(() => [...document.querySelectorAll('[data-w=tool]')].length === 4 && [...document.querySelectorAll('[data-w=tool]')].every((b) => b.getAttribute('aria-pressed') === 'false' && /Off/.test(b.textContent))));
104
- ok('R3 nothing was read or started before Scan', !P.S.posts.some((p) => ['scan', 'plan', 'refresh'].includes(p[0])) && !P.S.reqs.some((r) => /onboarding\/(scan|structure)|sources\/refresh/.test(r)));
105
- await click(P.page, '[data-w=folder]'); await until(() => P.page.evaluate(() => /growth-notes/.test(document.querySelector('#wlCard').textContent)));
106
- ok('R3 Add another folder asks the chooser and registers the folder without focusing it', P.S.posts.some((p) => p[0] === 'pick-folder') && JSON.stringify(P.S.posts.find((p) => p[0] === 'workspaces')[1]) === JSON.stringify({ root: '/home/u/growth-notes', name: 'growth-notes', focus: false }));
107
- await click(P.page, '[data-w=tool][data-k=calendar]'); await click(P.page, '[data-w=tool][data-k=inbox]');
108
- ok('R3 the Scan button names the tools it will read', /Scan the folder and read 2 tools/.test(await text(P.page, '[data-w=scan]')));
109
- await click(P.page, '[data-w=scan]');
110
- ok('R4 the scan ends on What PMOS found', await heading(P.page, /What PMOS found/));
111
- const posts = P.S.posts.map((p) => p[0]);
112
- ok('R3 Scan turned the Inbox on for the Briefing, prepared the day, refreshed Calendar only, then scanned with the added folder', JSON.stringify(P.S.posts.find((p) => p[0] === 'settings' && p[1].briefSources)[1]) === '{"briefSources":{"mail":true}}' && posts.includes('plan') && P.S.posts.filter((p) => p[0] === 'refresh').map((p) => p[1].source).join() === 'calendar' && JSON.stringify(P.S.posts.find((p) => p[0] === 'scan')[1].extra_roots) === '["/home/u/growth-notes"]');
113
- ok('R4 the scan\'s sentence and findings are shown with their file and line', /214 files read/.test(await text(P.page, '.wl-lede')) && /payments\/refund-codes-prd\.md:14/.test(await text(P.page, '#wlCard')));
114
- ok('R10 text taken from the folder is text: no element was made from it', await P.page.evaluate(() => !window.__pwn && !document.querySelector('#wlCard img') && /<img src=x/.test(document.querySelector('#wlCard').textContent) && !document.querySelector('#wlCard b + small b')));
115
- ok('R4 the portfolio shows each board with its unsorted count and each row with lane, anchor, stage and documents', /Payments/.test(await text(P.page, '.wl-bh')) && /3 documents unsorted/.test(await text(P.page, '.wl-bh')) && /feature · no anchor · Specified · 2 documents/.test(await text(P.page, '.wl-ed')));
116
- ok('R4 the row the scan proposed unchecked starts left out, and the button counts the others', await P.page.evaluate(() => document.querySelectorAll('.wl-ed.off').length === 1) && /Import 2 initiatives into 2 boards/.test(await text(P.page, '[data-w=import]')));
117
- await click(P.page, '[data-w=inc][data-id=g1]');
118
- ok('R4 Leave out takes a row from the count and Edit is off for it', /Import 1 initiative into 1 board/.test(await text(P.page, '[data-w=import]')) && await P.page.evaluate(() => document.querySelector('[data-w=edit][data-id=g1]').disabled));
119
- await click(P.page, '[data-w=inc][data-id=g1]'); await click(P.page, '[data-w=inc][data-id=p3]');
120
- ok('R4 a left-out row can be brought back, and a left-in one counts', /Import 3 initiatives into 2 boards/.test(await text(P.page, '[data-w=import]')));
121
- await click(P.page, '[data-w=inc][data-id=p3]');
122
- await click(P.page, '[data-w=edit][data-id=p1]'); await fillIn(P.page, '[data-f=title][data-id=p1]', 'Refund codes');
123
- await P.page.selectOption('[data-f=board][data-id=p1]', 'growth');
124
- ok('R4 Edit changes the title and the board of a row', await until(() => P.page.evaluate(() => document.querySelector('[data-f=title][data-id=p1]').value === 'Refund codes')) && /Import 2 initiatives into 1 board/.test(await text(P.page, '[data-w=import]')));
125
- ok('R5 the defaults list each scan question with the default it will send', /Anchor for the ones with none/.test(await text(P.page, '.wl-def')) && /Each board’s domain anchor/.test(await text(P.page, '.wl-def')) && /January/.test(await text(P.page, '.wl-def')));
126
- await click(P.page, '[data-w=defs]'); await P.page.selectOption('[data-f=answer][data-id=anchor]', 'health:upkeep'); await click(P.page, '[data-w=skipq][data-id=fiscal]');
127
- ok('R5 Change the defaults shows the inputs, and a skipped question says nothing is sent', await until(() => P.page.evaluate(() => /Skipped\. Nothing is sent/.test(document.querySelector('.wl-def dl').textContent))) && /health:upkeep/.test(await text(P.page, '.wl-def dl')));
128
- await click(P.page, '[data-w=import]');
129
- ok('R6 Import posts once with the ticked ids, the revisions and the answers', await until(() => P.S.applied.length === 1) && JSON.stringify(P.S.applied[0]) === JSON.stringify({ ws: 'w1', include: ['p1', 'g1'], revisions: { p1: { title: 'Refund codes', board: 'growth' } }, answers: { anchor: 'health:upkeep' } }), JSON.stringify(P.S.applied));
130
- ok('R6 the page then lands on the premium Briefing with the import id', await until(() => P.page.url().includes('/premium.html?ws=w1&first=imp1'), 15000), P.page.url());
131
- ok('R10 every write carried the launch nonce', P.S.headers.length > 5 && P.S.headers.every((h) => h.length > 8));
132
- const allowed = /^(GET \/api\/(workspaces|proactive\/settings|onboarding\/(status|structure|briefing)|briefing-premium|notes|premium-[a-z-]+|calendar-views|search|bell|sessions[a-z/-]*|board-metrics-premium|[a-z-]+)|POST \/api\/(proactive\/settings|proactive\/goals\/plan|pick-folder|workspaces|sources\/refresh|onboarding\/(scan|apply|dismiss|undo)))$/;
133
- const welcomeReqs = P.S.reqs.slice(0, P.S.reqs.findIndex((r) => /briefing-premium/.test(r)) > 0 ? P.S.reqs.findIndex((r) => /briefing-premium/.test(r)) : P.S.reqs.length);
134
- ok('R10 Welcome sent no request beyond the onboarding, settings and source routes', welcomeReqs.every((r) => allowed.test(r)), welcomeReqs.filter((r) => !allowed.test(r)).join());
135
- ok('R10 no script error on the way', P.S.errors.length === 0, P.S.errors.join(' | '));
136
-
137
- /* R7 the first-Briefing card, and Undo */
138
- const C = await open({ url: '/premium.html?ws=w1&first=imp1', tools: { calendar: { started: true }, inbox: { error: 'No connection for Inbox.' } } });
139
- // premium-agreed-design: Home has no columns; the card sits at the top of Home's list (the scroller of #hmList, above the Elsewhere foot), plain; premium-uncovered-features drew it as the Today card (HmDay), so it has no Waiting for design marker
140
- ok('R7 the card sits at the top of Home\'s list with the import\'s item, its initiative and its file', await until(() => C.page.evaluate(() => { const c = document.querySelector('#wlFirst'); const l = document.querySelector('#hmList > .hm-lsc'); return !!c && !!l && c.parentElement === l && [...l.children].filter((x) => !x.hidden).indexOf(c) === 0 && !/Waiting for design/.test(c.textContent) && /Refund reason codes needs an anchor/.test(c.textContent) && /payments board/.test(c.textContent) && /refund-codes-prd\.md:1/.test(c.textContent); })));
141
- ok('R7 the card lists the ticked tools: one being read, one with its reason', await C.page.evaluate(() => /Calendar is being read in an agent session/.test(document.querySelector('#wlFirst').textContent) && /No connection for Inbox\./.test(document.querySelector('#wlFirst').textContent) && !/Slack|Jira/.test(document.querySelector('#wlFirst').textContent)));
142
- await click(C.page, '#wlUndo');
143
- ok('R7 Undo this import retracts that import and returns to the found step', await until(() => C.S.undone.length === 1) && JSON.stringify(C.S.undone[0]) === '{"ws":"w1","import_id":"imp1"}' && await until(() => C.page.url().includes('/premium-welcome.html?ws=w1&step=found')) && await heading(C.page, /What PMOS found/));
144
- ok('R7 the found step after Undo shows no first-look sentence it does not hold', await C.page.evaluate(() => !document.querySelector('.wl-lede') && !/Nothing in this folder needs you/.test(document.querySelector('#wlCard').textContent) && document.querySelectorAll('.wl-ed').length === 3));
145
- await C.ctx.close();
146
- const E = await open({ url: '/premium.html?ws=w1&first=imp9', briefing: { ok: true, items: [] } });
147
- ok('R7 a Briefing with no items says nothing needs the PM and lists nothing', await until(() => E.page.evaluate(() => { const c = document.querySelector('#wlFirst'); return !!c && /Nothing needs you right now/.test(c.textContent) && !c.querySelector('ol'); })));
148
- await E.ctx.close();
149
- const N = await open({ url: '/premium.html?ws=w1' });
150
- ok('R7 without first= Home has no first card', await until(() => N.page.evaluate(() => document.querySelectorAll('#hmList .hm-pg, #hmList .hm-none').length > 0 && !/Reading your work/.test(document.querySelector('#hmList').textContent))) && await N.page.evaluate(() => !document.querySelector('#wlFirst')));
151
- await N.ctx.close();
152
-
153
- /* R8 not now, R9 already imported */
154
- const Q = await open();
155
- await heading(Q.page, /Welcome to PMOS/); await click(Q.page, '#wlSkip');
156
- ok('R8 Not now dismisses the first run for this folder and lands on the premium Briefing, and writes nothing else', await until(() => Q.page.url().includes('/premium.html?ws=w1')) && Q.S.dismissed === 1 && Q.S.posts.every((p) => p[0] === 'dismiss'));
157
- await Q.ctx.close();
158
- const R = await open({ status: { ok: true, state: 'imported', first_run: false, imports: [{ import_id: 'old', retracted: true }, { import_id: 'imp7' }] } });
159
- ok('R9 a folder with a live import goes to that import\'s card', await until(() => R.page.url().includes('/premium.html?ws=w1&first=imp7'), 15000), R.page.url());
160
- await R.ctx.close();
161
-
162
- /* failures say why and change nothing */
163
- const X = await open({ applyError: 'the import stopped: a board is missing', toolError: { source: 'calendar', error: 'No calendar connection.' } });
164
- await heading(X.page, /Welcome to PMOS/); await click(X.page, '[data-w=about]'); await heading(X.page, /Where does your work/);
165
- await click(X.page, '[data-w=tool][data-k=calendar]'); await click(X.page, '[data-w=scan]'); await heading(X.page, /What PMOS found/);
166
- ok('R3 a tool that cannot start does not stop the scan', X.S.posts.some((p) => p[0] === 'scan'));
167
- await click(X.page, '[data-w=import]');
168
- ok('R6 a refused import shows the server\'s reason, stays on the found step and keeps the choices', await until(() => X.page.evaluate(() => /a board is missing/.test((document.querySelector('.wl-err') || {}).textContent || ''))) && /What PMOS found/.test(await text(X.page, '#wlH')) && X.page.url().includes('premium-welcome') && await X.page.evaluate(() => document.querySelectorAll('.wl-ed.off').length === 1));
169
- await click(X.page, '[data-w=inc][data-id=p1]'); await click(X.page, '[data-w=inc][data-id=g1]');
170
- ok('R6 with nothing to import the button is off', await X.page.evaluate(() => document.querySelector('[data-w=import]').disabled && /Import 0 initiatives into 0 boards/.test(document.querySelector('[data-w=import]').textContent)));
171
- await X.ctx.close();
172
-
173
- /* R11 floors and fidelity */
174
- let mk = null; let mp = { close: async () => {} };
175
- const mkOf = async (w, th) => { if (mk) await mk.close(); mk = await browser.newContext({ viewport: { width: w, height: w === 390 ? 800 : 900 }, colorScheme: th }); return mk; };
176
- const mockupHtml = fs.readFileSync(mockupFile, 'utf8');
177
- const pick = (sel, props) => (s, p) => document.querySelector(s) && p.map((k) => getComputedStyle(document.querySelector(s))[k]).join('|');
178
- const css = (page, sel, props) => page.evaluate(([s, p]) => { const e = document.querySelector(s); if (!e) return null; const k = getComputedStyle(e); return p.map((n) => k[n]).join('|'); }, [sel, props]);
179
- const CMP = [
180
- ['the brand pill', '.wl-brand', ['fontWeight', 'fontSize', 'borderRadius', 'height', 'paddingLeft']],
181
- ['the heading', '#wlH', ['fontSize', 'fontWeight', 'letterSpacing', 'lineHeight', 'color']],
182
- ['the lede', '.wl-lede', ['fontSize', 'color', 'maxWidth']],
183
- ['a field label', '.wl-f label', ['fontSize', 'fontWeight', 'color']],
184
- ['a field', '.wl-f input', ['height', 'borderRadius', 'paddingLeft', 'fontSize', 'backgroundColor']],
185
- ['the text area', '.wl-f textarea', ['minHeight', 'borderRadius', 'lineHeight']],
186
- ['the main button', '.wl-foot .wl-btn', ['height', 'borderRadius', 'fontWeight', 'backgroundColor', 'color', 'paddingLeft']],
187
- ['the card', '.wl-card', ['borderRadius', 'paddingLeft', 'backgroundColor']],
188
- ['a step label', '.wl-steps li span', ['fontSize', 'fontWeight', 'letterSpacing', 'textTransform']],
189
- ];
190
- for (const [w, th] of [[1280, 'light'], [1280, 'dark'], [390, 'light'], [390, 'dark']]) {
191
- const A = await open({ w, h: w === 390 ? 800 : 900, theme: th, touch: w === 390 });
192
- await heading(A.page, /Welcome to PMOS/);
193
- await mp.close(); mp = await (await mkOf(w, th)).newPage(); await mp.goto('file://' + mockupFile); await CT.applyToPage(mp, CT_VENDOR); await mp.evaluate((t) => { document.documentElement.dataset.theme = t; }, th); await mp.waitForTimeout(500);
194
- const diffs = [];
195
- // on a touch phone a text field is 16 px so focus does not zoom the page (premium.css); the mockup's 14 px and its line height do not apply there
196
- const TOUCH = w === 390 ? { '.wl-f input': ['fontSize'], '.wl-f textarea': ['lineHeight'] } : {};
197
- for (const [name, sel, all] of CMP) { const props = all.filter((k) => !(TOUCH[sel] || []).includes(k)); const a = await css(A.page, sel, props), m = await css(mp, sel, props); if (a !== m) diffs.push(`${name}: ${a} vs ${m}`); }
198
- if (w === 390) diffs.push(...(await A.page.evaluate(() => ['.wl-f input', '.wl-f textarea'].map((s) => getComputedStyle(document.querySelector(s)).fontSize).filter((f) => f !== '16px').map((f) => 'a text field on a touch phone: ' + f))));
199
- ok(`R11 fidelity at ${w} px (${th}): About you keeps the mockup's type, radii, colours and sizes`, diffs.length === 0, diffs.join(' ; '));
200
- const scrolls = [];
201
- const floor = async (label) => scrolls.push(await A.page.evaluate((l) => ({ l, scroll: document.documentElement.scrollWidth <= innerWidth + 1, btn: [...document.querySelectorAll('#wlCard button, #wlSkip')].filter((b) => b.offsetParent).map((b) => Math.round(b.getBoundingClientRect().height)) }), label));
202
- await floor('about'); await click(A.page, '[data-w=about]'); await heading(A.page, /Where does your work/); await floor('sources');
203
- await click(A.page, '[data-w=scan]'); await heading(A.page, /What PMOS found/); await floor('found');
204
- const foot = await A.page.evaluate(() => { const f = document.querySelector('.wl-foot').getBoundingClientRect(); return [Math.round(f.bottom), innerHeight]; });
205
- ok(`R11 at ${w} px (${th}) the three steps have no sideways scroll${w === 390 ? ' and every press is at least 44 px' : ''}`, scrolls.every((s) => s.scroll) && (w !== 390 || scrolls.every((s) => s.btn.length && s.btn.every((n) => n >= 43.5))), JSON.stringify(scrolls));
206
- if (w === 390) ok('R11 at 390 px the footer buttons stay at the bottom of the screen on the found step', foot[0] >= foot[1] - 2 && foot[0] <= foot[1] + 2, foot.join('/'));
207
- if (th === 'light' && w === 1280) {
208
- await mp.goto('file://' + mockupFile + '#found'); await mp.reload(); await CT.applyToPage(mp, CT_VENDOR); await mp.waitForTimeout(500);
209
- const FCMP = [['a row', '.wl-ed .wl-row', ['display', 'gap', 'paddingLeft']], ['a row button', '.wl-ed .wgo', ['height', 'borderRadius', 'fontSize', 'fontWeight']], ['a section label', '.wl-sec', ['fontSize', 'letterSpacing', 'textTransform', 'color']], ['the defaults box', '.wl-def', ['borderRadius', 'borderTopStyle', 'paddingLeft']]];
210
- const d2 = [];
211
- for (const [name, sel, props] of FCMP) { const a = await css(A.page, sel, props), m = await css(mp, sel, props); if (a !== m) d2.push(`${name}: ${a} vs ${m}`); }
212
- ok('R11 fidelity: the found step\'s rows, buttons, labels and defaults box keep the mockup\'s styles', d2.length === 0, d2.join(' ; '));
213
- }
214
- await A.ctx.close();
215
- }
216
- if (mk) await mk.close();
217
- try { fs.unlinkSync(mockupFile); } catch { /* gone */ }
218
- finish();
219
- })();