- app/oidc.py is now a byte-identical copy of the canonical module (ops-docs: scripts/shared/oidc_client.py); this app's identity (logger name, session cookie, session salt) is set via oidc.configure() in main.py with the app's historical values, so existing sessions survive. tests/test_oidc_sync.py pins the copy to the canonical revision — a hand edit goes red; changes go through the canonical + sync-oidc-module.sh. - The guest trail pill consumes the portal-served `state` (the single invited-vs-active derivation, tested in the portal) with the old status-only payload fallback kept; dashboard-guests-harness.js asserts both shapes through the real page JS.
66 lines
3.1 KiB
JavaScript
66 lines
3.1 KiB
JavaScript
// 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 setup</.test(t),
|
|
"portal-served state='invited' renders the awaiting-setup pill even though the ledger says active");
|
|
assert(!/>active guest</.test(t),
|
|
"a pending guest is never rendered as an active guest");
|
|
assert(/gpill done[^>]*>ended — time ran out</.test(t),
|
|
"state='expired' renders the ended pill");
|
|
assert(t.indexOf("pending@example.com") !== -1 && t.indexOf("lapsed@example.com") !== -1,
|
|
"both trail rows render");
|
|
assert(document.getElementById("guest-invite-wrap").style.display === "none",
|
|
"used invite: the form is hidden (next-date hint takes its place)");
|
|
assert(document.getElementById("guest-allowance").textContent.indexOf("next invite is available") !== -1,
|
|
"the next-open date is surfaced");
|
|
}
|
|
|
|
// Old payload shape: status only, no state — the shim falls back to it.
|
|
await runRender({
|
|
eligible: true,
|
|
trail: [
|
|
{ kind: "guest", recipient: "friend@example.com", created_at: "2026-11-09 10:00:00",
|
|
status: "active" },
|
|
],
|
|
});
|
|
{
|
|
const t = document.getElementById("guest-trail").innerHTML;
|
|
assert(/gpill ok[^>]*>active guest</.test(t),
|
|
"old payload (status only) falls back to the ledger status");
|
|
assert(document.getElementById("guest-invite-wrap").style.display === "",
|
|
"eligible: the invite form is shown");
|
|
}
|
|
|
|
console.log("DASHBOARD GUESTS HARNESS OK: consumes the portal's state, old-shape fallback intact");
|
|
})().catch((e) => { console.error("FAIL: " + (e && e.stack || e)); process.exit(1); });
|