agent-ecosystem/test/main/services/team/FileContentResolver.test.ts
iliya a30727d3b0 feat: enhance team file handling and logging improvements
- Added support for a new worker in the team file system to list teams, improving performance and reliability in team management.
- Introduced event loop lag monitoring in various IPC handlers to track and log slow operations, enhancing observability.
- Implemented caching for CLI installation status to reduce redundant calls and improve responsiveness.
- Updated project and team data services to include total session counts, optimizing data handling and performance.
- Enhanced error handling and logging across multiple services to provide clearer insights into performance issues and failures.

Made-with: Cursor
2026-03-03 22:00:11 +02:00

52 lines
1.6 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest';
import type { SnippetDiff } from '@shared/types';
vi.mock('fs/promises', async (importOriginal) => {
const actual = await importOriginal<typeof import('fs/promises')>();
const access = vi.fn();
const readFile = vi.fn();
return {
...actual,
access,
readFile,
// ESM interop: some code paths expect a default export
default: { ...actual, access, readFile },
};
});
describe('FileContentResolver', () => {
it('treats empty on-disk content as valid for write-new reconstruction', async () => {
const fsPromises = await import('fs/promises');
const readFile = fsPromises.readFile as unknown as ReturnType<typeof vi.fn>;
readFile.mockResolvedValue('');
const { FileContentResolver } = await import('@main/services/team/FileContentResolver');
const logsFinder = {
findMemberLogPaths: vi.fn().mockResolvedValue([]),
};
const resolver = new FileContentResolver(logsFinder as any);
const snippets: SnippetDiff[] = [
{
toolUseId: 't1',
filePath: '/tmp/empty-new.txt',
toolName: 'Write',
type: 'write-new',
oldString: '',
newString: '',
replaceAll: false,
timestamp: new Date().toISOString(),
isError: false,
},
];
const content = await resolver.getFileContent('team', 'member', '/tmp/empty-new.txt', snippets);
expect(content.isNewFile).toBe(true);
expect(content.originalFullContent).toBe('');
expect(content.modifiedFullContent).toBe('');
expect(content.contentSource).toBe('snippet-reconstruction');
});
});