feat: sync GridSmart agendas and use event-relative demo time

Support script and URL sources, automatic Sessionize polling, staff-linked service sessions, chronological agenda blocks, and inline Placeholders. Fix demo mode to use the active event date and document deployed behavior with regression coverage.
This commit is contained in:
Lago committed 2026-10-11 08:39:15 +02:00
1 parent 40f24cf5f7
commit c0fbf495dc
27 files changed
+1215 -60

No files matched your search

@@ -0,0 +1,32 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { createSessionizePoller } = require('../src/sessionize-poller');
test('polls events sequentially and isolates upstream failures', async () => {
const calls = [];
const failures = [];
const poll = createSessionizePoller({ listEvents: async () => [{ id: 'first' }, { id: 'second' }],
isBusy: () => false, syncEvent: async id => { calls.push(id); if (id === 'first') throw new Error('unavailable'); },
onError: (error, id) => failures.push(id) });
await poll();
assert.deepEqual(calls, ['first', 'second']);
assert.deepEqual(failures, ['first']);
});
test('does not overlap manual imports or another polling pass', async () => {
let finish;
let reads = 0;
let busy = true;
const pending = new Promise(resolve => { finish = resolve; });
const poll = createSessionizePoller({ listEvents: async () => { reads++; await pending; return []; },
isBusy: () => busy, syncEvent: async () => {}, onError: () => {} });
await poll();
assert.equal(reads, 0);
busy = false;
const first = poll();
await poll();
assert.equal(reads, 1);
finish();
await first;
await poll();
assert.equal(reads, 2);
});
@@ -0,0 +1,46 @@
const { test } = require('node:test');
const assert = require('node:assert/strict');
const { normalizeSessionizeSource, parseGridSmart, readSessionizeSource } = require('../src/sessionize-source');
const url = 'https://sessionize.com/api/v2/z0s5f2j2/view/GridSmart';
const card = (id, title, classes = '') => `<div class="sz-session ${classes}" data-sessionid="${id}">
<div class="sz-session__room">Main Stage</div>
<div class="sz-session__time" data-sztz="TimeWithDuration|en-US|2026-10-23T06:30:00.0000000Z|2026-10-23T07:00:00.0000000Z"></div>
<h3 class="sz-session__title">${title}</h3></div>`;
test('normalizes URL and script tag without executing code', () => {
assert.equal(normalizeSessionizeSource(url), url);
assert.equal(normalizeSessionizeSource(`<script type="text/javascript" src='${url}'></script>`), url);
for (const input of ['https://example.org/a', 'http://sessionize.com/api/v2/test/view/All',
'https://sessionize.com@localhost/api/v2/test/view/All', '<script>alert(1)</script>',
'https://sessionize.com:4430/api/v2/test/view/All']) assert.throws(() => normalizeSessionizeSource(input));
});
test('extracts service identity, entities, room, local time and deduplicates cards', () => {
const html = card('service-id', 'Arrival &amp; Coffee', 'sz-session--service') + card('service-id', 'Arrival &amp; Coffee', 'sz-session--service') + card('talk-id', 'Talk');
const result = parseGridSmart(html, 120);
assert.equal(result.sessions.length, 2);
assert.deepEqual(result.sessions[0], { external_id: 'service-id', title: 'Arrival & Coffee', description: null,
room: 'Main Stage', date: '2026-10-23', start_time: '08:30:00', end_time: '09:00:00',
is_service_session: true, speakers: [], level: null, area: null });
assert.equal(result.sessions[1].is_service_session, false);
});
test('rejects empty, malformed and conflicting schedules', () => {
assert.throws(() => parseGridSmart('', 120));
assert.throws(() => parseGridSmart(card('id', 'Talk').replace('2026-10-23T06:30:00.0000000Z', 'bad'), 120));
assert.throws(() => parseGridSmart(card('id', 'Talk') + card('id', 'Different'), 120));
assert.throws(() => parseGridSmart(card('id', 'Talk')));
});
test('reads loader and HTML without executing embed JavaScript', async () => {
const calls = [];
const result = await readSessionizeSource(`<script src="${url}"></script>`, { fetchImpl: async source => {
calls.push(source);
return { ok: true, text: async () => source.includes('under=True') ? card('id', 'Lunch', 'sz-session--plenum') : "sessionize.eventTimezone = 'UTC+02';" };
} });
assert.equal(result.format, 'gridsmart');
assert.equal(result.payload.sessions[0].is_service_session, true);
assert.deepEqual(calls, [url, `${url}?under=True`]);
});
test('retains JSON API compatibility and fails on upstream errors', async () => {
const result = await readSessionizeSource(url.replace('GridSmart', 'All'), { fetchImpl: async () => ({ ok: true, text: async () => '{"sessions":[]}' }) });
assert.equal(result.format, 'json');
await assert.rejects(readSessionizeSource(url, { fetchImpl: async () => ({ ok: false, status: 503 }) }), /503/);
});