Skip to content

Commit 63234ec

Browse files
committed
revert test changes
1 parent 29e8911 commit 63234ec

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
@@ -96,9 +96,6 @@ describe('Integration | errorSampleRate', () => {
9696
]),
9797
});
9898

99-
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
100-
await new Promise(process.nextTick);
101-
10299
// This is from when we stop recording and start a session recording
103100
expect(replay).toHaveLastSentReplay({
104101
recordingPayloadHeader: { segment_id: 1 },
@@ -110,6 +107,20 @@ describe('Integration | errorSampleRate', () => {
110107
]),
111108
});
112109

110+
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
111+
112+
// New checkout when we call `startRecording` again after uploading segment
113+
// after an error occurs
114+
expect(replay).toHaveLastSentReplay({
115+
recordingData: JSON.stringify([
116+
{
117+
data: { isCheckout: true },
118+
timestamp: BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + 40,
119+
type: 2,
120+
},
121+
]),
122+
});
123+
113124
// Check that click will get captured
114125
domHandler({
115126
name: 'click',
@@ -119,15 +130,14 @@ describe('Integration | errorSampleRate', () => {
119130
await new Promise(process.nextTick);
120131

121132
expect(replay).toHaveLastSentReplay({
122-
recordingPayloadHeader: { segment_id: 2 },
123133
recordingData: JSON.stringify([
124134
{
125135
type: 5,
126-
timestamp: BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80,
136+
timestamp: BASE_TIMESTAMP + 10000 + 60,
127137
data: {
128138
tag: 'breadcrumb',
129139
payload: {
130-
timestamp: (BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY + 80) / 1000,
140+
timestamp: (BASE_TIMESTAMP + 10000 + 60) / 1000,
131141
type: 'default',
132142
category: 'ui.click',
133143
message: '<unknown>',
@@ -620,10 +630,6 @@ describe('Integration | errorSampleRate', () => {
620630

621631
expect(replay).toHaveLastSentReplay();
622632

623-
// Flush from calling `stopRecording`
624-
jest.runAllTimers()
625-
await new Promise(process.nextTick);
626-
627633
// Now wait after session expires - should stop recording
628634
mockRecord.takeFullSnapshot.mockClear();
629635
(getCurrentHub().getClient()!.getTransport()!.send as unknown as jest.SpyInstance<any>).mockClear();
@@ -730,9 +736,10 @@ it('sends a replay after loading the session multiple times', async () => {
730736
captureException(new Error('testing'));
731737

732738
await new Promise(process.nextTick);
733-
await advanceTimers(DEFAULT_FLUSH_MIN_DELAY);
739+
jest.advanceTimersByTime(DEFAULT_FLUSH_MIN_DELAY);
740+
await new Promise(process.nextTick);
734741

735-
expect(replay).toHaveLastSentReplay({
742+
expect(replay).toHaveSentReplay({
736743
recordingPayloadHeader: { segment_id: 0 },
737744
recordingData: JSON.stringify([
738745
{ data: { isCheckout: true }, timestamp: BASE_TIMESTAMP, type: 2 },
@@ -741,11 +748,10 @@ it('sends a replay after loading the session multiple times', async () => {
741748
]),
742749
});
743750

744-
await advanceTimers(DEFAULT_FLUSH_MIN_DELAY);
745751
// Latest checkout when we call `startRecording` again after uploading segment
746752
// after an error occurs (e.g. when we switch to session replay recording)
747753
expect(replay).toHaveLastSentReplay({
748754
recordingPayloadHeader: { segment_id: 1 },
749-
recordingData: JSON.stringify([{ data: { isCheckout: true }, timestamp: BASE_TIMESTAMP + 10040, type: 2 }]),
755+
recordingData: JSON.stringify([{ data: { isCheckout: true }, timestamp: BASE_TIMESTAMP + 5040, type: 2 }]),
750756
});
751757
});

0 commit comments

Comments
 (0)