Files
openclaw/test/e2e/qa-lab/plugins/plugin-lifecycle-probe.e2e.test.ts
Dallin Romney 0a6736af09 test: fold lifecycle and package proof into QA Lab (#93114)
* test: fold script coverage into qa scenarios

* test: migrate script checks into qa e2e

* test: point qa code refs at migrated e2e

* test: fold plugin lifecycle probe into qa e2e

* test: use shared temp dirs in plugin lifecycle probe

* test: fold plugin lifecycle sweep into qa lab

* test: trim lifecycle docker text assertions

* test: keep followup script conversions split

* test: make lifecycle docker runner script-safe

* test: update changed helper routing expectation
2026-06-17 14:22:04 -07:00

74 lines
2.4 KiB
TypeScript

// Plugin Lifecycle Probe tests cover QA Lab plugin lifecycle evidence.
import { mkdirSync, writeFileSync } from "node:fs";
import path from "node:path";
import { afterEach, describe, expect, it } from "vitest";
import { createTempDirTracker } from "../../../helpers/temp-dir.js";
import {
assertInspectLoaded,
assertUninstalled,
parseDurationMs,
} from "./plugin-lifecycle-probe-runtime.js";
const tempDirs = createTempDirTracker();
function makeTempDir(): string {
return tempDirs.make("openclaw-plugin-lifecycle-probe-");
}
afterEach(tempDirs.cleanup);
describe("plugin lifecycle matrix probe", () => {
it("accepts inspect JSON for an enabled loaded plugin", async () => {
const dir = makeTempDir();
const inspectPath = path.join(dir, "inspect.json");
writeFileSync(
inspectPath,
`${JSON.stringify({ plugin: { enabled: true, id: "lifecycle-claw", status: "loaded" } })}\n`,
"utf8",
);
expect(() => assertInspectLoaded("lifecycle-claw", inspectPath)).not.toThrow();
});
it("rejects inspect JSON that does not prove the runtime loaded", async () => {
const dir = makeTempDir();
const inspectPath = path.join(dir, "inspect.json");
writeFileSync(
inspectPath,
`${JSON.stringify({ plugin: { enabled: true, id: "lifecycle-claw", status: "pending" } })}\n`,
"utf8",
);
expect(() => assertInspectLoaded("lifecycle-claw", inspectPath)).toThrow(
"expected lifecycle-claw inspect status loaded, got pending",
);
});
it("rejects missing inspect JSON instead of treating it as an empty object", async () => {
const dir = makeTempDir();
const inspectPath = path.join(dir, "missing.json");
expect(() => assertInspectLoaded("lifecycle-claw", inspectPath)).toThrow(
`failed to read JSON from ${inspectPath}`,
);
});
it("rejects unreadable config during uninstall proof", async () => {
const dir = makeTempDir();
const configFile = path.join(dir, ".openclaw", "openclaw.json");
mkdirSync(path.dirname(configFile), { recursive: true });
writeFileSync(configFile, "{ malformed\n", "utf8");
expect(() =>
assertUninstalled("lifecycle-claw", {
HOME: dir,
OPENCLAW_CONFIG_PATH: configFile,
}),
).toThrow(`failed to read JSON from ${configFile}`);
});
it("preserves disabled npm install timeout semantics", () => {
expect(parseDurationMs("0", "600s")).toBeUndefined();
});
});