import assert from "node:assert/strict"; import { access, readFile, readdir } from "node:fs/promises"; import test from "node:test"; test("builds the finished operations console assets", async () => { const [page, layout, clientFiles, hosting] = await Promise.all([ readFile(new URL("../app/page.tsx", import.meta.url), "utf8"), readFile(new URL("../app/layout.tsx", import.meta.url), "utf8"), readdir(new URL("../dist/client/assets/", import.meta.url)), readFile(new URL("../dist/.openai/hosting.json", import.meta.url), "utf8"), ]); assert.match(page, /AdminConsole/); assert.match(layout, /智能回收运营平台/); assert.match(layout, /og\.png/); assert.ok(clientFiles.some((file) => file.startsWith("AdminConsole-") && file.endsWith(".js"))); assert.equal(JSON.parse(hosting).d1, "DB"); await access(new URL("../dist/client/og.png", import.meta.url)); }); test("removes starter preview and includes persistent API routes", async () => { const [client, consoleApi, deviceApi, packageJson, readme] = await Promise.all([ readFile(new URL("../app/AdminConsole.tsx", import.meta.url), "utf8"), readFile(new URL("../app/api/console/route.ts", import.meta.url), "utf8"), readFile(new URL("../app/api/v1/[...path]/route.ts", import.meta.url), "utf8"), readFile(new URL("../package.json", import.meta.url), "utf8"), readFile(new URL("../README.md", import.meta.url), "utf8"), ]); assert.match(client, /废料称重/); assert.match(client, /地磅核对/); assert.match(client, /导体追溯/); assert.match(client, /人员设备/); assert.match(client, /终端模拟/); assert.match(consoleApi, /person\.face/); assert.match(consoleApi, /alert\.status/); assert.match(deviceApi, /heartbeat/); assert.match(deviceApi, /deliveries/); assert.match(deviceApi, /people/); assert.doesNotMatch(packageJson, /react-loading-skeleton/); assert.match(readme, /Docker Compose/); await assert.rejects(access(new URL("../app/_sites-preview", import.meta.url))); await access(new URL("../drizzle/", import.meta.url)); });