Skip to content

Commit 56599e5

Browse files
committed
fix integration tests
1 parent 424964d commit 56599e5

5 files changed

Lines changed: 15 additions & 16 deletions

File tree

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('Integration | coreHandlers | handleAfterSendEvent', () => {
5353
handler(error4, { statusCode: undefined });
5454

5555
expect(Array.from(replay.getContext().errorIds)).toEqual(['err2']);
56-
expect(Array.from(replay.getContext().traceIds)).toEqual([]);
56+
expect(Array.from(replay.getContext().traceIds)).toEqual([[-1, expect.any(String)]]);
5757
});
5858

5959
it('records traceIds from sent transaction events', async () => {
@@ -84,20 +84,16 @@ describe('Integration | coreHandlers | handleAfterSendEvent', () => {
8484
handler(transaction4, { statusCode: undefined });
8585

8686
expect(Array.from(replay.getContext().errorIds)).toEqual([]);
87-
// traceIds is now a Set of [timestamp, trace_id] tuples
88-
const traceIds = Array.from(replay.getContext().traceIds);
89-
expect(traceIds).toHaveLength(1);
90-
expect(traceIds[0][1]).toBe('tr2');
91-
expect(typeof traceIds[0][0]).toBe('number');
87+
const traceIds = replay.getContext().traceIds;
88+
expect(traceIds).toEqual([[expect.any(Number), 'tr2']]);
9289

9390
// Does not affect error session
9491
await vi.advanceTimersToNextTimerAsync();
9592

9693
expect(Array.from(replay.getContext().errorIds)).toEqual([]);
9794
// Verify traceIds are still there after advancing timers
98-
const traceIdsAfter = Array.from(replay.getContext().traceIds);
99-
expect(traceIdsAfter).toHaveLength(1);
100-
expect(traceIdsAfter[0][1]).toBe('tr2');
95+
const traceIdsAfter = replay.getContext().traceIds;
96+
expect(traceIdsAfter).toEqual([[expect.any(Number), 'tr2']]);
10197
expect(replay.isEnabled()).toBe(true);
10298
expect(replay.isPaused()).toBe(false);
10399
expect(replay.recordingMode).toBe('buffer');
@@ -126,7 +122,7 @@ describe('Integration | coreHandlers | handleAfterSendEvent', () => {
126122
.fill(undefined)
127123
.map((_, i) => `err-${i}`),
128124
);
129-
expect(Array.from(replay.getContext().traceIds)).toEqual([]);
125+
expect(replay.getContext().traceIds).toEqual([[-1, expect.any(String)]]);
130126
});
131127

132128
it('limits traceIds to max. 100', async () => {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ describe('Integration | errorSampleRate', () => {
702702
replay_start_timestamp: BASE_TIMESTAMP / 1000,
703703
timestamp: (BASE_TIMESTAMP + DEFAULT_FLUSH_MIN_DELAY + DEFAULT_FLUSH_MIN_DELAY) / 1000,
704704
error_ids: [expect.any(String)],
705-
trace_ids: [],
705+
trace_ids: [expect.any(String)],
706+
traces_by_timestamp: [[-1, expect.any(String)]],
706707
urls: ['http://localhost:3000/'],
707708
replay_id: expect.any(String),
708709
}),
@@ -909,7 +910,8 @@ describe('Integration | errorSampleRate', () => {
909910
replayEventPayload: expect.objectContaining({
910911
replay_start_timestamp: (BASE_TIMESTAMP + stepDuration * steps) / 1000,
911912
error_ids: [expect.any(String)],
912-
trace_ids: [],
913+
trace_ids: [expect.any(String)],
914+
traces_by_timestamp: [[-1, expect.any(String)]],
913915
urls: ['http://localhost:3000/'],
914916
replay_id: expect.any(String),
915917
}),

packages/replay-internal/test/integration/sampling.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('Integration | sampling', () => {
3737
// This is what the `_context` member is initialized with
3838
expect(replay.getContext()).toEqual({
3939
errorIds: new Set(),
40-
traceIds: new Set(),
40+
traceIds: [],
4141
urls: [],
4242
initialTimestamp: expect.any(Number),
4343
initialUrl: '',
@@ -78,7 +78,7 @@ describe('Integration | sampling', () => {
7878
errorIds: new Set(),
7979
initialTimestamp: expect.any(Number),
8080
initialUrl: 'http://localhost:3000/',
81-
traceIds: new Set(),
81+
traceIds: [],
8282
urls: ['http://localhost:3000/'],
8383
});
8484
expect(replay.recordingMode).toBe('buffer');

packages/replay-internal/test/integration/sendReplayEvent.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ describe('Integration | sendReplayEvent', () => {
340340
replay_start_timestamp: BASE_TIMESTAMP / 1000,
341341
// timestamp is set on first try, after 5s flush
342342
timestamp: (BASE_TIMESTAMP + 5000) / 1000,
343-
trace_ids: [],
343+
trace_ids: [expect.any(String)],
344+
traces_by_timestamp: [[-1, expect.any(String)]],
344345
urls: ['http://localhost:3000/'],
345346
}),
346347
recordingPayloadHeader: { segment_id: 0 },

packages/replay-internal/test/integration/session.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ describe('Integration | session', () => {
252252
initialTimestamp: newTimestamp - DEFAULT_FLUSH_MIN_DELAY,
253253
urls: [],
254254
errorIds: new Set(),
255-
traceIds: new Set(),
255+
traceIds: [[-1, expect.any(String)]],
256256
});
257257
});
258258

0 commit comments

Comments
 (0)