Skip to content

[WIP] Progress towards unit test coverage #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
- Package: `yarn package`
- Lint: `yarn lint`
- Lint with auto-fix: `yarn lint:fix`
- Run all tests: `yarn test`
- Run specific test: `vitest ./src/filename.test.ts`
- CI test mode: `yarn test:ci`
- Run all tests: `yarn test:ci` (always use CI mode for reliable results, runs all test files automatically)
- Watch mode (development only): `yarn test`
- Run tests with coverage: `yarn test:coverage`
- View coverage in browser: `yarn test:coverage:ui`

## Code Style Guidelines

Expand Down
131 changes: 131 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# VSCode Coder Extension - Testing Status & Coverage Roadmap

## Current Status ✅

**Test Infrastructure Complete:** 17/17 source files have test files
**Total Tests:** 345 tests passing across 17 test files
**Test Framework:** Vitest with comprehensive mocking infrastructure
**Overall Line Coverage:** 70.43% (significant gaps remain)

---

## Test Coverage Analysis 📊

### 🎯 **100% Coverage Achieved (4 files)**
| File | Lines | Status |
|------|-------|---------|
| `api-helper.ts` | 100% | ✅ Perfect coverage |
| `api.ts` | 100% | ✅ Perfect coverage |
| `inbox.ts` | 100% | ✅ Perfect coverage |
| `proxy.ts` | 100% | ✅ Perfect coverage |

### 🟢 **High Coverage (90%+ lines, 5 files)**
| File | Lines | Tests | Priority |
|------|-------|-------|----------|
| `workspaceMonitor.ts` | 98.65% | 19 | ✅ Nearly complete |
| `sshConfig.ts` | 96.21% | 14 | ✅ Nearly complete |
| `extension.ts` | 93.44% | 26 | 🔸 Minor gaps |
| `featureSet.ts` | 90.9% | 2 | 🔸 Minor gaps |
| `cliManager.ts` | 90.05% | 6 | 🔸 Minor gaps |

### 🟡 **Medium Coverage (70-90% lines, 4 files)**
| File | Lines | Tests | Key Gaps |
|------|-------|-------|----------|
| `storage.ts` | 89.19% | 55 | Error scenarios, file operations |
| `sshSupport.ts` | 88.78% | 9 | Edge cases, environment detection |
| `headers.ts` | 85.08% | 9 | Complex header parsing scenarios |
| `util.ts` | 79.19% | 8 | Helper functions, path operations |

### 🔴 **Major Coverage Gaps (< 70% lines, 4 files)**
| File | Lines | Tests | Status | Major Issues |
|------|-------|-------|---------|--------------|
| **`remote.ts`** | **25.4%** | 17 | 🚨 **Critical gap** | SSH setup, workspace lifecycle, error handling |
| **`workspacesProvider.ts`** | **65.12%** | 27 | 🔸 Significant gaps | Tree operations, refresh logic, agent handling |
| **`error.ts`** | **64.6%** | 11 | 🔸 Significant gaps | Error transformation, logging scenarios |
| **`commands.ts`** | **56.01%** | 12 | 🔸 Significant gaps | Command implementations, user interactions |

---

## Next Steps - Coverage Improvement 🎯

### **Phase 1: Critical Coverage Gaps (High Priority)**

#### 1. **`remote.ts` - Critical Priority** 🚨
- **Current:** 25.4% lines covered (Major problem!)
- **Missing:** SSH connection setup, workspace lifecycle, process management
- **Action:** Expand existing 17 tests to cover:
- Complete `setup()` method flow
- `maybeWaitForRunning()` scenarios
- SSH config generation and validation
- Process monitoring and error handling

#### 2. **`commands.ts` - High Priority** 🔸
- **Current:** 56.01% lines covered
- **Missing:** Command implementations, user interaction flows
- **Action:** Expand existing 12 tests to cover all command handlers

#### 3. **`workspacesProvider.ts` - High Priority** 🔸
- **Current:** 65.12% lines covered
- **Missing:** Tree refresh logic, agent selection, error scenarios
- **Action:** Expand existing 27 tests for complete tree operations

#### 4. **`error.ts` - Medium Priority** 🔸
- **Current:** 64.6% lines covered
- **Missing:** Error transformation scenarios, logging paths
- **Action:** Expand existing 11 tests for all error types

### **Phase 2: Polish Existing High Coverage Files**
- **Target:** Get 90%+ files to 95%+ coverage
- **Files:** `extension.ts`, `storage.ts`, `headers.ts`, `util.ts`, `sshSupport.ts`
- **Effort:** Low (minor gap filling)

### **Phase 3: Integration & Edge Case Testing**
- **Cross-module integration scenarios**
- **Complex error propagation testing**
- **Performance and timeout scenarios**

---

## Success Metrics 🎯

### **Completed ✅**
- [x] **17/17** source files have test files
- [x] **345** tests passing (zero flaky tests)
- [x] **4/17** files at 100% line coverage
- [x] **9/17** files at 85%+ line coverage

### **Target Goals 🎯**
- [ ] **70% → 90%** overall line coverage (primary goal)
- [ ] **`remote.ts`** from 25% → 80%+ coverage (critical)
- [ ] **15/17** files at 85%+ line coverage
- [ ] **8/17** files at 95%+ line coverage

---

## Recent Achievements 🏆

✅ **Test Infrastructure Complete** (Just completed)
- Created test files for all 17 source files
- Fixed workspacesProvider test failures through strategic refactoring
- Added comprehensive tests for proxy, inbox, and workspaceMonitor
- Established robust mocking patterns for VSCode APIs

✅ **Perfect Coverage Achieved** (4 files)
- `api-helper.ts`, `api.ts`, `inbox.ts`, `proxy.ts` at 100% coverage
- Strong foundation with core API and utility functions fully tested

---

## Priority Action Items 📋

**Immediate (Next Session):**
1. 🚨 **Fix `remote.ts` coverage** - Expand from 25% to 80%+ (critical business logic)
2. 🔸 **Improve `commands.ts`** - Expand from 56% to 80%+ (user-facing functionality)
3. 🔸 **Polish `workspacesProvider.ts`** - Expand from 65% to 80%+ (UI component)

**Secondary:**
4. Fill remaining gaps in medium-coverage files
5. Add integration test scenarios
6. Performance and edge case testing

**Target:** Achieve **90% overall line coverage** with robust, maintainable tests.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@
"lint": "eslint . --ext ts,md",
"lint:fix": "yarn lint --fix",
"test": "vitest ./src",
"test:ci": "CI=true yarn test"
"test:ci": "CI=true yarn test",
"test:coverage": "vitest run --coverage",
"test:coverage:ui": "vitest --coverage --ui"
},
"devDependencies": {
"@types/eventsource": "^3.0.0",
Expand All @@ -291,6 +293,8 @@
"@types/ws": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitest/coverage-v8": "^0.34.6",
"@vitest/ui": "^0.34.6",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^2.21.1",
"bufferutil": "^4.0.9",
Expand Down
Loading
Loading