Skip to content

Commit 62fbc18

Browse files
committed
WIP todo file
1 parent 8816fef commit 62fbc18

File tree

1 file changed

+204
-0
lines changed

1 file changed

+204
-0
lines changed

TODO.md

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# Testing Improvement TODO
2+
3+
This document outlines the comprehensive testing improvements needed for the VSCode Coder extension, focusing on achieving better test coverage and code quality.
4+
5+
## Current Testing Status
6+
7+
**Files with existing tests (7 files):**
8+
- `src/util.test.ts` (8 tests)
9+
- `src/featureSet.test.ts` (2 tests)
10+
- `src/sshSupport.test.ts` (9 tests)
11+
- `src/sshConfig.test.ts` (14 tests)
12+
- `src/headers.test.ts` (9 tests)
13+
- `src/error.test.ts` (11 tests)
14+
- `src/cliManager.test.ts` (6 tests)
15+
16+
**Total: 59 tests passing**
17+
18+
## Priority 1: Core API Module Testing
19+
20+
### 🎯 `src/api.ts` - Complete Test Suite (FOCUS)
21+
22+
**Functions needing comprehensive tests:**
23+
24+
1. **`needToken()`** - Configuration-based token requirement logic
25+
- Test with mTLS enabled (cert + key files present)
26+
- Test with mTLS disabled (no cert/key files)
27+
- Test with partial mTLS config (cert only, key only)
28+
- Test with empty/whitespace config values
29+
30+
2. **`createHttpAgent()`** - HTTP agent configuration
31+
- Test proxy configuration with different proxy settings
32+
- Test TLS certificate loading (cert, key, CA files)
33+
- Test insecure mode vs secure mode
34+
- Test file reading errors and fallbacks
35+
- Test alternative hostname configuration
36+
- Mock file system operations
37+
38+
3. **`makeCoderSdk()`** - SDK instance creation and configuration
39+
- Test with valid token authentication
40+
- Test without token (mTLS authentication)
41+
- Test header injection from storage
42+
- Test request interceptor functionality
43+
- Test response interceptor and error wrapping
44+
- Mock external dependencies (Api, Storage)
45+
46+
4. **`createStreamingFetchAdapter()`** - Streaming fetch adapter
47+
- Test successful stream creation and data flow
48+
- Test error handling during streaming
49+
- Test stream cancellation
50+
- Test different response status codes
51+
- Test header extraction
52+
- Mock AxiosInstance responses
53+
54+
5. **`startWorkspaceIfStoppedOrFailed()`** - Workspace lifecycle management
55+
- Test with already running workspace (early return)
56+
- Test successful workspace start process
57+
- Test workspace start failure scenarios
58+
- Test stdout/stderr handling and output formatting
59+
- Test process exit codes and error messages
60+
- Mock child process spawning
61+
62+
6. **`waitForBuild()`** - Build monitoring and log streaming
63+
- Test initial log fetching
64+
- Test WebSocket connection for follow logs
65+
- Test log streaming and output formatting
66+
- Test WebSocket error handling
67+
- Test build completion detection
68+
- Mock WebSocket and API responses
69+
70+
**Test Infrastructure Needs:**
71+
- Mock VSCode workspace configuration
72+
- Mock file system operations (fs/promises)
73+
- Mock child process spawning
74+
- Mock WebSocket connections
75+
- Mock Axios instances and responses
76+
- Mock Storage interface
77+
78+
## Priority 2: Missing Test Files
79+
80+
### 🔴 `src/api-helper.ts` - Error handling utilities
81+
- Test `errToStr()` function with various error types
82+
- Test error message formatting and sanitization
83+
84+
### 🔴 `src/commands.ts` - VSCode command implementations
85+
- Test all command handlers
86+
- Test command registration and lifecycle
87+
- Mock VSCode command API
88+
89+
### 🔴 `src/extension.ts` - Extension entry point
90+
- Test extension activation/deactivation
91+
- Test command registration
92+
- Test provider registration
93+
- Mock VSCode extension API
94+
95+
### 🔴 `src/inbox.ts` - Message handling
96+
- Test message queuing and processing
97+
- Test different message types
98+
99+
### 🔴 `src/proxy.ts` - Proxy configuration
100+
- Test proxy URL resolution
101+
- Test bypass logic
102+
- Test different proxy configurations
103+
104+
### 🔴 `src/remote.ts` - Remote connection handling
105+
- Test remote authority resolution
106+
- Test connection establishment
107+
- Test error scenarios
108+
109+
### 🔴 `src/storage.ts` - Data persistence
110+
- Test header storage and retrieval
111+
- Test configuration persistence
112+
- Mock file system operations
113+
114+
### 🔴 `src/workspaceMonitor.ts` - Workspace monitoring
115+
- Test workspace state tracking
116+
- Test change detection and notifications
117+
118+
### 🔴 `src/workspacesProvider.ts` - VSCode tree view provider
119+
- Test workspace tree construction
120+
- Test refresh logic
121+
- Test user interactions
122+
- Mock VSCode tree view API
123+
124+
## Priority 3: Test Quality Improvements
125+
126+
### 🔧 Existing Test Enhancements
127+
128+
1. **Increase coverage in existing test files:**
129+
- Add edge cases and error scenarios
130+
- Test async/await error handling
131+
- Add integration test scenarios
132+
133+
2. **Improve test structure:**
134+
- Group related tests using `describe()` blocks
135+
- Add setup/teardown with `beforeEach()`/`afterEach()`
136+
- Consistent test naming conventions
137+
138+
3. **Add performance tests:**
139+
- Test timeout handling
140+
- Test concurrent operations
141+
- Memory usage validation
142+
143+
## Priority 4: Test Infrastructure
144+
145+
### 🛠 Testing Utilities
146+
147+
1. **Create test helpers:**
148+
- Mock factory functions for common objects
149+
- Shared test fixtures and data
150+
- Custom matchers for VSCode-specific assertions
151+
152+
2. **Add test configuration:**
153+
- Test environment setup
154+
- Coverage reporting configuration
155+
- CI/CD integration improvements
156+
157+
3. **Mock improvements:**
158+
- Better VSCode API mocking
159+
- File system operation mocking
160+
- Network request mocking
161+
162+
## Implementation Strategy
163+
164+
### Phase 1: `src/api.ts` Complete Coverage (Week 1)
165+
- Create `src/api.test.ts` with comprehensive test suite
166+
- Focus on the 6 main functions with all edge cases
167+
- Set up necessary mocks and test infrastructure
168+
169+
### Phase 2: Core Extension Files (Week 2)
170+
- `src/extension.ts` - Entry point testing
171+
- `src/commands.ts` - Command handler testing
172+
- `src/storage.ts` - Persistence testing
173+
174+
### Phase 3: Remaining Modules (Week 3)
175+
- All remaining untested files
176+
- Integration between modules
177+
- End-to-end workflow testing
178+
179+
### Phase 4: Quality & Coverage (Week 4)
180+
- Achieve >90% code coverage
181+
- Performance and reliability testing
182+
- Documentation of testing patterns
183+
184+
## Testing Standards
185+
186+
- Use Vitest framework (already configured)
187+
- Follow existing patterns from current test files
188+
- Mock external dependencies (VSCode API, file system, network)
189+
- Test both success and failure scenarios
190+
- Include async/await error handling tests
191+
- Use descriptive test names and organize with `describe()` blocks
192+
- Maintain fast test execution (all tests should run in <5 seconds)
193+
194+
## Success Metrics
195+
196+
- [ ] All 17 source files have corresponding test files
197+
- [ ] `src/api.ts` achieves >95% code coverage
198+
- [ ] All tests pass in CI mode (`yarn test:ci`)
199+
- [ ] Test execution time remains under 5 seconds
200+
- [ ] Zero flaky tests (consistent pass/fail results)
201+
202+
---
203+
204+
**Next Action:** Start with `src/api.test.ts` implementation focusing on the `needToken()` and `createHttpAgent()` functions first.

0 commit comments

Comments
 (0)