test: characterize plugin registry repairs

This commit is contained in:
Shakker
2026-05-11 20:26:41 +01:00
parent 2bb4e23ea1
commit 0961d5c8a8
+55 -10
View File
@@ -239,8 +239,23 @@ describe("maybeRepairPluginRegistryState", () => {
expect(nextConfig).toStrictEqual({});
const persisted = await readRequiredPersistedInstalledPluginIndex(stateDir);
expect(persisted.refreshReason).toBe("migration");
expect(persisted.plugins).toHaveLength(1);
expect(persisted.plugins[0]?.pluginId).toBe("demo");
expect(persisted.plugins).toStrictEqual([
expect.objectContaining({
compat: [],
enabled: true,
manifestPath: path.join(pluginDir, "openclaw.plugin.json"),
origin: "global",
pluginId: "demo",
rootDir: pluginDir,
source: path.join(pluginDir, "index.ts"),
startup: {
agentHarnesses: [],
deferConfiguredChannelFullLoadUntilAfterListen: false,
memory: false,
sidecar: false,
},
}),
]);
});
it("does not repair when registry migration is disabled", async () => {
@@ -350,10 +365,25 @@ describe("maybeRepairPluginRegistryState", () => {
).not.toHaveProperty("dependencies");
const persisted = await readRequiredPersistedInstalledPluginIndex(stateDir);
expect(persisted.refreshReason).toBe("migration");
expect(persisted.plugins).toHaveLength(1);
expect(persisted.plugins[0]?.pluginId).toBe("google-meet");
expect(persisted.plugins[0]?.origin).toBe("bundled");
expect(persisted.plugins[0]?.rootDir).toBe(bundledDir);
expect(persisted.plugins).toStrictEqual([
expect.objectContaining({
compat: [],
enabled: true,
manifestPath: path.join(bundledDir, "openclaw.plugin.json"),
origin: "bundled",
packageName: "@openclaw/google-meet",
packageVersion: "2026.5.3",
pluginId: "google-meet",
rootDir: bundledDir,
source: path.join(bundledDir, "index.ts"),
startup: {
agentHarnesses: [],
deferConfiguredChannelFullLoadUntilAfterListen: false,
memory: false,
sidecar: false,
},
}),
]);
expect(vi.mocked(note).mock.calls.join("\n")).toContain(
"Removed stale managed npm plugin package",
);
@@ -408,10 +438,25 @@ describe("maybeRepairPluginRegistryState", () => {
const persisted = await readRequiredPersistedInstalledPluginIndex(stateDir);
expect(persisted.installRecords).toStrictEqual({});
expect(persisted.refreshReason).toBe("migration");
expect(persisted.plugins).toHaveLength(1);
expect(persisted.plugins[0]?.pluginId).toBe("google-meet");
expect(persisted.plugins[0]?.origin).toBe("bundled");
expect(persisted.plugins[0]?.rootDir).toBe(bundledDir);
expect(persisted.plugins).toStrictEqual([
expect.objectContaining({
compat: [],
enabled: true,
manifestPath: path.join(bundledDir, "openclaw.plugin.json"),
origin: "bundled",
packageName: "@openclaw/google-meet",
packageVersion: "2026.5.3",
pluginId: "google-meet",
rootDir: bundledDir,
source: path.join(bundledDir, "index.ts"),
startup: {
agentHarnesses: [],
deferConfiguredChannelFullLoadUntilAfterListen: false,
memory: false,
sidecar: false,
},
}),
]);
});
it("removes stale managed npm packages from the package lock during repair", async () => {