import assert from "node:assert/strict"; import { generateKeyPairSync, randomUUID, sign, type JsonWebKey } from "node:crypto"; import { cpSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import type { AddressInfo } from "node:net"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { after, before, test, type TestContext } from "node:test"; import { fileURLToPath } from "node:url"; import { createApp } from "./app.ts"; import { CSRF_COOKIE, issueCsrfToken } from "./csrf.ts"; import { can, check, GuardError, requireSession } from "./guards.ts"; import { staticJwks } from "./jwks.ts"; import type { ExpandTree, KetoClient, RelationTuple, SubjectSet } from "./keto-client.ts"; import type { Identity, KratosAdmin } from "./kratos-admin.ts"; import { KratosError, type Flow, type FlowType, type KratosPublic, type Session, type UiNode } from "./kratos-public.ts"; import { SESSION_COOKIE } from "./login.ts"; import type { Plugin } from "./plugin.ts"; import { contentTypeFor, resolveStaticPath, routePublic } from "./static.ts"; const viewsDir = join(dirname(fileURLToPath(import.meta.url)), "..", "views"); const server = createApp(); let base = ""; before(async () => { await new Promise((resolve) => server.listen(0, resolve)); base = `http://localhost:${(server.address() as AddressInfo).port}`; }); after(() => server.close()); test("serves the home page: the app-shell People dashboard, filterable via the URL", async () => { const res = await fetch(base + "/"); assert.equal(res.status, 200); assert.match(res.headers.get("content-type") ?? "", /text\/html/); const html = await res.text(); // Shell + building blocks composed around the mock data. assert.match(html, /Plainpages/); // sidebar brand assert.match(html, /