Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(replays): Fix 'clearQueryCache' method in 'useReplayData' hook #70539

Merged
merged 1 commit into from
May 9, 2024

Conversation

floels
Copy link
Contributor

@floels floels commented May 8, 2024

Goal

The goal of this PR is to fix a bug currently causing the clearQueryCache method defined in static/app/utils/replays/hooks/useReplayData.tsx to have no effect (extra arrow function declaration).

Approach

Remove the duplicated arrow function declaration syntax (() => { ... }).

We also add a unit test to cover this behavior of the custom hook. You can see that the test fails if you revert the fix in useReplayData.tsx.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 8, 2024
queryKey: [`/organizations/${orgSlug}/replays-events-meta/`],
});
};
queryClient.invalidateQueries({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only removing the extraneous () => { on line 217 and the corresponding } on line 231.

@floels floels marked this pull request as ready for review May 8, 2024 20:35
@floels floels requested a review from a team as a code owner May 8, 2024 20:35
@ryan953 ryan953 added the Trigger: getsentry tests once code is reviewed: apply label to PR to trigger getsentry tests label May 8, 2024
@floels floels changed the title fix(replays): fix 'clearQueryCache' method in 'useReplayData' hook fix(replays): Fix 'clearQueryCache' method in 'useReplayData' hook May 8, 2024
Copy link
Member

@ryan953 ryan953 left a comment

Choose a reason for hiding this comment

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

Looks awesome, thanks for identifying that problem @floels and writing tests too!

@@ -32,10 +32,14 @@ jest.mocked(useProjects).mockReturnValue({
placeholders: [],
});

const mockInvalidateQueries = jest.fn();
Copy link
Member

Choose a reason for hiding this comment

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

Can we reset this before or after each test? This way if another test gets added the state from a previous test won't affect the new one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes good point, added in the existing beforeEach.

Fix a bug currently causing the 'clearQueryCache' method defined in
'static/app/utils/replays/hooks/useReplayData.tsx' to have no effect
(extra arrow function declaration).
Add a unit test to cover this behavior of the custom hook.
@github-actions github-actions bot removed the Trigger: getsentry tests once code is reviewed: apply label to PR to trigger getsentry tests label May 8, 2024
@ryan953 ryan953 added the Trigger: getsentry tests once code is reviewed: apply label to PR to trigger getsentry tests label May 8, 2024
@ryan953 ryan953 merged commit fee059f into getsentry:master May 9, 2024
41 of 43 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2024
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 Trigger: getsentry tests once code is reviewed: apply label to PR to trigger getsentry tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants