From a37eb95b8b97e912c173e82596c8fc316d99ae0c Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 27 Jan 2025 12:05:38 +0100 Subject: [PATCH 1/2] test(e2e): Unflake replay recording data optional e2e test --- .../tests/send-to-sentry.test.ts | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts b/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts index d9c3e09f2ad2..5711b1ef7f17 100644 --- a/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts +++ b/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts @@ -180,24 +180,26 @@ test('Sends a Replay recording to Sentry', async ({ browser }) => { .toBe(200); // now fetch the first recording segment - await expect - .poll( - async () => { - const response = await fetch( - `https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/replays/${replayId}/recording-segments/?cursor=100%3A0%3A1`, - { headers: { Authorization: `Bearer ${authToken}` } }, - ); - - if (response.ok) { - const data = await response.json(); - return data[0]; - } + const data = expect.poll( + async () => { + const response = await fetch( + `https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/replays/${replayId}/recording-segments/?cursor=100%3A0%3A1`, + { headers: { Authorization: `Bearer ${authToken}` } }, + ); + + if (response.ok) { + const data = await response.json(); + return data[0]; + } + + return response.status; + }, + { + timeout: EVENT_POLLING_TIMEOUT, + }, + ); - return response.status; - }, - { - timeout: EVENT_POLLING_TIMEOUT, - }, - ) - .toEqual(ReplayRecordingData); + // Check that that all expected data is present but relax the order + expect(data).toEqual(expect.arrayContaining(ReplayRecordingData)); + expect(data).toHaveLength(ReplayRecordingData.length); }); From 3752a3dd9f80d149a679475652c9554b19f2eca7 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 27 Jan 2025 12:21:48 +0100 Subject: [PATCH 2/2] avoid timeout --- .../tests/send-to-sentry.test.ts | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts b/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts index 5711b1ef7f17..dc33d271bc18 100644 --- a/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts +++ b/dev-packages/e2e-tests/test-applications/react-send-to-sentry/tests/send-to-sentry.test.ts @@ -180,26 +180,25 @@ test('Sends a Replay recording to Sentry', async ({ browser }) => { .toBe(200); // now fetch the first recording segment - const data = expect.poll( - async () => { - const response = await fetch( - `https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/replays/${replayId}/recording-segments/?cursor=100%3A0%3A1`, - { headers: { Authorization: `Bearer ${authToken}` } }, - ); - - if (response.ok) { - const data = await response.json(); - return data[0]; - } - - return response.status; - }, - { - timeout: EVENT_POLLING_TIMEOUT, - }, - ); + await expect + .poll( + async () => { + const response = await fetch( + `https://sentry.io/api/0/projects/${sentryTestOrgSlug}/${sentryTestProject}/replays/${replayId}/recording-segments/?cursor=100%3A0%3A1`, + { headers: { Authorization: `Bearer ${authToken}` } }, + ); - // Check that that all expected data is present but relax the order - expect(data).toEqual(expect.arrayContaining(ReplayRecordingData)); - expect(data).toHaveLength(ReplayRecordingData.length); + if (response.ok) { + const data = await response.json(); + return { data: data[0], length: data[0].length }; + } + + return response.status; + }, + { + timeout: EVENT_POLLING_TIMEOUT, + }, + ) + // Check that that all expected data is present but relax the order to avoid flakes + .toEqual({ data: expect.arrayContaining(ReplayRecordingData), length: ReplayRecordingData.length }); });