Skip to content

Commit 6b1e428

Browse files
committed
fix test
1 parent a8c7998 commit 6b1e428

File tree

1 file changed

+5
-6
lines changed
  • packages/integration-tests/suites/replay/sessionMaxAge

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ for (let i = 0; i < 1; i++) {
4040

4141
await page.goto(url);
4242
const req0 = await reqPromise0;
43+
const startTimestamp = Date.now();
4344

4445
const replayEvent0 = getReplayEvent(req0);
4546
expect(replayEvent0).toEqual(getExpectedReplayEvent({}));
@@ -52,9 +53,7 @@ for (let i = 0; i < 1; i++) {
5253
// We wait for another segment 0
5354
const reqPromise2 = waitForReplayRequest(page, 0);
5455

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));
56+
// Wait for an incremental snapshot
5857
await page.click('#button1');
5958

6059
const req1 = await reqPromise1;
@@ -90,12 +89,12 @@ for (let i = 0; i < 1; i++) {
9089
const replay = await getReplaySnapshot(page);
9190
const oldSessionId = replay.session?.id;
9291

93-
await new Promise(resolve => setTimeout(resolve, SESSION_MAX_AGE / 2));
94-
92+
// Wait for session to expire
93+
await new Promise(resolve => setTimeout(resolve, SESSION_MAX_AGE - (Date.now() - startTimestamp)));
9594
await page.click('#button2');
9695

97-
const replay2 = await getReplaySnapshot(page);
9896
const req2 = await reqPromise2;
97+
const replay2 = await getReplaySnapshot(page);
9998

10099
expect(replay2.session?.id).not.toEqual(oldSessionId);
101100

0 commit comments

Comments
 (0)