Skip to content

Commit 251b44e

Browse files
feat: add processor field to crash upload (#101)
* feat: add processor field to crash upload * chore: refactor optional processor param * chore: add tests --------- Co-authored-by: Bobby Galli <bobbyg603@gmail.com>
1 parent 03ddcda commit 251b44e

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/common/client/oauth-client-credentials-api-client/oauth-client-credentials-api-client.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { createFakeFormData } from '@spec/fakes/common/form-data';
22
import { createFakeResponseBody, FakeResponseBody } from '@spec/fakes/common/response';
3-
import { BugSplatResponse } from 'dist/esm';
4-
import { OAuthLoginResponse } from 'dist/esm/common/client/oauth-client-credentials-api-client/oauth-login-response';
53
import { OAuthClientCredentialsClient } from './oauth-client-credentials-api-client';
4+
import { BugSplatResponse } from '@common';
5+
import { OAuthLoginResponse } from './oauth-login-response';
66

77
describe('OAuthClientCredentialsClient', () => {
88
let clientId: string;

src/crash/crash-api-client/crash-api-client.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ describe('CrashApiClient', () => {
9494
let fakeReprocessApiResponse;
9595
let fakeBugSplatApiClient;
9696
let result;
97+
const processor = 'Oban-127.0.0.1';
9798

9899
beforeEach(async () => {
99100
fakeReprocessApiResponse = { success: true };
@@ -108,10 +109,17 @@ describe('CrashApiClient', () => {
108109
expect(fakeBugSplatApiClient.fetch).toHaveBeenCalledWith('/api/crash/reprocess', jasmine.anything());
109110
});
110111

112+
it('should call form data append with processor if provided', async () => {
113+
await client.reprocessCrash(database, id, true, processor);
114+
115+
expect(fakeFormData.append).toHaveBeenCalledWith('processor', processor);
116+
});
117+
111118
it('should call fetch with formData containing database, id and force', () => {
112119
expect(fakeFormData.append).toHaveBeenCalledWith('database', database);
113120
expect(fakeFormData.append).toHaveBeenCalledWith('id', id.toString());
114121
expect(fakeFormData.append).toHaveBeenCalledWith('force', 'true');
122+
expect(fakeFormData.append).not.toHaveBeenCalledWith('processor', processor);
115123
expect(fakeBugSplatApiClient.fetch).toHaveBeenCalledWith(
116124
jasmine.any(String),
117125
jasmine.objectContaining({

src/crash/crash-api-client/crash-api-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class CrashApiClient {
3636
return createCrashDetails(json as CrashDetailsRawResponse);
3737
}
3838

39-
async reprocessCrash(database: string, crashId: number, force = false): Promise<SuccessResponse> {
39+
async reprocessCrash(database: string, crashId: number, force = false, processor = ''): Promise<SuccessResponse> {
4040
ac.assertNonWhiteSpaceString(database, 'database');
4141
ac.assertBoolean(force, 'force');
4242
if (crashId <= 0) {
@@ -47,6 +47,9 @@ export class CrashApiClient {
4747
formData.append('database', database);
4848
formData.append('id', crashId.toString());
4949
formData.append('force', force.toString());
50+
if (processor) {
51+
formData.append('processor', processor);
52+
}
5053
const init = {
5154
method: 'POST',
5255
body: formData,

0 commit comments

Comments
 (0)