Skip to content

Commit 67437ec

Browse files
committed
convert integration tests
1 parent f65f56b commit 67437ec

File tree

8 files changed

+257
-916
lines changed

8 files changed

+257
-916
lines changed
Lines changed: 56 additions & 204 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from '@playwright/test';
2-
import type { OtelLogEnvelope } from '@sentry/core';
2+
import type { LogEnvelope } from '@sentry/core';
3+
34
import { sentryTest } from '../../../../utils/fixtures';
45
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
56

@@ -12,237 +13,88 @@ sentryTest('should capture console object calls', async ({ getLocalTestUrl, page
1213

1314
const url = await getLocalTestUrl({ testDir: __dirname });
1415

15-
const event = await getFirstSentryEnvelopeRequest<OtelLogEnvelope>(page, url, properFullEnvelopeRequestParser);
16+
const event = await getFirstSentryEnvelopeRequest<LogEnvelope>(page, url, properFullEnvelopeRequestParser);
1617
const envelopeItems = event[1];
1718

1819
expect(envelopeItems[0]).toEqual([
1920
{
20-
type: 'otel_log',
21-
},
22-
{
23-
severityText: 'trace',
24-
body: { stringValue: 'console.trace 123 false' },
25-
attributes: [
26-
{
27-
key: 'sentry.origin',
28-
value: {
29-
stringValue: 'auto.console.logging',
30-
},
31-
},
32-
{
33-
key: 'sentry.sdk.name',
34-
value: {
35-
stringValue: 'sentry.javascript.browser',
36-
},
37-
},
38-
{
39-
key: 'sentry.sdk.version',
40-
value: {
41-
stringValue: expect.any(String),
42-
},
43-
},
44-
],
45-
timeUnixNano: expect.any(String),
46-
traceId: expect.any(String),
47-
severityNumber: 1,
48-
},
49-
]);
50-
51-
expect(envelopeItems[1]).toEqual([
52-
{
53-
type: 'otel_log',
21+
type: 'log',
22+
item_count: 7,
23+
content_type: 'application/vnd.sentry.items.log+json',
5424
},
5525
{
56-
severityText: 'debug',
57-
body: { stringValue: 'console.debug 123 false' },
58-
attributes: [
26+
items: [
5927
{
60-
key: 'sentry.origin',
61-
value: {
62-
stringValue: 'auto.console.logging',
28+
timestamp: expect.any(Number),
29+
level: 'trace',
30+
body: 'console.trace 123 false',
31+
attributes: {
32+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
33+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
34+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
6335
},
6436
},
6537
{
66-
key: 'sentry.sdk.name',
67-
value: {
68-
stringValue: 'sentry.javascript.browser',
38+
timestamp: expect.any(Number),
39+
level: 'debug',
40+
body: 'console.debug 123 false',
41+
attributes: {
42+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
43+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
44+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
6945
},
7046
},
7147
{
72-
key: 'sentry.sdk.version',
73-
value: {
74-
stringValue: expect.any(String),
75-
},
76-
},
77-
],
78-
timeUnixNano: expect.any(String),
79-
traceId: expect.any(String),
80-
severityNumber: 5,
81-
},
82-
]);
83-
84-
expect(envelopeItems[2]).toEqual([
85-
{
86-
type: 'otel_log',
87-
},
88-
{
89-
severityText: 'info',
90-
body: { stringValue: 'console.log 123 false' },
91-
attributes: [
92-
{
93-
key: 'sentry.origin',
94-
value: {
95-
stringValue: 'auto.console.logging',
96-
},
97-
},
98-
{
99-
key: 'sentry.sdk.name',
100-
value: {
101-
stringValue: 'sentry.javascript.browser',
102-
},
103-
},
104-
{
105-
key: 'sentry.sdk.version',
106-
value: {
107-
stringValue: expect.any(String),
108-
},
109-
},
110-
],
111-
timeUnixNano: expect.any(String),
112-
traceId: expect.any(String),
113-
severityNumber: 10,
114-
},
115-
]);
116-
117-
expect(envelopeItems[3]).toEqual([
118-
{
119-
type: 'otel_log',
120-
},
121-
{
122-
severityText: 'info',
123-
body: { stringValue: 'console.info 123 false' },
124-
attributes: [
125-
{
126-
key: 'sentry.origin',
127-
value: {
128-
stringValue: 'auto.console.logging',
48+
timestamp: expect.any(Number),
49+
level: 'info',
50+
body: 'console.log 123 false',
51+
attributes: {
52+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
53+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
54+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
12955
},
13056
},
13157
{
132-
key: 'sentry.sdk.name',
133-
value: {
134-
stringValue: 'sentry.javascript.browser',
58+
timestamp: expect.any(Number),
59+
level: 'info',
60+
body: 'console.info 123 false',
61+
attributes: {
62+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
63+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
64+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
13565
},
13666
},
13767
{
138-
key: 'sentry.sdk.version',
139-
value: {
140-
stringValue: expect.any(String),
141-
},
142-
},
143-
],
144-
timeUnixNano: expect.any(String),
145-
traceId: expect.any(String),
146-
severityNumber: 9,
147-
},
148-
]);
149-
150-
expect(envelopeItems[4]).toEqual([
151-
{
152-
type: 'otel_log',
153-
},
154-
{
155-
severityText: 'warn',
156-
body: { stringValue: 'console.warn 123 false' },
157-
attributes: [
158-
{
159-
key: 'sentry.origin',
160-
value: {
161-
stringValue: 'auto.console.logging',
162-
},
163-
},
164-
{
165-
key: 'sentry.sdk.name',
166-
value: {
167-
stringValue: 'sentry.javascript.browser',
168-
},
169-
},
170-
{
171-
key: 'sentry.sdk.version',
172-
value: {
173-
stringValue: expect.any(String),
174-
},
175-
},
176-
],
177-
timeUnixNano: expect.any(String),
178-
traceId: expect.any(String),
179-
severityNumber: 13,
180-
},
181-
]);
182-
183-
expect(envelopeItems[5]).toEqual([
184-
{
185-
type: 'otel_log',
186-
},
187-
{
188-
severityText: 'error',
189-
body: { stringValue: 'console.error 123 false' },
190-
attributes: [
191-
{
192-
key: 'sentry.origin',
193-
value: {
194-
stringValue: 'auto.console.logging',
195-
},
196-
},
197-
{
198-
key: 'sentry.sdk.name',
199-
value: {
200-
stringValue: 'sentry.javascript.browser',
201-
},
202-
},
203-
{
204-
key: 'sentry.sdk.version',
205-
value: {
206-
stringValue: expect.any(String),
207-
},
208-
},
209-
],
210-
timeUnixNano: expect.any(String),
211-
traceId: expect.any(String),
212-
severityNumber: 17,
213-
},
214-
]);
215-
216-
expect(envelopeItems[6]).toEqual([
217-
{
218-
type: 'otel_log',
219-
},
220-
{
221-
severityText: 'error',
222-
body: { stringValue: 'Assertion failed: console.assert 123 false' },
223-
attributes: [
224-
{
225-
key: 'sentry.origin',
226-
value: {
227-
stringValue: 'auto.console.logging',
68+
timestamp: expect.any(Number),
69+
level: 'warn',
70+
body: 'console.warn 123 false',
71+
attributes: {
72+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
73+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
74+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
22875
},
22976
},
23077
{
231-
key: 'sentry.sdk.name',
232-
value: {
233-
stringValue: 'sentry.javascript.browser',
78+
timestamp: expect.any(Number),
79+
level: 'error',
80+
body: 'console.error 123 false',
81+
attributes: {
82+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
83+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
84+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
23485
},
23586
},
23687
{
237-
key: 'sentry.sdk.version',
238-
value: {
239-
stringValue: expect.any(String),
88+
timestamp: expect.any(Number),
89+
level: 'error',
90+
body: 'Assertion failed: console.assert 123 false',
91+
attributes: {
92+
'sentry.origin': { value: 'auto.console.logging', type: 'string' },
93+
'sentry.sdk.name': { value: 'sentry.javascript.browser', type: 'string' },
94+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
24095
},
24196
},
24297
],
243-
timeUnixNano: expect.any(String),
244-
traceId: expect.any(String),
245-
severityNumber: 17,
24698
},
24799
]);
248100
});

0 commit comments

Comments
 (0)