Repository navigation
test: add unit tests for the useDeployments hook - #65
Merged
Merged
Conversation
Cover the first load, error handling, polling while the tab is visible, pausing while it's hidden, refetching on visibility change and refetch(), and cleanup on unmount.
codxbrexx
self-requested a review
October 29, 2026 15:06
Collaborator
|
@mohdTahaRafi! Great work on the comprehensive test coverage and regression checks! Appreciate the effort! |
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.
Description
Adds
src/tests/unit/use_deployments_test.tsxwith 10 tests foruseDeployments, using fake timers and a controllabledocument.hidden:refetch()No app code changes. To check the tests actually catch regressions, I broke the hook four ways (polling while hidden, no visibility listener, not resetting the error, no abort on cleanup). Each one made exactly one test fail.
Test results:
npm run unitis 152/152 (ran it three times to check the timer tests aren't flaky), and lint, format:check and typecheck pass.npm run test(Playwright) is 96/97. The one failure isdashboard.spec.ts:96, which also fails onmasterand is fixed in #61.Fixes #64
Part of #20
Type of Change
fix:Bug fix (non-breaking change which fixes an issue)feat:New feature (non-breaking change which adds functionality)refactor:Code refactor (no functional changes, no API changes)docs:Documentation updatetest:Adding or updating testschore:Maintenance (CI, dependencies, tooling)Checklist
npm run unitandnpm run test).npm run lint).fix: resolve login redirect).