-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
30 lines (22 loc) · 1006 Bytes
/
test.ts
File metadata and controls
30 lines (22 loc) · 1006 Bytes
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
import { expect } from '@playwright/test';
import type { Event } from '@sentry/core';
import { sentryTest } from '../../../../utils/fixtures';
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers';
sentryTest('sanitizes data URLs in XHR span name and attributes', async ({ getLocalTestUrl, page }) => {
if (shouldSkipTracingTest()) {
sentryTest.skip();
}
const url = await getLocalTestUrl({ testDir: __dirname });
const eventData = await getFirstSentryEnvelopeRequest<Event>(page, url);
const requestSpans = eventData.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: 'xhr',
});
expect(span?.data?.['http.url']).toBe(sanitizedUrl);
});