Skip to content

test(ui): remove useLocation mock from useLocationQuery tests#111567

Merged
scttcper merged 1 commit intomasterfrom
scttcper/test-rm-use-location-query
Mar 26, 2026
Merged

test(ui): remove useLocation mock from useLocationQuery tests#111567
scttcper merged 1 commit intomasterfrom
scttcper/test-rm-use-location-query

Conversation

@scttcper
Copy link
Member

@scttcper scttcper commented Mar 25, 2026

migrate useLocationQuery tests from mocked useLocation to renderHookWithProviders

Replace direct useLocation mocks with renderHookWithProviders and route-backed
query state, including router navigation for identity stability assertions.

Made-with: Cursor
@scttcper scttcper requested a review from a team as a code owner March 25, 2026 21:10
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 25, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

rerender(props);

router.navigate('/mock-pathname/?name=Adam&titles=Mr.&titles=Dr.');
await waitFor(() => expect(result.current.name).toBe('Adam'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waitFor assertion is a no-op for navigation verification

Low Severity

The waitFor on line 156 checks result.current.name equals 'Adam', but this was already true from the initial render (the initial query has name: 'Adam'). This means waitFor resolves immediately without actually confirming that the navigation re-render occurred. The captured second reference could trivially equal first because no re-render has been observed, making the expect(first).toBe(second) assertion potentially pass for the wrong reason. Currently this works only because router.navigate synchronously flushes via act(), but the waitFor doesn't guard the intent of the test.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think thats okay we don't need to count renders

@scttcper scttcper changed the title test(ui): migrate useLocationQuery spec to providers test(ui): remove useLocation mock from useLocationQuery tests Mar 25, 2026
@scttcper scttcper merged commit 81ee950 into master Mar 26, 2026
82 of 86 checks passed
@scttcper scttcper deleted the scttcper/test-rm-use-location-query branch March 26, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants