Skip to content

Commit bf31b60

Browse files
committed
fix tests
1 parent 3d5d500 commit bf31b60

File tree

7 files changed

+75
-34
lines changed

7 files changed

+75
-34
lines changed

dev-packages/browser-integration-tests/suites/public-api/logger/integration/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { expect } from '@playwright/test';
22
import type { LogEnvelope } from '@sentry/core';
3-
43
import { sentryTest } from '../../../../utils/fixtures';
54
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
65

dev-packages/browser-integration-tests/suites/public-api/logger/simple/test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { expect } from '@playwright/test';
22
import type { LogEnvelope } from '@sentry/core';
3-
43
import { sentryTest } from '../../../../utils/fixtures';
54
import { getFirstSentryEnvelopeRequest, properFullEnvelopeRequestParser } from '../../../../utils/helpers';
65

dev-packages/node-integration-tests/suites/winston/test.ts

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ describe('winston integration', () => {
1515
timestamp: expect.any(Number),
1616
level: 'info',
1717
body: 'Test info message',
18+
severity_number: expect.any(Number),
19+
trace_id: expect.any(String),
1820
attributes: {
1921
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
2022
'sentry.release': { value: '1.0.0', type: 'string' },
@@ -24,16 +26,12 @@ describe('winston integration', () => {
2426
'server.address': { value: expect.any(String), type: 'string' },
2527
},
2628
},
27-
],
28-
},
29-
})
30-
.expect({
31-
log: {
32-
items: [
3329
{
3430
timestamp: expect.any(Number),
3531
level: 'error',
3632
body: 'Test error message',
33+
severity_number: expect.any(Number),
34+
trace_id: expect.any(String),
3735
attributes: {
3836
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
3937
'sentry.release': { value: '1.0.0', type: 'string' },
@@ -61,6 +59,38 @@ describe('winston integration', () => {
6159
timestamp: expect.any(Number),
6260
level: 'info',
6361
body: 'Test info message',
62+
severity_number: expect.any(Number),
63+
trace_id: expect.any(String),
64+
attributes: {
65+
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
66+
'sentry.release': { value: '1.0.0', type: 'string' },
67+
'sentry.environment': { value: 'test', type: 'string' },
68+
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
69+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
70+
'server.address': { value: expect.any(String), type: 'string' },
71+
},
72+
},
73+
{
74+
timestamp: expect.any(Number),
75+
level: 'error',
76+
body: 'Test error message',
77+
severity_number: expect.any(Number),
78+
trace_id: expect.any(String),
79+
attributes: {
80+
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
81+
'sentry.release': { value: '1.0.0', type: 'string' },
82+
'sentry.environment': { value: 'test', type: 'string' },
83+
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
84+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
85+
'server.address': { value: expect.any(String), type: 'string' },
86+
},
87+
},
88+
{
89+
timestamp: expect.any(Number),
90+
level: 'info',
91+
body: 'Test info message',
92+
severity_number: expect.any(Number),
93+
trace_id: expect.any(String),
6494
attributes: {
6595
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
6696
'sentry.release': { value: '1.0.0', type: 'string' },
@@ -70,16 +100,12 @@ describe('winston integration', () => {
70100
'server.address': { value: expect.any(String), type: 'string' },
71101
},
72102
},
73-
],
74-
},
75-
})
76-
.expect({
77-
log: {
78-
items: [
79103
{
80104
timestamp: expect.any(Number),
81105
level: 'error',
82106
body: 'Test error message',
107+
severity_number: expect.any(Number),
108+
trace_id: expect.any(String),
83109
attributes: {
84110
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
85111
'sentry.release': { value: '1.0.0', type: 'string' },
@@ -107,6 +133,8 @@ describe('winston integration', () => {
107133
timestamp: expect.any(Number),
108134
level: 'info',
109135
body: 'Test info message',
136+
severity_number: expect.any(Number),
137+
trace_id: expect.any(String),
110138
attributes: {
111139
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
112140
'sentry.release': { value: '1.0.0', type: 'string' },
@@ -116,23 +144,36 @@ describe('winston integration', () => {
116144
'server.address': { value: expect.any(String), type: 'string' },
117145
},
118146
},
119-
],
120-
},
121-
})
122-
.expect({
123-
log: {
124-
items: [
125147
{
126148
timestamp: expect.any(Number),
127149
level: 'error',
128150
body: 'Test error message',
151+
severity_number: expect.any(Number),
152+
trace_id: expect.any(String),
153+
attributes: {
154+
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
155+
'sentry.release': { value: '1.0.0', type: 'string' },
156+
'sentry.environment': { value: 'test', type: 'string' },
157+
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
158+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
159+
'server.address': { value: expect.any(String), type: 'string' },
160+
},
161+
},
162+
{
163+
timestamp: expect.any(Number),
164+
level: 'info',
165+
body: 'Test message with metadata',
166+
severity_number: expect.any(Number),
167+
trace_id: expect.any(String),
129168
attributes: {
130169
'sentry.origin': { value: 'auto.logging.winston', type: 'string' },
131170
'sentry.release': { value: '1.0.0', type: 'string' },
132171
'sentry.environment': { value: 'test', type: 'string' },
133172
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
134173
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
135174
'server.address': { value: expect.any(String), type: 'string' },
175+
foo: { value: 'bar', type: 'string' },
176+
number: { value: 42, type: 'integer' },
136177
},
137178
},
138179
],

dev-packages/node-integration-tests/utils/runner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type {
55
EnvelopeItemType,
66
Event,
77
EventEnvelope,
8-
SerializedLogContainer,
98
SerializedCheckIn,
9+
SerializedLogContainer,
1010
SerializedSession,
1111
SessionAggregates,
1212
TransactionEvent,

packages/core/src/logs/envelope.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { DsnComponents } from '../types-hoist/dsn';
2-
import type { SdkMetadata } from '../types-hoist/sdkmetadata';
3-
import type { SerializedLog } from '../types-hoist/log';
42
import type { LogContainerItem, LogEnvelope } from '../types-hoist/envelope';
3+
import type { SerializedLog } from '../types-hoist/log';
4+
import type { SdkMetadata } from '../types-hoist/sdkmetadata';
55
import { dsnToString } from '../utils-hoist/dsn';
66
import { createEnvelope } from '../utils-hoist/envelope';
77

packages/core/src/logs/exports.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { Client } from '../client';
2-
import type { SerializedLog, SerializedLogAttributeValue, Log } from '../types-hoist/log';
3-
42
import { _getTraceInfoFromScope } from '../client';
53
import { getClient, getCurrentScope } from '../currentScopes';
64
import { DEBUG_BUILD } from '../debug-build';
7-
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';
5+
import type { Log,SerializedLog, SerializedLogAttributeValue } from '../types-hoist/log';
86
import { _getSpanForScope } from '../utils/spanOnScope';
9-
import { createLogEnvelope } from './envelope';
10-
import { logger } from '../utils-hoist/logger';
117
import { isParameterizedString } from '../utils-hoist/is';
8+
import { logger } from '../utils-hoist/logger';
129
import { timestampInSeconds } from '../utils-hoist/time';
10+
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';
11+
import { createLogEnvelope } from './envelope';
1312

1413
const MAX_LOG_BUFFER_SIZE = 100;
1514

packages/core/test/lib/logs/envelope.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
1+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2+
23
import { createLogContainerEnvelopeItem, createLogEnvelope } from '../../../src/logs/envelope';
34
import type { DsnComponents } from '../../../src/types-hoist/dsn';
4-
import type { SdkMetadata } from '../../../src/types-hoist/sdkmetadata';
55
import type { SerializedLog } from '../../../src/types-hoist/log';
6+
import type { SdkMetadata } from '../../../src/types-hoist/sdkmetadata';
67
import * as utilsDsn from '../../../src/utils-hoist/dsn';
78
import * as utilsEnvelope from '../../../src/utils-hoist/envelope';
89

@@ -26,7 +27,7 @@ describe('createLogContainerEnvelopeItem', () => {
2627

2728
expect(result).toHaveLength(2);
2829
expect(result[0]).toEqual({ type: 'log', item_count: 2, content_type: 'application/vnd.sentry.items.log+json' });
29-
expect(result[1]).toBe(mockLog);
30+
expect(result[1]).toEqual({ items: [mockLog, mockLog] });
3031
});
3132
});
3233

@@ -127,12 +128,14 @@ describe('createLogEnvelope', () => {
127128

128129
createLogEnvelope(mockLogs);
129130

130-
// Check that createEnvelope was called with an array of envelope items
131+
// Check that createEnvelope was called with a single container item containing all logs
131132
expect(utilsEnvelope.createEnvelope).toHaveBeenCalledWith(
132133
expect.anything(),
133134
expect.arrayContaining([
134-
expect.arrayContaining([{ type: 'log' }, mockLogs[0]]),
135-
expect.arrayContaining([{ type: 'log' }, mockLogs[1]]),
135+
expect.arrayContaining([
136+
{ type: 'log', item_count: 2, content_type: 'application/vnd.sentry.items.log+json' },
137+
{ items: mockLogs },
138+
]),
136139
]),
137140
);
138141
});

0 commit comments

Comments
 (0)