calendar
All repositories: gitoria
26.2 KB
// tests/push.mjs — calendar#9 part 2 (mission 008): WEB PUSH, a reminder reaches a device whose calendar is CLOSED.// node tests/push.mjs [app dir] env: PUSH_GATE_PORT (app, default 8700; ident +1; the fake push service +2; Chrome +4),// PUSH_GATE_SCRATCH. A real headless Chrome as a 390 px phone, own ident, own server + storage, VAPID keys made here.// The FAKE PUSH SERVICE is a local http server that decrypts like a user agent (ECDH with the subscription's private key,// RFC 8291; the approach of hybriel tests/core-ast/web-tickets.mjs #173): it answers 201 at /ok/*, 410 at /gone/*.// Headless Chrome cannot reach a real push service, so the browser's `PushManager.subscribe` is replaced by one that answers// the subscription made here (the page's own code — subscribePush, the button, the server emit — is the real one).// 1 ok tap "Turn on notifications" → the page says it is subscribed; the browser is then CLOSED; at the reminder time// the fake service gets ONE encrypted push: VAPID header with the app's key, payload = event title + "Starts in 1 minute"// 2 gone a device whose service answers 410 gets the first push, and none after it (the subscription is dropped)// 4 test a subscribed device taps "Send a test notification": ONE push, ~10 s later, to that device only (calendar#12)// 3 shown + off a device that allowed notifications before is subscribed when the app is shown again (no touch); "Turn off on this device" unsubscribes it and the server drops it: no push, a reload does not subscribe it again (PUSH_GATE_ONLY3=1 runs only this)import { spawn } from 'node:child_process';import { writeFileSync, existsSync, mkdirSync, rmSync } from 'node:fs';import { createServer as httpServer } from 'node:http';import { generateKeyPairSync, createECDH, hkdfSync, createDecipheriv, randomBytes, verify } from 'node:crypto';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';const HERE = dirname(fileURLToPath(import.meta.url));const APP = resolve(process.argv[2] || resolve(HERE, '..'));const PORT = Number(process.env.PUSH_GATE_PORT || 8700);const FPORT = PORT + 2, CPORT = PORT + 4;const BASE = `http://127.0.0.1:${PORT}`;const SCRATCH = resolve(process.env.PUSH_GATE_SCRATCH || join(APP, '.scratch', 'push-gate'));rmSync(SCRATCH, { recursive: true, force: true });mkdirSync(join(SCRATCH, 'chrome'), { recursive: true });process.env.TMPDIR = join(SCRATCH, 'chrome');if (!process.env.HL_CHROME && existsSync('/opt/google/chrome/chrome')) process.env.HL_CHROME = '/opt/google/chrome/chrome';const { launchBrowser } = await import('./cdp.mjs');const { startIdent } = await import('./identkit.mjs');const IDENT_DIR = process.env.CALENDAR_GATE_IDENT_DIR || [resolve(APP, '../ident.worldapi.org'), '/media/STORAGE/projects/WorldAPI/ident.worldapi.org'].find(d => existsSync(join(d, 'project.hl')));const sleep = (ms) => new Promise(r => setTimeout(r, ms));const J = JSON.stringify;const pad = (n) => String(n).padStart(2, '0');const b64 = (b) => Buffer.from(b).toString('base64url');let failures = 0, passes = 0;function check(label, ok, detail = '') { console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`); if (ok) passes++; else failures++; }const say = (what) => console.log(`${new Date().toTimeString().slice(0, 8)} ${what}`);// the app's VAPID pairconst app = generateKeyPairSync('ec', { namedCurve: 'P-256' });const jwk = app.privateKey.export({ format: 'jwk' });const PUB = b64(Buffer.concat([Buffer.from([4]), Buffer.from(jwk.x, 'base64url'), Buffer.from(jwk.y, 'base64url')]));const PRIV = jwk.d;// the fake push service: a user agent per subscription (its ECDH key and auth secret), decrypting what arrivesconst agents = {};function newAgent(path) { const ua = createECDH('prime256v1'); ua.generateKeys(); agents[path] = { ua, auth: randomBytes(16) }; return { endpoint: `http://127.0.0.1:${FPORT}${path}`, keys: { p256dh: b64(ua.getPublicKey()), auth: b64(agents[path].auth) } }; }const received = [];function decrypt(path, b) {const { ua, auth } = agents[path]; const uaPub = ua.getPublicKey();const salt = b.subarray(0, 16); const idlen = b[20]; const asPub = b.subarray(21, 21 + idlen);const ikm = Buffer.from(hkdfSync('sha256', ua.computeSecret(asPub), auth, Buffer.concat([Buffer.from('WebPush: info\0'), uaPub, asPub]), 32));const cek = Buffer.from(hkdfSync('sha256', ikm, salt, Buffer.from('Content-Encoding: aes128gcm\0'), 16));const nonce = Buffer.from(hkdfSync('sha256', ikm, salt, Buffer.from('Content-Encoding: nonce\0'), 12));const rec = b.subarray(21 + idlen);const d = createDecipheriv('aes-128-gcm', cek, nonce); d.setAuthTag(rec.subarray(rec.length - 16));const pt = Buffer.concat([d.update(rec.subarray(0, rec.length - 16)), d.final()]);return pt.subarray(0, pt.lastIndexOf(2)).toString('utf8');}const fake = httpServer((q, r) => {const c = []; q.on('data', d => c.push(d));q.on('end', () => {const body = Buffer.concat(c); let plain = null, err = null;try { plain = decrypt(q.url, body); } catch (e) { err = String(e.message); }received.push({ at: Date.now(), url: q.url, headers: q.headers, plain, err });r.statusCode = q.url.startsWith('/gone') ? 410 : 201; r.end('');});});const ANDROID_UA = 'Mozilla/5.0 (Linux; Android 14; Pixel 7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Mobile Safari/537.36';let ident = null, server = null, log = '', APPKEY = null, browser = null;async function stopAll() {if (browser) { try { await browser.close(); } catch {} browser = null; }if (ident) { try { await ident.stop(); } catch {} ident = null; }try { fake.close(); } catch {}if (server) { try { server.kill('SIGTERM'); } catch {} await new Promise(r => { if (server.exitCode !== null || server.signalCode !== null) return r(); server.once('exit', r); setTimeout(r, 3000); }); server = null; }}const shot = async (page, name) => { const { data } = await page.send('Page.captureScreenshot', { format: 'png' }); writeFileSync(join(SCRATCH, `${name}.png`), Buffer.from(data, 'base64')); };async function tap(page, sel) {const at = await page.evaluate(`(() => { const e = document.querySelector(${J(sel)}); if (!e) return null; e.scrollIntoView({ block: 'center' }); const r = e.getBoundingClientRect(); return { x: Math.round(r.x + r.width / 2), y: Math.round(r.y + r.height / 2) }; })()`);if (!at) throw new Error('tap: no ' + sel);await page.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [{ x: at.x, y: at.y }] });await page.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] });}// the notification controls live in the reminder settings (C13): user menu → "Reminder settings" (a real tap each), the dialog openasync function openSettings(page) {if (await page.evaluate(`document.querySelector('#settingseditor').matches(':popover-open')`)) return;await tap(page, '#settings-open');await page.waitFor(`document.querySelector('#settingseditor').matches(':popover-open')`, { timeout: 30000, label: 'reminder settings open' }).catch(async (e) => { console.log('---- page console\n' + page.dumpConsole().slice(-1500)); throw e; });await sleep(300);}const hydrated = (page) => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { timeout: 120000, label: 'hydrated' });// a signed-in phone of `who`; `sub` is what the (replaced) browser subscribe answersasync function phone(who, sub) {browser = await launchBrowser({ debugPortRange: [CPORT, CPORT] });const page = await browser.newPage();await page.addInitScript(`(() => { const want = ${J({ endpoint: sub.endpoint, expirationTime: null, keys: sub.keys })}; let held = JSON.parse(sessionStorage.getItem('__held') || 'null');const mk = () => ({ endpoint: want.endpoint, toJSON: () => want, unsubscribe: () => { sessionStorage.setItem('__held', 'null'); held = null; window.__unsub = (window.__unsub || 0) + 1; return Promise.resolve(true); } });PushManager.prototype.subscribe = function (o) { window.__subKey = String(o.applicationServerKey) + '|' + o.userVisibleOnly; sessionStorage.setItem('__held', '1'); held = 1; return Promise.resolve(mk()); };PushManager.prototype.getSubscription = function () { return Promise.resolve(held ? mk() : null); }; })();`);await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 800, deviceScaleFactor: 2, mobile: true });await page.send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });await page.send('Emulation.setUserAgentOverride', { userAgent: ANDROID_UA, platform: 'Linux armv8l' });const code = await ident.selectorCode(who, APPKEY, BASE);await page.goto(BASE + '/login/callback?ident_code=' + code, { timeout: 120000 });await page.waitForSelector('#logout', { timeout: 60000 });await hydrated(page);await page.waitFor(`navigator.serviceWorker.getRegistration().then(r => !!(r && r.active))`, { label: 'service worker active', timeout: 60000 });return page;}// an event starting `ahead` ms from now (rounded up to a whole minute), own reminder 1 minute before → the reminder's instantasync function addEvent(page, title, ahead) {const zone = await page.evaluate('Intl.DateTimeFormat().resolvedOptions().timeZone');const now = Date.now();const start = new Date(Math.ceil((now + ahead) / 60000) * 60000);const dateOf = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;const cookie = (await page.cookies([BASE])).map(c => c.name + '=' + c.value).join('; ');const fields = { title, allDay: false, startDate: dateOf(start), startTime: `${pad(start.getHours())}:${pad(start.getMinutes())}`, endDate: '', endTime: '', place: '', notes: '', zone, custom: true, reminders: [{ unit: 'minutes', n: '1', time: '09:00' }] };const r = await fetch(BASE + '/__hl/emit', { method: 'POST', headers: { 'content-type': 'application/json', cookie }, body: J({ t: 'emit', i: 1, event: 'calSave', payload: [fields, dateOf(new Date(now - 259200000)), dateOf(new Date(now + 777600000))] }) });const j = JSON.parse(await r.text());if (!j.value || j.value.error) throw new Error('calSave: ' + r.status + ' ' + J(j));return start.getTime() - 60000;}const until = async (t) => { const w = t - Date.now(); if (w > 0) await sleep(w); };// which notification controls the page shows (C13): ONE consistent state — "Turn on" only while not subscribed, test + off only while subscribedconst vis = (page) => page.evaluate(`(() => { const v = (id) => { const e = document.querySelector(id); return !!e && !e.classList.contains('hidden') && e.getBoundingClientRect().height > 0; }; return { ask: v('#notify-ask'), test: v('#push-test'), off: v('#push-off'), blocked: v('#notify-blocked') }; })()`);const oneState = (x) => (x.ask && !x.test && !x.off) || (!x.ask && x.test && x.off) || (!x.ask && !x.test && !x.off);const pushText = (page) => page.evaluate(`(document.querySelector('#push-state') || {}).textContent || ''`);async function main() {mkdirSync(join(SCRATCH, 'store', 'sessions'), { recursive: true });await new Promise(res => fake.listen(FPORT, '127.0.0.1', res));ident = await startIdent({ identDir: IDENT_DIR, workDir: join(SCRATCH, 'store', 'ident'), port: PORT + 1 });const alice = await ident.signIn('[email protected]'), bob = await ident.signIn('[email protected]');APPKEY = await ident.registerApp(alice, 'calendar (push gate)', [BASE]);server = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, env: { ...process.env, CALENDAR_PORT: String(PORT), HL_HOST: '127.0.0.1', CALENDAR_SESSIONS: join(SCRATCH, 'store', 'sessions') + '/',CALENDAR_STORAGE: join(SCRATCH, 'store', 'mpackdb'), CALENDAR_WATCH: '0', CALENDAR_PUBLIC_URL: BASE, IDENT_URL: ident.base, IDENT_EXCHANGE_URL: ident.base,IDENT_API_KEY: APPKEY.key, IDENT_API_SECRET: APPKEY.secret, CALENDAR_PUSH_PUBLIC: PUB, CALENDAR_PUSH_PRIVATE: PRIV, CALENDAR_PUSH_SUBJECT: 'mailto:[email protected]',CALENDAR_PUSH_EVERY: '0.5', CALENDAR_PUSH_ALLOW_HTTP: '1' }, stdio: ['ignore', 'pipe', 'pipe'] });server.stdout.on('data', d => log += d); server.stderr.on('data', d => log += d);for (let i = 0; ; i++) { try { if ((await fetch(BASE + '/')).ok) break; } catch {} if (i > 600) throw new Error('server did not come up\n' + log); await sleep(250); }say('app up');if (process.env.PUSH_GATE_ONLY5) { await first(alice, bob); return; }let page, text = '';if (!process.env.PUSH_GATE_ONLY3 && !process.env.PUSH_GATE_ONLY4) {// ---- 1 ok: subscribed by a real tap, browser closed, the push arrives with the title ----const sub1 = newAgent('/ok/dev1');page = await phone(alice, sub1);await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});await tap(page, '#month-title'); await sleep(800);await shot(page, 'ok-1-before-tap');await openSettings(page);const askShown = await page.evaluate(`!document.querySelector('#notify-ask').classList.contains('hidden')`);say('button offered: ' + askShown + ' (permission ' + await page.evaluate('Notification.permission') + ')');if (askShown) await tap(page, '#notify-ask');text = '';for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }await shot(page, 'ok-2-subscribed');if (!/closed/.test(text)) console.log('---- page console\n' + page.dumpConsole().slice(-1500));check('1 the tap subscribes: the page says reminders also reach it when the calendar is closed', /also reach this device when the calendar is closed/.test(text), J(text));const v1 = await vis(page);check('1 subscribed: "Turn on" is hidden, test + off are shown (one state)', !v1.ask && v1.test && v1.off, J(v1));check('1 subscribe got the app\'s VAPID key and userVisibleOnly', (await page.evaluate('window.__subKey')) === PUB + '|true', await page.evaluate('window.__subKey'));if (process.env.PUSH_GATE_STOP1 && !/closed/.test(text)) return;const at1 = await addEvent(page, 'Zahnarzt Push', 150000);say('reminder at ' + new Date(at1).toTimeString().slice(0, 8) + '; closing the browser');await browser.close(); browser = null; // the phone's browser is gone: only the server can reach the device nowawait until(at1 + 20000);const got1 = received.filter(x => x.url === '/ok/dev1');say('fake push service got: ' + J(got1.map(x => ({ late: Math.round((x.at - at1) / 1000), plain: x.plain }))));check('1 the reminder was pushed to the closed device, once', got1.length === 1, J(got1.map(x => x.plain)));const p1 = got1[0] && got1[0].plain ? JSON.parse(got1[0].plain) : {};check('1 the payload (decrypted like a user agent) is the event title and "Starts in 1 minute"', p1.title === 'Zahnarzt Push' && p1.body === 'Starts in 1 minute' && /^[\w-]+:\d+$/.test(p1.tag || ''), J(p1));check('1 it came at the reminder time (within 15 s)', got1[0] && got1[0].at >= at1 - 1000 && got1[0].at - at1 < 15000, got1[0] && (got1[0].at - at1) + ' ms');const h = got1[0] ? got1[0].headers : {};const mm = /^vapid t=([\w-]+)\.([\w-]+)\.([\w-]+), k=([\w-]+)$/.exec(h.authorization || '');check('1 VAPID: k is the app\'s public key and the JWT verifies; aes128gcm', !!mm && mm[4] === PUB && verify('sha256', Buffer.from(mm[1] + '.' + mm[2]), { key: app.publicKey, dsaEncoding: 'ieee-p1363' }, Buffer.from(mm[3], 'base64url')) && h['content-encoding'] === 'aes128gcm', J(h));await sleep(4000);check('1 nothing is sent twice for the same reminder', received.filter(x => x.url === '/ok/dev1').length === 1, String(received.length));// ---- 2 gone: the service answers 410 → the subscription is dropped (no second push for the next reminder) ----const sub2 = newAgent('/gone/dev2');page = await phone(bob, sub2);await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});await tap(page, '#month-title'); await sleep(800);await openSettings(page);await tap(page, '#notify-ask');text = ''; for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }const a = await addEvent(page, 'Gone one', 150000);const b = await addEvent(page, 'Gone two', 150000 + 70000);await browser.close(); browser = null;await until(b + 20000);const got2 = received.filter(x => x.url === '/gone/dev2');say('gone device saw: ' + J(got2.map(x => x.plain)));check('2 the first reminder went to the dead subscription (410)', got2.length >= 1 && JSON.parse(got2[0].plain).title === 'Gone one', J(got2.map(x => x.plain)));check('2 after the 410 the subscription is dropped: the next reminder is not sent to it', got2.length === 1, J(got2.map(x => x.plain)));}// ---- 3 shown again + off: a device that already allowed notifications is subscribed when the app is shown again (no tap); "Turn off on this device"// unsubscribes it and the server drops it: the reminder is not pushed to it, and a reload does not subscribe it again ----if (!process.env.PUSH_GATE_ONLY4) {if (process.env.PUSH_GATE_ONLY3) received.push({ url: '/ok/dev1', plain: 'Off device' });const sub3 = newAgent('/ok/dev3');page = await phone(alice, sub3);await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});await page.goto(BASE + '/', { timeout: 120000 }); await hydrated(page); // permission is there before the page loads: no touch at allawait sleep(3000);// the first `pageshow` comes before the page's components are hydrated (measured: no subscription at load, Hybriel's `on client shown`// only hears later shows); a tab shown again (visibilitychange → visible) subscribes without any touchconst atLoad = await pushText(page);await page.evaluate(`document.dispatchEvent(new Event('visibilitychange'))`);text = ''; for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }check('3 permission already given: the app shown again subscribes the device without any touch (not yet at first load: "' + atLoad + '")', /also reach this device when the calendar is closed/.test(text), J(text));await openSettings(page);await shot(page, 'off-1-on');const offVisible = await page.evaluate(`(() => { const e = document.querySelector('#push-off'); if (!e || e.classList.contains('hidden')) return null; const r = e.getBoundingClientRect(); return { h: r.height, w: r.width, text: e.textContent }; })()`);check('3 "Turn off on this device" is shown next to the on-state text, a 44 px tap', !!offVisible && offVisible.h >= 44 && /Turn off on this device/.test(offVisible.text), J(offVisible));await tap(page, '#push-off'); await sleep(2500);await shot(page, 'off-2-off');const unsubs = await page.evaluate('window.__unsub || 0'); text = await pushText(page);check('3 the tap unsubscribes the browser and the page says reminders show only while open', unsubs === 1 && /while the calendar is open/.test(text), unsubs + ' ' + J(text));const v3 = await vis(page);check('3 the control is gone and "Turn on notifications" is offered again (and only it)', v3.ask && !v3.test && !v3.off, J(v3));// "Turn on" after "off" (the state on caramboleyo's phone showed Turn on + test + off together: the state was read before the off choice was undone)await tap(page, '#notify-ask');const seenStates = []; text = '';for (let i = 0; i < 60 && !/closed/.test(text); i++) { await sleep(150); text = await pushText(page); seenStates.push(await vis(page)); }check('3 "Turn on" after "off": subscribed again, at no moment two states at once', /closed/.test(text) && seenStates.every(oneState), J(seenStates.filter(x => !oneState(x))));const v3b = await vis(page);check('3 after "Turn on" the button is gone and test + off are back', !v3b.ask && v3b.test && v3b.off, J(v3b));await tap(page, '#push-off'); await sleep(2000);await page.goto(BASE + '/', { timeout: 120000 }); await hydrated(page); await sleep(6000);check('3 a reload does not subscribe the device again', !/closed/.test(await pushText(page)) && (await page.evaluate('window.__subKey')) == null, J(await pushText(page)));const c = await addEvent(page, 'Off device', 150000);await browser.close(); browser = null;await until(c + 20000);const got3 = received.filter(x => x.url === '/ok/dev3');check('3 after "off" no push reaches that device (its server row is gone)', got3.length === 0, J(got3.map(x => x.plain)));check('3 the same reminder still reached the owner\'s other device', received.some(x => x.url === '/ok/dev1' && /Off device/.test(x.plain || '')), J(received.map(x => x.url)));}// ---- 4 test notification (calendar#12): "Send a test notification" on a subscribed device → ONE push to that device only, ~10 s later,// with the calendar closed: title "Calendar test", body "Push works on this device" ----const sub4 = newAgent('/ok/dev4'), sub1 = { endpoint: `http://127.0.0.1:${FPORT}/ok/dev1` };page = await phone(bob, sub4);await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});await tap(page, '#month-title'); await sleep(800);await openSettings(page);if (await page.evaluate(`!document.querySelector('#notify-ask').classList.contains('hidden')`)) await tap(page, '#notify-ask'); // a device that allowed notifications before is subscribed by the first touch alreadytext = ''; for (let i = 0; i < 40 && !/closed/.test(text); i++) { await sleep(500); text = await pushText(page); }const testBtn = await page.evaluate(`(() => { const e = document.querySelector('#push-test'); if (!e || e.classList.contains('hidden')) return null; const r = e.getBoundingClientRect(); return { h: r.height, text: e.textContent }; })()`);await shot(page, 'test-1-button');check('4 a subscribed device offers "Send a test notification" (44 px tap)', !!testBtn && testBtn.h >= 44 && /Send a test notification/.test(testBtn.text), J(testBtn));const before4 = received.filter(x => x.url === '/ok/dev4').length;await tap(page, '#push-test'); const t4 = Date.now();text = ''; for (let i = 0; i < 20 && !/on its way/.test(text); i++) { await sleep(500); text = await pushText(page); }await shot(page, 'test-2-sent');check('4 the page says the test is on its way', /on its way/.test(text), J(text));await sleep(1500);check('4 not at once: the phone has time to leave the app (nothing yet after 1.5 s)', received.filter(x => x.url === '/ok/dev4').length === before4);// abuse: a second tap within 30 s is refused (rate limit per device); bob cannot test alice's device (/ok/dev1) — owner onlyawait tap(page, '#push-test'); await sleep(1500); text = await pushText(page);check('4 a second test within 30 s is refused ("wait 30 seconds")', /wait 30 seconds/.test(text), J(text));const cookie4 = (await page.cookies([BASE])).map(c => c.name + '=' + c.value).join('; ');const emitTest = async (ep, i) => JSON.parse(await (await fetch(BASE + '/__hl/emit', { method: 'POST', headers: { 'content-type': 'application/json', cookie: cookie4 }, body: J({ t: 'emit', i, event: 'calPushTest', payload: [ep] }) })).text());const foreign = await emitTest(sub1.endpoint, 7), none = await emitTest('https://example.org/x', 8);check('4 a test for a device that is not the signed-in user\'s is refused', !!foreign.value && !!foreign.value.error && !!none.value && !!none.value.error, J([foreign, none]));await browser.close(); browser = null;await until(t4 + 25000);const got4 = received.filter(x => x.url === '/ok/dev4').slice(before4);const p4 = got4[0] && got4[0].plain ? JSON.parse(got4[0].plain) : {};check('4 ONE test push reached the closed device, 8-20 s after the tap, with title "Calendar test" and body "Push works on this device"', got4.length === 1 && p4.title === 'Calendar test' && p4.body === 'Push works on this device' && got4[0].at - t4 > 8000 && got4[0].at - t4 < 20000, J(got4.map(x => [x.at - t4, x.plain])));await first(alice, bob);check('4 no other device got a test (alice\'s dev1 neither)', !received.some(x => x.at >= t4 && x.url !== '/ok/dev4' && /Calendar test/.test(x.plain || '')), J(received.filter(x => x.at >= t4).map(x => x.url)));}// ---- 5 FIRST LOOK on a touch phone (C13, caramboleyo's phone): the page is opened and NOT touched (no grid, no month header); straight to the menu, then the// reminder settings: the notification state must be right at once. No permission yet → only "Turn on"; permission given → subscribed by opening// the settings (the menu is outside the month view, no pointer event of the month view came) and never "Turn on" + test + off together ----async function first(alice, bob) {let page, text = "";const subA = newAgent('/ok/dev5');page = await phone(alice, subA); // permission NOT granted: "default"await page.goto(BASE + '/', { timeout: 120000 }); await hydrated(page); await sleep(1500);await openSettings(page);const vA = await vis(page); const tA = await pushText(page);await shot(page, 'first-1-default');check('5 first look, no permission yet, nothing touched before: only "Turn on notifications" (no test, no off, no blocked hint)', vA.ask && !vA.test && !vA.off && !vA.blocked && !!tA, J([vA, tA]));await browser.close(); browser = null;const subB = newAgent('/ok/dev6');page = await phone(bob, subB);await page.send('Browser.grantPermissions', { origin: BASE, permissions: ['notifications'] }).catch(() => {});await page.goto(BASE + '/', { timeout: 120000 }); await hydrated(page); await sleep(1500);await openSettings(page);const states = []; text = '';for (let i = 0; i < 100 && !/closed/.test(text); i++) { text = await pushText(page); states.push(await vis(page)); await sleep(150); }await shot(page, 'first-2-granted');check('5 first look, permission given, nothing touched before: opening the settings subscribes the device (no grid touch needed)', /also reach this device when the calendar is closed/.test(text), J(text));check('5 never "Turn on" together with test / off while it loads', states.every(oneState), J(states.filter(x => !oneState(x))));const vB = await vis(page);check('5 settled: "Turn on" hidden, test + off shown', !vB.ask && vB.test && vB.off && !vB.blocked, J(vB));}try { await main(); } catch (e) { check('gate ran', false, String(e && e.stack || e)); }if (failures) console.log('---- server log (tail)\n' + log.slice(-2500));await stopAll();console.log(`${passes} passed, ${failures} failed (app ${APP})`);process.exit(failures ? 1 : 0);
Branches
Latest commits
- e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas
- eff166a4Re-vendor complete Hybriel plugins and runtime to day44mre
- cef81394Wait for the DST fixture page instead of an unused socketmre
- 42434f47Check lazy-session cookies after login with a stored anonymous fixturemre
- 728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre
- cbd7ff43Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 59d1da0acalendar: plain declarations instead of needless let in 9 files (calendar#17): 49 declarations that are never reassigned; reassigned ones and the timer closure's p stay letmre
- f5415cf9calendar: the Style blocks in the language's nested form (calendar#16): rules named after the View's own elements with their children nested, pseudo-classes and @media nested, merged duplicate select rule; same CSS, shots identical in Chrome at 4 sizesmre
- edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
- bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre
- 5d8579d7README: login.js stays by caramboleyo's explicit rulemre
- cc759328Merge sb3-standby: calendar deploys through its standbymre
- f2fcdc6dcalendar: a standby container (port 45015, profile standby, reminder clock off) and a /health page; deploy hands over through standby-swap.sh without a gapmre
- 229643f7Merge branch 'cal-14'mre
- 1110b26fcalendar#14: the month name no longer breaks into two lines on a phone (Reminder settings drops to its own row when the header is too narrow), gate checks for one-line title and all header controls on screenmre
- 490c658aident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- 18095868calendar: Reminder settings button opens its dialog again (the dialog's open handler still closed the removed user menu and stopped); old e2e and gate scripts use the new headermre
- 6eee4b5acalendar header: the selector alone top right plus Log out as before the theme missions; Reminder settings back on the month page (WIP: the settings test still fails)mre
- 0b909decident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- 0c8f9364Merge branch 'sy-sync'mre