Skip to content

Commit 6a1a153

Browse files
committed
revert test changes
1 parent db360c0 commit 6a1a153

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

packages/replay/test/integration/coreHandlers/handleAfterSendEvent.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getCurrentHub } from '@sentry/core';
22
import type { ErrorEvent, Event } from '@sentry/types';
33

4-
import { UNABLE_TO_SEND_REPLAY, DEFAULT_FLUSH_MIN_DELAY } from '../../../src/constants';
4+
import { UNABLE_TO_SEND_REPLAY } from '../../../src/constants';
55
import { handleAfterSendEvent } from '../../../src/coreHandlers/handleAfterSendEvent';
66
import type { ReplayContainer } from '../../../src/replay';
77
import { Error } from '../../fixtures/error';
@@ -146,18 +146,11 @@ describe('Integration | coreHandlers | handleAfterSendEvent', () => {
146146

147147
expect(Array.from(replay.getContext().errorIds)).toEqual(['err1']);
148148

149-
jest.runAllTimers()
150-
await new Promise(process.nextTick);
151-
152-
// Flush from the error
153-
expect(mockSend).toHaveBeenCalledTimes(1);
154-
155-
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
149+
jest.runAllTimers();
156150
await new Promise(process.nextTick);
157151

158-
// Flush for converting to session-based replay (startRecording call)
152+
// Send twice, one for the error & one right after for the session conversion
159153
expect(mockSend).toHaveBeenCalledTimes(2);
160-
161154
// This is removed now, because it has been converted to a "session" session
162155
expect(Array.from(replay.getContext().errorIds)).toEqual([]);
163156
expect(replay.isEnabled()).toBe(true);

packages/replay/test/integration/errorSampleRate.test.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ describe('Integration | errorSampleRate', () => {
9999
]),
100100
});
101101

102-
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
103-
await new Promise(process.nextTick);
104-
105102
// This is from when we stop recording and start a session recording
106103
expect(replay).toHaveLastSentReplay({
107104
recordingPayloadHeader: { segment_id: 1 },
@@ -119,6 +116,20 @@ describe('Integration | errorSampleRate', () => {
119116
]),
120117
});
121118

119+
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
120+
121+
// New checkout when we call `startRecording` again after uploading segment
122+
// after an error occurs
123+
expect(replay).toHaveLastSentReplay({
124+
recordingData: JSON.stringify([
125+
{
126+
data: { isCheckout: true },
127+
timestamp: BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + 40,
128+
type: 2,
129+
},
130+
]),
131+
});
132+
122133
// Check that click will get captured
123134
domHandler({
124135
name: 'click',
@@ -128,15 +139,14 @@ describe('Integration | errorSampleRate', () => {
128139
await new Promise(process.nextTick);
129140

130141
expect(replay).toHaveLastSentReplay({
131-
recordingPayloadHeader: { segment_id: 2 },
132142
recordingData: JSON.stringify([
133143
{
134144
type: 5,
135-
timestamp: BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80,
145+
timestamp: BASE_TIMESTAMP + 10000 + 60,
136146
data: {
137147
tag: 'breadcrumb',
138148
payload: {
139-
timestamp: (BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80) / 1000,
149+
timestamp: (BASE_TIMESTAMP + 10000 + 60) / 1000,
140150
type: 'default',
141151
category: 'ui.click',
142152
message: '<unknown>',
@@ -527,10 +537,6 @@ describe('Integration | errorSampleRate', () => {
527537

528538
expect(replay).toHaveLastSentReplay();
529539

530-
// Flush from calling `stopRecording`
531-
jest.runAllTimers()
532-
await new Promise(process.nextTick);
533-
534540
// Now wait after session expires - should stop recording
535541
mockRecord.takeFullSnapshot.mockClear();
536542
(getCurrentHub().getClient()!.getTransport()!.send as unknown as jest.SpyInstance<any>).mockClear();
@@ -632,16 +638,16 @@ it('sends a replay after loading the session multiple times', async () => {
632638
captureException(new Error('testing'));
633639

634640
await new Promise(process.nextTick);
635-
await advanceTimers(DEFAULT_FLUSH_MIN_DELAY);
641+
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
642+
await new Promise(process.nextTick);
636643

637-
expect(replay).toHaveLastSentReplay({
644+
expect(replay).toHaveSentReplay({
638645
recordingData: JSON.stringify([{ data: { isCheckout: true }, timestamp: BASE_TIMESTAMP, type: 2 }, TEST_EVENT]),
639646
});
640647

641-
await advanceTimers(DEFAULT_FLUSH_MIN_DELAY);
642648
// Latest checkout when we call `startRecording` again after uploading segment
643649
// after an error occurs (e.g. when we switch to session replay recording)
644650
expect(replay).toHaveLastSentReplay({
645-
recordingData: JSON.stringify([{ data: { isCheckout: true }, timestamp: BASE_TIMESTAMP + 10040, type: 2 }]),
651+
recordingData: JSON.stringify([{ data: { isCheckout: true }, timestamp: BASE_TIMESTAMP + 5040, type: 2 }]),
646652
});
647653
});

0 commit comments

Comments
 (0)