Skip to content

Commit e7a4b40

Browse files
committed
fix tests
1 parent 3dd0051 commit e7a4b40

File tree

4 files changed

+37
-35
lines changed

4 files changed

+37
-35
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ window.Sentry = Sentry;
55

66
Sentry.init({
77
dsn: 'https://[email protected]/1337',
8-
integrations: [Sentry.browserTracingIntegration()],
8+
integrations: [
9+
Sentry.browserTracingIntegration({
10+
// To avoid having this test run for 15s
11+
childSpanTimeout: 2000,
12+
}),
13+
],
14+
defaultIntegrations: false,
915
tracesSampleRate: 1,
1016
});
1117

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect } from '@playwright/test';
2+
import type { Event } from '@sentry/types';
3+
4+
import { sentryTest } from '../../../../utils/fixtures';
5+
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
6+
7+
// This tests asserts that the pageload span will finish itself after the child span timeout if it
8+
// has a child span without adding any additional ones or finishing any of them finishing. All of the child spans that
9+
// are still running should have the status "cancelled".
10+
sentryTest('should send a pageload span terminated via child span timeout', async ({ getLocalTestPath, page }) => {
11+
if (shouldSkipTracingTest()) {
12+
sentryTest.skip();
13+
}
14+
15+
const url = await getLocalTestPath({ testDir: __dirname });
16+
17+
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
18+
19+
expect(eventData.contexts?.trace?.op).toBe('pageload');
20+
expect(eventData.spans?.length).toBeGreaterThanOrEqual(1);
21+
const testSpan = eventData.spans?.find(span => span.description === 'pageload-child-span');
22+
expect(testSpan).toBeDefined();
23+
expect(testSpan?.status).toBe('cancelled');
24+
});

dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/pageloadWithHeartbeatTimeout/test.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/tracing-internal/test/browser/browserTracingIntegration.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,9 @@ describe('browserTracingIntegration', () => {
619619
expect(dynamicSamplingContext).toBeDefined();
620620
expect(dynamicSamplingContext).toStrictEqual({ release: '2.1.14' });
621621

622-
// Propagation context is correct
623-
expect(propagationContext.sampled).toBe(false);
624-
expect(propagationContext.traceId).toEqual('12312012123120121231201212312012');
625-
expect(propagationContext.parentSpanId).toEqual('1121201211212012');
622+
// Propagation context is reset and does not contain the meta tag data
623+
expect(propagationContext.traceId).not.toEqual('12312012123120121231201212312012');
624+
expect(propagationContext.parentSpanId).not.toEqual('1121201211212012');
626625
});
627626

628627
it('puts frozen Dynamic Sampling Context on pageload span if sentry-trace data and only 3rd party baggage is present', () => {
@@ -657,10 +656,9 @@ describe('browserTracingIntegration', () => {
657656
expect(dynamicSamplingContext).toBeDefined();
658657
expect(dynamicSamplingContext).toStrictEqual({});
659658

660-
// Propagation context is correct
661-
expect(propagationContext.sampled).toBe(false);
662-
expect(propagationContext.traceId).toEqual('12312012123120121231201212312012');
663-
expect(propagationContext.parentSpanId).toEqual('1121201211212012');
659+
// Propagation context is reset and does not contain the meta tag data
660+
expect(propagationContext.traceId).not.toEqual('12312012123120121231201212312012');
661+
expect(propagationContext.parentSpanId).not.toEqual('1121201211212012');
664662
});
665663

666664
it('ignores the meta tag data for navigation spans', () => {

0 commit comments

Comments
 (0)