Skip to main content
Glama
index.ts4.37 kB
import 'dotenv/config'; import { describe, it, expect, beforeAll, afterAll } from 'vitest'; import { SuperglueClient } from '@superglue/client'; const INTEGRATION_ID = 'github-test'; let client: SuperglueClient; let toolId: string | null = null; const endpoint = process.env.GRAPHQL_ENDPOINT || 'http://localhost:3000'; const apiKey = process.env.AUTH_TOKEN; const githubToken = process.env.GITHUB_API_TOKEN; beforeAll(() => { if (!apiKey) { throw new Error('AUTH_TOKEN environment variable is required'); } if (!githubToken) { throw new Error('GITHUB_API_TOKEN environment variable is required'); } client = new SuperglueClient({ endpoint, apiKey }); }); afterAll(async () => { if (toolId) { await client.deleteWorkflow(toolId).catch(() => {}); } await client.deleteIntegration(INTEGRATION_ID).catch(() => {}); }); describe('Superglue SDK Integration Tests', () => { it('should create GitHub integration', async () => { const integration = await client.upsertIntegration(INTEGRATION_ID, { name: 'GitHub', urlHost: 'https://api.github.com', urlPath: '', documentationUrl: 'https://docs.github.com/en/rest', credentials: { api_token: githubToken }, documentationKeywords: ['repositories', 'issues', 'pull_requests', 'commits'] }); expect(integration.id).toBe(INTEGRATION_ID); expect(integration.name).toBe('GitHub'); }); it('should list integrations and find created one', async () => { const integrationsList = await client.listIntegrations(50, 0); const foundIntegration = integrationsList.items.find(i => i.id === INTEGRATION_ID); expect(foundIntegration).toBeDefined(); expect(foundIntegration?.id).toBe(INTEGRATION_ID); expect(foundIntegration?.name).toBe('GitHub'); }); it('should update integration', async () => { const updatedIntegration = await client.upsertIntegration(INTEGRATION_ID, { name: 'GitHub Updated', documentationKeywords: ['repositories', 'issues', 'pull_requests', 'commits', 'branches'] }); expect(updatedIntegration.name).toBe('GitHub Updated'); }); it('should build a workflow', async () => { const tool = await client.buildWorkflow({ instruction: 'List all repositories for the authenticated user. I want the final output to be a JSON object with the following structure: { repositories: [{id: number, name: string, isPublic: boolean}] }.', integrationIds: [INTEGRATION_ID], payload: {}, save: true }); toolId = tool.id; expect(toolId).toBeDefined(); expect(tool.id).toBeTruthy(); }); it('should execute the workflow', async () => { expect(toolId).toBeDefined(); const result = await client.executeWorkflow({ id: toolId!, payload: {}, credentials: { [`${INTEGRATION_ID}_api_token`]: githubToken } }); expect(result.success).toBe(true); expect(result.data).toBeDefined(); }); it('should verify integration modifications', async () => { const verifyList = await client.listIntegrations(50, 0); const verifiedIntegration = verifyList.items.find(i => i.id === INTEGRATION_ID); expect(verifiedIntegration?.name).toBe('GitHub Updated'); }); it('should list workflows and find created one', async () => { const toolsList = await client.listWorkflows(50, 0); const foundTool = toolsList.items.find(t => t.id === toolId); expect(foundTool).toBeDefined(); expect(foundTool?.id).toBe(toolId); expect(foundTool?.instruction).toBeTruthy(); }); it('should delete workflow', async () => { expect(toolId).toBeDefined(); const deleted = await client.deleteWorkflow(toolId!); expect(deleted).toBe(true); toolId = null; }); it('should delete integration', async () => { const deleted = await client.deleteIntegration(INTEGRATION_ID); expect(deleted).toBe(true); }); it('should verify cleanup', async () => { const finalIntegrationsList = await client.listIntegrations(50, 0); const stillExists = finalIntegrationsList.items.find(i => i.id === INTEGRATION_ID); expect(stillExists).toBeUndefined(); const finalToolsList = await client.listWorkflows(50, 0); const toolStillExists = finalToolsList.items.find(t => t.id === toolId); expect(toolStillExists).toBeUndefined(); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/superglue-ai/superglue'

If you have feedback or need assistance with the MCP directory API, please join our Discord server