agent-ecosystem/test/renderer/utils/taskChangeRequest.test.ts
iliya 1ccc1432fc feat: enhance task change handling and improve plugin catalog integration
- Added a 'source' field to PluginCatalogItem to distinguish between official and third-party plugins.
- Refactored ChangeExtractorService to improve caching mechanisms and normalize file paths for better consistency.
- Updated TaskBoundaryParser to support task IDs with underscores, enhancing task identification.
- Enhanced TeamMcpConfigBuilder to merge user-defined MCP configurations with generated ones, improving configuration management.
- Improved UI components to display source information for plugins and MCP servers, enhancing user experience and clarity.
2026-03-11 18:16:40 +02:00

67 lines
1.8 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
buildTaskChangePresenceKey,
buildTaskChangeRequestOptions,
deriveTaskSince,
} from '@renderer/utils/taskChangeRequest';
describe('taskChangeRequest', () => {
it('derives since from the earliest known task timestamp with grace window', () => {
const since = deriveTaskSince({
id: 't1',
owner: 'alice',
status: 'completed',
createdAt: '2026-03-01T10:05:00.000Z',
updatedAt: '2026-03-01T12:00:00.000Z',
workIntervals: [{ startedAt: '2026-03-01T10:10:00.000Z' }],
historyEvents: [
{
id: 'evt-1',
type: 'status_changed',
from: 'pending',
to: 'in_progress',
timestamp: '2026-03-01T10:00:00.000Z',
},
],
});
expect(since).toBe('2026-03-01T09:58:00.000Z');
});
it('builds canonical task change request options', () => {
const options = buildTaskChangeRequestOptions(
{
id: 't1',
owner: 'alice',
status: 'completed',
createdAt: '2026-03-01T10:05:00.000Z',
updatedAt: '2026-03-01T12:00:00.000Z',
workIntervals: [{ startedAt: '2026-03-01T10:10:00.000Z' }],
historyEvents: [],
},
{ summaryOnly: true }
);
expect(options).toEqual({
owner: 'alice',
status: 'completed',
intervals: [{ startedAt: '2026-03-01T10:10:00.000Z' }],
since: '2026-03-01T10:03:00.000Z',
summaryOnly: true,
});
});
it('uses scope inputs for presence keys', () => {
const base = {
owner: 'alice',
status: 'completed',
intervals: [{ startedAt: '2026-03-01T10:10:00.000Z' }],
since: '2026-03-01T10:03:00.000Z',
};
expect(buildTaskChangePresenceKey('team-a', '1', base)).not.toBe(
buildTaskChangePresenceKey('team-a', '1', { ...base, owner: 'bob' })
);
});
});