import test from "node:test"; import assert from "node:assert/strict"; import http from "node:http"; import { startServer } from "../lib/server.mjs"; const data = { period: "7d", generatedAt: "2026-10-31T00:00:00.000Z", summary: { accounts: 0, calls: 0, tokens: 0 }, accounts: [], warnings: [], }; // Several loopback servers run in this file. On Windows the HTTP client can // still be retiring a reused socket as the next test finishes; keep them // serial so one server's teardown cannot overlap another's. test("the page's service routes", { concurrency: false }, async (t) => { await t.test("serves a token-protected account tree", async (t) => { const info = await startServer({ port: 0, load: async () => data, }); t.after(async () => { await info.close(); }); const html = await fetch(`http://127.0.0.1:${info.port}/`); assert.equal(html.status, 200); const htmlBody = await html.text(); assert.match(htmlBody, /meta name="usage-tree-token"/); assert.match(htmlBody, /
/); assert.match(htmlBody, /usage-tree-currency" content="usd"/); assert.match(htmlBody, /usage-tree-settings" content="0"/); assert.match(htmlBody, /