Skip to content

Commit 2a872df

Browse files
committed
make test less flaky
1 parent a9f2651 commit 2a872df

File tree

1 file changed

+54
-6
lines changed
  • packages/browser-integration-tests/suites/replay/privacyInput

1 file changed

+54
-6
lines changed

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

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,34 @@ sentryTest(
2424
sentryTest.skip();
2525
}
2626

27+
// We want to ensure to check the correct event payloads
28+
const inputMutationSegmentIds: number[] = [];
2729
const reqPromise0 = waitForReplayRequest(page, 0);
28-
const reqPromise1 = waitForReplayRequest(page, 1);
29-
const reqPromise2 = waitForReplayRequest(page, 2);
30-
const reqPromise3 = waitForReplayRequest(page, 3);
30+
const reqPromise1 = waitForReplayRequest(page, (event, res) => {
31+
const check = inputMutationSegmentIds.length === 0 && getIncrementalRecordingSnapshots(res).some(isInputMutation);
32+
33+
if (check) {
34+
inputMutationSegmentIds.push(event.segment_id);
35+
}
36+
37+
return check;
38+
});
39+
const reqPromise2 = waitForReplayRequest(page, (event, res) => {
40+
const check =
41+
inputMutationSegmentIds.length === 1 &&
42+
inputMutationSegmentIds[0] < event.segment_id &&
43+
getIncrementalRecordingSnapshots(res).some(isInputMutation);
44+
45+
if (check) {
46+
inputMutationSegmentIds.push(event.segment_id);
47+
}
48+
49+
return check;
50+
});
51+
const reqPromise3 = waitForReplayRequest(page, event => {
52+
// This one should not have any input mutations
53+
return inputMutationSegmentIds.length === 2 && inputMutationSegmentIds[1] < event.segment_id;
54+
});
3155

3256
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
3357
return route.fulfill({
@@ -72,10 +96,34 @@ sentryTest(
7296
sentryTest.skip();
7397
}
7498

99+
// We want to ensure to check the correct event payloads
100+
const inputMutationSegmentIds: number[] = [];
75101
const reqPromise0 = waitForReplayRequest(page, 0);
76-
const reqPromise1 = waitForReplayRequest(page, 1);
77-
const reqPromise2 = waitForReplayRequest(page, 2);
78-
const reqPromise3 = waitForReplayRequest(page, 3);
102+
const reqPromise1 = waitForReplayRequest(page, (event, res) => {
103+
const check = inputMutationSegmentIds.length === 0 && getIncrementalRecordingSnapshots(res).some(isInputMutation);
104+
105+
if (check) {
106+
inputMutationSegmentIds.push(event.segment_id);
107+
}
108+
109+
return check;
110+
});
111+
const reqPromise2 = waitForReplayRequest(page, (event, res) => {
112+
const check =
113+
inputMutationSegmentIds.length === 1 &&
114+
inputMutationSegmentIds[0] < event.segment_id &&
115+
getIncrementalRecordingSnapshots(res).some(isInputMutation);
116+
117+
if (check) {
118+
inputMutationSegmentIds.push(event.segment_id);
119+
}
120+
121+
return check;
122+
});
123+
const reqPromise3 = waitForReplayRequest(page, event => {
124+
// This one should not have any input mutations
125+
return inputMutationSegmentIds.length === 2 && inputMutationSegmentIds[1] < event.segment_id;
126+
});
79127

80128
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
81129
return route.fulfill({

0 commit comments

Comments
 (0)