feat(FN-1228): add Node Dashboard UI with mesh topology and routes tests

This commit is contained in:
gsxdsm
2026-04-09 12:34:03 -07:00
parent ced3ad3be6
commit 07e193b0a0
11 changed files with 806 additions and 9 deletions

View File

@@ -59,6 +59,32 @@ describe("CLI bundle output", () => {
expect(tsupConfig).toContain("cpSync(dashboardClientSrc, dashboardClientDest, { recursive: true });");
});
it("preserves node: prefix in node:sqlite imports", () => {
const content = readFileSync(bundlePath, "utf-8");
// Should have node:sqlite, not bare "sqlite"
expect(content).toContain('from "node:sqlite"');
expect(content).not.toMatch(/from\s+["']sqlite["'][^s]/);
});
it("provides require via createRequire banner", () => {
const content = readFileSync(bundlePath, "utf-8");
// Banner should inject createRequire for ESM CJS interop
expect(content).toContain('createRequire');
expect(content).toContain("import.meta.url");
// Banner should be near the top of the file (after shebang)
const shebangEnd = content.indexOf("\n");
const bannerPosition = content.indexOf("createRequire");
expect(bannerPosition).toBeLessThan(100);
expect(bannerPosition).toBeGreaterThan(shebangEnd);
});
it("preserves node: prefix in other node built-in imports", () => {
const content = readFileSync(bundlePath, "utf-8");
// Verify removeNodeProtocol: false is effective for other node: imports
expect(content).toMatch(/from\s+["']node:fs["']/);
expect(content).toMatch(/from\s+["']node:path["']/);
});
it("runtime native assets are staged after build:exe", () => {
const runtimeDir = join(cliRoot, "dist", "runtime");
if (!existsSync(runtimeDir)) return;

View File

@@ -62,4 +62,12 @@ describe("Docker configuration", () => {
expect(docs).toContain("run");
expect(docs).toContain("environment variables");
});
it("does not patch the CLI bundle at build time", () => {
const dockerfile = readFileSync(dockerfilePath, "utf8");
// The tsup bundle should be self-contained without runtime patches
expect(dockerfile).not.toContain("sed -i");
expect(dockerfile).not.toContain("node_modules/sqlite");
expect(dockerfile).not.toContain("createRequire");
});
});

View File

@@ -30,6 +30,10 @@ export default defineConfig({
noExternal: [/^@fusion\//],
splitting: false,
clean: true,
removeNodeProtocol: false,
banner: {
js: 'import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);',
},
onSuccess: async () => {
if (existsSync(dashboardClientDest)) {
rmSync(dashboardClientDest, { recursive: true, force: true });