Skip to content

Commit 2363bba

Browse files
committed
fix(): tests fixed
1 parent d252bce commit 2363bba

6 files changed

Lines changed: 52 additions & 111 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"@hawk.so/nodejs": "^3.1.1",
51-
"@hawk.so/types": "^0.1.32-rc.7",
51+
"@hawk.so/types": "^0.1.32-rc.9",
5252
"@types/amqplib": "^0.8.2",
5353
"@types/jest": "^29.2.3",
5454
"@types/mongodb": "^3.5.15",

workers/archiver/tests/index.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ describe('Archiver worker', () => {
102102

103103
const changedProject = await projectCollection.findOne({ _id: mockedProject._id });
104104

105+
// console.log('Changed project:', changedProject);
106+
// console.log('repetitions: ', await repetitionsCollection.find({projectId: changedProject._id}).toArray());
107+
// console.log('events: ', await eventsCollection.find({projectId: changedProject._id}).toArray());
108+
105109
let originalEventsDeletedCount = 0;
106110

107111
mockedEvents.forEach(event => {
@@ -110,6 +114,9 @@ describe('Archiver worker', () => {
110114
}
111115
});
112116

117+
// console.log('originalEventsDeletedCount:', originalEventsDeletedCount);
118+
// console.log('archiveEventsCount:', archiveEventsCount);
119+
113120
expect(changedProject.archivedEventsCount).toBe(archiveEventsCount + originalEventsDeletedCount);
114121
});
115122

workers/archiver/tests/repetitions.mock.ts

Lines changed: 33 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,203 +4,137 @@ export const mockedRepetitions = [
44
*/
55
{
66
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
7-
payload: {
8-
timestamp: 1586892935,
9-
},
7+
timestamp: 1586892935,
108
},
119
{
1210
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
13-
payload: {
14-
timestamp: 1586892954,
15-
},
11+
timestamp: 1586892954,
1612
},
1713
{
1814
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
19-
payload: {
20-
timestamp: 1586892999,
21-
},
15+
timestamp: 1586892999,
2216
},
2317
{
2418
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
25-
payload: {
26-
timestamp: 1586893592,
27-
},
19+
timestamp: 1586893592,
2820
},
2921
{
3022
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
31-
payload: {
32-
timestamp: 1586894214,
33-
},
23+
timestamp: 1586894214,
3424
},
3525
{
3626
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
37-
payload: {
38-
timestamp: 1586894521,
39-
},
27+
timestamp: 1586894521,
4028
},
4129
{
4230
groupHash: '10a964aeb1ca8daa7a041c249b1c4d9cc351afe86ee7e13c5aa441c42c3f9b12',
43-
payload: {
44-
timestamp: 1586894553,
45-
},
31+
timestamp: 1586894553,
4632
},
4733

4834
/**
4935
* Older than 30 days
5036
*/
5137
{
5238
groupHash: '14b86d7afd3a4e8faba23faeed4b2587d1404528944616a2b8dee7d8a6bd6a38',
53-
payload: {
54-
timestamp: 1584980933,
55-
},
39+
timestamp: 1584980933,
5640
},
5741
{
5842
groupHash: '14b86d7afd3a4e8faba23faeed4b2587d1404528944616a2b8dee7d8a6bd6a38',
59-
payload: {
60-
timestamp: 1584980939,
61-
},
43+
timestamp: 1584980939,
6244
},
6345
{
6446
groupHash: '14b86d7afd3a4e8faba23faeed4b2587d1404528944616a2b8dee7d8a6bd6a38',
65-
payload: {
66-
timestamp: 1584989402,
67-
},
47+
timestamp: 1584989402,
6848
},
6949
{
7050
groupHash: '14b86d7afd3a4e8faba23faeed4b2587d1404528944616a2b8dee7d8a6bd6a38',
71-
payload: {
72-
timestamp: 1584989402,
73-
},
51+
timestamp: 1584989402,
7452
},
7553
{
7654
groupHash: '14b86d7afd3a4e8faba23faeed4b2587d1404528944616a2b8dee7d8a6bd6a38',
77-
payload: {
78-
timestamp: 1584989420,
79-
},
55+
timestamp: 1584989420,
8056
},
8157
{
8258
groupHash: '5f24dd5d6be4226e846383e015fd976affcee9f02eaa1d5cafc7d48710a9dfe7',
83-
payload: {
84-
timestamp: 1584989420,
85-
},
59+
timestamp: 1584989420,
8660
},
8761
{
8862
groupHash: '3e980313a7262b728e11feff38dc090e6187b379ea9fc7861506d122d3e5ccf2',
89-
payload: {
90-
timestamp: 1584989420,
91-
},
63+
timestamp: 1584989420,
9264
},
9365
{
9466
groupHash: '3e980313a7262b728e11feff38dc090e6187b379ea9fc7861506d122d3e5ccf2',
95-
payload: {
96-
timestamp: 1584989420,
97-
},
67+
timestamp: 1584989420,
9868
},
9969
{
10070
groupHash: '3e980313a7262b728e11feff38dc090e6187b379ea9fc7861506d122d3e5ccf2',
101-
payload: {
102-
timestamp: 1584989420,
103-
},
71+
timestamp: 1584989420,
10472
},
10573
{
10674
groupHash: '5c9e6da01f91bb4b0a9d32acd862c23584a1ef037083d75f37a386a8a0275685',
107-
payload: {
108-
timestamp: 1584989420,
109-
},
75+
timestamp: 1584989420,
11076
},
11177
{
11278
groupHash: '5c9e6da01f91bb4b0a9d32acd862c23584a1ef037083d75f37a386a8a0275685',
113-
payload: {
114-
timestamp: 1584989420,
115-
},
79+
timestamp: 1584989420,
11680
},
11781
{
11882
groupHash: '5c9e6da01f91bb4b0a9d32acd862c23584a1ef037083d75f37a386a8a0275685',
119-
payload: {
120-
timestamp: 1584989420,
121-
},
83+
timestamp: 1584989420,
12284
},
12385
{
12486
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
125-
payload: {
126-
timestamp: 1584989420,
127-
},
87+
timestamp: 1584989420,
12888
},
12989
{
13090
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
131-
payload: {
132-
timestamp: 1584989420,
133-
},
91+
timestamp: 1584989420,
13492
},
13593
{
13694
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
137-
payload: {
138-
timestamp: 1584989420,
139-
},
95+
timestamp: 1584989420,
14096
},
14197
{
14298
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
143-
payload: {
144-
timestamp: 1584989420,
145-
},
99+
timestamp: 1584989420,
146100
},
147101
{
148102
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
149-
payload: {
150-
timestamp: 1584989420,
151-
},
103+
timestamp: 1584989420,
152104
},
153105
{
154106
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
155-
payload: {
156-
timestamp: 1584989420,
157-
},
107+
timestamp: 1584989420,
158108
},
159109
{
160110
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
161-
payload: {
162-
timestamp: 1584989420,
163-
},
111+
timestamp: 1584989420,
164112
},
165113
{
166114
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
167-
payload: {
168-
timestamp: 1584989420,
169-
},
115+
timestamp: 1584989420,
170116
},
171117
{
172118
groupHash: '1143a799caa8f596740ed3741d280bbf6bac614797fc4e0e3cc628f218bab8ca',
173-
payload: {
174-
timestamp: 1584989420,
175-
},
119+
timestamp: 1584989420,
176120
},
177121
{
178122
groupHash: '0e69096ae18dffb3128ccebbee103ad78ef755160ba25ae4dcbf3d1285f30590',
179-
payload: {
180-
timestamp: 1584989420,
181-
},
123+
timestamp: 1584989420,
182124
},
183125
{
184126
groupHash: 'ce59309fb0976b294fceaf0d132b0b5e05def0e70a35e7e328e35953248a2b64',
185-
payload: {
186-
timestamp: 1584989420,
187-
},
127+
timestamp: 1584989420,
188128
},
189129
{
190130
groupHash: 'ce59309fb0976b294fceaf0d132b0b5e05def0e70a35e7e328e35953248a2b64',
191-
payload: {
192-
timestamp: 1584989420,
193-
},
131+
timestamp: 1584989420,
194132
}, {
195133
groupHash: '6c59197338205460a0cb0bdfbe2c3bae6e575ab361c81b2e93bd91ce49646fde',
196-
payload: {
197-
timestamp: 1584989420,
198-
},
134+
timestamp: 1584989420,
199135
},
200136
{
201137
groupHash: '6c59197338205460a0cb0bdfbe2c3bae6e575ab361c81b2e93bd91ce49646fde',
202-
payload: {
203-
timestamp: 1584989420,
204-
},
138+
timestamp: 1584989420,
205139
},
206140
];

workers/javascript/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as pkg from '../package.json';
99
import { JavaScriptEventWorkerTask } from '../types/javascript-event-worker-task';
1010
import HawkCatcher from '@hawk.so/nodejs';
1111
import Crypto from '../../../lib/utils/crypto';
12-
import { BacktraceFrame, CatcherMessagePayload, CatcherMessageType, SourceCodeLine, SourceMapDataExtended } from '@hawk.so/types';
12+
import { BacktraceFrame, CatcherMessagePayload, CatcherMessageType, ErrorsCatcherType, SourceCodeLine, SourceMapDataExtended } from '@hawk.so/types';
1313
import { beautifyUserAgent } from './utils';
1414
import { Collection } from 'mongodb';
1515
import { parse } from '@babel/parser';
@@ -64,7 +64,7 @@ export default class JavascriptEventWorker extends EventWorker {
6464
*
6565
* @param event - event to handle
6666
*/
67-
public async handle(event: JavaScriptEventWorkerTask<'errors/javascript'>): Promise<void> {
67+
public async handle(event: JavaScriptEventWorkerTask): Promise<void> {
6868
if (event.payload.release && event.payload.backtrace) {
6969
this.logger.info('beautifyBacktrace called');
7070

@@ -84,7 +84,7 @@ export default class JavascriptEventWorker extends EventWorker {
8484
catcherType: this.type as CatcherMessageType,
8585
payload: event.payload as CatcherMessagePayload<CatcherMessageType>,
8686
timestamp: event.timestamp,
87-
} as GroupWorkerTask<CatcherMessageType>);
87+
} as GroupWorkerTask<ErrorsCatcherType>);
8888
}
8989

9090
/**
@@ -94,7 +94,7 @@ export default class JavascriptEventWorker extends EventWorker {
9494
* @param {JavaScriptEventWorkerTask} event — js error minified
9595
* @returns {BacktraceFrame[]} - parsed backtrace
9696
*/
97-
private async beautifyBacktrace(event: JavaScriptEventWorkerTask<'errors/javascript'>): Promise<BacktraceFrame[]> {
97+
private async beautifyBacktrace(event: JavaScriptEventWorkerTask): Promise<BacktraceFrame[]> {
9898
const releaseRecord: SourceMapsRecord = await this.cache.get(
9999
`releaseRecord:${event.projectId}:${event.payload.release.toString()}`,
100100
() => {

workers/sentry/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Envelope, EnvelopeItem, EventEnvelope, EventItem, parseEnvelope } from
66
import { Worker } from '../../../lib/worker';
77
import { composeAddons, composeBacktrace, composeContext, composeTitle, composeUserData } from './utils/converter';
88
import { b64decode } from './utils/base64';
9-
import { CatcherMessagePayload, ErrorsCatcherType } from '@hawk.so/types';
9+
import { CatcherMessagePayload } from '@hawk.so/types';
1010
import { TextDecoder } from 'util';
1111
import { JavaScriptEventWorkerTask } from '../../javascript/types/javascript-event-worker-task';
1212
/**
@@ -139,7 +139,7 @@ export default class SentryEventWorker extends Worker {
139139
const user = composeUserData(eventPayload);
140140
const addons = composeAddons(eventPayload);
141141

142-
const event: CatcherMessagePayload<'errors/default'> = {
142+
const event: CatcherMessagePayload<'errors/default' | 'errors/javascript'> = {
143143
title,
144144
type: eventPayload.level || 'error',
145145
catcherVersion: pkg.version,
@@ -158,7 +158,7 @@ export default class SentryEventWorker extends Worker {
158158
}
159159

160160
if (addons) {
161-
event.addons = addons;
161+
event.addons.sentry = addons;
162162
}
163163

164164
/**

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@
428428
dependencies:
429429
"@types/mongodb" "^3.5.34"
430430

431-
"@hawk.so/types@^0.1.32-rc.7":
432-
version "0.1.32-rc.7"
433-
resolved "https://registry.yarnpkg.com/@hawk.so/types/-/types-0.1.32-rc.7.tgz#a9717577f83728134cd858061eaa65e9fb86d74d"
434-
integrity sha512-D5ei6FvTxj5pkjo1xmHcPIOaJvQgXQSV++BLbVucjyQM0THQEd55v0XbCSw1CHz+v2O4gnpBZBDSQIamA5ZDuQ==
431+
"@hawk.so/types@^0.1.32-rc.9":
432+
version "0.1.32-rc.9"
433+
resolved "https://registry.yarnpkg.com/@hawk.so/types/-/types-0.1.32-rc.9.tgz#794eba6db2639a99b343a93c7fdd55360cc28b5a"
434+
integrity sha512-wecSdMwQ0xPrNrbtu+oKdIcfhbSwn3USwczT2hsGz3XFceujmKB+UNRweALDkdsAkwozIzOM6lZV2k8SlwT2Qw==
435435
dependencies:
436436
"@types/mongodb" "^3.5.34"
437437

0 commit comments

Comments
 (0)