// Harness for the member dashboard's GUEST TRAIL (the member's own invite // history), run through the panel's vendored checker: // bash ../admin-panel/tests/check-page-js.sh app/main.py dashboard-guests-harness.js // // The portal derives the trail's display state (the SINGLE derivation, tested // in the portal's tests/test_guest_invited_state.py); this page CONSUMES it: // * state='invited' wins even though the ledger status underneath is still // 'active' — a provisioned-but-not-set-up guest is never 'active'; // * state carries the ledger status once accepted/ended (expired ...); // * an older payload with status only falls back to it (the thin shim). // The checker evals in CommonJS (no top-level await), so the body is wrapped. const assert = (cond, msg) => { if (!cond) { console.error("FAIL: " + msg); process.exit(1); } }; const count = (s, re) => (String(s).match(re) || []).length; async function runRender(payload) { globalThis.fetch = async () => ({ status: 200, json: async () => payload }); await loadGuests(); } (async () => { // New payload: the portal serves `state` on every trail entry. await runRender({ eligible: false, next_eligible_at: "2026-12-15T00:00:00Z", trail: [ { kind: "guest", recipient: "pending@example.com", created_at: "2026-11-10 10:00:00", status: "active", state: "invited" }, { kind: "guest", recipient: "lapsed@example.com", created_at: "2026-09-01 10:00:00", decided_at: "2026-10-30 10:00:00", status: "expired", state: "expired" }, ], }); { const t = document.getElementById("guest-trail").innerHTML; assert(/gpill invited[^>]*>Invited — awaiting setupactive guest]*>ended — time ran out]*>active guest { console.error("FAIL: " + (e && e.stack || e)); process.exit(1); });