Files
boss/tests/admin-domain-routing.test.ts

36 lines
1.2 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFile } from "node:fs/promises";
const appRootPath = new URL("../src/app/page.tsx", import.meta.url);
const appUiPath = new URL("../src/components/app-ui.tsx", import.meta.url);
const caddyfilePath = new URL("../deployment/Caddyfile", import.meta.url);
async function readSource(path: URL) {
return readFile(path, "utf8");
}
test("admin host root redirects to the platform admin console", async () => {
const source = await readSource(appRootPath);
assert.match(source, /headers/);
assert.match(source, /admin\.boss\.hyzq\.net/);
assert.match(source, /redirect\(session \? "\/admin" : "\/auth\/login"\)/);
});
test("web login returns admin host users to the admin console", async () => {
const source = await readSource(appUiPath);
assert.match(source, /admin\.boss\.hyzq\.net/);
assert.match(source, /navigateAfterLogin/);
assert.match(source, /\/admin/);
});
test("Caddy serves the platform admin subdomain", async () => {
const source = await readSource(caddyfilePath);
assert.match(source, /admin\.boss\.hyzq\.net/);
assert.match(source, /redir \/ \/admin/);
assert.match(source, /reverse_proxy 127\.0\.0\.1:3000/);
});