Repository navigation
Closed
Description
Refactor Integration Tests to Use skipIfEndpointUnavailable() Utility
Type: Technical Debt / Code Quality
Priority: Low
Effort: Small (~30 minutes)
Current Status (Updated 2025-11-03)
Phase 3 test files no longer exist - they were refactored/renamed.
Current State:
- Utility function exists and is well-documented at
test-node-helpers.ts:142 - 10 instances of inline error handling remain (down from ~40!)
- Pattern still duplicated across 3 test files
Problem
The inline error handling pattern is still repeated in current tests:
// Current pattern (repeated 10 times)
catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
if (errorMessage.includes('405') || errorMessage.includes('500')) {
console.log('[Test] Container endpoint not yet active - test skipped');
expect(error).toBeTruthy();
} else {
throw error;
}
}Issues:
- Code duplication (10 instances across 3 files)
- Harder to update error handling logic centrally
- Violates DRY principle
- Inconsistent with available utility
Proposed Solution
Refactor inline patterns to use the existing utility:
// After refactoring
catch (error) {
if (skipIfEndpointUnavailable(error, 'Container endpoint')) {
expect(error).toBeTruthy();
return;
}
throw error;
}Files to Update
All located in packages/desktop-app/src/tests/integration/:
-
regression-prevention.test.ts
- 6 instances at lines: 179, 263, 325, 384, 434, 491
-
edge-cases.test.ts
- 3 instances at lines: 188, 384, 420
-
integration-scenarios.test.ts
- 1 instance at line: 127
Implementation Steps
-
Import the utility in all 3 test files:
import { skipIfEndpointUnavailable } from '../utils/test-node-helpers';
-
Replace each inline pattern with utility call (10 replacements total)
-
Update endpoint names to be descriptive:
- "Container endpoint"
- "Mention endpoint"
- "Node update endpoint"
-
Run tests to verify no behavioral changes:
bun run test src/tests/integration/regression-prevention.test.ts bun run test src/tests/integration/edge-cases.test.ts bun run test src/tests/integration/integration-scenarios.test.ts
-
Run quality checks:
bun run quality:fix
Acceptance Criteria
- Import
skipIfEndpointUnavailableadded to all 3 test files - All 10 inline error handling patterns refactored to use utility
- Descriptive endpoint names used in all utility calls
- All tests still passing/skipping as before (no behavioral changes)
- Code passes
bun run quality:fixwith zero warnings
Success Metrics
Before:
- 10 instances of ~10 lines each = ~100 lines of duplicated code
- 10 locations to update if error handling logic changes
After:
- 10 instances of ~3 lines each = ~30 lines (70% reduction)
- Single location (utility function) to update error handling logic
Notes
- This is a pure refactoring - no functional changes expected
- Low risk since pattern is well-established
- Quick win on code quality (~30 minutes)
- Good first issue for new contributors
Activity
Refactor integration tests to use skipIfEndpointUnavailable() utility
Refactor integration tests to use skipIfEndpointUnavailable() utility
Refactor integration tests to use skipIfEndpointUnavailable() utility
Refactor integration tests to use skipIfEndpointUnavailable() utility