mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:40:43 +00:00
test: lower matrix bind coverage boundary
This commit is contained in:
@@ -1,17 +1,10 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import {
|
||||
createBindingResolverTestPlugin,
|
||||
createTestRegistry,
|
||||
} from "../test-utils/channel-plugins.js";
|
||||
import {
|
||||
loadFreshAgentsBindCommandModuleForTest,
|
||||
readConfigFileSnapshotMock,
|
||||
resetAgentsBindTestHarness,
|
||||
runtime,
|
||||
writeConfigFileMock,
|
||||
} from "./agents.bind.test-support.js";
|
||||
import { baseConfigSnapshot } from "./test-runtime-config-helpers.js";
|
||||
import { parseBindingSpecs } from "./agents.bindings.js";
|
||||
|
||||
const matrixBindingPlugin = createBindingResolverTestPlugin({
|
||||
id: "matrix",
|
||||
@@ -25,37 +18,21 @@ const matrixBindingPlugin = createBindingResolverTestPlugin({
|
||||
},
|
||||
});
|
||||
|
||||
let agentsBindCommand: typeof import("./agents.commands.bind.js").agentsBindCommand;
|
||||
|
||||
describe("agents bind matrix integration", () => {
|
||||
beforeEach(async () => {
|
||||
({ agentsBindCommand } = await loadFreshAgentsBindCommandModuleForTest());
|
||||
resetAgentsBindTestHarness();
|
||||
|
||||
it("uses matrix plugin binding resolver when accountId is omitted", () => {
|
||||
setActivePluginRegistry(
|
||||
createTestRegistry([{ pluginId: "matrix", plugin: matrixBindingPlugin, source: "test" }]),
|
||||
);
|
||||
|
||||
const parsed = parseBindingSpecs({ agentId: "main", specs: ["matrix"], config: {} });
|
||||
|
||||
expect(parsed.errors).toEqual([]);
|
||||
expect(parsed.bindings).toEqual([
|
||||
{ type: "route", agentId: "main", match: { channel: "matrix", accountId: "main" } },
|
||||
]);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
setActivePluginRegistry(createTestRegistry());
|
||||
});
|
||||
|
||||
it("uses matrix plugin binding resolver when accountId is omitted", async () => {
|
||||
readConfigFileSnapshotMock.mockResolvedValue({
|
||||
...baseConfigSnapshot,
|
||||
config: {},
|
||||
});
|
||||
|
||||
await agentsBindCommand({ agent: "main", bind: ["matrix"] }, runtime);
|
||||
|
||||
expect(writeConfigFileMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
bindings: [
|
||||
{ type: "route", agentId: "main", match: { channel: "matrix", accountId: "main" } },
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(runtime.exit).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user