Skip to content

Commit

Permalink
test: Fix flaky replay DSC test (#7973)
Browse files Browse the repository at this point in the history
Also one test was actually incorrect.
  • Loading branch information
mydea committed Apr 26, 2023
1 parent 5f9b9ce commit ec1a441
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ jobs:
needs: [job_get_metadata, job_build]
if: needs.job_get_metadata.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request'
runs-on: ubuntu-20.04
timeout-minutes: 15
timeout-minutes: 18
strategy:
fail-fast: false
matrix:
Expand Down
16 changes: 12 additions & 4 deletions packages/browser-integration-tests/suites/replay/dsc/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import type { EventEnvelopeHeaders } from '@sentry/types';
import { sentryTest } from '../../../utils/fixtures';
import {
envelopeHeaderRequestParser,
envelopeRequestParser,
getFirstSentryEnvelopeRequest,
shouldSkipTracingTest,
waitForTransactionRequest,
} from '../../../utils/helpers';
import { getReplaySnapshot, shouldSkipReplayTest, waitForReplayRunning } from '../../../utils/replayHelpers';

Expand All @@ -21,6 +23,8 @@ sentryTest('should add replay_id to dsc of transactions', async ({ getLocalTestP
const url = await getLocalTestPath({ testDir: __dirname });
await page.goto(url);

await waitForReplayRunning(page);

await page.evaluate(() => {
(window as unknown as TestWindow).Sentry.configureScope(scope => {
scope.setUser({ id: 'user123', segment: 'segmentB' });
Expand All @@ -30,7 +34,6 @@ sentryTest('should add replay_id to dsc of transactions', async ({ getLocalTestP

const envHeader = await getFirstSentryEnvelopeRequest<EventEnvelopeHeaders>(page, url, envelopeHeaderRequestParser);

await waitForReplayRunning(page);
const replay = await getReplaySnapshot(page);

expect(replay.session?.id).toBeDefined();
Expand Down Expand Up @@ -65,6 +68,10 @@ sentryTest(
const url = await getLocalTestPath({ testDir: __dirname });
await page.goto(url);

await waitForReplayRunning(page);

const transactionReq = waitForTransactionRequest(page);

await page.evaluate(async () => {
await (window as unknown as TestWindow).Replay.stop();

Expand All @@ -74,12 +81,13 @@ sentryTest(
});
});

const envHeader = await getFirstSentryEnvelopeRequest<EventEnvelopeHeaders>(page, url, envelopeHeaderRequestParser);
const req0 = await transactionReq;

const envHeader = envelopeRequestParser(req0, 0) as EventEnvelopeHeaders;

await waitForReplayRunning(page);
const replay = await getReplaySnapshot(page);

expect(replay.session?.id).toBeDefined();
expect(replay.session).toBeUndefined();

expect(envHeader.trace).toBeDefined();
expect(envHeader.trace).toEqual({
Expand Down

0 comments on commit ec1a441

Please sign in to comment.