calendar
All repositories: gitoria
7.1 KB
// tests/dst.mjs — mission 009: the reminder times of the NEW code (hl:time in the browser) equal python zoneinfo and those of the OLD code// (Intl by hand, tests/dst/old-reminders.hl) except where the old one broke the fold/gap rule (reported, one hour), for 3500 cases per device zone across the DST changes of Europe/Vienna (last// Sundays of March/October), New York, Lord Howe, UTC, Kolkata; timed and all-day events; minutes/hours/days rows.// node tests/dst.mjs env: DST_GATE_PORT (app, default 8700), DST_GATE_CHROME (debug port, default PORT+1), DST_GATE_SCRATCH// Real headless Chrome; its time zone is set to the device zones below (the all-day events are read in the device zone).import { spawn, execFileSync } from 'node:child_process';import { existsSync, mkdirSync, rmSync } from 'node:fs';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';const HERE = dirname(fileURLToPath(import.meta.url));const APP = resolve(HERE, '..');const PORT = Number(process.env.DST_GATE_PORT || 8700);const CPORT = Number(process.env.DST_GATE_CHROME || PORT + 1);const SCRATCH = resolve(process.env.DST_GATE_SCRATCH || join(APP, '.scratch', 'dst-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');let passes = 0, failures = 0;const check = (l, ok, d = '') => { console.log(`${ok ? 'ok ' : 'FAIL'} ${l}${ok ? '' : ' — ' + d}`); ok ? passes++ : failures++; };const sleep = (ms) => new Promise(r => setTimeout(r, ms));// hybriel 8f4e7ffa: wait for this page, which does not need a socket, then let its handlers attach.const hydrated = async (page) => {await page.waitFor("!!window.__hl && document.querySelector('#go') != null", { timeout: 60000, label: 'page hydrated' });await sleep(1500);};// python zoneinfo: the instant of a wall clock in a zone (fold = the earlier instant, gap = moved forward by its length)const py = `import sys, jsonfrom datetime import datetime, timedeltafrom zoneinfo import ZoneInfodef inst(y,mo,d,h,mi,zone):z = ZoneInfo(zone)dt = datetime(y,mo,d,h,mi,tzinfo=z) # fold=0: earlier; a gap reads with the offset before the change = forwardt0 = int(dt.timestamp()*1000); t1 = int(dt.replace(fold=1).timestamp()*1000)AMB.append(t0 != t1)return t0def prev(dstr,n):y,m,d = map(int,dstr.split('-')); return (datetime(y,m,d)-timedelta(days=n)).strftime('%Y-%m-%d')AMB = []cases = json.load(sys.stdin); dev = sys.argv[1]; out = []for c in cases:zone = dev if c['allday'] else c['zone']st = c['startDate'] + ('T00:00' if c['allday'] else 'T' + c['startTime'])p = lambda s: inst(int(s[0:4]),int(s[5:7]),int(s[8:10]),int(s[11:13]),int(s[14:16]),zone)s = p(st)if c['unit']=='minutes': at = s - int(c['n'])*60000elif c['unit']=='hours': at = s - int(c['n'])*3600000else: at = p(prev(c['startDate'], int(c['n'])) + 'T' + c['time'])out.append([at, any(AMB)]); AMB.clear()print(json.dumps(out))`;let server = null, browser = null;async function stop() {if (browser) { try { await browser.close(); } catch {} browser = null; }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; }}try {server = spawn(join(APP, 'bin', 'hybriel'), ['tests/dst/project.hl'], { cwd: APP, env: { ...process.env, DST_GATE_PORT: String(PORT), HL_HOST: '127.0.0.1' }, stdio: 'ignore' });let up = false;for (let i = 0; i < 100 && !up; i++) { await sleep(2000); try { up = (await fetch(`http://127.0.0.1:${PORT}/`)).ok; } catch {} }check('the test page is served', up);if (!up) throw new Error('no server');browser = await launchBrowser({ debugPortRange: [CPORT, CPORT] });const page = await browser.newPage();for (const dev of ['Europe/Vienna', 'America/New_York', 'Australia/Lord_Howe']) {await page.send('Emulation.setTimezoneOverride', { timezoneId: dev });await page.goto(`http://127.0.0.1:${PORT}/`);await page.waitForSelector('#go');await hydrated(page);await page.click('#go');let text = '';for (let i = 0; i < 120 && text.split(';').length < 3500; i++) { await sleep(1000); text = await page.evaluate("document.querySelector('#out').textContent"); }const cases = text.split(';').filter(Boolean).map(l => { const f = l.split('|'); return { id: f[0], zone: f[1], allday: f[2] == 'allday', startDate: f[3], startTime: f[4], unit: f[5], n: f[6], time: f[7], old: f[8], now: f[9] }; });check(`[device ${dev}] cases computed`, cases.length == 3500, 'got ' + cases.length);const refAmb = JSON.parse(execFileSync('python3', ['-I', '-c', py, dev], { input: JSON.stringify(cases), maxBuffer: 1 << 26 }).toString());const ref = refAmb.map(x => x[0]), amb = refAmb.map(x => x[1]);const diffOldNew = cases.filter(c => c.old !== c.now);const diffRef = cases.filter((c, i) => c.now !== String(ref[i]));const nAmb = amb.filter(Boolean).length;// the ONE intended difference: a wall clock inside a fold (autumn, the hour that repeats) or a gap (spring) — old and new disagree where// the Intl by hand picked another instant than the documented rule (fold = the earlier, gap = moved forward); hl:time (as the// server already did for Web Push) follows the rule and python zoneinfo agreesconst unexplained = cases.filter((c, i) => c.old !== c.now && !amb[i]);check(`[device ${dev}] new = python zoneinfo for all ${cases.length} cases`, diffRef.length == 0, diffRef.length + ' differ, first ' + JSON.stringify(diffRef[0]) + ' ref ' + ref[cases.indexOf(diffRef[0])]);check(`[device ${dev}] new = old except in a fold/gap (${diffOldNew.length} of ${nAmb} fold/gap cases differ)`, unexplained.length == 0, unexplained.length + ' differ outside a fold/gap, first ' + JSON.stringify(unexplained[0]));const later = diffOldNew.filter(c => Number(c.now) < Number(c.old)).length, earlier = diffOldNew.length - later;check(`[device ${dev}] every difference is exactly one hour (a whole DST step; ${later} fold cases now earlier, ${earlier} gap cases now later)`, diffOldNew.every(c => Math.abs(Number(c.now) - Number(c.old)) == 3600000));console.log(' differences old→new (ms):', [...new Set(diffOldNew.map(c => Number(c.now) - Number(c.old)))].join(', '), ' zones:', [...new Set(diffOldNew.map(c => c.zone + (c.allday ? ' all-day' : '')))].join(', '));const edge = cases.filter(c => c.zone == 'Europe/Vienna' && !c.allday && (c.startDate == '2026-10-25' || c.startDate == '2026-03-29') && c.startTime == '02:30' && c.unit == 'hours' && c.n == '1');console.log(' Vienna edge, 02:30 start, 1 h before:', edge.map(c => `${c.startDate} → ${new Date(Number(c.now)).toISOString()}`).join(' ; '));}} catch (e) { check('ran', false, String(e && e.stack || e)); }await stop();console.log(`${passes} passed, ${failures} failed`);process.exit(failures ? 1 : 0);
Branches
Latest commits
- f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
- 66341793|||PR Vendor Hybriel day61Atlas
- 36fc596bMerge branch 'vendor-day59' into mainAtlas
- b37cc1da|||PR Vendor Hybriel day59Atlas
- 05665102Merge branch 'vendor-day56' into mainAtlas
- 687296fb|||PR Vendor Hybriel day56Atlas
- a6166d4eMerge branch 'hl-standard-3' into mainAtlas
- 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
- add4b499|||PR Make calendar day actions keyboard accessibleAtlas
- 79e49b4dMerge branch 'hl-standard' into mainAtlas
- 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