#4095: Test/add format duration tests
Cluster:
Backoff and Duration Tests
Closes #4025
## Summary
Adds missing unit tests for `src/infra/format-duration.ts` to ensure accurate time formatting (e.g., "1.5s", "500ms") across the CLI and logs.
## Changes
- **src/infra/format-duration.test.ts**: New test file covering `formatDurationSeconds` and `formatDurationMs` with edge cases for decimals and unit labels.
## Verification
- [x] Ran `npx vitest run format-duration`
- [x] Verified 11/11 tests passed
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Adds new unit tests for duration formatting helpers (`formatDurationSeconds`/`formatDurationMs`), plus additional regression coverage for transient network error classification and backoff/sleep utilities. The runtime behavior change in `isTransientNetworkError` broadens the set of `TypeError("fetch failed")` cases treated as transient when a cause exists but is not classified as fatal or configuration-related, aligning with the intent to avoid crashing the gateway on undici fetch failures.
<h3>Confidence Score: 4/5</h3>
- This PR is generally safe to merge; changes are mostly tests with a small, targeted error-classification tweak.
- I reviewed the changed files and the related implementations. The only notable issue is a probabilistic jitter test that could be flaky in CI; otherwise the additions are straightforward and align with existing behavior (formatting outputs, abort handling, and transient fetch failure handling).
- src/infra/backoff.test.ts (jitter test determinism)
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11421: Tests: add unit tests for infra/format-duration
by PythonUser42 · 2026-02-07
89.5%
#4086: Test/add backoff tests
by TechWizard9999 · 2026-01-29
85.4%
#4137: [AI-assisted] test(cli): add missing test cases for parseDurationMs
by sind00 · 2026-01-29
83.9%
#12684: Test: add missing unit tests for src/utils modules
by shaynhornik · 2026-02-09
78.9%
#9333: Tests: add test coverage for security/audit-fs.ts
by M00N7682 · 2026-02-05
78.9%
#15569: test: comprehensive test coverage expansion (57 new test files)
by tangcruz · 2026-02-13
78.5%
#20496: test(utils): add comprehensive unit tests for utility functions
by masifislamm · 2026-02-19
78.5%
#8964: test(msteams): add comprehensive tests for graph-upload module
by RajdeepKushwaha5 · 2026-02-04
76.5%
#21027: fix(tests): resolve TypeScript type errors in CLI test files
by kittipond2365 · 2026-02-19
76.3%
#19104: test(discord): improve gateway logging test coverage
by Clawborn · 2026-02-17
75.9%