agent-ecosystem/mcp-server/test/tools/task-comment.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

33 lines
1.3 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { register } from '../../src/tools/task-comment.js';
import { createMockRunner, createMockServer, ok, fail } from './test-helpers.js';
describe('task_comment', () => {
function setup(response = ok('OK comment added to task #1\n')) {
const runner = createMockRunner(response);
const { server, tools } = createMockServer();
register(server, runner);
return { runner, tool: tools.get('task_comment')! };
}
it('builds correct CLI args', async () => {
const { runner, tool } = setup();
await tool.execute({ team: 'acme', task_id: '1', text: 'Looking good!' });
expect(runner.execute).toHaveBeenCalledWith([
'--team', 'acme', 'task', 'comment', '1', '--text', 'Looking good!',
]);
});
it('includes from flag', async () => {
const { runner, tool } = setup();
await tool.execute({ team: 'acme', task_id: '1', text: 'Done', from: 'alice' });
const args = runner.execute.mock.calls[0]![0] as string[];
expect(args).toContain('--from');
expect(args[args.indexOf('--from') + 1]).toBe('alice');
});
it('throws on CLI failure', async () => {
const { tool } = setup(fail('task not found'));
await expect(tool.execute({ team: 'acme', task_id: '99', text: 'Hi' })).rejects.toThrow('Failed to add comment');
});
});