gh-workflow-mcp: Additional test coverage for edge cases and integration
Additional Test Coverage for Edge Cases and Integration
Tracking 6 test coverage improvements identified in PR #432 all-hands-review (iteration 3) but deemed out-of-scope for immediate implementation.
Items from Test Analyzer
Issue #6: End-to-End Monitor Function Tests
Priority: MEDIUM
Files: monitor-run.ts, monitor-pr-checks.ts
Currently missing true end-to-end tests that:
- Start a real GitHub Actions workflow (in test environment)
- Monitor it with actual gh CLI commands
- Verify completion detection and status reporting
- Test both success and failure paths
Rationale: Current integration tests mock gh CLI. E2E tests would catch issues with actual GitHub API behavior, rate limits, and timing edge cases.
Implementation suggestion:
- Create test repository with simple workflow
- Use GitHub API to trigger runs
- Test monitor functions against real runs
- Add to CI but with appropriate timeouts and retry logic
Issue #7: Actual Timeout Behavior Tests
Priority: MEDIUM
Files: gh-watch-integration.test.ts
Current tests mock delays but don't verify:
- Actual AbortController signal propagation
- Timer cleanup on abort vs natural completion
- Race conditions between timeout and completion
- Signal handling in execa subprocess
Rationale: Mocked tests verify logic but not actual Node.js timeout mechanisms.
Implementation suggestion:
- Create tests that actually wait for timeouts (with short durations)
- Verify no hanging promises or unclosed timers
- Test timer cleanup in error paths
- Use
--timeoutin test runner for safety
Additional Edge Cases (4 items)
Watch command stderr output handling
Test createAbortableWatch with various stderr patterns:
- Warning messages mixed with success
- Progress indicators during long runs
- Unexpected output formats
Multiple concurrent run monitoring
Test monitor-run.ts with:
- Runs completing in different orders
- Some runs timeout, others succeed
- Simultaneous failure detection across runs
PR checks with changing status
Test monitor-pr-checks.ts with:
- Checks added after monitoring starts
- Required vs optional checks
- Check re-runs during monitoring
Fail-fast race conditions
Test edge cases in fail-fast mode:
- Failure detected exactly when watch completes
- Multiple simultaneous failures
- Polling errors during failure detection
Priority
Medium - Would improve confidence in edge cases but core functionality is well-tested (122+ tests passing).
Related Issues
- #432 - Parent PR for gh watch implementation
- #15372 - Documentation improvements (formerly planned as #540)
Implementation Notes
- E2E tests should be optional or have reasonable timeouts
- Consider test environment configuration (test repo, credentials)
- Balance coverage vs test execution time
- May need separate test suite for integration tests
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗