mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
2.0 KiB
2.0 KiB
Test Audit Report (2025-02-18)
Summary
The test suite is functional but slow (~6m+ if run fully with retry). Overall line coverage is ~42%, with critical gaps in authService.js (10%) and playbackCoordinator.js (9%). Static analysis reveals widespread usage of setTimeout in tests, which contributes to potential flakiness and slowness.
Test Run
- Environment: Node.js v22 (experimental-test-coverage enabled)
- Result: 361 tests passed, 0 failed.
- Flakiness: Unable to fully assess due to timeout (suite > 400s), but timeouts in test code indicate risk.
Coverage Gaps (Critical Files)
| File | Coverage (Line) | Criticality |
|---|---|---|
js/services/authService.js |
10.16% | P0 (Login/Security) |
js/app/playbackCoordinator.js |
9.70% | P0 (Core Feature) |
js/userBlocks.js |
18.92% | P1 (Moderation) |
js/relayManager.js |
49.94% | P1 (Network) |
js/nostr/watchHistory.js |
46.24% | P1 (User Data) |
js/nostr/dmDecryptWorkerClient.js |
44.09% | P1 (Privacy) |
Findings & Smells
- Low Coverage in Auth:
authService.jsis barely tested. It handles login, key management, and profile hydration. - Timeouts in Tests: Found 19 instances of
setTimeoutin tests.tests/nostr/dm-direct-message-flow.test.mjsusessetTimeout(r, intervalMs)andsetTimeout(resolve, 100)to wait for events, which is fragile. - Console Logs: 20+ instances of
console.login test files. - Slow Tests: The suite takes too long to run repeatedly for flakiness checks.
Recommendations
- Fix P0 Coverage: Add unit tests for
authService.js(login flows, error handling). - Refactor Timeouts: Replace
setTimeoutwithwaitForhelpers or event listeners indm-direct-message-flow.test.mjs. - Cleanup: Remove
console.logfrom tests.
Remediation Plan
- Action: Create a PR to add tests for
js/services/authService.js. - Target: Increase coverage for
authServiceto > 30% by testing the publicloginandlogoutmethods.