-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
55 lines (42 loc) · 1.72 KB
/
test.ts
File metadata and controls
55 lines (42 loc) · 1.72 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
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import {
envelopeRequestParser,
hidePage,
shouldSkipTracingTest,
waitForClientReportRequest,
} from '../../../../utils/helpers';
import { waitForStreamedSpans } from '../../../../utils/spanUtils';
import type { ClientReport } from '@sentry/core';
sentryTest(
'ignored child spans are dropped and their children are reparented to the grandparent',
async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const spansPromise = waitForStreamedSpans(page, spans => !!spans?.find(s => s.name === 'parent-span'));
const clientReportPromise = waitForClientReportRequest(page);
const url = await getLocalTestUrl({ testDir: __dirname });
await page.goto(url);
const spans = await spansPromise;
await hidePage(page);
const clientReport = envelopeRequestParser<ClientReport>(await clientReportPromise);
const segmentSpanId = spans.find(s => s.name === 'parent-span')?.span_id;
expect(spans.some(s => s.name === 'keep-me')).toBe(true);
expect(spans.some(s => s.name === 'another-keeper')).toBe(true);
expect(spans.some(s => s.name?.includes('ignore'))).toBe(false);
const grandchild1 = spans.find(s => s.name === 'grandchild-1');
const grandchild2 = spans.find(s => s.name === 'grandchild-2');
expect(grandchild1).toBeDefined();
expect(grandchild2).toBeDefined();
expect(grandchild1?.parent_span_id).toBe(segmentSpanId);
expect(grandchild2?.parent_span_id).toBe(segmentSpanId);
expect(clientReport.discarded_events).toEqual([
{
category: 'span',
quantity: 1,
reason: 'ignored',
},
]);
},
);