ident
All repositories: gitoria
25.3 KB
// tests/delivery.mjs — THE GATE OF PIECE 5 (ticket ident#7, mission 011): the daily mail at 17:00 in the user's time// zone, urgent at once. A FAKE CLOCK: the server runs with IDENT_TEST_CLOCK = a file holding an epoch-ms instant that// delivery takes as "now" (lib/delivery-helpers.hl clockNow) and IDENT_DIGEST_EVERY=0.2 (a round every 200 ms); this// script moves that instant. Real headless Chrome (tests/cdp.mjs) for what users do (sign in with the browser's// emulated zone, switch mail off on the per-app page, change the zone on `/`); this script plays the APP'S SERVER.// users: vienna (Europe/Vienna), newyork (America/New_York), tokyo (Asia/Tokyo), off (Europe/Vienna, switches the// app's mail off), utc (signs in with a zone nobody knows → UTC).// checks: nothing before anyone's 17:00; urgent arrives at once (and not again in the digest); each user's digest at// THEIR 17:00 (16:59 = nothing), exactly once, only their own notifications, name/app/identity/text/link; "off" gets// nothing (switched off before AND after arrival); one arriving after 17:00 waits for tomorrow; a server that was// down at 17:00 sends at its first round after it; a restart sends nothing twice; DST days (Vienna 25 Oct 2026,// New York 1 Nov 2026: 17:00 is an hour later in UTC); a zone changed on `/` moves the hour (Australia/Adelaide, +10:30).// Own servers only, NEVER real mail: ident :8700 (IDENT_MAIL_SINK; notification mails = <sink>.mail, JSON lines).// Own storage .scratch/delivery-gate/ (wiped at start). Chrome debug ports 8706-8719.// Screenshots .scratch/delivery-account-{390,1280}.png — look at them.// Run: node tests/delivery.mjs (exit 0 = all passed)import { spawn, execFileSync } from 'node:child_process';import { readFileSync, writeFileSync, rmSync, mkdirSync, existsSync, cpSync } from 'node:fs';import { dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';import { launchBrowser, sleep } from './cdp.mjs';// H2: a server-rendered page can be clicked before the client mounted — the click is lost (or a native form GET). Every goto() on a Hybriel// page (the SSR HTML carries #hl-seed) therefore waits until the page is live (socket open) before the test touches it.function live(page) {const goto = page.goto.bind(page);page.goto = async (url, o) => {const r = await goto(url, o);await page.waitFor("!document.getElementById('hl-seed') || (!!window.__hl && !!window.__hl.socket && window.__hl.socket.readyState === 1)", { label: 'page hydrated ' + url });return r;};return page;}if (!process.env.HL_CHROME && existsSync('/opt/google/chrome/chrome')) process.env.HL_CHROME = '/opt/google/chrome/chrome';const APP = join(dirname(fileURLToPath(import.meta.url)), '..');const G = join(APP, '.scratch/delivery-gate');const SHOTS = join(APP, '.scratch');const PORT = Number(process.env.DELIVERY_GATE_PORT || 8700); // deploy gates run beside workers: give it a free slotconst ID = 'http://127.0.0.1:' + PORT;const SITE = 'http://127.0.0.1:' + (PORT + 1); // the app's origin (only in URLs: nothing listens there)const CHROME_PORTS = (process.env.DELIVERY_GATE_CHROME || '8706-8719').split('-').map(Number);const J = JSON.stringify;const STORE = join(G, 'ident'), SINK = join(G, 'mail.txt'), MAILS = SINK + '.mail', CLOCK = join(G, 'clock');let passed = 0, failed = 0;const check = (name, ok, detail = '') => {if (ok) { passed++; console.log(' ok ' + name); }else { failed++; console.log(' FAIL ' + name + (detail ? ' — ' + detail : '')); }};// ---- the server and its clock ----------------------------------------------------------let proc = null, log = '';function startServer() {log = '';proc = spawn(join(APP, 'bin/hybriel'), ['project.hl'], {cwd: APP, stdio: ['ignore', 'pipe', 'pipe'],env: { ...process.env, SMTP_HOST: '', SMTP_USER: '', SMTP_PASSWORD: '', IDENT_PORT: String(PORT), IDENT_STORAGE: STORE,IDENT_SESSIONS: join(G, 'sess') + '/', IDENT_MAIL_SINK: SINK, IDENT_IP_LIMIT: '1000', IDENT_IP_DAY_LIMIT: '1000',IDENT_TEST_CLOCK: CLOCK, IDENT_DIGEST_EVERY: '0.2', IDENT_WATCH: '0' },});proc.stdout.on('data', d => { log += d; }); proc.stderr.on('data', d => { log += d; });}async function up() { // a cold start compiles the app first (18-41 s): wait up to 150 sfor (let i = 0; i < 600; i++) { try { await fetch(ID + '/', { redirect: 'manual' }); return; } catch {} await sleep(250); }throw new Error('server did not come up');}async function stopServer() {const p = proc; proc = null;writeFileSync(join(G, 'ident-' + Date.now() + '.log'), log);await new Promise(r => { p.on('exit', r); p.kill(); });}const at = (iso) => Date.parse(iso);function setClock(iso) { writeFileSync(CLOCK, String(at(iso))); }const ROUNDS = 1500; // ≥ 7 rounds of 200 ms// ---- the mail sink -----------------------------------------------------------------------const mails = () => existsSync(MAILS) ? readFileSync(MAILS, 'utf8').trim().split('\n').filter(Boolean).map(l => JSON.parse(l)) : [];const mailsTo = (email) => mails().filter(m => m.to === email);async function waitMails(n, ms = 5000) { const t0 = Date.now(); while (Date.now() - t0 < ms) { if (mails().length >= n) return; await sleep(100); } }const lastCode = (email) => {const lines = readFileSync(SINK, 'utf8').trim().split('\n').filter(l => l.startsWith(email + ' '));return lines.length ? lines[lines.length - 1].split(' ')[1] : null;};// ---- HTTP helpers (as tests/notify.mjs) ---------------------------------------------------let emitI = 0;async function emit(event, payload, cookie) {const r = await fetch(ID + '/__hl/emit', { method: 'POST', headers: { 'content-type': 'application/json', ...(cookie ? { cookie } : {}) }, body: J({ t: 'emit', i: ++emitI, event, payload }) });const t = await r.text();let j = null; try { j = JSON.parse(t); } catch {}return { status: r.status, cookie: (r.headers.get('set-cookie') || '').split(';')[0], value: j && j.value, raw: t };}async function api(path, body) {const r = await fetch(ID + path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: J(body) });const t = await r.text();let j = null; try { j = JSON.parse(t); } catch {}return { status: r.status, j, t };}async function apiLogin(email, zone) {const q = await fetch(ID + '/api/code', { method: 'POST', headers: { 'content-type': 'application/json' }, body: J({ email }) });if (q.status !== 200) throw new Error('code request failed: ' + q.status);const v = await emit('verifyCode', [email, lastCode(email), zone]);if (!v.value || !v.value.account || !v.cookie) throw new Error('api login failed: ' + v.raw);return { cookie: v.cookie, identity: v.value.identities[0].id };}async function appIdentity(cookie, app, identity) {const l = await fetch(ID + '/login?key=' + app.key + '&return=' + encodeURIComponent(SITE + '/callback'), { redirect: 'manual' });const rid = (l.headers.get('location') || '').split('/').pop();const c = await emit('chooseIdentity', [rid, identity], cookie);const code = new URL(c.value.url).searchParams.get('ident_code');const x = await api('/api/exchange', { key: app.key, secret: app.secret, code });if (x.status !== 200) throw new Error('exchange failed: ' + x.t);return x.j.identity;}let copyN = 0;function store() {const copy = join(G, 'copy-' + (++copyN));cpSync(STORE, copy, { recursive: true });const out = execFileSync(join(APP, 'bin/hybriel'), ['tools/dump-store.hl'], { cwd: APP, env: { ...process.env, IDENT_STORAGE: copy }, encoding: 'utf8' });rmSync(copy, { recursive: true, force: true });return JSON.parse(out.split('\n').find(l => l.startsWith('{')));}// ---- browser helpers -------------------------------------------------------------------------const pages = [];async function ready(p) { await p.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1', { label: 'hydrated' }); }async function viewport(p, w) { await p.send('Emulation.setDeviceMetricsOverride', { width: w, height: w < 500 ? 844 : 900, deviceScaleFactor: 1, mobile: w < 500 }); }const txt = (p, sel) => p.evaluate(`(document.querySelector(${J(sel)}) || {}).textContent || ''`);const attr = (p, sel, a) => p.evaluate(`(document.querySelector(${J(sel)}) || { getAttribute: () => null }).getAttribute(${J(a)})`);// a user in their own Chrome, the browser's zone emulated: email → code → Skip. Answers { page, cookie, identity }async function browserUser(email, zone) {const br = await launchBrowser({ debugPortRange: CHROME_PORTS }); browsers.push(br);const p = live(await br.newPage()); pages.push(p);await viewport(p, 1280);await p.send('Emulation.setTimezoneOverride', { timezoneId: zone });await p.goto(ID + '/');await p.waitForSelector('#email'); await ready(p);await p.type('#email', email);await p.click('#sendcode');await p.waitFor('/\\/code$/.test(location.pathname) && !!document.querySelector("#code")', { label: 'code page' });await ready(p);await p.type('#code', lastCode(email));await p.click('#verify');await p.waitForSelector('#skip');await p.click('#skip');await p.waitFor('!document.querySelector("#identityform") && !!document.querySelector("#timezone")', { label: 'signed in' });const { cookies } = await p.send('Network.getCookies', { urls: [ID + '/'] });const c = cookies.find(x => x.name === 'identsid');const st = store();const account = st.accounts.find(a => a.email === email);return { page: p, cookie: 'identsid=' + c.value, identity: st.identities.find(i => i.account === account.id).id };}const browsers = [];let clean = [];rmSync(G, { recursive: true, force: true });mkdirSync(G, { recursive: true });try {setClock('2026-10-21T05:00:00Z'); // Vienna 07:00, New York 01:00, Tokyo 14:00 — before 17:00 everywherestartServer();await up();// ==== 0. users, the app, per-app ids ====================================================console.log('# setup: users in Vienna, New York, Tokyo, one who switches mail off, one without a known zone');const V = '[email protected]', NY = '[email protected]', T = '[email protected]', OFF = '[email protected]', U = '[email protected]';const vienna = await browserUser(V, 'Europe/Vienna');check('vienna: the browser\'s zone stored at the first login, the page says when the daily mail comes', (await txt(vienna.page, '#timezone')) === 'Europe/Vienna' && /daily mail .* 17:00 in this time zone/.test(await txt(vienna.page, '#digestnote')), await txt(vienna.page, '#timezonesection'));for (const w of [390, 1280]) {await viewport(vienna.page, w); await sleep(200);const over = await vienna.page.evaluate('document.documentElement.scrollWidth > window.innerWidth');check(`account page @${w}px: no horizontal overflow`, !over);await vienna.page.evaluate('document.querySelector("#timezonesection").scrollIntoView()');const { data } = await vienna.page.send('Page.captureScreenshot', { format: 'png' });writeFileSync(join(SHOTS, `delivery-account-${w}.png`), Buffer.from(data, 'base64'));}await viewport(vienna.page, 1280);const newyork = await browserUser(NY, 'America/New_York');check('newyork: zone America/New_York', (await txt(newyork.page, '#timezone')) === 'America/New_York', await txt(newyork.page, '#timezone'));const off = await browserUser(OFF, 'Europe/Vienna');const tokyo = await apiLogin(T, 'Asia/Tokyo');const utc = await apiLogin(U, 'Mars/Olympus_Mons');let s = store();const acct = (e) => s.accounts.find(a => a.email === e);check('a zone the database does not know is stored as UTC at the first login', acct(U).timeZone === 'UTC' && acct(T).timeZone === 'Asia/Tokyo', J([acct(U).timeZone, acct(T).timeZone]));let e = await emit('changeTimeZone', ['Mars/Olympus_Mons'], tokyo.cookie);check('changeTimeZone: an unknown zone of the right shape is refused by the SERVER (hl:time isZone)', e.value && /unknown time zone/.test(e.value.error), e.raw);e = await emit('changeTimeZone', ['Asia/Tokyo'], tokyo.cookie);check('changeTimeZone: a known zone is taken', e.value && e.value.timeZone === 'Asia/Tokyo', e.raw);const appV = (await emit('appCreate', [{ name: 'Chat app', origins: [SITE] }], tokyo.cookie)).value;const A = { key: appV.app.apiKey, secret: appV.secret };const idV = await appIdentity(vienna.cookie, A, vienna.identity);const idNY = await appIdentity(newyork.cookie, A, newyork.identity);const idOff = await appIdentity(off.cookie, A, off.identity);const idT = await appIdentity(tokyo.cookie, A, tokyo.identity);const idU = await appIdentity(utc.cookie, A, utc.identity);let r = await api('/api/kinds', { key: A.key, secret: A.secret, kinds: [{ name: 'Comment', push: false, email: true }, { name: 'Alert', push: true, email: false }] });check('the app registers Comment (mail) and Alert (push)', r.status === 200, r.t);const send = async (identity, body) => { const x = await api('/api/notify', { key: A.key, secret: A.secret, identity, ...body }); if (x.status !== 200) throw new Error('send failed: ' + x.t); return x.j.id; };// ==== 1. notifications arrive; nothing is mailed before 17:00 ===========================console.log('# before 17:00');const T1 = await send(idT, { name: 'Comment', text: 'TOKYO-ONE: Bea commented', link: SITE + '/post/1' });const T2 = await send(idT, { name: 'Comment', text: 'TOKYO-TWO first line\nsecond line' });const V1 = await send(idV, { name: 'Comment', text: 'VIENNA-ONE', link: SITE + '/post/2' });const V2 = await send(idV, { name: 'Mention', text: 'VIENNA-TWO (an unregistered name: daily mail)' });const N1 = await send(idNY, { name: 'Comment', text: 'NEWYORK-ONE' });const O1 = await send(idOff, { name: 'Comment', text: 'OFF-ONE (arrived while mail was on)' });const U1 = await send(idU, { name: 'Comment', text: 'UTC-ONE' });// "off" switches the app's mail off on the per-app page: override all → on, email → offs = store();const connOff = s.connections.find(c => c.identity === off.identity);await off.page.goto(ID + '/inbox/' + connOff.id); await off.page.waitForSelector('#ovactive'); await ready(off.page);await off.page.click('#ovactive');await off.page.waitFor('document.querySelector("#ovactive").getAttribute("aria-checked") === "true"', { label: 'override on' });await off.page.click('#ovemail');await off.page.waitFor('document.querySelector("#ovemail").getAttribute("aria-checked") === "false"', { label: 'email off' });check('off: the per-app page shows mail off for every kind', (await attr(off.page, '#ovemail', 'aria-checked')) === 'false');const O2 = await send(idOff, { name: 'Comment', text: 'OFF-TWO (arrived with mail off)' });await sleep(ROUNDS);check('05:00 UTC: no mail yet (before 17:00 in every zone)', mails().length === 0, J(mails()));// ==== 2. urgent: at once ====================================================================console.log('# urgent');const VU = await send(idV, { name: 'Alert', text: 'VIENNA-URGENT server down', link: SITE + '/status', urgent: true });let m = mails();check('urgent: mailed AT ONCE (before the answer), to vienna only', m.length === 1 && m[0].to === V, J(m));check('urgent mail: subject "<app>: <name>", text + link', m[0] && m[0].subject === 'Chat app: Alert' && m[0].text.includes('VIENNA-URGENT server down') && m[0].text.includes(SITE + '/status'), J(m[0]));const OU = await send(idOff, { name: 'Alert', text: 'OFF-URGENT', urgent: true });await sleep(300);check('urgent for a user with mail AND push off: no mail', mails().length === 1, J(mails().map(x => x.to)));s = store();const note = (id) => s.notifications.find(n => n.id === id);check('stored: the urgent one is mailed (mailSent, mailedAt), the off one is mail none, unsent', note(VU).mailSent === true && note(VU).mailedAt > 0 && note(OU).mail === 'none' && note(OU).mailSent === false, J([note(VU), note(OU)]));// ==== 3. Tokyo's 17:00 (08:00 UTC) =========================================================console.log('# Tokyo 17:00 = 08:00 UTC');setClock('2026-10-21T07:59:00Z'); await sleep(ROUNDS);check('Tokyo 16:59: no daily mail', mails().length === 1, J(mails().map(x => x.subject)));setClock('2026-10-21T08:00:00Z'); await waitMails(2); await sleep(ROUNDS);m = mailsTo(T);check('Tokyo 17:00: ONE daily mail to tokyo, nobody else', m.length === 1 && mails().length === 2, J(mails().map(x => x.to + ' ' + x.subject)));check('tokyo\'s mail: subject counts 2, dated tokyo\'s local day', m[0] && m[0].subject === 'ident: 2 notifications (2026-10-21)', m[0] && m[0].subject);check('tokyo\'s mail lists both: name — app · identity, text (line breaks kept), action link, the zone', m[0] && m[0].text.includes('* Comment — Chat app · Default') && m[0].text.includes('TOKYO-ONE: Bea commented') && m[0].text.includes('TOKYO-TWO first line\n second line') && m[0].text.includes(SITE + '/post/1') && m[0].text.includes('(17:00, Asia/Tokyo)') && m[0].text.indexOf('TOKYO-ONE') < m[0].text.indexOf('TOKYO-TWO'), m[0] && m[0].text);check('tokyo\'s mail holds nobody else\'s', m[0] && !/VIENNA|NEWYORK|OFF-|UTC-ONE/.test(m[0].text));await sleep(ROUNDS);check('Tokyo: not twice (more rounds at 17:00+)', mailsTo(T).length === 1);s = store();check('stored: tokyo\'s two mailed, its round dated 2026-10-21 (count 2)', note(T1).mailSent && note(T2).mailSent && s.digests.some(d => d.account === acct(T).id && d.lastDate === '2026-10-21' && d.count === 2), J(s.digests));const T3 = await send(idT, { name: 'Comment', text: 'TOKYO-THREE (after 17:00: tomorrow)' });await sleep(ROUNDS);check('one arriving after Tokyo\'s 17:00 is not mailed today', mailsTo(T).length === 1);// ==== 4. Vienna's 17:00 (CEST: 15:00 UTC), New York's (EDT: 21:00 UTC), UTC's =================console.log('# Vienna 17:00 = 15:00 UTC, UTC 17:00, New York 17:00 = 21:00 UTC');setClock('2026-10-21T14:59:00Z'); await sleep(ROUNDS);check('Vienna 16:59: nothing for vienna or off', mailsTo(V).length === 1 && mailsTo(OFF).length === 0);setClock('2026-10-21T15:00:00Z'); await waitMails(3); await sleep(ROUNDS);m = mailsTo(V);check('Vienna 17:00: vienna\'s daily mail (one)', m.length === 2 && m[1].subject === 'ident: 2 notifications (2026-10-21)', J(m.map(x => x.subject)));check('vienna\'s mail: VIENNA-ONE + the unregistered Mention, NOT the urgent one again', m[1] && m[1].text.includes('VIENNA-ONE') && m[1].text.includes('* Mention — Chat app') && !m[1].text.includes('VIENNA-URGENT'), m[1] && m[1].text);check('off (Vienna too): nothing — one switched off after it arrived, one that arrived switched off', mailsTo(OFF).length === 0);setClock('2026-10-21T16:59:00Z'); await sleep(ROUNDS);check('UTC 16:59: nothing for utc (its zone: UTC, the default)', mailsTo(U).length === 0);setClock('2026-10-21T17:00:00Z'); await waitMails(4); await sleep(ROUNDS);check('UTC 17:00: utc\'s daily mail', mailsTo(U).length === 1 && mailsTo(U)[0].text.includes('UTC-ONE') && mailsTo(U)[0].text.includes('(17:00, UTC)'), J(mailsTo(U)));setClock('2026-10-21T20:59:00Z'); await sleep(ROUNDS);check('New York 16:59: nothing for newyork', mailsTo(NY).length === 0);setClock('2026-10-21T21:00:00Z'); await waitMails(5); await sleep(ROUNDS);check('New York 17:00: newyork\'s daily mail, dated its local day', mailsTo(NY).length === 1 && mailsTo(NY)[0].subject === 'ident: 1 notification (2026-10-21)' && mailsTo(NY)[0].text.includes('NEWYORK-ONE'), J(mailsTo(NY)));check('after the day: 5 mails in all (1 urgent + 4 daily), none to off', mails().length === 5 && mailsTo(OFF).length === 0, J(mails().map(x => x.to)));s = store();check('stored: off\'s are pending, not mailed (not lost: inbox; switched on, tomorrow\'s mail)', note(O1).mail === 'daily' && note(O1).mailSent === false && note(O2).mail === 'none' && note(O2).mailSent === false, J([note(O1), note(O2)]));// ==== 5. down at 17:00, restart: catch up once, never twice =================================console.log('# restart');clean = pages.map(x => x.problems().length);check('no console errors or warnings until the restart', clean.every(n => n === 0), pages.flatMap(x => x.problems().map(q => q.text)).join(' | '));await stopServer();setClock('2026-10-22T09:00:00Z'); // Tokyo 18:00 on the 22nd: its 17:00 passed while the server was downstartServer(); await up(); await waitMails(6); await sleep(ROUNDS);m = mailsTo(T);check('server down at Tokyo\'s 17:00: the first round after the start sends the 22nd\'s mail, with the one that waited', m.length === 2 && m[1].subject === 'ident: 1 notification (2026-10-22)' && m[1].text.includes('TOKYO-THREE'), J(m.map(x => x.subject)));check('…and nothing else after the restart (no day sent twice)', mails().length === 6, J(mails().map(x => x.to + ' ' + x.subject)));await stopServer();setClock('2026-10-22T09:30:00Z');startServer(); await up(); await sleep(ROUNDS * 2);check('a second restart the same day: nothing (the sent day is stored)', mails().length === 6, J(mails().map(x => x.to + ' ' + x.subject)));s = store();check('stored: TOKYO-THREE mailed', note(T3).mailSent === true);// ==== 6. DST days ===============================================================================console.log('# DST: Vienna 25 Oct 2026 (CET from 03:00), New York 1 Nov 2026 (EST from 02:00)');const V3 = await send(idV, { name: 'Comment', text: 'VIENNA-DST' });const N2 = await send(idNY, { name: 'Comment', text: 'NEWYORK-DST' });setClock('2026-10-25T15:00:00Z'); await sleep(ROUNDS); // Vienna 16:00 CET (17:00 at the summer offset)check('Vienna DST day, 15:00 UTC = 16:00 CET: nothing yet (a fixed +2 would send)', mailsTo(V).length === 2, J(mailsTo(V).map(x => x.subject)));setClock('2026-10-25T16:00:00Z'); await waitMails(7); await sleep(ROUNDS);check('Vienna DST day, 16:00 UTC = 17:00 CET: vienna\'s mail, dated the 25th', mailsTo(V).length === 3 && mailsTo(V)[2].subject === 'ident: 1 notification (2026-10-25)' && mailsTo(V)[2].text.includes('VIENNA-DST'), J(mailsTo(V).map(x => x.subject)));setClock('2026-11-01T21:00:00Z'); await sleep(ROUNDS); // New York 16:00 ESTcheck('New York DST day, 21:00 UTC = 16:00 EST: nothing yet', mailsTo(NY).length === 1, J(mailsTo(NY).map(x => x.subject)));setClock('2026-11-01T22:00:00Z'); await waitMails(8); await sleep(ROUNDS);check('New York DST day, 22:00 UTC = 17:00 EST: newyork\'s mail, dated 1 Nov', mailsTo(NY).length === 2 && mailsTo(NY)[1].subject === 'ident: 1 notification (2026-11-01)' && mailsTo(NY)[1].text.includes('NEWYORK-DST'), J(mailsTo(NY).map(x => x.subject)));check('nothing else on those days (no pending = no mail, off still nothing)', mails().length === 8 && mailsTo(OFF).length === 0, J(mails().map(x => x.to + ' ' + x.subject)));// ==== 7. the user changes the zone on `/`: the hour follows ==================================console.log('# vienna moves to Australia/Adelaide (+10:30 in November, its summer time) on the account page');const p = vienna.page;await p.goto(ID + '/'); await p.waitForSelector('#tzinput'); await ready(p);await p.type('#tzinput', 'Australia/Adelaide', { clear: true });await p.click('#savetz');await p.waitFor('document.querySelector("#timezone").textContent === "Australia/Adelaide"', { label: 'zone saved' });check('account page: zone changed to Australia/Adelaide (typed, saved)', (await txt(p, '#timezone')) === 'Australia/Adelaide');const V4 = await send(idV, { name: 'Comment', text: 'VIENNA-NOW-ADELAIDE' });setClock('2026-11-02T06:29:00Z'); await sleep(ROUNDS); // Adelaide 16:59 ACDT (Vienna would be 07:29)check('Adelaide 16:59: nothing', mailsTo(V).length === 3);setClock('2026-11-02T06:30:00Z'); await waitMails(9); await sleep(ROUNDS);check('Adelaide 17:00 (06:30 UTC): the mail comes at the new zone\'s 17:00, dated its local day', mailsTo(V).length === 4 && mailsTo(V)[3].subject === 'ident: 1 notification (2026-11-02)' && mailsTo(V)[3].text.includes('VIENNA-NOW-ADELAIDE') && mailsTo(V)[3].text.includes('(17:00, Australia/Adelaide)'), J(mailsTo(V).map(x => x.subject)));setClock('2026-11-02T16:00:00Z'); await sleep(ROUNDS); // Vienna's own 17:00 that day: nothing morecheck('…and not again at Vienna\'s 17:00 (one mail per local day)', mailsTo(V).length === 4);s = store();check('stored: every daily one mailed except off\'s', [T1, T2, T3, V1, V2, V3, V4, N1, N2, U1].every(id => note(id).mailSent === true) && !note(O1).mailSent && !note(O2).mailSent && !note(OU).mailSent, J(s.notifications.map(n => [n.text.slice(0, 12), n.mail, n.mailSent])));check('every mail went to the sink (the server log has no SMTP send)', !/mail: sent/.test(log));// up to the restart: clean. While the gate has the server stopped (section 5) the open pages' socket, hl:web's// reconnect probe (/__hl/up) and the shell's offline probe (/api/online) fail — expected; nothing else may appear.const probs = pages.flatMap((x, i) => x.problems().map(q => q.text).filter((t, k) => k < (clean[i] || 0) || !new RegExp('^network: .*127\\.0\\.0\\.1:' + PORT + '/').test(t)));check('no console errors or warnings (until the restart: none at all; after it: only the stopped server\'s network errors)', probs.length === 0, probs.join(' | '));} catch (err) {failed++;console.log(' FAIL (aborted) ' + (err && err.stack || err));for (const x of pages) console.log('--- console:\n' + x.dumpConsole());} finally {for (const b of browsers) { try { await b.close(); } catch {} }if (proc) { try { await stopServer(); } catch {} }await sleep(300);}console.log(`\n${passed} passed, ${failed} failed`);process.exit(failed ? 1 : 0);
Branches
Latest commits
- 0f6d1592Merge branch 'f18b-shell-session' into mainIdent
- 19868218|||PR ident#39 shell reads its session member instead of a cross-file emitmre
- 5d1b3fedMerge branch 'v61-day61' into mainIdent
- 83faeb15|||PR ident: vendor Hybriel day61mre
- b2572b34Merge branch 'v59-day59' into mainIdent
- 67cf016d|||PR ident: vendor Hybriel day59mre
- 600c043dMerge branch 'v58-day58' into mainIdent
- 365f8c80|||PR ident: vendor Hybriel day58mre
- 585126e5Merge branch 'f16-setf' into mainIdent
- 953bf03a|||PR ident setF mirror dropped (hybriel#370)mre
- a1419d9cMerge branch 'f15-navigate' into mainIdent
- 3b3e451f|||PR ident#36 navigate to the app instead of location.assignmre
- e36f4516Merge branch 'f14-online' into mainIdent
- 2c5eac91|||PR ident#38 online state without probe timermre
- bf1980f2Merge branch 'v56-day56' into mainIdent
- 62ae0adf|||PR ident: vendor Hybriel day56mre
- 0d18abc4Merge branch 'f13-avatar' into mainIdent
- 2a99730a|||PR ident#37 avatar in hlmre
- fa4ed25bMerge branch 'f11-upsert' into mainIdent
- 8f3d9bc9|||PR ident#42 keyed upsert and removemre