Files
clawhub/scripts/github/plugin-inspector-pin-change.test.mjs
Patrick Erichsen 79d9a86e6f ci: dispatch plugin inspector scans on pin bumps (#2584)
* ci: dispatch plugin inspector bulk scans on pin bump

* ci: rename plugin inspector bulk scan workflow

* fix: include CLI plugin inspector pin in scan dispatch

* chore: remove stale plugin inspector cron comment

* fix: dispatch inspector scans from main pushes
2026-06-09 21:45:29 -07:00

82 lines
2.5 KiB
JavaScript

import { describe, expect, it } from "vitest";
import {
detectPinnedPluginInspectorChange,
readPinnedPluginInspectorVersion,
} from "./plugin-inspector-pin-change.mjs";
const packageJson = (version) =>
JSON.stringify({
dependencies: {
"@openclaw/plugin-inspector": version,
react: "19.2.7",
},
});
const packageJsonsByPath = (rootVersion, cliVersion = rootVersion) => ({
"package.json": packageJson(rootVersion),
"packages/clawhub/package.json": packageJson(cliVersion),
});
describe("plugin inspector pin change detection", () => {
it("detects merged changes to the pinned plugin inspector dependency", () => {
expect(
detectPinnedPluginInspectorChange({
changedFiles: ["package.json", "bun.lock"],
basePackageJson: packageJson("0.3.12"),
headPackageJson: packageJson("0.3.13"),
}),
).toEqual({
changed: true,
oldVersion: "0.3.12",
newVersion: "0.3.13",
reason: "pinned @openclaw/plugin-inspector changed in package.json from 0.3.12 to 0.3.13",
});
});
it("detects merged changes to the CLI package inspector pin", () => {
expect(
detectPinnedPluginInspectorChange({
changedFiles: ["packages/clawhub/package.json", "bun.lock"],
basePackageJsonByPath: packageJsonsByPath("0.3.12"),
headPackageJsonByPath: packageJsonsByPath("0.3.12", "0.3.13"),
}),
).toEqual({
changed: true,
oldVersion: "0.3.12",
newVersion: "0.3.13",
reason:
"pinned @openclaw/plugin-inspector changed in packages/clawhub/package.json from 0.3.12 to 0.3.13",
});
});
it("does not dispatch for unrelated merged changes", () => {
expect(
detectPinnedPluginInspectorChange({
changedFiles: ["src/routes/index.tsx"],
basePackageJson: packageJson("0.3.12"),
headPackageJson: packageJson("0.3.12"),
}),
).toMatchObject({
changed: false,
reason: "no package manager files changed",
});
});
it("does not dispatch when package files changed but the inspector pin did not", () => {
expect(
detectPinnedPluginInspectorChange({
changedFiles: ["package.json", "bun.lock"],
basePackageJson: packageJson("0.3.12"),
headPackageJson: packageJson("0.3.12"),
}),
).toMatchObject({
changed: false,
reason: "pinned @openclaw/plugin-inspector did not change",
});
});
it("reads the pinned dependency version from package.json", () => {
expect(readPinnedPluginInspectorVersion(packageJson("0.3.12"))).toBe("0.3.12");
});
});