agent-ecosystem/mcp-server/test/tools/task-attach.test.ts
iliya 161c675aaa feat: update pnpm lockfile and workspace configuration, enhance tool usage tracking and UI components
- Added new dependencies for mcp-server in pnpm-lock.yaml, including fastmcp and zod.
- Updated pnpm-workspace.yaml to include mcp-server in the workspace packages.
- Modified TeamDataService and TeamProvisioningService to exclude 'SendMessage' from tool usage counts, improving accuracy in tool tracking.
- Enhanced ChatHistory component to display context injection percentages, improving user feedback on context usage.
- Updated TeamDetailView to ensure session details are fetched periodically for active tabs, enhancing data freshness.
- Improved ActivityTimeline styling for better visual separation of sessions and messages.
2026-03-06 15:54:55 +02:00

49 lines
1.8 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { register } from '../../src/tools/task-attach.js';
import { createMockRunner, createMockServer, ok, fail } from './test-helpers.js';
describe('task_attach', () => {
const attachJson = '{"id":"att_123","filename":"report.pdf","mimeType":"application/pdf"}';
function setup(response = ok(attachJson)) {
const runner = createMockRunner(response);
const { server, tools } = createMockServer();
register(server, runner);
return { runner, tool: tools.get('task_attach')! };
}
it('builds minimal CLI args', async () => {
const { runner, tool } = setup();
await tool.execute({ team: 'acme', task_id: '1', file: '/tmp/report.pdf' });
expect(runner.execute).toHaveBeenCalledWith([
'--team', 'acme', 'task', 'attach', '1', '--file', '/tmp/report.pdf',
]);
});
it('includes all optional flags', async () => {
const { runner, tool } = setup();
await tool.execute({
team: 'acme', task_id: '1', file: '/tmp/file.pdf',
filename: 'renamed.pdf', mime_type: 'application/pdf',
mode: 'link', from: 'alice',
});
const args = runner.execute.mock.calls[0]![0] as string[];
expect(args).toContain('--filename');
expect(args).toContain('--mime-type');
expect(args).toContain('--mode');
expect(args).toContain('--from');
});
it('returns parsed JSON', async () => {
const { tool } = setup();
const result = await tool.execute({ team: 'acme', task_id: '1', file: '/tmp/report.pdf' });
expect(result).toEqual({ id: 'att_123', filename: 'report.pdf', mimeType: 'application/pdf' });
});
it('throws on CLI failure', async () => {
const { tool } = setup(fail('file too large'));
await expect(
tool.execute({ team: 'acme', task_id: '1', file: '/tmp/huge.bin' }),
).rejects.toThrow('Failed to attach file');
});
});