Files
boss/tests/admin-refine-page.test.ts
2026-05-17 02:20:08 +08:00

36 lines
1.2 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { access, readFile } from "node:fs/promises";
const adminPagePath = new URL("../src/app/admin/page.tsx", import.meta.url);
const adminAppPath = new URL("../src/components/admin/boss-admin-app.tsx", import.meta.url);
const dataProviderPath = new URL("../src/components/admin/boss-admin-data-provider.ts", import.meta.url);
async function readSource(path: URL) {
return readFile(path, "utf8");
}
async function fileExists(path: URL) {
try {
await access(path);
return true;
} catch {
return false;
}
}
test("/admin is only a compatibility redirect to the admin root domain", async () => {
const source = await readSource(adminPagePath);
assert.match(source, /redirect/);
assert.match(source, /redirect\("\/"\)/);
assert.doesNotMatch(source, /BossAdminApp/);
assert.doesNotMatch(source, /antd\/dist\/reset\.css/);
assert.doesNotMatch(source, /api\/v1\/admin\/overview/);
});
test("legacy Next admin UI files are removed after enterprise-admin migration", async () => {
assert.equal(await fileExists(adminAppPath), false);
assert.equal(await fileExists(dataProviderPath), false);
});