Skip to content

Commit 69df6e4

Browse files
committed
ref
ref tests ref test
1 parent e151815 commit 69df6e4

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

packages/integration-tests/suites/replay/sessionExpiry/test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ for (let i = 0; i < 100; i++) {
3535
const url = await getLocalTestPath({ testDir: __dirname });
3636

3737
await page.goto(url);
38+
const req0 = await reqPromise0;
3839

39-
const replayEvent0 = getReplayEvent(await reqPromise0);
40+
const replayEvent0 = getReplayEvent(req0);
4041
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
4142

42-
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
43+
const fullSnapshots0 = getFullRecordingSnapshots(req0);
4344
expect(fullSnapshots0.length).toEqual(1);
4445
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
4546
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
@@ -48,15 +49,17 @@ for (let i = 0; i < 100; i++) {
4849
const reqPromise2 = waitForReplayRequest(page, 0);
4950

5051
await page.click('#button1');
51-
const replayEvent1 = getReplayEvent(await reqPromise1);
52+
const req1 = await reqPromise1;
53+
54+
const replayEvent1 = getReplayEvent(req1);
5255
expect(replayEvent1).toEqual(
5356
getExpectedReplayEvent({ replay_start_timestamp: undefined, segment_id: 1, urls: [] }),
5457
);
5558

56-
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise1);
59+
const fullSnapshots1 = getFullRecordingSnapshots(req1);
5760
expect(fullSnapshots1.length).toEqual(0);
5861

59-
const incrementalSnapshots1 = getIncrementalRecordingSnapshots(await reqPromise1);
62+
const incrementalSnapshots1 = getIncrementalRecordingSnapshots(req1);
6063
// The number of incremental snapshots depends on the browser
6164
expect(incrementalSnapshots1.length).toBeGreaterThanOrEqual(4);
6265

@@ -82,15 +85,16 @@ for (let i = 0; i < 100; i++) {
8285
await new Promise(resolve => setTimeout(resolve, SESSION_TIMEOUT));
8386

8487
await page.click('#button2');
88+
const req2 = await reqPromise2;
8589

8690
const replay2 = await getReplaySnapshot(page);
8791

8892
expect(replay2.session?.id).not.toEqual(oldSessionId);
8993

90-
const replayEvent2 = getReplayEvent(await reqPromise2);
94+
const replayEvent2 = getReplayEvent(req2);
9195
expect(replayEvent2).toEqual(getExpectedReplayEvent({}));
9296

93-
const fullSnapshots2 = getFullRecordingSnapshots(await reqPromise2);
97+
const fullSnapshots2 = getFullRecordingSnapshots(req2);
9498
expect(fullSnapshots2.length).toEqual(1);
9599
const stringifiedSnapshot2 = normalize(fullSnapshots2[0]);
96100
expect(stringifiedSnapshot2).toMatchSnapshot('snapshot-2.json');

packages/integration-tests/suites/replay/sessionInactive/test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ for (let i = 0; i < 100; i++) {
3333
const url = await getLocalTestPath({ testDir: __dirname });
3434

3535
await page.goto(url);
36+
const req0 = await reqPromise0;
3637

37-
const replayEvent0 = getReplayEvent(await reqPromise0);
38+
const replayEvent0 = getReplayEvent(req0);
3839
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
3940

40-
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
41+
const fullSnapshots0 = getFullRecordingSnapshots(req0);
4142
expect(fullSnapshots0.length).toEqual(1);
4243
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
4344
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
@@ -70,17 +71,18 @@ for (let i = 0; i < 100; i++) {
7071

7172
// Trigger an action, should re-start the recording
7273
await page.click('#button2');
74+
const req1 = await reqPromise1;
7375

7476
const replay3 = await getReplaySnapshot(page);
7577
// @ts-ignore private api
7678
expect(replay3._isEnabled).toEqual(true);
7779
// @ts-ignore private api
7880
expect(replay3._isPaused).toEqual(false);
7981

80-
const replayEvent1 = getReplayEvent(await reqPromise1);
82+
const replayEvent1 = getReplayEvent(req1);
8183
expect(replayEvent1).toEqual(getExpectedReplayEvent({}));
8284

83-
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise0);
85+
const fullSnapshots1 = getFullRecordingSnapshots(req1);
8486
expect(fullSnapshots1.length).toEqual(1);
8587
const stringifiedSnapshot1 = normalize(fullSnapshots1[0]);
8688
expect(stringifiedSnapshot1).toMatchSnapshot('snapshot-1.json');

packages/integration-tests/suites/replay/sessionMaxAge/test.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,35 @@ for (let i = 0; i < 100; i++) {
3939
const url = await getLocalTestPath({ testDir: __dirname });
4040

4141
await page.goto(url);
42+
const req0 = await reqPromise0;
4243

43-
const replayEvent0 = getReplayEvent(await reqPromise0);
44+
const replayEvent0 = getReplayEvent(req0);
4445
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
4546

46-
const fullSnapshots0 = getFullRecordingSnapshots(await reqPromise0);
47+
const fullSnapshots0 = getFullRecordingSnapshots(req0);
4748
expect(fullSnapshots0.length).toEqual(1);
4849
const stringifiedSnapshot = normalize(fullSnapshots0[0]);
4950
expect(stringifiedSnapshot).toMatchSnapshot('snapshot-0.json');
5051

5152
// We wait for another segment 0
5253
const reqPromise2 = waitForReplayRequest(page, 0);
5354

54-
await new Promise(resolve => setTimeout(resolve, SESSION_MAX_AGE / 2));
55+
// Wait a bit, but not until session max age is reached (4000ms)
56+
// Note: We assume that we'll not reach the 4000ms with the actions we did before + 200ms here
57+
await new Promise(resolve => setTimeout(resolve, 200));
5558
await page.click('#button1');
5659

57-
const replayEvent1 = getReplayEvent(await reqPromise1);
60+
const req1 = await reqPromise1;
61+
const replayEvent1 = getReplayEvent(req1);
62+
const fullSnapshots1 = getFullRecordingSnapshots(req1);
63+
const incrementalSnapshots1 = getIncrementalRecordingSnapshots(req1);
64+
5865
expect(replayEvent1).toEqual(
5966
getExpectedReplayEvent({ replay_start_timestamp: undefined, segment_id: 1, urls: [] }),
6067
);
6168

62-
const fullSnapshots1 = getFullRecordingSnapshots(await reqPromise1);
6369
expect(fullSnapshots1.length).toEqual(0);
6470

65-
const incrementalSnapshots1 = getIncrementalRecordingSnapshots(await reqPromise1);
6671
// The number of incremental snapshots depends on the browser
6772
expect(incrementalSnapshots1.length).toBeGreaterThanOrEqual(4);
6873

@@ -90,13 +95,14 @@ for (let i = 0; i < 100; i++) {
9095
await page.click('#button2');
9196

9297
const replay2 = await getReplaySnapshot(page);
98+
const req2 = await reqPromise2;
9399

94100
expect(replay2.session?.id).not.toEqual(oldSessionId);
95101

96-
const replayEvent2 = getReplayEvent(await reqPromise2);
102+
const replayEvent2 = getReplayEvent(req2);
97103
expect(replayEvent2).toEqual(getExpectedReplayEvent({}));
98104

99-
const fullSnapshots2 = getFullRecordingSnapshots(await reqPromise2);
105+
const fullSnapshots2 = getFullRecordingSnapshots(req2);
100106
expect(fullSnapshots2.length).toEqual(1);
101107
const stringifiedSnapshot2 = normalize(fullSnapshots2[0]);
102108
expect(stringifiedSnapshot2).toMatchSnapshot('snapshot-2.json');

0 commit comments

Comments
 (0)