-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
63 lines (54 loc) · 2.12 KB
/
test.ts
File metadata and controls
63 lines (54 loc) · 2.12 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { expect } from '@playwright/test';
import { SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE } from '@sentry/core';
import { sentryTest } from '../../../../../utils/fixtures';
import { shouldSkipTracingTest } from '../../../../../utils/helpers';
import { getSpanOp, waitForStreamedSpan } from '../../../../../utils/spanUtils';
sentryTest('manually started custom traces are linked correctly in the chain', async ({ getLocalTestUrl, page }) => {
sentryTest.skip(shouldSkipTracingTest());
const url = await getLocalTestUrl({ testDir: __dirname });
const pageloadSpan = await sentryTest.step('Initial pageload', async () => {
const pageloadSpanPromise = waitForStreamedSpan(page, span => getSpanOp(span) === 'pageload');
await page.goto(url);
return pageloadSpanPromise;
});
const customTraceSpan = await sentryTest.step('Custom trace', async () => {
const customSpanPromise = waitForStreamedSpan(page, span => getSpanOp(span) === 'custom');
await page.locator('#btn1').click();
const span = await customSpanPromise;
expect(span.trace_id).not.toEqual(pageloadSpan.trace_id);
expect(span.links).toEqual([
{
trace_id: pageloadSpan.trace_id,
span_id: pageloadSpan.span_id,
sampled: true,
attributes: {
[SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: {
type: 'string',
value: 'previous_trace',
},
},
},
]);
return span;
});
await sentryTest.step('Navigation', async () => {
const navigationSpanPromise = waitForStreamedSpan(page, span => getSpanOp(span) === 'navigation');
await page.goto(`${url}#foo`);
const navSpan = await navigationSpanPromise;
expect(navSpan.trace_id).not.toEqual(customTraceSpan.trace_id);
expect(navSpan.trace_id).not.toEqual(pageloadSpan.trace_id);
expect(navSpan.links).toEqual([
{
trace_id: customTraceSpan.trace_id,
span_id: customTraceSpan.span_id,
sampled: true,
attributes: {
[SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: {
type: 'string',
value: 'previous_trace',
},
},
},
]);
});
});