Skip to content

Commit 3c96d57

Browse files
committed
fix throttle test, needs to account for perf spans too
1 parent aca771e commit 3c96d57

File tree

1 file changed

+9
-6
lines changed
  • packages/browser-integration-tests/suites/replay/throttleBreadcrumbs

1 file changed

+9
-6
lines changed

packages/browser-integration-tests/suites/replay/throttleBreadcrumbs/test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from '@playwright/test';
22

33
import { sentryTest } from '../../../utils/fixtures';
4-
import { getCustomRecordingEvents, shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers';
4+
import { getCustomRecordingEvents, getReplayRecordingContent, shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers';
55

66
const THROTTLE_LIMIT = 300;
77

@@ -26,16 +26,19 @@ sentryTest(
2626
const url = await getLocalTestUrl({ testDir: __dirname });
2727

2828
await page.goto(url);
29-
await reqPromise0;
29+
await forceFlushReplay();
30+
const res0 = getCustomRecordingEvents(await reqPromise0)
3031

3132
await page.click('[data-console]');
3233
await forceFlushReplay();
3334

34-
const { breadcrumbs } = getCustomRecordingEvents(await reqPromise1);
35+
const res1 = getCustomRecordingEvents(await reqPromise1);
3536

36-
// 1 click breadcrumb + 1 throttled breadcrumb is why console logs are less
37-
// than throttle limit
38-
expect(breadcrumbs.length).toBe(THROTTLE_LIMIT);
37+
const breadcrumbs = [...res0.breadcrumbs, ...res1.breadcrumbs];
38+
const spans = [...res0.performanceSpans, ...res1.performanceSpans];
3939
expect(breadcrumbs.filter(breadcrumb => breadcrumb.category === 'replay.throttled').length).toBe(1);
40+
// replay.throttled breadcrumb does *not* use the throttledAddEvent as we
41+
// alwants want that breadcrumb to be present in replay
42+
expect(breadcrumbs.length + spans.length).toBe(THROTTLE_LIMIT + 1);
4043
},
4144
);

0 commit comments

Comments
 (0)