Skip to content

Commit 08d44f1

Browse files
JoshuaKGoldberggeorge-sentry
authored andcommitted
fix(test): stabilize flaky EventReplay inline onboarding test (#111902)
The `ReplayInlineOnboardingPanel` component is loaded via `React.lazy()`, creating an async code-splitting boundary. Inside that lazy-loaded component, `usePrompt` calls `useApiQuery` (React Query), adding another async data-fetching boundary. The combination of these two async layers occasionally exceeded the `findByText` default timeout in CI, causing the test to flake. This PR mocks the `replayInlineOnboardingPanel` module (a pattern already used for `replayClipPreview`) and asserts on a `data-test-id` instead of the rendered text. Fixes REPLAY-879 ~Note that CI Jest tests are failing because the https://github.com/getsentry/sentry/labels/Frontend%3A%20Rerun%20Flaky%20Tests label is causing _other_, still-flaky tests to be run.~ No longer applicable now that this is targeting `master` and #111860 is not yet merged. Made with [Cursor](https://cursor.com)
1 parent d3ec18c commit 08d44f1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

static/app/components/events/eventReplay/index.spec.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import type {RawReplayError} from 'sentry/utils/replays/types';
2121

2222
jest.mock('sentry/utils/replays/hooks/useReplayOnboarding');
2323
jest.mock('sentry/utils/replays/hooks/useLoadReplayReader');
24-
jest.mock('sentry/utils/replays/hooks/useReplayOnboarding');
2524
// Replay clip preview is very heavy, mock it out
2625
jest.mock(
2726
'sentry/components/events/eventReplay/replayClipPreview',
@@ -30,6 +29,12 @@ jest.mock(
3029
return <div data-test-id="replay-clip" />;
3130
}
3231
);
32+
jest.mock('sentry/components/events/eventReplay/replayInlineOnboardingPanel', () => ({
33+
__esModule: true,
34+
default: function MockReplayOnboardingPanel() {
35+
return <div data-test-id="replay-inline-onboarding" />;
36+
},
37+
}));
3338

3439
const mockEventTimestamp = new Date('2022-09-22T16:59:41Z');
3540
const mockReplayId = '761104e184c64d439ee1014b72b4d83b';
@@ -136,15 +141,9 @@ describe('EventReplay', () => {
136141
MockUseReplayOnboardingSidebarPanel.mockReturnValue({
137142
activateSidebar: jest.fn(),
138143
});
139-
MockApiClient.addMockResponse({
140-
url: '/organizations/org-slug/prompts-activity/',
141-
body: {data: {dismissed_ts: null}},
142-
});
143144
render(<EventReplay {...defaultProps} />, {organization});
144145

145-
expect(
146-
await screen.findByText('Watch the errors and latency issues your users face')
147-
).toBeInTheDocument();
146+
expect(await screen.findByTestId('replay-inline-onboarding')).toBeInTheDocument();
148147
});
149148

150149
it('should render a replay when there is a replayId from tags', async () => {

0 commit comments

Comments
 (0)