-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
42 lines (35 loc) · 1.66 KB
/
test.ts
File metadata and controls
42 lines (35 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { expect } from '@playwright/test';
import { SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from '@sentry/core';
import { sentryTest } from '../../../../../utils/fixtures';
import { envelopeRequestParser, shouldSkipTracingTest, waitForTransactionRequest } from '../../../../../utils/helpers';
sentryTest('includes a span link to a previously negatively sampled span', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
await sentryTest.step('Initial pageload', async () => {
// No event to check for an event here because this pageload span is sampled negatively!
await page.goto(url);
});
await sentryTest.step('Navigation', async () => {
const navigationRequestPromise = waitForTransactionRequest(page, evt => evt.contexts?.trace?.op === 'navigation');
await page.goto(`${url}#foo`);
const navigationEvent = envelopeRequestParser(await navigationRequestPromise);
const navigationTraceContext = navigationEvent.contexts?.trace;
expect(navigationTraceContext?.op).toBe('navigation');
expect(navigationTraceContext?.links).toEqual([
{
trace_id: expect.stringMatching(/[a-f\d]{32}/),
span_id: expect.stringMatching(/[a-f\d]{16}/),
sampled: false,
attributes: {
[SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace',
},
},
]);
expect(navigationTraceContext?.data).toMatchObject({
'sentry.previous_trace': expect.stringMatching(/[a-f\d]{32}-[a-f\d]{16}-0/),
});
expect(navigationTraceContext?.trace_id).not.toEqual(navigationTraceContext?.links![0].trace_id);
});
});