Skip to content

test(insights): Remove useLocation/usePageFilters mocks from simple tests#111497

Merged
scttcper merged 1 commit intomasterfrom
scooper/remove-hook-mocks-simple
Mar 25, 2026
Merged

test(insights): Remove useLocation/usePageFilters mocks from simple tests#111497
scttcper merged 1 commit intomasterfrom
scooper/remove-hook-mocks-simple

Conversation

@scttcper
Copy link
Copy Markdown
Member

Remove unnecessary jest.mock calls for useLocation and usePageFilters hooks in tests that don't rely on specific location or page filter state

…ests

Remove unnecessary jest.mock calls for useLocation and usePageFilters
hooks in tests that don't rely on specific location or page filter state.
Where needed, replace with PageFiltersStore.onInitializeUrlState() to
provide page filter state through the real store.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@scttcper scttcper requested a review from a team March 24, 2026 23:28
@scttcper scttcper requested a review from a team as a code owner March 24, 2026 23:28
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 24, 2026
Copy link
Copy Markdown
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.

const setupMocks = () => {
const mockProjects = [ProjectFixture()];
ProjectsStore.loadInitialData(mockProjects);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing PageFiltersStore initialization breaks enabled-images test

High Severity

The usePageFilters mock was removed from setupMocks without adding a PageFiltersStore.onInitializeUrlState(...) call as a replacement. The SampleImages component uses useSpans, which internally depends on pageFiltersReady (from PageFiltersStore.isReady). Without initialization, isReady remains false, the query stays disabled, and isPending is permanently true. This causes the "When project setting is enabled" test to hang — the loading indicator is never removed because showImages && isLoadingImages stays true. The other modified test files (webVitalsDetailPanel.spec.tsx, screenDetailsPage.spec.tsx) correctly added PageFiltersStore.onInitializeUrlState(...) but this file did not.

Fix in Cursor Fix in Web

@scttcper scttcper merged commit ddc7dc5 into master Mar 25, 2026
79 of 81 checks passed
@scttcper scttcper deleted the scooper/remove-hook-mocks-simple branch March 25, 2026 15:38
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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