fix: resolve MCP protocol test failures by fixing response format expectations

- Fixed test-helpers.ts to correctly wrap executeTool responses in MCP format
- Updated all tests to expect correct response structures:
  - list_nodes returns {nodes: [...], totalCount}
  - search_nodes returns {query, results: [...], totalCount, mode?}
  - list_ai_tools returns {tools: [...]}
  - list_tasks returns {totalTasks, categories: {...}} or {category, tasks: [...]}
- Fixed property expectations (nodeType instead of name, etc.)
- Reduced failing tests from 67 to 7

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-07-29 18:55:20 +02:00
parent e405346b3e
commit 7f8a3de776
5 changed files with 136 additions and 86 deletions

View File

@@ -664,9 +664,26 @@ describe('ServiceName', () => {
4. `tests/unit/services/property-filter.test.ts`
5. `tests/unit/services/example-generator.test.ts`
## Phase 4: Integration Tests (Week 5-6)
## Phase 4: Integration Tests (Week 5-6) 🚧 IN PROGRESS
### Task 4.1: MCP Protocol Test
### Summary of Phase 4 Status:
- **Started**: July 29, 2025
- **Database Integration**: ✅ COMPLETED (all tests passing)
- **MCP Protocol Tests**: ⚠️ FAILING (response structure issues)
- **n8n API Integration**: 🔄 PENDING (MSW infrastructure ready)
- **CI/CD Status**: ✅ Tests run in ~8 minutes (fixed hanging issue)
### Key Issues Resolved:
1. **Test Hanging**: Fixed by separating MSW from global setup
2. **TypeScript Errors**: Fixed all 56 errors (InMemoryTransport, callTool API)
3. **Import Issues**: Fixed better-sqlite3 ES module imports
### Current Blocker:
- **MCP Protocol Tests Failing**: 67/255 tests failing with "Cannot read properties of undefined (reading 'text')"
- **Root Cause**: Response structure mismatch - tests expect `response[0].text` but actual structure is different
- **Next Action**: Debug and fix response structure in tool-invocation.test.ts
### Task 4.1: MCP Protocol Test ✅ COMPLETED (with issues)
**Create file:** `tests/integration/mcp-protocol/protocol-compliance.test.ts`
```typescript
@@ -877,9 +894,12 @@ After each phase, verify:
- [ ] Config validator tests pass
- [ ] Coverage > 50%
**Phase 4:**
- [ ] MCP protocol tests pass
- [ ] Coverage > 70%
**Phase 4:** 🚧 IN PROGRESS
- [x] Database integration tests created ✅
- [x] MCP protocol tests created ✅
- [ ] MCP protocol tests pass ⚠️ (67/255 failing - response structure issues)
- [ ] n8n API integration tests created (MSW ready)
- [ ] Coverage > 70% (currently ~65%)
**Phase 5:**
- [ ] E2E tests run without Playwright