Files
fusion/packages/cli/src/__tests__/bundle-output-helpers.test.ts
Fusion 3bbd153819 feat(FN-3170): harden plugin bundling contract and fix verification regress
Hardened the roadmap plugin bundling contract with new output-validation tests and tsup config cleanup, then resolved regressions those changes introduced in the bundle and package-config test suites. A small dashboard UI tweak (TaskDetailModal) was also included.

Fusion-Task-Id: FN-3170
2026-05-10 06:14:19 -07:00

81 lines
2.6 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
const state = {
existingPaths: new Set<string>(),
indexHtml: "",
};
vi.mock("node:fs", () => ({
existsSync: (path: string) => state.existingPaths.has(path),
readFileSync: () => state.indexHtml,
execFileSync: vi.fn(),
execSync: vi.fn(),
}));
import {
bundlePath,
clientIndexPath,
dashboardClientStubMarker,
droidPluginMcpServerPath,
hasBuiltDashboardAssets,
openclawMcpSchemaServerPath,
} from "./bundle-output-helpers";
const cursorPluginManifestPath = bundlePath.replace(
"dist/bin.js",
"dist/plugins/fusion-plugin-cursor-runtime/manifest.json",
);
const roadmapPluginBundledPath = bundlePath.replace(
"dist/bin.js",
"dist/plugins/fusion-plugin-roadmap/bundled.js",
);
describe("hasBuiltDashboardAssets", () => {
beforeEach(() => {
state.existingPaths.clear();
state.indexHtml = "<html><body><script src=\"assets/app.js\"></script></body></html>";
});
it("returns false when openclaw mcp-schema-server.cjs is missing", () => {
state.existingPaths.add(bundlePath);
state.existingPaths.add(clientIndexPath);
state.existingPaths.add(cursorPluginManifestPath);
state.existingPaths.add(roadmapPluginBundledPath);
expect(hasBuiltDashboardAssets()).toBe(false);
});
it("returns false when droid mcp-schema-server.cjs is missing", () => {
state.existingPaths.add(bundlePath);
state.existingPaths.add(clientIndexPath);
state.existingPaths.add(cursorPluginManifestPath);
state.existingPaths.add(roadmapPluginBundledPath);
state.existingPaths.add(openclawMcpSchemaServerPath);
expect(hasBuiltDashboardAssets()).toBe(false);
});
it("returns true when all required assets exist and dashboard stub marker is absent", () => {
state.existingPaths.add(bundlePath);
state.existingPaths.add(clientIndexPath);
state.existingPaths.add(cursorPluginManifestPath);
state.existingPaths.add(roadmapPluginBundledPath);
state.existingPaths.add(openclawMcpSchemaServerPath);
state.existingPaths.add(droidPluginMcpServerPath);
expect(hasBuiltDashboardAssets()).toBe(true);
});
it("returns false when dashboard client index contains stub marker", () => {
state.existingPaths.add(bundlePath);
state.existingPaths.add(clientIndexPath);
state.existingPaths.add(cursorPluginManifestPath);
state.existingPaths.add(roadmapPluginBundledPath);
state.existingPaths.add(openclawMcpSchemaServerPath);
state.existingPaths.add(droidPluginMcpServerPath);
state.indexHtml = dashboardClientStubMarker;
expect(hasBuiltDashboardAssets()).toBe(false);
});
});