Commit 0d0c8aa3 authored by Savas Vedova's avatar Savas Vedova

Fix create issue error by providing the missing param

parent fd13f8ad
...@@ -121,6 +121,7 @@ export const createIssue = ({ dispatch }, { vulnerability, flashError }) => { ...@@ -121,6 +121,7 @@ export const createIssue = ({ dispatch }, { vulnerability, flashError }) => {
vulnerability_feedback: { vulnerability_feedback: {
feedback_type: 'issue', feedback_type: 'issue',
category: vulnerability.report_type, category: vulnerability.report_type,
project_fingerprint: vulnerability.project_fingerprint,
vulnerability_data: { vulnerability_data: {
...vulnerability, ...vulnerability,
category: vulnerability.report_type, category: vulnerability.report_type,
......
import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
import createState from 'ee/security_dashboard/store/modules/unscanned_projects/state';
import * as actions from 'ee/security_dashboard/store/modules/vulnerabilities/actions';
import axios from '~/lib/utils/axios_utils';
describe('EE Vulnerabilities actions', () => {
const mockEndpoint = 'mock-list-endpoint';
const mockResponse = [{ key_foo: 'valueFoo' }];
let mockAxios;
let state;
let vulnerability;
beforeEach(() => {
mockAxios = new MockAdapter(axios);
state = createState();
vulnerability = {
create_vulnerability_feedback_issue_path: mockEndpoint,
report_type: 'issue',
project_fingerprint: 'some-fingerprint',
};
});
afterEach(() => {
mockAxios.restore();
});
describe('createIssue', () => {
it('calls the createIssue endpoint and receives a success response', done => {
mockAxios.onPost(mockEndpoint).replyOnce(200, mockResponse);
const spy = jest.spyOn(axios, 'post');
return testAction(
actions.createIssue,
{
vulnerability,
},
state,
[],
[
{ type: 'requestCreateIssue' },
{ type: 'receiveCreateIssueSuccess', payload: mockResponse },
],
() => {
expect(spy).toHaveBeenCalledWith(mockEndpoint, {
vulnerability_feedback: {
category: 'issue',
feedback_type: 'issue',
project_fingerprint: 'some-fingerprint',
vulnerability_data: {
category: 'issue',
create_vulnerability_feedback_issue_path: mockEndpoint,
project_fingerprint: 'some-fingerprint',
report_type: 'issue',
},
},
});
done();
},
);
});
it('handles an API error by dispatching "receiveCreateIssueError"', done => {
mockAxios.onPost(mockEndpoint).replyOnce(500);
return testAction(
actions.createIssue,
{
vulnerability,
},
state,
[],
[
{ type: 'requestCreateIssue' },
{ type: 'receiveCreateIssueError', payload: { flashError: undefined } },
],
done,
);
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment