Skip to content

Commit ae64c40

Browse files
jaggederestclaude
andcommitted
refactor: improve remote.ts testability by extracting callbacks and complex logic
- Extract anonymous callbacks into named methods for better testability - Remove recursive promise pattern in findSSHProcessID - Split complex logic in maybeWaitForRunning into smaller methods - Extract network status update logic for easier testing - Add protected methods that can be overridden in tests - Update TODO.md with detailed 100% coverage sprint plan These changes make remote.ts more modular and testable without changing functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 36edebe commit ae64c40

File tree

2 files changed

+427
-284
lines changed

2 files changed

+427
-284
lines changed

TODO.md

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**Test Infrastructure Complete:** 17/17 source files have test files
66
**Total Tests:** 345 tests passing across 17 test files
77
**Test Framework:** Vitest with comprehensive mocking infrastructure
8-
**Overall Line Coverage:** 70.43% (significant gaps remain)
8+
**Overall Line Coverage:** 70.43% (Target: 100%)
99

1010
---
1111

@@ -20,29 +20,29 @@
2020
| `proxy.ts` | 100% | ✅ Perfect coverage |
2121

2222
### 🟢 **High Coverage (90%+ lines, 5 files)**
23-
| File | Lines | Tests | Priority |
23+
| File | Lines | Tests | Remaining Gaps |
2424
|------|-------|-------|----------|
25-
| `workspaceMonitor.ts` | 98.65% | 19 | ✅ Nearly complete |
26-
| `sshConfig.ts` | 96.21% | 14 | ✅ Nearly complete |
27-
| `extension.ts` | 93.44% | 26 | 🔸 Minor gaps |
28-
| `featureSet.ts` | 90.9% | 2 | 🔸 Minor gaps |
29-
| `cliManager.ts` | 90.05% | 6 | 🔸 Minor gaps |
25+
| `workspaceMonitor.ts` | 98.65% | 19 | Lines 158-159, 183 |
26+
| `sshConfig.ts` | 96.21% | 14 | Lines 175, 251, 286-287 |
27+
| `extension.ts` | 93.44% | 26 | Lines 271-272, 320-321 |
28+
| `featureSet.ts` | 90.9% | 2 | Lines 18-20 |
29+
| `cliManager.ts` | 90.05% | 6 | Lines 140, 152, 165, 167 |
3030

3131
### 🟡 **Medium Coverage (70-90% lines, 4 files)**
32-
| File | Lines | Tests | Key Gaps |
32+
| File | Lines | Tests | Uncovered Lines |
3333
|------|-------|-------|----------|
34-
| `storage.ts` | 89.19% | 55 | Error scenarios, file operations |
35-
| `sshSupport.ts` | 88.78% | 9 | Edge cases, environment detection |
36-
| `headers.ts` | 85.08% | 9 | Complex header parsing scenarios |
37-
| `util.ts` | 79.19% | 8 | Helper functions, path operations |
34+
| `storage.ts` | 89.19% | 55 | Lines 373-374, 390-410 |
35+
| `sshSupport.ts` | 88.78% | 9 | Lines 38, 78-79, 89-90 |
36+
| `headers.ts` | 85.08% | 9 | Lines 33-47, 90-91 |
37+
| `util.ts` | 79.19% | 8 | Lines 127-129, 148-149 |
3838

3939
### 🔴 **Major Coverage Gaps (< 70% lines, 4 files)**
40-
| File | Lines | Tests | Status | Major Issues |
41-
|------|-------|-------|---------|--------------|
42-
| **`remote.ts`** | **25.4%** | 17 | 🚨 **Critical gap** | SSH setup, workspace lifecycle, error handling |
43-
| **`workspacesProvider.ts`** | **65.12%** | 27 | 🔸 Significant gaps | Tree operations, refresh logic, agent handling |
44-
| **`error.ts`** | **64.6%** | 11 | 🔸 Significant gaps | Error transformation, logging scenarios |
45-
| **`commands.ts`** | **56.01%** | 12 | 🔸 Significant gaps | Command implementations, user interactions |
40+
| File | Lines | Tests | Uncovered Lines |
41+
|------|-------|-------|----------|
42+
| **`remote.ts`** | **25.4%** | 17 | Lines 264-996, 1009-1038 (775 lines!) |
43+
| **`workspacesProvider.ts`** | **65.12%** | 27 | Lines 468-485, 521-539 |
44+
| **`error.ts`** | **64.6%** | 11 | Lines 145-166, 171-178 |
45+
| **`commands.ts`** | **56.01%** | 12 | Lines 550-665, 715-723 |
4646

4747
---
4848

@@ -95,10 +95,10 @@
9595
- [x] **9/17** files at 85%+ line coverage
9696

9797
### **Target Goals 🎯**
98-
- [ ] **70% → 90%** overall line coverage (primary goal)
99-
- [ ] **`remote.ts`** from 25% → 80%+ coverage (critical)
100-
- [ ] **15/17** files at 85%+ line coverage
101-
- [ ] **8/17** files at 95%+ line coverage
98+
- [ ] **70% → 100%** overall line coverage (updated goal)
99+
- [ ] **`remote.ts`** from 25% → 100% coverage (critical)
100+
- [ ] **17/17** files at 100% line coverage
101+
- [ ] **100%** branch coverage across all files
102102

103103
---
104104

@@ -118,14 +118,40 @@
118118

119119
## Priority Action Items 📋
120120

121-
**Immediate (Next Session):**
122-
1. 🚨 **Fix `remote.ts` coverage** - Expand from 25% to 80%+ (critical business logic)
123-
2. 🔸 **Improve `commands.ts`** - Expand from 56% to 80%+ (user-facing functionality)
124-
3. 🔸 **Polish `workspacesProvider.ts`** - Expand from 65% to 80%+ (UI component)
121+
**Immediate - 100% Coverage Sprint:**
122+
123+
1. 🚨 **`remote.ts`** (25.4% → 100%) - 775 uncovered lines
124+
- Complete SSH setup and workspace lifecycle tests
125+
- Error handling and process management scenarios
126+
- Mock all VSCode API interactions
127+
128+
2. 🔸 **`commands.ts`** (56.01% → 100%) - ~340 uncovered lines
129+
- Test all command implementations
130+
- User interaction flows and error cases
131+
132+
3. 🔸 **`error.ts`** (64.6% → 100%) - ~60 uncovered lines
133+
- Error transformation scenarios
134+
- Logging and telemetry paths
135+
136+
4. 🔸 **`workspacesProvider.ts`** (65.12% → 100%) - ~200 uncovered lines
137+
- Tree operations and refresh logic
138+
- Agent selection scenarios
139+
140+
5. 📈 **Medium Coverage Files** (70-90% → 100%)
141+
- `util.ts` (79.19% → 100%)
142+
- `headers.ts` (85.08% → 100%)
143+
- `sshSupport.ts` (88.78% → 100%)
144+
- `storage.ts` (89.19% → 100%)
145+
146+
6.**Final Polish** (90%+ → 100%)
147+
- `cliManager.ts` (90.05% → 100%)
148+
- `featureSet.ts` (90.9% → 100%)
149+
- `extension.ts` (93.44% → 100%)
150+
- `sshConfig.ts` (96.21% → 100%)
151+
- `workspaceMonitor.ts` (98.65% → 100%)
125152

126-
**Secondary:**
127-
4. Fill remaining gaps in medium-coverage files
128-
5. Add integration test scenarios
129-
6. Performance and edge case testing
153+
7. 🌿 **Branch Coverage**
154+
- `api.ts` (98.52% → 100% branches)
155+
- `proxy.ts` (95.12% → 100% branches)
130156

131-
**Target:** Achieve **90% overall line coverage** with robust, maintainable tests.
157+
**Target:** Achieve **100% line and branch coverage** across all files.

0 commit comments

Comments
 (0)