by adom
See the shots your AI never showed you, and know it actually SAW them. adom-shotlog streams every screenshot the AI gathers into a live gallery (webview/pup/browser/phone), reports whether a human is really watching and on which surface, and ingests Adom Bridge child-window arrays via --meta.
master
Drew Owens
Publish 0.29.6
688e620
#!/usr/bin/env node
// Unit test for the viewer's date+time label (src/html/index.html, fmtCardTime).
// Every place the gallery shows a shot's time must show its DATE too.
// Usage: node tools/test-card-time.cjs (exit 0 = pass)
const fs = require('fs'), path = require('path'), assert = require('assert');
const html = fs.readFileSync(path.join(__dirname, '..', 'src', 'html', 'index.html'), 'utf8');
const grab = name => { const m = html.match(new RegExp(' function ' + name + '\\([\\s\\S]*?\\n }\\n'));
if (!m) throw new Error('cannot find ' + name + ' in index.html'); return m[0]; };
const { fmtCardTime, fmtDate, fmtTimeTooltip } = new Function(
grab('fmtCardTime') + html.match(/ function fmtDate\(ts\)\{[^\n]*\n/)[0] + grab('fmtIsoLocal') + grab('fmtTimeTooltip') +
'return { fmtCardTime, fmtDate, fmtTimeTooltip };')();
const now = new Date(2026, 10, 30, 12, 30);
const t = (y, mo, d, h, mi) => new Date(y, mo, d, h, mi).toISOString();
let n = 0; const eq = (a, b, why) => { assert.strictEqual(a, b, why); n++; };
eq(fmtCardTime(t(2026, 10, 30, 12, 10), now), 'Nov 30 · 12:10 PM', 'a shot taken TODAY still shows its date');
eq(fmtCardTime(t(2026, 10, 30, 0, 5), now), 'Nov 30 · 12:05 AM', 'midnight hour');
eq(fmtCardTime(t(2026, 10, 29, 23, 59), now), 'Nov 29 · 11:59 PM', 'yesterday shows the real date');
eq(fmtCardTime(t(2026, 0, 3, 9, 3), now), 'Jan 3 · 9:03 AM', 'earlier this year: no year');
eq(fmtCardTime(t(2025, 10, 18, 9, 3), now), 'Nov 18, 2025 · 9:03 AM', 'another year adds the year');
eq(fmtCardTime(t(2027, 0, 1, 13, 0), now), 'Jan 1, 2027 · 1:00 PM', 'a later year adds the year too');
eq(fmtCardTime('', now), '', 'empty input');
eq(fmtCardTime('not-a-date', now), '', 'invalid input');
// The classic meta line uses the same label.
const real = new Date(); real.setHours(8, 7, 0, 0);
eq(fmtDate(real.toISOString()), fmtCardTime(real.toISOString()), 'classic meta line == card header label');
assert.match(fmtCardTime(real.toISOString()), /^[A-Z][a-z]{2} \d{1,2} · 8:07 AM$/); n++;
// The tooltip keeps the full stamp: year, seconds and the ISO form.
const tip = fmtTimeTooltip(t(2026, 10, 30, 12, 10));
assert.match(tip, /2026/); assert.match(tip, /\n2026-11-30T12:10:00[+-]\d\d:\d\d$/); n += 2;
// Every time display in the viewer goes through the dated label (no time-only helper left).
assert.ok(!/function fmtTime\(/.test(html), 'time-only fmtTime helper must be gone'); n++;
assert.ok(!/if \(sameDay\) return clock/.test(html), 'no time-only branch for today'); n++;
for (const use of ["ts.textContent=fmtDate(e.timestamp)", "fmtCardTime(e.timestamp);", "add('ts', fmtCardTime(e.timestamp)"]) {
assert.ok(html.includes(use), 'viewer no longer renders: ' + use); n++; }
console.log('OK: ' + n + ' card-time checks passed');