diff --git a/tests/workflow-engine.test.ts b/tests/workflow-engine.test.ts index 9ba50e4..de5e3cb 100644 --- a/tests/workflow-engine.test.ts +++ b/tests/workflow-engine.test.ts @@ -52,21 +52,18 @@ function createMockWorkflowEngine( const engine = new WorkflowEngine(vault as any, app as any, 'http://localhost:11434', 'llama3'); - // Access private properties via jest mocking - const mockVaultIndexer = VaultIndexer as unknown as jest.Mocked; - const mockToolExecutor = ToolExecutor as unknown as jest.Mocked; - const mockOllamaClient = OllamaClient as unknown as jest.Mocked; - const mockConversationStateManager = ConversationStateManager as unknown as jest.Mocked< - typeof ConversationStateManager - >; + // Access the actual mock instances created inside WorkflowEngine constructor + const mockVaultIndexer = (engine as any).vaultIndexer as jest.Mocked; + const mockToolExecutor = (engine as any).toolExecutor as jest.Mocked; + const mockOllamaClient = (engine as any).ollamaClient as jest.Mocked; + const mockConversationStateManager = (engine as any).conversationStateManager as jest.Mocked; return { engine, - mockVaultIndexer: mockVaultIndexer.prototype as unknown as jest.Mocked, - mockToolExecutor: mockToolExecutor.prototype as unknown as jest.Mocked, - mockOllamaClient: mockOllamaClient.prototype as unknown as jest.Mocked, - mockConversationStateManager: - mockConversationStateManager.prototype as unknown as jest.Mocked, + mockVaultIndexer, + mockToolExecutor, + mockOllamaClient, + mockConversationStateManager, }; } @@ -534,18 +531,18 @@ describe('WorkflowEngine', () => { it('should execute vault search step successfully', async () => { const mockEntries = [ { - file: { path: 'meeting-note.md', basename: 'meeting-note' }, + path: 'meeting-note.md', title: 'Team Meeting', content: 'Meeting notes content', score: 10, - frontmatter: { tags: 'meeting,team' }, + tags: 'meeting,team', }, { - file: { path: 'project-update.md', basename: 'project-update' }, + path: 'project-update.md', title: 'Project Update', content: 'Project progress notes', score: 8, - frontmatter: { tags: 'meeting,project' }, + tags: 'meeting,project', }, ]; @@ -581,18 +578,18 @@ describe('WorkflowEngine', () => { it('should apply tag filter in vault search', async () => { const mockEntries = [ { - file: { path: 'meeting-note.md', basename: 'meeting-note' }, + path: 'meeting-note.md', title: 'Team Meeting', content: 'Meeting notes', score: 10, - frontmatter: { tags: 'meeting,team' }, + tags: 'meeting,team', }, { - file: { path: 'personal-note.md', basename: 'personal-note' }, + path: 'personal-note.md', title: 'Personal Note', content: 'Personal thoughts', score: 8, - frontmatter: { tags: 'personal,daily' }, + tags: 'personal,daily', }, ]; @@ -727,7 +724,7 @@ describe('WorkflowEngine', () => { it('should execute format step with variable interpolation', async () => { mockVaultIndexer.searchVault.mockResolvedValueOnce([ { - file: { path: 'note.md' }, + path: 'note.md', title: 'Test Note', content: 'Note content', score: 10, @@ -845,7 +842,7 @@ describe('WorkflowEngine', () => { it('should execute multiple steps in sequence', async () => { mockVaultIndexer.searchVault.mockResolvedValueOnce([ { - file: { path: 'note.md' }, + path: 'note.md', title: 'Test Note', content: 'Content', score: 10, @@ -994,7 +991,7 @@ describe('WorkflowEngine', () => { it('should handle initial variables correctly', async () => { mockVaultIndexer.searchVault.mockResolvedValueOnce([ { - file: { path: 'note.md' }, + path: 'note.md', title: 'Meeting', content: 'Content', score: 10, @@ -1083,7 +1080,7 @@ describe('WorkflowEngine', () => { it('should interpolate simple variables', async () => { mockVaultIndexer.searchVault.mockResolvedValueOnce([ { - file: { path: 'note.md' }, + path: 'note.md', title: 'Note', content: 'Content', score: 10,