From 39e27c82763d423de9094e4cc926a4293f4d9799 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sat, 6 Jun 2026 23:46:46 +0200 Subject: [PATCH] fix(test): require lifecycle uninstall config proof --- scripts/e2e/lib/plugin-lifecycle-matrix/probe.mjs | 6 +++++- test/scripts/plugin-lifecycle-probe.test.ts | 14 +++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/e2e/lib/plugin-lifecycle-matrix/probe.mjs b/scripts/e2e/lib/plugin-lifecycle-matrix/probe.mjs index 919f3518d16f..779e47d5437e 100644 --- a/scripts/e2e/lib/plugin-lifecycle-matrix/probe.mjs +++ b/scripts/e2e/lib/plugin-lifecycle-matrix/probe.mjs @@ -39,6 +39,10 @@ function config() { return readJson(process.env.OPENCLAW_CONFIG_PATH ?? openclawPath("openclaw.json")); } +function requiredConfig() { + return readRequiredJson(process.env.OPENCLAW_CONFIG_PATH ?? openclawPath("openclaw.json")); +} + function assert(condition, message) { if (!condition) { throw new Error(message); @@ -117,7 +121,7 @@ function printInstallPath(pluginId) { } function assertUninstalled(pluginId) { - const cfg = config(); + const cfg = requiredConfig(); const record = recordFor(pluginId); assert(!record, `install record still present for ${pluginId}`); assert(!cfg.plugins?.entries?.[pluginId], `plugin config entry still present for ${pluginId}`); diff --git a/test/scripts/plugin-lifecycle-probe.test.ts b/test/scripts/plugin-lifecycle-probe.test.ts index 4c1e7ffcf75f..35a452eb3779 100644 --- a/test/scripts/plugin-lifecycle-probe.test.ts +++ b/test/scripts/plugin-lifecycle-probe.test.ts @@ -1,6 +1,6 @@ // Plugin Lifecycle Probe tests cover plugin lifecycle probe script behavior. import { spawnSync } from "node:child_process"; -import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; @@ -72,4 +72,16 @@ describe("plugin lifecycle matrix probe", () => { expect(result.status).not.toBe(0); expect(result.stderr).toContain(`failed to read JSON from ${inspectPath}`); }); + + it("rejects unreadable config during uninstall proof", () => { + const dir = makeTempDir(); + const configPath = path.join(dir, ".openclaw", "openclaw.json"); + mkdirSync(path.dirname(configPath), { recursive: true }); + writeFileSync(configPath, "{ malformed\n", "utf8"); + + const result = runProbe(["assert-uninstalled", "lifecycle-claw"], dir); + + expect(result.status).not.toBe(0); + expect(result.stderr).toContain(`failed to read JSON from ${configPath}`); + }); });