Files
openclaw/src/cli/plugins-cli.registry.test.ts
T
Peter Steinberger 73d279c232 fix(plugins): preserve shipped SDK and lifecycle state (#113101)
* fix(plugins): restore shipped channel compatibility

* docs(plugins): record shipped channel compatibility

* test(plugin-sdk): budget shipped channel compatibility

* docs(plugin-sdk): track shipped channel compat window

* test(plugins): align shipped compat guardrails
2026-07-23 12:30:54 -07:00

48 lines
1.4 KiB
TypeScript

import { beforeEach, describe, expect, it } from "vitest";
import {
refreshPluginRegistry,
resetPluginsCliTestState,
runPluginsCommand,
} from "./plugins-cli-test-helpers.js";
function deferred(): { promise: Promise<void>; resolve: () => void } {
let resolve!: () => void;
const promise = new Promise<void>((resolvePromise) => {
resolve = resolvePromise;
});
return { promise, resolve };
}
describe("plugins registry refresh", () => {
beforeEach(() => {
resetPluginsCliTestState();
});
it("serializes registry rebuilds with other plugin lifecycle mutations", async () => {
const firstEntered = deferred();
const releaseFirst = deferred();
const entries: number[] = [];
refreshPluginRegistry.mockImplementation(async () => {
const entry = entries.length + 1;
entries.push(entry);
if (entry === 1) {
firstEntered.resolve();
await releaseFirst.promise;
}
return { plugins: [] };
});
const first = runPluginsCommand(["plugins", "registry", "--refresh", "--json"]);
await firstEntered.promise;
const second = runPluginsCommand(["plugins", "registry", "--refresh", "--json"]);
await new Promise((resolve) => {
setTimeout(resolve, 50);
});
expect(entries).toEqual([1]);
releaseFirst.resolve();
await Promise.all([first, second]);
expect(entries).toEqual([1, 2]);
});
});