import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import test from "node:test"; async function render() { const workerUrl = new URL("../dist/server/index.js", import.meta.url); workerUrl.searchParams.set("test", `${process.pid}-${Date.now()}`); const { default: worker } = await import(workerUrl.href); return worker.fetch( new Request("http://localhost/", { headers: { accept: "text/html" } }), { ASSETS: { fetch: async () => new Response("Not found", { status: 404 }) } }, { waitUntil() {}, passThroughOnException() {} }, ); } test("server-renders the OrbitFlow admin template", async () => { const response = await render(); assert.equal(response.status, 200); assert.match(response.headers.get("content-type") ?? "", /^text\/html\b/i); const html = await response.text(); assert.match(html, /OrbitFlow/); assert.match(html, /下午好,林知夏/); assert.match(html, /流程泳道/); assert.match(html, /定时任务/); assert.doesNotMatch(html, /codex-preview|Your site is taking shape/); }); test("uses local JSON data without backend bindings", async () => { const [data, hosting, page] = await Promise.all([ readFile(new URL("../app/data/mock-data.json", import.meta.url), "utf8"), readFile(new URL("../.openai/hosting.json", import.meta.url), "utf8"), readFile(new URL("../app/page.tsx", import.meta.url), "utf8"), ]); const mock = JSON.parse(data); const hostingConfig = JSON.parse(hosting); assert.ok(mock.projects.length >= 3); assert.ok(mock.board.length >= 4); assert.ok(mock.schedules.length >= 4); assert.equal(hostingConfig.d1, null); assert.equal(hostingConfig.r2, null); assert.match(page, /localStorage/); assert.doesNotMatch(page, /fetch\(|axios|\/api\//); });