mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-21 01:51:39 -06:00
e4d1b7e0d3
* refactor(plugins): move plugin contributions into the registry bundle * fix(plugins): guard embedding owner union and drop unused test-util imports * fix(plugins): break registry facade import cycles * fix(plugins): remove obsolete registry snapshot seams * test(gateway): preserve plugin runtime mock exports * test(auto-reply): install builder registry in diagnostics fixture * test(plugins): activate registry-backed capability fixtures
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({ warn: vi.fn() }));
|
|
|
|
vi.mock("../logging/subsystem.js", () => ({
|
|
createSubsystemLogger: () => ({ warn: mocks.warn }),
|
|
}));
|
|
|
|
import { requireActivePluginChannelRegistry } from "./runtime.js";
|
|
import {
|
|
clearSessionDiscussionProvider,
|
|
getSessionDiscussionProvider,
|
|
registerSessionDiscussionProvider,
|
|
type SessionDiscussionProvider,
|
|
} from "./session-discussion-registry.js";
|
|
|
|
function provider(id: string): SessionDiscussionProvider {
|
|
return {
|
|
id,
|
|
info: vi.fn().mockResolvedValue({ state: "available" }),
|
|
open: vi.fn().mockResolvedValue({ state: "open" }),
|
|
};
|
|
}
|
|
|
|
describe("session discussion provider registry", () => {
|
|
beforeEach(() => {
|
|
mocks.warn.mockClear();
|
|
clearSessionDiscussionProvider();
|
|
});
|
|
|
|
it("keeps providers owner-keyed without silently displacing the first owner", () => {
|
|
const first = provider("first");
|
|
const second = provider("second");
|
|
|
|
registerSessionDiscussionProvider(first);
|
|
expect(getSessionDiscussionProvider()).toBe(first);
|
|
expect(mocks.warn).not.toHaveBeenCalled();
|
|
|
|
registerSessionDiscussionProvider(second);
|
|
expect(getSessionDiscussionProvider()).toBe(first);
|
|
expect([...requireActivePluginChannelRegistry().sessionDiscussionProviders.keys()]).toEqual([
|
|
"first",
|
|
"second",
|
|
]);
|
|
expect(mocks.warn).toHaveBeenCalledWith(
|
|
"session discussion provider second registered alongside first; retaining first as the default",
|
|
);
|
|
});
|
|
});
|