Daily Test Coverage Improver - Add helper/TabCounter test coverage#5753
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Daily Test Coverage Improver - Add helper/TabCounter test coverage#5753github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
- Add 30 test cases covering all methods and edge cases - Achieve 100% statement coverage, 96.15% branch coverage, 100% function coverage - Test constructor, getData/updateData, updateActive, tabsCount, clearList, onTabChange, pause/start - Include integration tests for tab lifecycle and callbacks - Use fake timers for interval-based tests following project patterns Coverage improvement: - helper/TabCounter.ts: 0% → 100% statements (62 statements covered) - Overall React project: 7.56% → 7.96% statement coverage (+0.4%)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal and Rationale
This PR adds comprehensive test coverage for
react/src/helper/TabCounter.ts, a utility class that tracks browser tabs via localStorage. This file had 0% coverage despite being a critical utility for tab management. The implementation is similar tolib/TabCounter.tswhich already has 98.6% coverage, making it a good candidate for test improvement.Approach
The testing strategy follows established patterns from the existing
lib/TabCounter.test.ts:The test suite includes 30 test cases organized into 8 describe blocks covering all 14 functions in the TabCounter class.
Impact Measurement
Test Coverage Results
Detailed Coverage
The test suite achieves near-perfect coverage:
Only 1 branch remains uncovered (line 94), which appears to be an edge case in the clearList timeout logic.
Trade-offs
Added:
Benefits:
Validation
Testing Approach
Tests verified through:
Success Criteria
✅ All 30 tests pass
✅ Statement coverage increased from 0% to 100%
✅ Branch coverage increased from 0% to 96.15%
✅ Function coverage increased from 0% to 100%
✅ No linting errors
✅ Follows project test patterns
Future Work
Additional Coverage Opportunities:
helper/ directory files - Multiple untested utility files:
loginSessionAuth.ts(0% coverage, 275 statements)loginConfig.ts(0.72% coverage, 644 statements)appLauncherProxy.ts(0% coverage, 200+ statements)hooks/ directory - Many custom hooks lack coverage:
useBackendAIAppLauncher.tsx(0% coverage)useBAINotification.tsx(0% coverage)useDefaultImagesWithFallback.ts(0% coverage)Complete branch coverage - Investigate uncovered branch at line 94 to determine if additional test case is needed
Integration tests - Add tests for TabCounter integration with actual React components
Reproducibility
Setup Commands
Measurement Procedures
Coverage data collected using Jest's built-in coverage tool with Istanbul. The coverage summary shows:
coverage-steps.log(React: 7.56% statements)react/coverage/coverage-final.json(React: 7.96% statements)Expected Results Format
Jest outputs coverage in multiple formats:
coverage/coverage-summary.jsonwith aggregate metricscoverage/coverage-final.jsonwith detailed line-by-line execution countsWhat Happens Next:
Once this PR is reviewed and merged, the next workflow run will select another low-coverage file to improve. The workflow systematically increases test coverage across the React project.