Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 104 lines 3.05 KB
Raw
1 /**
2 * Toolkit data integrity tests.
3 *
4 * Validates that toolkits.json and toolkits-list.json exist, are valid JSON,
5 * and contain the expected structure.
6 */
7 import { describe, test, expect } from "bun:test";
8 import { readFile } from "fs/promises";
9 import { join } from "path";
10
11 const DATA_DIR = join(import.meta.dir, "../../public/data");
12
13 interface ToolkitListItem {
14 slug: string;
15 name: string;
16 logo: string;
17 category: string;
18 toolCount: number;
19 triggerCount: number;
20 }
21
22 interface ToolkitFull extends ToolkitListItem {
23 description: string;
24 authSchemes: string[];
25 tools: Array<{ slug: string; name: string; description: string }>;
26 }
27
28 describe("Toolkit data - toolkits.json", () => {
29 let data: ToolkitFull[];
30
31 test("file exists and is valid JSON", async () => {
32 const raw = await readFile(join(DATA_DIR, "toolkits.json"), "utf-8");
33 data = JSON.parse(raw);
34 expect(Array.isArray(data)).toBe(true);
35 });
36
37 test("has a reasonable number of toolkits (> 50)", () => {
38 expect(data.length).toBeGreaterThan(50);
39 });
40
41 test("each toolkit has required fields", () => {
42 const invalid: string[] = [];
43
44 for (const toolkit of data) {
45 if (!toolkit.slug || typeof toolkit.slug !== "string") {
46 invalid.push(`missing slug: ${JSON.stringify(toolkit).slice(0, 80)}`);
47 continue;
48 }
49 if (!toolkit.name || typeof toolkit.name !== "string") {
50 invalid.push(`${toolkit.slug}: missing name`);
51 }
52 if (typeof toolkit.toolCount !== "number") {
53 invalid.push(`${toolkit.slug}: missing toolCount`);
54 }
55 if (!Array.isArray(toolkit.authSchemes)) {
56 invalid.push(`${toolkit.slug}: missing authSchemes array`);
57 }
58 }
59
60 expect(invalid).toEqual([]);
61 });
62
63 test("no duplicate slugs", () => {
64 const slugs = data.map((t) => t.slug);
65 const duplicates = slugs.filter((s, i) => slugs.indexOf(s) !== i);
66 expect(duplicates).toEqual([]);
67 });
68
69 test("well-known toolkits exist", () => {
70 const slugs = new Set(data.map((t) => t.slug));
71 const expected = ["github", "gmail", "slack", "notion"];
72 const missing = expected.filter((s) => !slugs.has(s));
73 expect(missing).toEqual([]);
74 });
75 });
76
77 describe("Toolkit data - toolkits-list.json", () => {
78 let data: ToolkitListItem[];
79
80 test("file exists and is valid JSON", async () => {
81 const raw = await readFile(join(DATA_DIR, "toolkits-list.json"), "utf-8");
82 data = JSON.parse(raw);
83 expect(Array.isArray(data)).toBe(true);
84 });
85
86 test("list count matches full data count", async () => {
87 const fullRaw = await readFile(join(DATA_DIR, "toolkits.json"), "utf-8");
88 const full = JSON.parse(fullRaw);
89 expect(data.length).toBe(full.length);
90 });
91
92 test("each entry has required list fields", () => {
93 const invalid: string[] = [];
94
95 for (const item of data) {
96 if (!item.slug) invalid.push("missing slug");
97 if (!item.name) invalid.push(`${item.slug}: missing name`);
98 if (typeof item.toolCount !== "number")
99 invalid.push(`${item.slug}: missing toolCount`);
100 }
101
102 expect(invalid).toEqual([]);
103 });
104 });