Files
openclaw/test/scripts/verify-plugin-npm-published-runtime.test.ts

73 lines
2.4 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { collectPluginNpmPublishedRuntimeErrors } from "../../scripts/verify-plugin-npm-published-runtime.mjs";
describe("collectPluginNpmPublishedRuntimeErrors", () => {
it("flags published plugin packages with TypeScript entries and no compiled runtime output", () => {
expect(
collectPluginNpmPublishedRuntimeErrors({
spec: "@openclaw/discord@2026.5.2",
packageJson: {
name: "@openclaw/discord",
version: "2026.5.2",
openclaw: {
extensions: ["./index.ts"],
},
},
files: ["package.json", "index.ts"],
}),
).toEqual([
"@openclaw/discord@2026.5.2 requires compiled runtime output for TypeScript entry ./index.ts: expected ./dist/index.js, ./dist/index.mjs, ./dist/index.cjs, ./index.js, ./index.mjs, ./index.cjs",
]);
});
it("accepts published plugin packages with explicit runtimeExtensions", () => {
expect(
collectPluginNpmPublishedRuntimeErrors({
packageJson: {
name: "@openclaw/zalo",
version: "2026.5.3",
openclaw: {
extensions: ["./index.ts"],
runtimeExtensions: ["./dist/index.js"],
},
},
files: ["package.json", "index.ts", "dist/index.js"],
}),
).toEqual([]);
});
it("flags missing explicit runtimeExtensions outputs", () => {
expect(
collectPluginNpmPublishedRuntimeErrors({
packageJson: {
name: "@openclaw/line",
version: "2026.5.3",
openclaw: {
extensions: ["./src/index.ts"],
runtimeExtensions: ["./dist/index.js"],
},
},
files: ["package.json", "src/index.ts"],
}),
).toEqual(["@openclaw/line@2026.5.3 runtime extension entry not found: ./dist/index.js"]);
});
it("flags runtimeExtensions length mismatches", () => {
expect(
collectPluginNpmPublishedRuntimeErrors({
packageJson: {
name: "@openclaw/acpx",
version: "2026.5.3",
openclaw: {
extensions: ["./index.ts", "./tools.ts"],
runtimeExtensions: ["./dist/index.js"],
},
},
files: ["package.json", "dist/index.js"],
}),
).toEqual([
"@openclaw/acpx@2026.5.3 package.json openclaw.runtimeExtensions length (1) must match openclaw.extensions length (2)",
]);
});
});