Skip to content

Commit 2d93c08

Browse files
committed
Refactor more.
1 parent 51afe11 commit 2d93c08

File tree

7 files changed

+32
-36
lines changed

7 files changed

+32
-36
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ sentryTest(
8484
await reqErrorPromise;
8585
expect(callsToSentry).toEqual(2);
8686

87-
const [, req0] = await Promise.all([
87+
const [req0] = await Promise.all([
88+
reqPromise0,
8889
await page.evaluate(async () => {
8990
const replayIntegration = (window as unknown as Window & { Replay: Replay }).Replay;
9091
await replayIntegration.flush();
9192
}),
92-
reqPromise0,
9393
]);
9494

9595
// 2 errors, 1 flush
@@ -227,12 +227,12 @@ sentryTest(
227227
await reqErrorPromise;
228228
expect(callsToSentry).toEqual(2);
229229

230-
const [, req0] = await Promise.all([
230+
const [req0] = await Promise.all([
231+
reqPromise0,
231232
page.evaluate(async () => {
232233
const replayIntegration = (window as unknown as Window & { Replay: Replay }).Replay;
233234
await replayIntegration.flush({ continueRecording: false });
234235
}),
235-
reqPromise0,
236236
]);
237237

238238
// 2 errors, 1 flush
@@ -348,11 +348,10 @@ sentryTest(
348348

349349
// Error sample rate is now at 1.0, this error should create a replay
350350
const reqErrorPromise1 = waitForErrorRequest(page);
351-
const [, req0] = await Promise.all([
352-
page.click('#error2'),
353-
351+
const [req0] = await Promise.all([
354352
// 1 unsampled error, 1 sampled error -> 1 flush
355353
reqPromise0,
354+
page.click('#error2'),
356355
]);
357356

358357
const reqError1 = await reqErrorPromise1;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ sentryTest('should capture console messages in replay', async ({ getLocalTestPat
3737
await page.click('[data-log]');
3838

3939
// Sometimes this doesn't seem to trigger, so we trigger it twice to be sure...
40-
const [, , req1] = await Promise.all([page.click('[data-log]'), forceFlushReplay(), reqPromise1]);
40+
const [req1] = await Promise.all([reqPromise1, page.click('[data-log]'), forceFlushReplay()]);
4141

4242
const { breadcrumbs } = getCustomRecordingEvents(req1);
4343

@@ -86,7 +86,7 @@ sentryTest('should capture very large console logs', async ({ getLocalTestPath,
8686
5_000,
8787
);
8888

89-
const [, , req1] = await Promise.all([page.click('[data-log-large]'), forceFlushReplay(), reqPromise1]);
89+
const [req1] = await Promise.all([reqPromise1, page.click('[data-log-large]'), forceFlushReplay()]);
9090

9191
const { breadcrumbs } = getCustomRecordingEvents(req1);
9292

packages/browser-integration-tests/suites/replay/errors/errorMode/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ sentryTest(
5858

5959
expect(callsToSentry).toEqual(0);
6060

61-
const [, req0] = await Promise.all([page.click('#error'), reqPromise0]);
61+
const [req0] = await Promise.all([reqPromise0, page.click('#error')]);
6262

6363
expect(callsToSentry).toEqual(2); // 1 error, 1 replay event
6464

65-
const [, req1] = await Promise.all([page.click('#go-background'), reqPromise1, reqErrorPromise]);
65+
const [req1] = await Promise.all([reqPromise1, page.click('#go-background'), reqErrorPromise]);
6666

6767
expect(callsToSentry).toEqual(3); // 1 error, 2 replay events
6868

6969
await page.click('#log');
7070

71-
const [, req2] = await Promise.all([page.click('#go-background'), reqPromise2]);
71+
const [req2] = await Promise.all([reqPromise2, page.click('#go-background')]);
7272

7373
const event0 = getReplayEvent(req0);
7474
const content0 = getReplayRecordingContent(req0);

packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,19 @@ sentryTest(
2727

2828
const url = await getLocalTestPath({ testDir: __dirname });
2929

30-
const [, res0] = await Promise.all([page.goto(url), reqPromise0]);
30+
const [res0] = await Promise.all([reqPromise0, page.goto(url)]);
3131

3232
const reqPromise1 = waitForReplayRequest(page);
3333

34-
const [, , res1] = await Promise.all([page.click('#button-add'), forceFlushReplay(), reqPromise1]);
34+
const [res1] = await Promise.all([reqPromise1, page.click('#button-add'), forceFlushReplay()]);
3535

3636
// replay should be stopped due to mutation limit
3737
let replay = await getReplaySnapshot(page);
3838
expect(replay.session).toBe(undefined);
3939
expect(replay._isEnabled).toBe(false);
4040

41-
await Promise.all([page.click('#button-modify'), await forceFlushReplay()]);
42-
43-
await Promise.all([page.click('#button-remove'), await forceFlushReplay()]);
41+
await Promise.all([page.click('#button-modify'), forceFlushReplay()]);
42+
await Promise.all([page.click('#button-remove'), forceFlushReplay()]);
4443

4544
const replayData0 = getReplayRecordingContent(res0);
4645
expect(replayData0.fullSnapshots.length).toBe(1);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ sentryTest('keeps track of max duration across reloads', async ({ getLocalTestPa
3535

3636
await new Promise(resolve => setTimeout(resolve, MAX_REPLAY_DURATION / 2 + 100));
3737

38-
const [, , req0, req1] = await Promise.all([
38+
const [req0, req1] = await Promise.all([
39+
reqPromise0,
40+
reqPromise1,
3941
page.click('#button1'),
4042
page.evaluate(
4143
`Object.defineProperty(document, 'visibilityState', {
@@ -47,8 +49,6 @@ sentryTest('keeps track of max duration across reloads', async ({ getLocalTestPa
4749
4850
document.dispatchEvent(new Event('visibilitychange'));`,
4951
),
50-
reqPromise0,
51-
reqPromise1,
5252
]);
5353

5454
const replayEvent0 = getReplayEvent(req0);

packages/browser-integration-tests/suites/replay/multiple-pages/test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ sentryTest(
5656

5757
const url = await getLocalTestPath({ testDir: __dirname });
5858

59-
const [, req0] = await Promise.all([page.goto(url), reqPromise0]);
59+
const [req0] = await Promise.all([reqPromise0, page.goto(url)]);
6060
const replayEvent0 = getReplayEvent(req0);
6161
const recording0 = getReplayRecordingContent(req0);
6262

6363
expect(replayEvent0).toEqual(getExpectedReplayEvent({ segment_id: 0 }));
6464
expect(normalize(recording0.fullSnapshots)).toMatchSnapshot('seg-0-snap-full');
6565
expect(recording0.incrementalSnapshots.length).toEqual(0);
6666

67-
const [, req1] = await Promise.all([page.click('#go-background'), reqPromise1]);
67+
const [req1] = await Promise.all([reqPromise1, page.click('#go-background')]);
6868

6969
const replayEvent1 = getReplayEvent(req1);
7070
const recording1 = getReplayRecordingContent(req1);
@@ -95,7 +95,7 @@ sentryTest(
9595
// -----------------------------------------------------------------------------------------
9696
// Test page reload
9797

98-
const [, req2] = await Promise.all([page.reload(), reqPromise2]);
98+
const [req2] = await Promise.all([reqPromise2, page.reload()]);
9999

100100
const replayEvent2 = getReplayEvent(req2);
101101
const recording2 = getReplayRecordingContent(req2);
@@ -104,7 +104,7 @@ sentryTest(
104104
expect(normalize(recording2.fullSnapshots)).toMatchSnapshot('seg-2-snap-full');
105105
expect(recording2.incrementalSnapshots.length).toEqual(0);
106106

107-
const [, req3] = await Promise.all([page.click('#go-background'), reqPromise3]);
107+
const [req3] = await Promise.all([reqPromise3, page.click('#go-background')]);
108108

109109
const replayEvent3 = getReplayEvent(req3);
110110
const recording3 = getReplayRecordingContent(req3);
@@ -133,7 +133,7 @@ sentryTest(
133133
// -----------------------------------------------------------------------------------------
134134
// Test subsequent link navigation to another page
135135

136-
const [, req4] = await Promise.all([page.click('a'), reqPromise4]);
136+
const [req4] = await Promise.all([reqPromise4, page.click('a')]);
137137

138138
const replayEvent4 = getReplayEvent(req4);
139139
const recording4 = getReplayRecordingContent(req4);
@@ -156,7 +156,7 @@ sentryTest(
156156
expect(normalize(recording4.fullSnapshots)).toMatchSnapshot('seg-4-snap-full');
157157
expect(recording4.incrementalSnapshots.length).toEqual(0);
158158

159-
const [, req5] = await Promise.all([page.click('#go-background'), reqPromise5]);
159+
const [req5] = await Promise.all([reqPromise5, page.click('#go-background')]);
160160

161161
const replayEvent5 = getReplayEvent(req5);
162162
const recording5 = getReplayRecordingContent(req5);
@@ -201,7 +201,7 @@ sentryTest(
201201
// -----------------------------------------------------------------------------------------
202202
// Test subsequent navigation without a page reload (i.e. SPA navigation)
203203

204-
const [, req6] = await Promise.all([page.click('#spa-navigation'), reqPromise6]);
204+
const [req6] = await Promise.all([reqPromise6, page.click('#spa-navigation')]);
205205

206206
const replayEvent6 = getReplayEvent(req6);
207207
const recording6 = getReplayRecordingContent(req6);
@@ -224,7 +224,7 @@ sentryTest(
224224
expect(recording6.fullSnapshots.length).toEqual(0);
225225
expect(normalize(recording6.incrementalSnapshots)).toMatchSnapshot('seg-6-snap-incremental');
226226

227-
const [, req7] = await Promise.all([page.click('#go-background'), reqPromise7]);
227+
const [req7] = await Promise.all([reqPromise7, page.click('#go-background')]);
228228

229229
const replayEvent7 = getReplayEvent(req7);
230230
const recording7 = getReplayRecordingContent(req7);
@@ -271,7 +271,7 @@ sentryTest(
271271
// // -----------------------------------------------------------------------------------------
272272
// // And just to finish this off, let's go back to the index page
273273

274-
const [, req8] = await Promise.all([page.click('a'), reqPromise8]);
274+
const [req8] = await Promise.all([reqPromise8, page.click('a')]);
275275

276276
const replayEvent8 = getReplayEvent(req8);
277277
const recording8 = getReplayRecordingContent(req8);
@@ -284,7 +284,7 @@ sentryTest(
284284
expect(normalize(recording8.fullSnapshots)).toMatchSnapshot('seg-8-snap-full');
285285
expect(recording8.incrementalSnapshots.length).toEqual(0);
286286

287-
const [, req9] = await Promise.all([page.click('#go-background'), reqPromise9]);
287+
const [req9] = await Promise.all([reqPromise9, page.click('#go-background')]);
288288

289289
const replayEvent9 = getReplayEvent(req9);
290290
const recording9 = getReplayRecordingContent(req9);

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ sentryTest('replay recording should contain fetch request span', async ({ getLoc
3131

3232
const url = await getLocalTestPath({ testDir: __dirname });
3333

34-
const [, req0] = await Promise.all([Promise.all([page.goto(url), page.click('#go-background')]), reqPromise0]);
34+
const [req0] = await Promise.all([reqPromise0, page.goto(url), page.click('#go-background')]);
3535

3636
const { performanceSpans: spans0 } = getReplayRecordingContent(req0);
3737

38-
const receivedResponse = page.waitForResponse('https://example.com');
39-
40-
await Promise.all([page.click('#fetch'), receivedResponse]);
38+
await Promise.all([page.waitForResponse('https://example.com'), page.click('#fetch')]);
4139

4240
const { performanceSpans: spans1 } = getReplayRecordingContent(await reqPromise1);
4341

@@ -71,11 +69,11 @@ sentryTest('replay recording should contain XHR request span', async ({ getLocal
7169

7270
const url = await getLocalTestPath({ testDir: __dirname });
7371

74-
const [, req0] = await Promise.all([Promise.all([page.goto(url), page.click('#go-background')]), reqPromise0]);
72+
const [req0] = await Promise.all([reqPromise0, page.goto(url), page.click('#go-background')]);
7573

7674
const { performanceSpans: spans0 } = getReplayRecordingContent(req0);
7775

78-
await Promise.all([page.click('#xhr'), page.waitForResponse('https://example.com')]);
76+
await Promise.all([page.waitForResponse('https://example.com'), page.click('#xhr')]);
7977

8078
const { performanceSpans: spans1 } = getReplayRecordingContent(await reqPromise1);
8179

0 commit comments

Comments
 (0)