test: update tests to use AIToolResponsePayload wrapper class

Refactor all test files to wrap tool response data in AIToolResponsePayload instances instead of passing raw objects directly to AIToolResponse constructor. Update assertions to access response data via payload.response property.
This commit is contained in:
Andrew Beal 2026-04-08 21:16:59 +01:00
parent 3bc2b34aa2
commit 540b76e0ea
6 changed files with 108 additions and 100 deletions

View file

@ -3,9 +3,11 @@ import { Conversation } from '../../Conversations/Conversation';
import { ConversationContent } from '../../Conversations/ConversationContent';
import { Role } from '../../Enums/Role';
import { AIToolResponse } from '../../AIClasses/ToolDefinitions/AIToolResponse';
import { AIToolResponsePayload } from '../../AIClasses/ToolDefinitions/AIToolResponsePayload';
import { AITool } from '../../Enums/AITool';
import { MimeType } from '../../Enums/MimeType';
import { StringTools } from '../../Helpers/StringTools';
import { Attachment } from '../../Conversations/Attachment';
describe('Conversation', () => {
describe('constructor', () => {
@ -383,11 +385,11 @@ describe('Conversation', () => {
const conversation = new Conversation();
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
new AIToolResponsePayload({
results: [
{ path: 'nonexistent.md', error: 'File does not exist: nonexistent.md' }
]
},
}),
'tool-123'
);
@ -403,21 +405,21 @@ describe('Conversation', () => {
// Parse the function response to verify error is included
const parsedResponse = JSON.parse(conversation.contents[0].functionResponse!);
expect(parsedResponse.functionResponse.response.results).toHaveLength(1);
expect(parsedResponse.functionResponse.response.results[0].error).toBe('File does not exist: nonexistent.md');
expect(parsedResponse.functionResponse.response.result.results).toHaveLength(1);
expect(parsedResponse.functionResponse.response.result.results[0].error).toBe('File does not exist: nonexistent.md');
});
it('should handle mix of successful reads and errors', () => {
const conversation = new Conversation();
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
new AIToolResponsePayload({
results: [
{ path: 'existing.md', type: 'md', contents: '# Hello' },
{ path: 'nonexistent.md', error: 'File does not exist: nonexistent.md' },
{ path: 'another.txt', type: 'txt', contents: 'World' }
]
},
}),
'tool-123'
);
@ -429,7 +431,7 @@ describe('Conversation', () => {
// Parse the function response
const parsedResponse = JSON.parse(conversation.contents[0].functionResponse!);
const results = parsedResponse.functionResponse.response.results;
const results = parsedResponse.functionResponse.response.result.results;
// Should have all 3 results (2 successful + 1 error)
expect(results).toHaveLength(3);
@ -449,11 +451,11 @@ describe('Conversation', () => {
const conversation = new Conversation();
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
new AIToolResponsePayload({
results: [
{ path: 'image.png', error: 'File does not exist: image.png' }
]
},
}),
'tool-123'
);
@ -467,19 +469,18 @@ describe('Conversation', () => {
// Verify error is in the function response
const parsedResponse = JSON.parse(conversation.contents[0].functionResponse!);
expect(parsedResponse.functionResponse.response.results[0].error).toBeDefined();
expect(parsedResponse.functionResponse.response.result.results[0].error).toBeDefined();
});
it('should handle binary files with errors not creating invalid attachments', () => {
const conversation = new Conversation();
const validAttachment = new Attachment('valid.png', MimeType.IMAGE_PNG, 'base64encodeddata...');
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
results: [
{ path: 'image.png', error: 'File does not exist: image.png' },
{ path: 'valid.png', type: 'png', contents: 'base64encodeddata...' }
]
},
new AIToolResponsePayload(
{ results: [{ path: 'image.png', error: 'File does not exist: image.png' }] },
[validAttachment]
),
'tool-123'
);
@ -488,10 +489,10 @@ describe('Conversation', () => {
// Should have 2 content items: function response + attachments
expect(conversation.contents).toHaveLength(2);
// First item should have the error and success message
// First item should have the error
const parsedResponse = JSON.parse(conversation.contents[0].functionResponse!);
expect(parsedResponse.functionResponse.response.results).toHaveLength(1);
expect(parsedResponse.functionResponse.response.results[0].error).toBe('File does not exist: image.png');
expect(parsedResponse.functionResponse.response.result.results).toHaveLength(1);
expect(parsedResponse.functionResponse.response.result.results[0].error).toBe('File does not exist: image.png');
// Second item should only have the valid attachment
expect(conversation.contents[1].attachments).toHaveLength(1);
@ -504,11 +505,11 @@ describe('Conversation', () => {
const conversation = new Conversation();
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
new AIToolResponsePayload({
results: [
{ path: 'file.md', type: 'md', contents: '# Title' }
]
},
}),
'tool-123'
);
@ -516,18 +517,18 @@ describe('Conversation', () => {
expect(conversation.contents).toHaveLength(1);
const parsedResponse = JSON.parse(conversation.contents[0].functionResponse!);
expect(parsedResponse.functionResponse.response.results[0].contents).toBe('# Title');
expect(parsedResponse.functionResponse.response.result.results[0].contents).toBe('# Title');
});
it('should create attachments for binary files', () => {
const conversation = new Conversation();
const attachment = new Attachment('image.png', MimeType.IMAGE_PNG, 'base64data...');
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
results: [
{ path: 'image.png', type: 'png', contents: 'base64data...' }
]
},
new AIToolResponsePayload(
{ message: 'Files retrieved successfully. The contents of the files are included below.', count: 1 },
[attachment]
),
'tool-123'
);
@ -544,13 +545,13 @@ describe('Conversation', () => {
it('should base64-encode document file contents and set mime type to text/plain', () => {
const conversation = new Conversation();
const documentText = 'This is the extracted text from a document file.';
const docAttachment = new Attachment('report.odt', MimeType.TEXT_PLAIN, StringTools.toBase64(documentText));
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
results: [
{ path: 'report.odt', type: 'odt', contents: documentText }
]
},
new AIToolResponsePayload(
{ message: 'Files retrieved successfully. The contents of the files are included below.', count: 1 },
[docAttachment]
),
'tool-123'
);
@ -570,15 +571,14 @@ describe('Conversation', () => {
it('should handle document files alongside text and binary files', () => {
const conversation = new Conversation();
const xlsxAttachment = new Attachment('spreadsheet.xlsx', MimeType.TEXT_PLAIN, StringTools.toBase64('Extracted spreadsheet text'));
const imgAttachment = new Attachment('photo.png', MimeType.IMAGE_PNG, 'base64imagedata...');
const functionResponse = new AIToolResponse(
AITool.ReadVaultFiles,
{
results: [
{ path: 'notes.md', type: 'md', contents: '# Notes' },
{ path: 'spreadsheet.xlsx', type: 'xlsx', contents: 'Extracted spreadsheet text' },
{ path: 'photo.png', type: 'png', contents: 'base64imagedata...' }
]
},
new AIToolResponsePayload(
{ results: [{ type: 'md', path: 'notes.md', contents: '# Notes' }], message: 'The contents of the files are included below.' },
[xlsxAttachment, imgAttachment]
),
'tool-123'
);
@ -589,8 +589,8 @@ describe('Conversation', () => {
// Text file in function response
const parsedResponse = JSON.parse(conversation.contents[0].functionResponse!);
expect(parsedResponse.functionResponse.response.results).toHaveLength(1);
expect(parsedResponse.functionResponse.response.results[0].path).toBe('notes.md');
expect(parsedResponse.functionResponse.response.result.results).toHaveLength(1);
expect(parsedResponse.functionResponse.response.result.results[0].path).toBe('notes.md');
// Document and binary as attachments
const attachments = conversation.contents[1].attachments;
@ -600,8 +600,8 @@ describe('Conversation', () => {
expect(docAttachment.mimeType).toBe(MimeType.TEXT_PLAIN);
expect(docAttachment.base64).toBe(StringTools.toBase64('Extracted spreadsheet text'));
const imgAttachment = attachments.find(a => a.fileName === 'photo.png')!;
expect(imgAttachment.base64).toBe('base64imagedata...');
const pngAttachment = attachments.find(a => a.fileName === 'photo.png')!;
expect(pngAttachment.base64).toBe('base64imagedata...');
});
});
@ -610,7 +610,7 @@ describe('Conversation', () => {
const conversation = new Conversation();
const functionResponse = new AIToolResponse(
AITool.WriteVaultFile,
{ success: true },
new AIToolResponsePayload({ success: true }),
'tool-123'
);

View file

@ -8,6 +8,7 @@ import { Role } from '../../Enums/Role';
import { AITool } from '../../Enums/AITool';
import { AIToolCall } from '../../AIClasses/AIToolCall';
import { AIToolResponse } from '../../AIClasses/ToolDefinitions/AIToolResponse';
import { AIToolResponsePayload } from '../../AIClasses/ToolDefinitions/AIToolResponsePayload';
/**
* INTEGRATION TESTS - AIControllerService
@ -53,7 +54,7 @@ describe('AIControllerService - Integration Tests', () => {
// Mock AIToolService
mockAIToolService = {
performAITool: vi.fn().mockResolvedValue(
new AIToolResponse(AITool.SearchVaultFiles, { results: [] }, 'test-tool-id')
new AIToolResponse(AITool.SearchVaultFiles, new AIToolResponsePayload({ results: [] }), 'test-tool-id')
)
};
RegisterSingleton(Services.AIToolService, mockAIToolService);

View file

@ -53,6 +53,10 @@ describe('AIToolService - Integration Tests', () => {
RegisterSingleton(Services.SettingsService, {
settings: { enableMemories: false, allowUpdatingMemories: false }
});
RegisterSingleton(Services.WebViewerService, {
getWebViewContent: vi.fn(),
takeScreenshot: vi.fn()
});
// Mock Exception.log
vi.spyOn(Exception, 'log').mockImplementation(() => {});
@ -105,7 +109,7 @@ describe('AIToolService - Integration Tests', () => {
expect(result.name).toBe(AITool.SearchVaultFiles);
expect(result.toolId).toBe('tool_1');
expect(result.response).toEqual([{searchTerm: 'test', results: [
expect(result.payload.response).toEqual([{searchTerm: 'test', results: [
{
path: 'notes/test.md',
snippets: [
@ -133,7 +137,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
// Empty search terms return empty results
expect(result.response).toEqual([{searchTerm: '', results: []}]);
expect(result.payload.response).toEqual([{searchTerm: '', results: []}]);
});
it('should return empty array when search term is whitespace', async () => {
@ -147,7 +151,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
// Whitespace search terms return empty results (after trim)
expect(result.response).toEqual([{searchTerm: ' ', results: []}]);
expect(result.payload.response).toEqual([{searchTerm: ' ', results: []}]);
});
it('should return empty array when no matches found', async () => {
@ -160,7 +164,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
// No matches returns empty results
expect(result.response).toEqual([{searchTerm: 'nonexistent', results: []}]);
expect(result.payload.response).toEqual([{searchTerm: 'nonexistent', results: []}]);
});
it('should handle single match', async () => {
@ -179,10 +183,10 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_5'
} as any);
expect(result.response).toHaveLength(1);
expect((result.response as any)[0].searchTerm).toBe('single');
expect((result.response as any)[0].results).toHaveLength(1);
expect((result.response as any)[0].results[0].path).toBe('single.md');
expect(result.payload.response).toHaveLength(1);
expect((result.payload.response as any)[0].searchTerm).toBe('single');
expect((result.payload.response as any)[0].results).toHaveLength(1);
expect((result.payload.response as any)[0].results[0].path).toBe('single.md');
});
});
@ -199,7 +203,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_6'
} as any);
expect(result.response).toEqual({
expect(result.payload.response).toEqual({
results: [
{ type: 'md', path: 'file1.md', contents: 'Content of file 1' },
{ type: 'md', path: 'file2.md', contents: 'Content of file 2' },
@ -223,7 +227,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_7'
} as any);
expect(result.response).toEqual({
expect(result.payload.response).toEqual({
results: [
{ type: 'md', path: 'exists.md', contents: 'Existing content' },
{ path: 'missing1.md', error: 'File not found' },
@ -244,10 +248,10 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_8'
} as any);
const results = (result.response as any).results;
expect(results[0].contents).toBe('Content A');
expect(results[1].error).toBe('File not found');
expect(results[2].contents).toBe('Content B');
const results = (result.payload.response as any).results;
expect(results.find((r: any) => r.contents === 'Content A')).toBeDefined();
expect(results.find((r: any) => r.contents === 'Content B')).toBeDefined();
expect(results.find((r: any) => r.error === 'File not found')).toBeDefined();
});
it('should handle empty file list', async () => {
@ -257,7 +261,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_9'
} as any);
expect(result.response).toEqual({ results: [] });
expect(result.payload.response).toEqual({ message: 'Files retrieved successfully. The contents of the files are included below.', count: 0 });
});
it('should handle single file read', async () => {
@ -269,8 +273,8 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_10'
} as any);
expect((result.response as any).results).toHaveLength(1);
expect((result.response as any).results[0].contents).toBe('Single file content');
expect((result.payload.response as any).results).toHaveLength(1);
expect((result.payload.response as any).results[0].contents).toBe('Single file content');
});
});
@ -292,7 +296,7 @@ describe('AIToolService - Integration Tests', () => {
'notes/new-note.md',
'# New Note\n\nContent here'
);
expect(result.response).toEqual({ success: true });
expect(result.payload.response).toEqual({ success: true });
});
it('should handle write failure', async () => {
@ -309,8 +313,8 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_12'
} as any);
expect((result.response as any).success).toBe(false);
expect((result.response as any).error).toBeDefined();
expect((result.payload.response as any).success).toBe(false);
expect((result.payload.response as any).error).toBeDefined();
});
it('should normalize file path', async () => {
@ -347,7 +351,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
expect(mockFileSystemService.writeFile).toHaveBeenCalledWith('empty.md', '');
expect((result.response as any).success).toBe(true);
expect((result.payload.response as any).success).toBe(true);
});
});
@ -370,7 +374,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
expect(mockFileSystemService.patchFile).toHaveBeenCalledWith('notes/test.md', oldContent, newContent);
expect(result.response).toEqual({ success: true });
expect(result.payload.response).toEqual({ success: true });
});
it('should handle patch failure', async () => {
@ -391,8 +395,8 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_patch_2'
} as any);
expect((result.response as any).success).toBe(false);
expect((result.response as any).error).toBe('Content to replace was not found in the file');
expect((result.payload.response as any).success).toBe(false);
expect((result.payload.response as any).error).toBe('Content to replace was not found in the file');
});
it('should normalize file path', async () => {
@ -438,8 +442,8 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_patch_4'
} as any);
expect((result.response as any).success).toBe(false);
expect((result.response as any).error).toContain('File does not exist');
expect((result.payload.response as any).success).toBe(false);
expect((result.payload.response as any).error).toContain('File does not exist');
});
it('should handle complex multi-line replacement', async () => {
@ -460,7 +464,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
expect(mockFileSystemService.patchFile).toHaveBeenCalledWith('complex.md', oldContent, newContent);
expect((result.response as any).success).toBe(true);
expect((result.payload.response as any).success).toBe(true);
});
it('should handle adding new content', async () => {
@ -480,7 +484,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_patch_6'
} as any);
expect((result.response as any).success).toBe(true);
expect((result.payload.response as any).success).toBe(true);
});
it('should handle removing content', async () => {
@ -500,7 +504,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_patch_7'
} as any);
expect((result.response as any).success).toBe(true);
expect((result.payload.response as any).success).toBe(true);
});
it('should handle permission denied error', async () => {
@ -521,8 +525,8 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_patch_8'
} as any);
expect((result.response as any).success).toBe(false);
expect((result.response as any).error).toBe('Permission denied');
expect((result.payload.response as any).success).toBe(false);
expect((result.payload.response as any).error).toBe('Permission denied');
});
it('should return correct toolId in response', async () => {
@ -557,7 +561,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_patch_invalid'
} as any);
expect((result.response as any).error).toContain('Invalid arguments for patch_vault_file');
expect((result.payload.response as any).error).toContain('Invalid arguments for patch_vault_file');
expect(mockFileSystemService.patchFile).not.toHaveBeenCalled();
});
});
@ -579,7 +583,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_15'
} as any);
expect(result.response).toEqual({
expect(result.payload.response).toEqual({
results: [
{ path: 'file1.md', success: true },
{ path: 'file2.md', success: true },
@ -599,7 +603,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_16'
} as any);
expect(result.response).toEqual({
expect(result.payload.response).toEqual({
error: 'Confirmation was false, no action taken'
});
expect(mockFileSystemService.deleteFile).not.toHaveBeenCalled();
@ -623,7 +627,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_17'
} as any);
expect((result.response as any).results).toEqual([
expect((result.payload.response as any).results).toEqual([
{ path: 'a.md', success: true },
{ path: 'missing.md', success: false, error: 'File not found' },
{ path: 'c.md', success: true }
@ -645,7 +649,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_18'
} as any);
const results = (result.response as any).results;
const results = (result.payload.response as any).results;
expect(results[0].success).toBe(false);
expect(results[1].success).toBe(false);
});
@ -661,7 +665,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_19'
} as any);
expect((result.response as any).results).toEqual([]);
expect((result.payload.response as any).results).toEqual([]);
});
});
@ -682,7 +686,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_20'
} as any);
expect(result.response).toEqual({
expect(result.payload.response).toEqual({
results: [
{ path: 'dest/a.md', success: true },
{ path: 'dest/b.md', success: true },
@ -702,7 +706,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_21'
} as any);
expect(result.response).toEqual({
expect(result.payload.response).toEqual({
error: 'Source paths array length does not equal destination paths array length'
});
expect(mockFileSystemService.moveFile).not.toHaveBeenCalled();
@ -726,7 +730,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_22'
} as any);
expect((result.response as any).results).toEqual([
expect((result.payload.response as any).results).toEqual([
{ path: 'new/a.md', success: true },
{ path: 'existing.md', success: false, error: 'Destination exists' },
{ path: 'new/c.md', success: true }
@ -760,7 +764,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_24'
} as any);
expect((result.response as any).results).toEqual([]);
expect((result.payload.response as any).results).toEqual([]);
});
});
@ -773,7 +777,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
expect(result.name).toBe(AITool.RequestWebSearch);
expect(result.response).toEqual({});
expect(result.payload.response).toEqual({});
expect(result.toolId).toBe('tool_25');
});
@ -784,7 +788,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'tool_26'
} as any);
expect(result.response).toEqual({});
expect(result.payload.response).toEqual({});
});
});
@ -797,7 +801,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
expect(result.name).toBe('unknown');
expect(result.toolId).toBe('tool_27');
expect(result.response).toEqual({ error: 'Unknown function request unknown' });
expect(result.payload.response).toEqual({ error: 'Unknown function request unknown' });
});
it('should return unknown response for invalid function', async () => {
@ -808,7 +812,7 @@ describe('AIToolService - Integration Tests', () => {
} as any);
expect(result.name).toBe('unknown');
expect(result.toolId).toBe('tool_error');
expect(result.response).toEqual({ error: 'Unknown function request unknown' });
expect(result.payload.response).toEqual({ error: 'Unknown function request unknown' });
});
});
@ -829,7 +833,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'search_1'
} as any);
const foundPath = (searchResult.response as any)[0].results[0].path;
const foundPath = (searchResult.payload.response as any)[0].results[0].path;
// Then read
mockFileSystemService.readFile.mockResolvedValue('File content here');
@ -840,8 +844,8 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'read_1'
} as any);
expect((readResult.response as any).results[0].contents).toBe('File content here');
expect((readResult.response as any).results[0].error).toBeUndefined();
expect((readResult.payload.response as any).results[0].contents).toBe('File content here');
expect((readResult.payload.response as any).results[0].error).toBeUndefined();
});
it('should handle write -> move workflow', async () => {
@ -858,7 +862,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'write_1'
} as any);
expect((writeResult.response as any).success).toBe(true);
expect((writeResult.payload.response as any).success).toBe(true);
// Then move
mockFileSystemService.moveFile.mockResolvedValue({ success: true });
@ -873,7 +877,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'move_1'
} as any);
expect((moveResult.response as any).results[0].success).toBe(true);
expect((moveResult.payload.response as any).results[0].success).toBe(true);
});
it('should handle read -> patch workflow', async () => {
@ -886,7 +890,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'read_2'
} as any);
expect((readResult.response as any).results[0].contents).toContain('Original');
expect((readResult.payload.response as any).results[0].contents).toContain('Original');
// Then patch it
mockFileSystemService.patchFile.mockResolvedValue(createMockFile('document.md', 'document'));
@ -905,7 +909,7 @@ describe('AIToolService - Integration Tests', () => {
toolId: 'patch_1'
} as any);
expect((patchResult.response as any).success).toBe(true);
expect((patchResult.payload.response as any).success).toBe(true);
expect(mockFileSystemService.patchFile).toHaveBeenCalledWith('document.md', oldContent, newContent);
});
});

View file

@ -5,6 +5,7 @@ import { Services } from '../../Services/Services';
import { AITool } from '../../Enums/AITool';
import { AIToolCall } from '../../AIClasses/AIToolCall';
import { AIToolResponse } from '../../AIClasses/ToolDefinitions/AIToolResponse';
import { AIToolResponsePayload } from '../../AIClasses/ToolDefinitions/AIToolResponsePayload';
import type { ExecutionStep } from '../../Types/ExecutionStep';
/**
@ -51,7 +52,7 @@ describe('ExecutionAgent - Unit Tests', () => {
// Mock AIToolService
mockAIToolService = {
performAITool: vi.fn().mockResolvedValue(
new AIToolResponse(AITool.SearchVaultFiles, { results: [] }, 'test-tool-id')
new AIToolResponse(AITool.SearchVaultFiles, new AIToolResponsePayload({ results: [] }), 'test-tool-id')
)
};
RegisterSingleton(Services.AIToolService, mockAIToolService);

View file

@ -11,6 +11,7 @@ import { Role } from '../../Enums/Role';
import { AITool } from '../../Enums/AITool';
import { AIToolCall } from '../../AIClasses/AIToolCall';
import { AIToolResponse } from '../../AIClasses/ToolDefinitions/AIToolResponse';
import { AIToolResponsePayload } from '../../AIClasses/ToolDefinitions/AIToolResponsePayload';
import type { ExecutionStep } from '../../Types/ExecutionStep';
/**
@ -61,7 +62,7 @@ describe('Multi-Agent Integration Tests', () => {
// Mock AIToolService
mockAIToolService = {
performAITool: vi.fn().mockResolvedValue(
new AIToolResponse(AITool.SearchVaultFiles, { results: ['file1.md', 'file2.md'] }, 'test-tool-id')
new AIToolResponse(AITool.SearchVaultFiles, new AIToolResponsePayload({ results: ['file1.md', 'file2.md'] }), 'test-tool-id')
)
};
RegisterSingleton(Services.AIToolService, mockAIToolService);

View file

@ -8,6 +8,7 @@ import { Role } from '../../Enums/Role';
import { AITool } from '../../Enums/AITool';
import { AIToolCall } from '../../AIClasses/AIToolCall';
import { AIToolResponse } from '../../AIClasses/ToolDefinitions/AIToolResponse';
import { AIToolResponsePayload } from '../../AIClasses/ToolDefinitions/AIToolResponsePayload';
/**
* UNIT TESTS - PlanningAgent
@ -53,7 +54,7 @@ describe('PlanningAgent - Unit Tests', () => {
// Mock AIToolService
mockAIToolService = {
performAITool: vi.fn().mockResolvedValue(
new AIToolResponse(AITool.SearchVaultFiles, { results: [] }, 'test-tool-id')
new AIToolResponse(AITool.SearchVaultFiles, new AIToolResponsePayload({ results: [] }), 'test-tool-id')
)
};
RegisterSingleton(Services.AIToolService, mockAIToolService);