TASK-006-testing-suite.md•3.12 kB
# TASK-006: Comprehensive Testing Suite
## Task Overview
**Priority**: P1 (Important)
**Estimated Effort**: 1.5 days
**Dependencies**: TASK-001 through TASK-005
**Status**: Not Started
## Description
Create comprehensive test coverage for the configuration mode feature, including unit tests, integration tests, and end-to-end tests.
## Acceptance Criteria
- [ ] Unit tests for ConfigToolsManager
- [ ] Unit tests for mode switching tools
- [ ] Integration tests for server mode logic
- [ ] End-to-end tests for complete workflows
- [ ] Test coverage >80% for new code
- [ ] All tests pass in CI
## Technical Details
### Test Categories
#### 1. Unit Tests
- ToolsProvider interface
- Both managers implement the interface
- getMcpTools() returns correct type
- ConfigToolsManager
- Initialization
- Tool registration
- getMcpTools() method
- Error handling
- Mode switching tools
- Tool schemas
- Handler logic
- Error cases
#### 2. Integration Tests
- Server mode management
- Initialization logic
- Mode transitions
- Tool routing
- Notifications
- Auto-exit triggers
- equip-toolset trigger
- build-toolset trigger
- Failure scenarios
#### 3. End-to-End Tests
- Complete workflow scenarios
- Start with no toolset → config mode
- Create toolset → auto-exit
- Manual mode switching
- Feature flag behavior
### Files to Create/Modify
- `src/config-tools/manager.test.ts`
- `src/config-tools/tools/*.test.ts`
- `src/server/enhanced.test.ts` (additions)
- `src/integration/configuration-mode.test.ts` (new)
- `src/e2e/configuration-mode.e2e.test.ts` (new)
### Test Scenarios
#### Scenario 1: Fresh Start
```typescript
test('starts in configuration mode when no toolset equipped', async () => {
const server = new EnhancedMCPServer({ /* no toolset */ });
const tools = await server.listTools();
expect(tools).toContainEqual(
expect.objectContaining({ name: 'build-toolset' })
);
expect(tools).not.toContainEqual(
expect.objectContaining({ name: 'enter-configuration-mode' })
);
});
```
#### Scenario 2: Mode Switching
```typescript
test('switches between modes correctly', async () => {
// Start in normal mode with toolset
const server = new EnhancedMCPServer({ /* with toolset */ });
// Enter configuration mode
await server.callTool('enter-configuration-mode', {});
const configTools = await server.listTools();
expect(configTools).toContainEqual(
expect.objectContaining({ name: 'exit-configuration-mode' })
);
// Exit configuration mode
await server.callTool('exit-configuration-mode', {});
const normalTools = await server.listTools();
expect(normalTools).toContainEqual(
expect.objectContaining({ name: 'enter-configuration-mode' })
);
});
```
## Testing Requirements
- All tests must be deterministic
- Mock external dependencies appropriately
- Test error conditions and edge cases
- Verify notifications are triggered correctly
- Test with and without feature flag
## Notes
Focus on testing the integration points and mode transition logic thoroughly, as these are the most complex parts of the feature.