@calltelemetry/openclaw-linear 0.8.2 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,100 @@
1
+ /**
2
+ * tools.test.ts — Integration tests for tool registration.
3
+ *
4
+ * Verifies createLinearTools() returns expected tools and handles
5
+ * configuration flags and graceful failure scenarios.
6
+ */
7
+ import { describe, expect, it, vi } from "vitest";
8
+
9
+ vi.mock("./code-tool.js", () => ({
10
+ createCodeTool: vi.fn(() => ({ name: "code_run", execute: vi.fn() })),
11
+ }));
12
+
13
+ vi.mock("./orchestration-tools.js", () => ({
14
+ createOrchestrationTools: vi.fn(() => [
15
+ { name: "spawn_agent", execute: vi.fn() },
16
+ { name: "ask_agent", execute: vi.fn() },
17
+ ]),
18
+ }));
19
+
20
+ import { createLinearTools } from "./tools.js";
21
+ import { createCodeTool } from "./code-tool.js";
22
+ import { createOrchestrationTools } from "./orchestration-tools.js";
23
+
24
+ // ── Helpers ────────────────────────────────────────────────────────
25
+
26
+ function makeApi(pluginConfig?: Record<string, unknown>) {
27
+ return {
28
+ logger: {
29
+ info: vi.fn(),
30
+ warn: vi.fn(),
31
+ error: vi.fn(),
32
+ debug: vi.fn(),
33
+ },
34
+ pluginConfig: pluginConfig ?? {},
35
+ } as any;
36
+ }
37
+
38
+ // ── Tests ──────────────────────────────────────────────────────────
39
+
40
+ describe("createLinearTools", () => {
41
+ it("returns code_run, spawn_agent, and ask_agent tools", () => {
42
+ const api = makeApi();
43
+ const tools = createLinearTools(api, {});
44
+
45
+ expect(tools).toHaveLength(3);
46
+ const names = tools.map((t: any) => t.name);
47
+ expect(names).toContain("code_run");
48
+ expect(names).toContain("spawn_agent");
49
+ expect(names).toContain("ask_agent");
50
+ });
51
+
52
+ it("includes orchestration tools by default", () => {
53
+ const api = makeApi();
54
+ createLinearTools(api, {});
55
+
56
+ expect(createOrchestrationTools).toHaveBeenCalled();
57
+ });
58
+
59
+ it("excludes orchestration tools when enableOrchestration is false", () => {
60
+ vi.mocked(createOrchestrationTools).mockClear();
61
+ const api = makeApi({ enableOrchestration: false });
62
+ const tools = createLinearTools(api, {});
63
+
64
+ expect(tools).toHaveLength(1);
65
+ expect(tools[0].name).toBe("code_run");
66
+ expect(createOrchestrationTools).not.toHaveBeenCalled();
67
+ });
68
+
69
+ it("handles code_run creation failure gracefully", () => {
70
+ vi.mocked(createCodeTool).mockImplementationOnce(() => {
71
+ throw new Error("CLI not found");
72
+ });
73
+
74
+ const api = makeApi();
75
+ const tools = createLinearTools(api, {});
76
+
77
+ expect(tools).toHaveLength(2);
78
+ const names = tools.map((t: any) => t.name);
79
+ expect(names).toContain("spawn_agent");
80
+ expect(names).toContain("ask_agent");
81
+ expect(api.logger.warn).toHaveBeenCalledWith(
82
+ expect.stringContaining("code_run tool not available"),
83
+ );
84
+ });
85
+
86
+ it("handles orchestration tools creation failure gracefully", () => {
87
+ vi.mocked(createOrchestrationTools).mockImplementationOnce(() => {
88
+ throw new Error("orchestration init failed");
89
+ });
90
+
91
+ const api = makeApi();
92
+ const tools = createLinearTools(api, {});
93
+
94
+ expect(tools).toHaveLength(1);
95
+ expect(tools[0].name).toBe("code_run");
96
+ expect(api.logger.warn).toHaveBeenCalledWith(
97
+ expect.stringContaining("Orchestration tools not available"),
98
+ );
99
+ });
100
+ });