Skip to content

Commit 19a12db

Browse files
committed
fix Python project management handling for delete/move
1 parent 37e216e commit 19a12db

6 files changed

Lines changed: 995 additions & 83 deletions

File tree

.github/instructions/testing-workflow.instructions.md

Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,36 @@ This guide covers the full testing lifecycle:
2020

2121
**User Requests Testing:**
2222

23-
- "Write tests for this function"
24-
- "Run the tests"
25-
- "Fix the failing tests"
26-
- "Test this code"
27-
- "Add test coverage"
23+
- "Write tests for this function"
24+
- "Run the tests"
25+
- "Fix the failing tests"
26+
- "Test this code"
27+
- "Add test coverage"
2828

2929
**File Context Triggers:**
3030

31-
- Working in `**/test/**` directories
32-
- Files ending in `.test.ts` or `.unit.test.ts`
33-
- Test failures or compilation errors
34-
- Coverage reports or test output analysis
31+
- Working in `**/test/**` directories
32+
- Files ending in `.test.ts` or `.unit.test.ts`
33+
- Test failures or compilation errors
34+
- Coverage reports or test output analysis
3535

3636
## Test Types
3737

3838
When implementing tests as an AI agent, choose between two main types:
3939

4040
### Unit Tests (`*.unit.test.ts`)
4141

42-
- **Fast isolated testing** - Mock all external dependencies
43-
- **Use for**: Pure functions, business logic, data transformations
44-
- **Execute with**: `runTests` tool with specific file patterns
45-
- **Mock everything** - VS Code APIs automatically mocked via `/src/test/unittests.ts`
42+
- **Fast isolated testing** - Mock all external dependencies
43+
- **Use for**: Pure functions, business logic, data transformations
44+
- **Execute with**: `runTests` tool with specific file patterns
45+
- **Mock everything** - VS Code APIs automatically mocked via `/src/test/unittests.ts`
4646

4747
### Extension Tests (`*.test.ts`)
4848

49-
- **Full VS Code integration** - Real environment with actual APIs
50-
- **Use for**: Command registration, UI interactions, extension lifecycle
51-
- **Execute with**: VS Code launch configurations or `runTests` tool
52-
- **Slower but comprehensive** - Tests complete user workflows
49+
- **Full VS Code integration** - Real environment with actual APIs
50+
- **Use for**: Command registration, UI interactions, extension lifecycle
51+
- **Execute with**: VS Code launch configurations or `runTests` tool
52+
- **Slower but comprehensive** - Tests complete user workflows
5353

5454
## 🤖 Agent Tool Usage for Test Execution
5555

@@ -172,17 +172,17 @@ function analyzeFailure(failure: TestFailure): TestFailureAnalysis {
172172

173173
**Choose Unit Tests (`*.unit.test.ts`) when analyzing:**
174174

175-
- Functions with clear inputs/outputs and no VS Code API dependencies
176-
- Data transformation, parsing, or utility functions
177-
- Business logic that can be isolated with mocks
178-
- Error handling scenarios with predictable inputs
175+
- Functions with clear inputs/outputs and no VS Code API dependencies
176+
- Data transformation, parsing, or utility functions
177+
- Business logic that can be isolated with mocks
178+
- Error handling scenarios with predictable inputs
179179

180180
**Choose Extension Tests (`*.test.ts`) when analyzing:**
181181

182-
- Functions that register VS Code commands or use `vscode.*` APIs
183-
- UI components, tree views, or command palette interactions
184-
- File system operations requiring workspace context
185-
- Extension lifecycle events (activation, deactivation)
182+
- Functions that register VS Code commands or use `vscode.*` APIs
183+
- UI components, tree views, or command palette interactions
184+
- File system operations requiring workspace context
185+
- Extension lifecycle events (activation, deactivation)
186186

187187
**Agent Implementation Pattern:**
188188

@@ -300,22 +300,22 @@ function generateTestScenarios(analysis: FunctionAnalysis): TestScenario[] {
300300

301301
#### Main Flows
302302

303-
- **Happy path scenarios** - normal expected usage
304-
- **Alternative paths** - different configuration combinations
305-
- **Integration scenarios** - multiple features working together
303+
-**Happy path scenarios** - normal expected usage
304+
-**Alternative paths** - different configuration combinations
305+
-**Integration scenarios** - multiple features working together
306306

307307
#### Edge Cases
308308

309-
- 🔸 **Boundary conditions** - empty inputs, missing data
310-
- 🔸 **Error scenarios** - network failures, permission errors
311-
- 🔸 **Data validation** - invalid inputs, type mismatches
309+
- 🔸 **Boundary conditions** - empty inputs, missing data
310+
- 🔸 **Error scenarios** - network failures, permission errors
311+
- 🔸 **Data validation** - invalid inputs, type mismatches
312312

313313
#### Real-World Scenarios
314314

315-
- **Fresh install** - clean slate
316-
- **Existing user** - migration scenarios
317-
- **Power user** - complex configurations
318-
- 🔸 **Error recovery** - graceful degradation
315+
-**Fresh install** - clean slate
316+
-**Existing user** - migration scenarios
317+
-**Power user** - complex configurations
318+
- 🔸 **Error recovery** - graceful degradation
319319

320320
### Example Test Plan Structure
321321

@@ -324,30 +324,30 @@ function generateTestScenarios(analysis: FunctionAnalysis): TestScenario[] {
324324

325325
### 1. Configuration Migration Tests
326326

327-
- No legacy settings exist
328-
- Legacy settings already migrated
329-
- Fresh migration needed
330-
- Partial migration required
331-
- Migration failures
327+
- No legacy settings exist
328+
- Legacy settings already migrated
329+
- Fresh migration needed
330+
- Partial migration required
331+
- Migration failures
332332

333333
### 2. Configuration Source Tests
334334

335-
- Global search paths
336-
- Workspace search paths
337-
- Settings precedence
338-
- Configuration errors
335+
- Global search paths
336+
- Workspace search paths
337+
- Settings precedence
338+
- Configuration errors
339339

340340
### 3. Path Resolution Tests
341341

342-
- Absolute vs relative paths
343-
- Workspace folder resolution
344-
- Path validation and filtering
342+
- Absolute vs relative paths
343+
- Workspace folder resolution
344+
- Path validation and filtering
345345

346346
### 4. Integration Scenarios
347347

348-
- Combined configurations
349-
- Deduplication logic
350-
- Error handling flows
348+
- Combined configurations
349+
- Deduplication logic
350+
- Error handling flows
351351
```
352352

353353
## 🔧 Step 4: Set Up Your Test Infrastructure
@@ -514,47 +514,47 @@ envConfig.inspect
514514

515515
### Configuration Tests
516516

517-
- Test different setting combinations
518-
- Test setting precedence (workspace > user > default)
519-
- Test configuration errors and recovery
520-
- Always use dynamic path construction with Node.js `path` module when testing functions that resolve paths against workspace folders to ensure cross-platform compatibility
517+
- Test different setting combinations
518+
- Test setting precedence (workspace > user > default)
519+
- Test configuration errors and recovery
520+
- Always use dynamic path construction with Node.js `path` module when testing functions that resolve paths against workspace folders to ensure cross-platform compatibility
521521

522522
### Data Flow Tests
523523

524-
- Test how data moves through the system
525-
- Test transformations (path resolution, filtering)
526-
- Test state changes (migrations, updates)
524+
- Test how data moves through the system
525+
- Test transformations (path resolution, filtering)
526+
- Test state changes (migrations, updates)
527527

528528
### Error Handling Tests
529529

530-
- Test graceful degradation
531-
- Test error logging
532-
- Test fallback behaviors
530+
- Test graceful degradation
531+
- Test error logging
532+
- Test fallback behaviors
533533

534534
### Integration Tests
535535

536-
- Test multiple features together
537-
- Test real-world scenarios
538-
- Test edge case combinations
536+
- Test multiple features together
537+
- Test real-world scenarios
538+
- Test edge case combinations
539539

540540
## 📊 Step 8: Review and Refine
541541

542542
### Test Quality Checklist
543543

544-
- [ ] **Clear naming** - test names describe the scenario and expected outcome
545-
- [ ] **Good coverage** - main flows, edge cases, error scenarios
546-
- [ ] **Resilient assertions** - won't break due to minor changes
547-
- [ ] **Readable structure** - follows Mock → Run → Assert pattern
548-
- [ ] **Isolated tests** - each test is independent
549-
- [ ] **Fast execution** - tests run quickly with proper mocking
544+
- [ ] **Clear naming** - test names describe the scenario and expected outcome
545+
- [ ] **Good coverage** - main flows, edge cases, error scenarios
546+
- [ ] **Resilient assertions** - won't break due to minor changes
547+
- [ ] **Readable structure** - follows Mock → Run → Assert pattern
548+
- [ ] **Isolated tests** - each test is independent
549+
- [ ] **Fast execution** - tests run quickly with proper mocking
550550

551551
### Common Anti-Patterns to Avoid
552552

553-
- ❌ Testing implementation details instead of behavior
554-
- ❌ Brittle assertions that break on cosmetic changes
555-
- ❌ Order-dependent tests that fail due to processing changes
556-
- ❌ Tests that don't clean up mocks properly
557-
- ❌ Overly complex test setup that's hard to understand
553+
- ❌ Testing implementation details instead of behavior
554+
- ❌ Brittle assertions that break on cosmetic changes
555+
- ❌ Order-dependent tests that fail due to processing changes
556+
- ❌ Tests that don't clean up mocks properly
557+
- ❌ Overly complex test setup that's hard to understand
558558

559559
## 🔄 Reviewing and Improving Existing Tests
560560

@@ -567,13 +567,14 @@ envConfig.inspect
567567

568568
### Common Fixes
569569

570-
- Over-complex mocks → Minimal mocks with only needed methods
571-
- Brittle assertions → Behavior-focused with error messages
572-
- Vague test names → Clear scenario descriptions (transform "should return X when Y" into "should [expected behavior] when [scenario context]")
573-
- Missing structure → Mock → Run → Assert pattern
574-
- Untestable Node.js APIs → Create proxy abstraction functions (use function overloads to preserve intelligent typing while making functions mockable)
570+
- Over-complex mocks → Minimal mocks with only needed methods
571+
- Brittle assertions → Behavior-focused with error messages
572+
- Vague test names → Clear scenario descriptions (transform "should return X when Y" into "should [expected behavior] when [scenario context]")
573+
- Missing structure → Mock → Run → Assert pattern
574+
- Untestable Node.js APIs → Create proxy abstraction functions (use function overloads to preserve intelligent typing while making functions mockable)
575575

576576
## 🧠 Agent Learnings
577-
- Avoid testing exact error messages or log output - assert only that errors are thrown or rejection occurs to prevent brittle tests (1)
578-
- Create shared mock helpers (e.g., `createMockLogOutputChannel()`) instead of duplicating mock setup across multiple test files (1)
579577

578+
- Avoid testing exact error messages or log output - assert only that errors are thrown or rejection occurs to prevent brittle tests (1)
579+
- Create shared mock helpers (e.g., `createMockLogOutputChannel()`) instead of duplicating mock setup across multiple test files (1)
580+
- Use `sinon.useFakeTimers()` with `clock.tickAsync()` instead of `await new Promise(resolve => setTimeout(resolve, ms))` for debounce/timeout handling - eliminates flakiness and speeds up tests significantly (1)

0 commit comments

Comments
 (0)