feat(FN-3297): add test coverage for incomplete runtime dist trees
Adds test coverage for incomplete runtime dist trees in the test-artifacts script, with one new test file and a small fix to the script itself. Fusion-Task-Id: FN-3297
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { detectMissingArtifacts, ensureTestArtifacts } from "../ensure-test-artifacts.mjs";
|
||||
import {
|
||||
detectMissingArtifacts,
|
||||
ensureTestArtifacts,
|
||||
REQUIRED_BUILD_PACKAGES,
|
||||
} from "../ensure-test-artifacts.mjs";
|
||||
|
||||
test("detectMissingArtifacts returns missing package list", () => {
|
||||
const missing = detectMissingArtifacts("/repo", () => false);
|
||||
assert.ok(missing.length >= 5);
|
||||
assert.equal(missing.length, REQUIRED_BUILD_PACKAGES.length);
|
||||
assert.equal(missing[0].name, "@fusion/core");
|
||||
});
|
||||
|
||||
@@ -31,3 +35,48 @@ test("ensureTestArtifacts builds only missing packages", () => {
|
||||
assert.equal(calls[0].cmd, "pnpm");
|
||||
assert.deepEqual(calls[0].args, ["--filter", "@fusion-plugin-examples/openclaw-runtime", "build"]);
|
||||
});
|
||||
|
||||
test("detectMissingArtifacts flags hermes when dist/index.js exists but dist/cli-spawn.js is missing", () => {
|
||||
const missing = detectMissingArtifacts("/repo", (fullPath) => !fullPath.endsWith("dist/cli-spawn.js"));
|
||||
const names = missing.map((pkg) => pkg.name);
|
||||
|
||||
assert.ok(names.includes("@fusion-plugin-examples/hermes-runtime"));
|
||||
});
|
||||
|
||||
test("ensureTestArtifacts rebuilds hermes for incomplete dist artifacts", () => {
|
||||
const calls = [];
|
||||
const built = ensureTestArtifacts(
|
||||
"/repo",
|
||||
(cmd, args, cwd) => calls.push({ cmd, args, cwd }),
|
||||
(fullPath) => !fullPath.endsWith("plugins/fusion-plugin-hermes-runtime/dist/cli-spawn.js"),
|
||||
);
|
||||
|
||||
assert.deepEqual(built, ["@fusion-plugin-examples/hermes-runtime"]);
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0].cmd, "pnpm");
|
||||
assert.deepEqual(calls[0].args, ["--filter", "@fusion-plugin-examples/hermes-runtime", "build"]);
|
||||
});
|
||||
|
||||
test("detectMissingArtifacts flags openclaw when dist/index.js exists but transitive files are missing", () => {
|
||||
const missing = detectMissingArtifacts(
|
||||
"/repo",
|
||||
(fullPath) => fullPath.endsWith("plugins/fusion-plugin-openclaw-runtime/dist/index.js"),
|
||||
);
|
||||
const names = missing.map((pkg) => pkg.name);
|
||||
|
||||
assert.ok(names.includes("@fusion-plugin-examples/openclaw-runtime"));
|
||||
});
|
||||
|
||||
test("ensureTestArtifacts rebuilds openclaw for incomplete dist artifacts", () => {
|
||||
const calls = [];
|
||||
const built = ensureTestArtifacts(
|
||||
"/repo",
|
||||
(cmd, args, cwd) => calls.push({ cmd, args, cwd }),
|
||||
(fullPath) => !fullPath.endsWith("plugins/fusion-plugin-openclaw-runtime/dist/runtime-adapter.js"),
|
||||
);
|
||||
|
||||
assert.deepEqual(built, ["@fusion-plugin-examples/openclaw-runtime"]);
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0].cmd, "pnpm");
|
||||
assert.deepEqual(calls[0].args, ["--filter", "@fusion-plugin-examples/openclaw-runtime", "build"]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user