test: dedupe plugin runtime registry suites

This commit is contained in:
Peter Steinberger
2026-03-28 02:34:14 +00:00
parent a9be5421d0
commit 4752aca926
6 changed files with 402 additions and 380 deletions

View File

@@ -24,6 +24,16 @@ function createCommandResult() {
};
}
function createGatewaySubagentRuntime() {
return {
run: vi.fn(),
waitForRun: vi.fn(),
getSessionMessages: vi.fn(),
getSession: vi.fn(),
deleteSession: vi.fn(),
};
}
describe("plugin runtime command execution", () => {
beforeEach(() => {
vi.restoreAllMocks();
@@ -135,13 +145,7 @@ describe("plugin runtime command execution", () => {
it("keeps subagent unavailable by default even after gateway initialization", async () => {
const runtime = createPluginRuntime();
setGatewaySubagentRuntime({
run: vi.fn(),
waitForRun: vi.fn(),
getSessionMessages: vi.fn(),
getSession: vi.fn(),
deleteSession: vi.fn(),
});
setGatewaySubagentRuntime(createGatewaySubagentRuntime());
expect(() => runtime.subagent.run({ sessionKey: "s-1", message: "hello" })).toThrow(
"Plugin runtime subagent methods are only available during a gateway request.",
@@ -153,11 +157,8 @@ describe("plugin runtime command execution", () => {
const runtime = createPluginRuntime({ allowGatewaySubagentBinding: true });
setGatewaySubagentRuntime({
...createGatewaySubagentRuntime(),
run,
waitForRun: vi.fn(),
getSessionMessages: vi.fn(),
getSession: vi.fn(),
deleteSession: vi.fn(),
});
await expect(runtime.subagent.run({ sessionKey: "s-2", message: "hello" })).resolves.toEqual({