getConnectorCredential, setConnectorCredential and setConnectorCredentialBundle are now plain functions over a SecretStore in packages/agent/src/connectors/connector-credentials.ts. The secret names, metadata layout and the rule that tokens never go into plaintext metadata are unchanged, so existing vault files keep working. A bundle still lands as one update: SecretStore gains writeBatch, which VaultStore applies with a single vault-file replacement. Connector tests seed a Map-backed SecretStore instead of mocking VaultStore methods; the helper tests from core and server moved to the agent package.
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
import { DiscordConnector } from '../src/connectors/discord-connector.js';
|
|
|
|
describe('Discord connector (communication)', () => {
|
|
let connector: DiscordConnector;
|
|
let originalFetch: typeof globalThis.fetch;
|
|
|
|
beforeEach(() => {
|
|
connector = new DiscordConnector();
|
|
originalFetch = globalThis.fetch;
|
|
});
|
|
|
|
afterEach(() => {
|
|
globalThis.fetch = originalFetch;
|
|
});
|
|
|
|
it('has correct id, name, and service', () => {
|
|
expect(connector.id).toBe('discord');
|
|
expect(connector.name).toBe('Discord');
|
|
expect(connector.service).toBe('discord.com');
|
|
});
|
|
|
|
it('has at least 5 actions', () => {
|
|
expect(connector.actions.length).toBeGreaterThanOrEqual(5);
|
|
});
|
|
|
|
it('execute returns error when not connected', async () => {
|
|
const result = await connector.execute('list_guilds', {});
|
|
expect(result.success).toBe(false);
|
|
expect(result.error).toContain('Not connected');
|
|
});
|
|
|
|
it('healthCheck returns disconnected when no token', async () => {
|
|
const health = await connector.healthCheck();
|
|
expect(health.status).toBe('disconnected');
|
|
});
|
|
});
|