-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
35 lines (26 loc) · 1.02 KB
/
test.ts
File metadata and controls
35 lines (26 loc) · 1.02 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
import { expect } from '@playwright/test';
import { sentryTest } from '../../../../utils/fixtures';
import {
envelopeRequestParser,
shouldSkipTracingTest,
waitForTransactionRequestOnUrl,
} from '../../../../utils/helpers';
sentryTest('sanitizes data URLs in fetch span name and attributes', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
const req = await waitForTransactionRequestOnUrl(page, url);
const transactionEvent = envelopeRequestParser(req);
const requestSpans = transactionEvent.spans?.filter(({ op }) => op === 'http.client');
expect(requestSpans).toHaveLength(1);
const span = requestSpans?.[0];
const sanitizedUrl = 'data:text/plain,base64,SGVsbG8gV2... [truncated]';
expect(span?.description).toBe(`GET ${sanitizedUrl}`);
expect(span?.data).toMatchObject({
'http.method': 'GET',
url: sanitizedUrl,
type: 'fetch',
});
expect(span?.data?.['http.url']).toBe(sanitizedUrl);
});