mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-18 08:31:49 -06:00
73d279c232
* 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
48 lines
1.4 KiB
TypeScript
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]);
|
|
});
|
|
});
|