Commit 469e2348 authored by Mark Florian's avatar Mark Florian

Merge branch '32041-deduplicate-state-props' into 'master'

Deduplicate state properties

See merge request gitlab-org/gitlab!26117
parents d7dbf2bf 8d76154d
......@@ -62,7 +62,14 @@ export default {
},
},
computed: {
...mapState('vulnerabilities', ['modal', 'pageInfo', 'loadingVulnerabilitiesErrorCode']),
...mapState('vulnerabilities', [
'modal',
'pageInfo',
'loadingVulnerabilitiesErrorCode',
'isCreatingIssue',
'isDismissingVulnerability',
'isCreatingMergeRequest',
]),
...mapGetters('filters', ['activeFilters']),
...mapGetters('vulnerabilities', ['loadingVulnerabilitiesFailedWithRecognizedErrorCode']),
canCreateIssue() {
......@@ -182,6 +189,9 @@ export default {
:can-create-issue="canCreateIssue"
:can-create-merge-request="canCreateMergeRequest"
:can-dismiss-vulnerability="canDismissVulnerability"
:is-creating-issue="isCreatingIssue"
:is-dismissing-vulnerability="isDismissingVulnerability"
:is-creating-merge-request="isCreatingMergeRequest"
@addDismissalComment="addDismissalComment({ vulnerability, comment: $event })"
@editVulnerabilityDismissalComment="openDismissalCommentBox()"
@showDismissalDeleteButtons="showDismissalDeleteButtons"
......
......@@ -101,7 +101,6 @@ export default {
},
[types.REQUEST_CREATE_ISSUE](state) {
state.isCreatingIssue = true;
Vue.set(state.modal, 'isCreatingNewIssue', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_CREATE_ISSUE_SUCCESS](state, payload) {
......@@ -110,12 +109,10 @@ export default {
},
[types.RECEIVE_CREATE_ISSUE_ERROR](state) {
state.isCreatingIssue = false;
Vue.set(state.modal, 'isCreatingNewIssue', false);
Vue.set(state.modal, 'error', __('There was an error creating the issue'));
},
[types.REQUEST_DISMISS_VULNERABILITY](state) {
state.isDismissingVulnerability = true;
Vue.set(state.modal, 'isDismissingVulnerability', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS](state, payload) {
......@@ -124,12 +121,10 @@ export default {
);
vulnerability.dismissal_feedback = payload.data;
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal.vulnerability, 'isDismissed', true);
},
[types.RECEIVE_DISMISS_VULNERABILITY_ERROR](state) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(
state.modal,
'error',
......@@ -167,7 +162,6 @@ export default {
},
[types.REQUEST_ADD_DISMISSAL_COMMENT](state) {
state.isDismissingVulnerability = true;
Vue.set(state.modal, 'isDismissingVulnerability', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_ADD_DISMISSAL_COMMENT_SUCCESS](state, payload) {
......@@ -177,18 +171,15 @@ export default {
if (vulnerability) {
vulnerability.dismissal_feedback = payload.data;
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal.vulnerability, 'isDismissed', true);
}
},
[types.RECEIVE_ADD_DISMISSAL_COMMENT_ERROR](state) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal, 'error', s__('Security Reports|There was an error adding the comment.'));
},
[types.REQUEST_DELETE_DISMISSAL_COMMENT](state) {
state.isDismissingVulnerability = true;
Vue.set(state.modal, 'isDismissingVulnerability', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_DELETE_DISMISSAL_COMMENT_SUCCESS](state, payload) {
......@@ -196,18 +187,15 @@ export default {
if (vulnerability) {
vulnerability.dismissal_feedback = payload.data;
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal.vulnerability, 'isDismissed', true);
}
},
[types.RECEIVE_DELETE_DISMISSAL_COMMENT_ERROR](state) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal, 'error', s__('Security Reports|There was an error deleting the comment.'));
},
[types.REQUEST_REVERT_DISMISSAL](state) {
state.isDismissingVulnerability = true;
Vue.set(state.modal, 'isDismissingVulnerability', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_REVERT_DISMISSAL_SUCCESS](state, payload) {
......@@ -216,12 +204,10 @@ export default {
);
vulnerability.dismissal_feedback = null;
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal.vulnerability, 'isDismissed', false);
},
[types.RECEIVE_REVERT_DISMISSAL_ERROR](state) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(
state.modal,
'error',
......@@ -236,7 +222,6 @@ export default {
},
[types.REQUEST_CREATE_MERGE_REQUEST](state) {
state.isCreatingMergeRequest = true;
Vue.set(state.modal, 'isCreatingMergeRequest', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_CREATE_MERGE_REQUEST_SUCCESS](state, payload) {
......@@ -245,7 +230,7 @@ export default {
},
[types.RECEIVE_CREATE_MERGE_REQUEST_ERROR](state) {
state.isCreatingIssue = false;
Vue.set(state.modal, 'isCreatingMergeRequest', false);
state.isCreatingMergeRequest = false;
Vue.set(
state.modal,
'error',
......
......@@ -21,12 +21,10 @@ export default () => ({
modal: {
vulnerability: {},
project: {},
isCreatingNewIssue: false,
isCreatingMergeRequest: false,
isDismissingVulnerability: false,
isCommentingOnDismissal: false,
isShowingDeleteButtons: false,
},
isDismissingVulnerability: false,
isDismissingVulnerabilities: false,
selectedVulnerabilities: {},
isCreatingIssue: false,
......
......@@ -47,6 +47,18 @@ export default {
required: false,
default: false,
},
isCreatingIssue: {
type: Boolean,
required: true,
},
isDismissingVulnerability: {
type: Boolean,
required: true,
},
isCreatingMergeRequest: {
type: Boolean,
required: true,
},
},
data: () => ({
localDismissalComment: '',
......@@ -251,6 +263,7 @@ export default {
v-if="modal.isCommentingOnDismissal"
:is-dismissed="vulnerability.isDismissed"
:is-editing-existing-feedback="isEditingExistingFeedback"
:is-dismissing-vulnerability="isDismissingVulnerability"
@addCommentAndDismiss="addCommentAndDismiss"
@addDismissalComment="addDismissalComment"
@cancel="$emit('closeDismissalCommentBox')"
......@@ -266,6 +279,9 @@ export default {
:can-download-patch="canDownloadPatchForThisVulnerability"
:can-dismiss-vulnerability="canDismissThisVulnerability"
:is-dismissed="vulnerability.isDismissed"
:is-creating-issue="isCreatingIssue"
:is-dismissing-vulnerability="isDismissingVulnerability"
:is-creating-merge-request="isCreatingMergeRequest"
@createMergeRequest="$emit('createMergeRequest')"
@createNewIssue="$emit('createNewIssue')"
@dismissVulnerability="$emit('dismissVulnerability')"
......
......@@ -48,6 +48,18 @@ export default {
required: false,
default: false,
},
isCreatingIssue: {
type: Boolean,
required: true,
},
isDismissingVulnerability: {
type: Boolean,
required: true,
},
isCreatingMergeRequest: {
type: Boolean,
required: true,
},
},
computed: {
actionButtons() {
......@@ -55,13 +67,13 @@ export default {
const issueButton = {
name: s__('ciReport|Create issue'),
tagline: s__('ciReport|Investigate this vulnerability by creating an issue'),
isLoading: this.modal.isCreatingNewIssue,
isLoading: this.isCreatingIssue,
action: 'createNewIssue',
};
const MRButton = {
name: s__('ciReport|Resolve with merge request'),
tagline: s__('ciReport|Automatically apply the patch in a new branch'),
isLoading: this.modal.isCreatingMergeRequest,
isLoading: this.isCreatingMergeRequest,
action: 'createMergeRequest',
};
const DownloadButton = {
......@@ -96,7 +108,7 @@ export default {
<dismiss-button
v-if="canDismissVulnerability"
:is-dismissing="modal.isDismissingVulnerability"
:is-dismissing="isDismissingVulnerability"
:is-dismissed="isDismissed"
:disabled="disabled"
@dismissVulnerability="$emit('dismissVulnerability')"
......
......@@ -134,6 +134,9 @@ export default {
'dependencyScanning',
'summaryCounts',
'modal',
'isCreatingIssue',
'isDismissingVulnerability',
'isCreatingMergeRequest',
]),
...mapGetters([
'groupedSummaryText',
......@@ -391,6 +394,9 @@ export default {
:can-create-issue="canCreateIssue"
:can-create-merge-request="canCreateMergeRequest"
:can-dismiss-vulnerability="canDismissVulnerability"
:is-creating-issue="isCreatingIssue"
:is-dismissing-vulnerability="isDismissingVulnerability"
:is-creating-merge-request="isCreatingMergeRequest"
@closeDismissalCommentBox="closeDismissalCommentBox()"
@createMergeRequest="createMergeRequest"
@createNewIssue="createNewIssue"
......
......@@ -135,52 +135,46 @@ export default {
},
[types.REQUEST_DISMISS_VULNERABILITY](state) {
Vue.set(state.modal, 'isDismissingVulnerability', true);
state.isDismissingVulnerability = true;
// reset error in case previous state was error
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS](state) {
Vue.set(state.modal, 'isDismissingVulnerability', false);
state.isDismissingVulnerability = false;
},
[types.RECEIVE_DISMISS_VULNERABILITY_ERROR](state, error) {
Vue.set(state.modal, 'error', error);
Vue.set(state.modal, 'isDismissingVulnerability', false);
state.isDismissingVulnerability = false;
},
[types.REQUEST_ADD_DISMISSAL_COMMENT](state) {
state.isDismissingVulnerability = true;
Vue.set(state.modal, 'isDismissingVulnerability', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_ADD_DISMISSAL_COMMENT_SUCCESS](state, payload) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal.vulnerability, 'isDismissed', true);
Vue.set(state.modal.vulnerability, 'dismissalFeedback', payload.data);
},
[types.RECEIVE_ADD_DISMISSAL_COMMENT_ERROR](state, error) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal, 'error', error);
},
[types.REQUEST_DELETE_DISMISSAL_COMMENT](state) {
state.isDismissingVulnerability = true;
Vue.set(state.modal, 'isDismissingVulnerability', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_DELETE_DISMISSAL_COMMENT_SUCCESS](state, payload) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal.vulnerability, 'isDismissed', true);
Vue.set(state.modal.vulnerability, 'dismissalFeedback', payload.data);
},
[types.RECEIVE_DELETE_DISMISSAL_COMMENT_ERROR](state, error) {
state.isDismissingVulnerability = false;
Vue.set(state.modal, 'isDismissingVulnerability', false);
Vue.set(state.modal, 'error', error);
},
[types.SHOW_DISMISSAL_DELETE_BUTTONS](state) {
......@@ -241,23 +235,22 @@ export default {
},
[types.REQUEST_CREATE_ISSUE](state) {
Vue.set(state.modal, 'isCreatingNewIssue', true);
state.isCreatingIssue = true;
// reset error in case previous state was error
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_CREATE_ISSUE_SUCCESS](state) {
Vue.set(state.modal, 'isCreatingNewIssue', false);
state.isCreatingIssue = false;
},
[types.RECEIVE_CREATE_ISSUE_ERROR](state, error) {
Vue.set(state.modal, 'error', error);
Vue.set(state.modal, 'isCreatingNewIssue', false);
state.isCreatingIssue = false;
},
[types.REQUEST_CREATE_MERGE_REQUEST](state) {
state.isCreatingMergeRequest = true;
Vue.set(state.modal, 'isCreatingMergeRequest', true);
Vue.set(state.modal, 'error', null);
},
[types.RECEIVE_CREATE_MERGE_REQUEST_SUCCESS](state, payload) {
......@@ -266,7 +259,6 @@ export default {
},
[types.RECEIVE_CREATE_MERGE_REQUEST_ERROR](state, error) {
state.isCreatingMergeRequest = false;
Vue.set(state.modal, 'isCreatingMergeRequest', false);
Vue.set(state.modal, 'error', error);
},
[types.OPEN_DISMISSAL_COMMENT_BOX](state) {
......
......@@ -71,10 +71,12 @@ export default () => ({
hasMergeRequest: false,
},
isCreatingNewIssue: false,
isDismissingVulnerability: false,
isShowingDeleteButtons: false,
isCommentingOnDismissal: false,
error: null,
},
isCreatingIssue: false,
isDismissingVulnerability: false,
isCreatingMergeRequest: false,
});
......@@ -8,8 +8,15 @@ import LoadingButton from '~/vue_shared/components/loading_button.vue';
describe('Security Reports modal footer', () => {
let wrapper;
const mountComponent = options => {
wrapper = mount(component, options);
const mountComponent = propsData => {
wrapper = mount(component, {
propsData: {
isCreatingIssue: false,
isDismissingVulnerability: false,
isCreatingMergeRequest: false,
...propsData,
},
});
};
describe('can only create issue', () => {
......@@ -18,7 +25,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal,
canCreateIssue: true,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('does not render dismiss button', () => {
......@@ -45,7 +52,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal,
canCreateMergeRequest: true,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('only renders the create merge request button', () => {
......@@ -68,7 +75,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal,
canDownloadPatch: true,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('renders the download patch button', () => {
......@@ -92,7 +99,7 @@ describe('Security Reports modal footer', () => {
canCreateIssue: true,
canCreateMergeRequest: true,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('renders create merge request and issue button as a split button', () => {
......@@ -112,7 +119,7 @@ describe('Security Reports modal footer', () => {
canCreateMergeRequest: true,
canDownloadPatch: true,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('renders the split button', () => {
......@@ -130,7 +137,7 @@ describe('Security Reports modal footer', () => {
modal: createState().modal,
canDismissVulnerability: true,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('should render the dismiss button', () => {
......
......@@ -7,8 +7,15 @@ import { mount, shallowMount } from '@vue/test-utils';
describe('Security Reports modal', () => {
let wrapper;
const mountComponent = (options, mountFn = shallowMount) => {
wrapper = mountFn(component, options);
const mountComponent = (propsData, mountFn = shallowMount) => {
wrapper = mountFn(component, {
propsData: {
isCreatingIssue: false,
isDismissingVulnerability: false,
isCreatingMergeRequest: false,
...propsData,
},
});
};
describe('with permissions', () => {
......@@ -24,7 +31,7 @@ describe('Security Reports modal', () => {
pipeline: { id: '123', path: '#' },
created_at: new Date().toString(),
};
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
});
it('renders dismissal author and associated pipeline', () => {
......@@ -48,7 +55,7 @@ describe('Security Reports modal', () => {
author: { username: 'jsmith', name: 'John Smith' },
pipeline: { id: '123', path: '#' },
};
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
});
it('renders dismissal author and hides associated pipeline', () => {
......@@ -64,7 +71,7 @@ describe('Security Reports modal', () => {
modal: createState().modal,
canDismissVulnerability: true,
};
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
});
it('allows the vulnerability to be dismissed', () => {
......@@ -82,7 +89,7 @@ describe('Security Reports modal', () => {
const summary = 'Upgrade to 123';
const diff = 'abc123';
propsData.modal.vulnerability.remediations = [{ summary, diff }];
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
});
it('renders create merge request and issue button as a split button', () => {
......@@ -125,7 +132,7 @@ describe('Security Reports modal', () => {
vulnerabilityFeedbackHelpPath: 'feedbacksHelpPath',
};
propsData.modal.title = 'Arbitrary file existence disclosure in Action Pack';
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
});
it('renders title', () => {
......@@ -149,7 +156,7 @@ describe('Security Reports modal', () => {
};
propsData.modal.vulnerability.remediations = [{ diff: '123' }];
propsData.modal.isResolved = true;
mountComponent({ propsData });
mountComponent(propsData);
});
it('disallows any actions in the footer', () => {
......@@ -168,7 +175,7 @@ describe('Security Reports modal', () => {
const propsData = {
modal: createState().modal,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('disallows any actions in the footer', () => {
......@@ -191,7 +198,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.issue_feedback = {
issue_url: 'http://issue.url',
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('displays a link to the issue', () => {
......@@ -209,7 +216,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.issue_feedback = {
issue_url: null,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('hides the link to the issue', () => {
......@@ -229,7 +236,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.merge_request_feedback = {
merge_request_path: 'http://mr.url',
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('displays a link to the merge request', () => {
......@@ -247,7 +254,7 @@ describe('Security Reports modal', () => {
propsData.modal.vulnerability.merge_request_feedback = {
merge_request_path: null,
};
mountComponent({ propsData });
mountComponent(propsData);
});
it('hides the link to the merge request', () => {
......@@ -263,7 +270,7 @@ describe('Security Reports modal', () => {
modal: createState().modal,
};
propsData.modal.isResolved = true;
mountComponent({ propsData });
mountComponent(propsData);
});
it('disallows any actions in the footer', () => {
......@@ -290,7 +297,7 @@ describe('Security Reports modal', () => {
file: fileValue,
operating_system: namespaceValue,
};
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
});
it('is rendered', () => {
......@@ -310,7 +317,7 @@ describe('Security Reports modal', () => {
const solution = 'Upgrade to XYZ';
propsData.modal.vulnerability.solution = solution;
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
const solutionCard = wrapper.find(SolutionCard);
......@@ -326,7 +333,7 @@ describe('Security Reports modal', () => {
const summary = 'Upgrade to 123';
const diff = 'foo';
propsData.modal.vulnerability.remediations = [{ summary, diff }];
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
const solutionCard = wrapper.find(SolutionCard);
......@@ -340,7 +347,7 @@ describe('Security Reports modal', () => {
const propsData = {
modal: createState().modal,
};
mountComponent({ propsData }, mount);
mountComponent(propsData, mount);
const solutionCard = wrapper.find(SolutionCard);
......@@ -372,7 +379,7 @@ describe('Security Reports modal', () => {
describe('with a non-dismissed vulnerability', () => {
beforeEach(() => {
mountComponent({ propsData });
mountComponent(propsData);
});
it('creates an error when an empty comment is submitted', () => {
......@@ -396,7 +403,7 @@ describe('Security Reports modal', () => {
describe('with a dismissed vulnerability', () => {
beforeEach(() => {
propsData.modal.vulnerability.dismissal_feedback = { author: {} };
mountComponent({ propsData });
mountComponent(propsData);
});
it('creates an error when an empty comment is submitted', () => {
......
......@@ -84,8 +84,7 @@ describe('security reports mutations', () => {
expect(stateCopy.modal.vulnerability.isDismissed).toEqual(false);
expect(stateCopy.modal.vulnerability.hasIssue).toEqual(false);
expect(stateCopy.modal.isCreatingNewIssue).toEqual(false);
expect(stateCopy.modal.isDismissingVulnerability).toEqual(false);
expect(stateCopy.isDismissingVulnerability).toEqual(false);
expect(stateCopy.modal.title).toEqual(null);
expect(stateCopy.modal.learnMoreUrl).toEqual(null);
......@@ -148,7 +147,7 @@ describe('security reports mutations', () => {
it('sets isDismissingVulnerability prop to true and resets error', () => {
mutations[types.REQUEST_DISMISS_VULNERABILITY](stateCopy);
expect(stateCopy.modal.isDismissingVulnerability).toEqual(true);
expect(stateCopy.isDismissingVulnerability).toEqual(true);
expect(stateCopy.modal.error).toBeNull();
});
});
......@@ -157,7 +156,7 @@ describe('security reports mutations', () => {
it('sets isDismissingVulnerability prop to false', () => {
mutations[types.RECEIVE_DISMISS_VULNERABILITY_SUCCESS](stateCopy);
expect(stateCopy.modal.isDismissingVulnerability).toEqual(false);
expect(stateCopy.isDismissingVulnerability).toEqual(false);
});
});
......@@ -165,7 +164,7 @@ describe('security reports mutations', () => {
it('sets isDismissingVulnerability prop to false and sets error', () => {
mutations[types.RECEIVE_DISMISS_VULNERABILITY_ERROR](stateCopy, 'error');
expect(stateCopy.modal.isDismissingVulnerability).toEqual(false);
expect(stateCopy.isDismissingVulnerability).toEqual(false);
expect(stateCopy.modal.error).toEqual('error');
});
});
......@@ -179,10 +178,6 @@ describe('security reports mutations', () => {
expect(stateCopy.isDismissingVulnerability).toBe(true);
});
it('should set isDismissingVulnerability in the modal data to true', () => {
expect(stateCopy.modal.isDismissingVulnerability).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(stateCopy.modal.error).toBeNull();
});
......@@ -204,11 +199,7 @@ describe('security reports mutations', () => {
expect(stateCopy.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability on the modal to false', () => {
expect(stateCopy.modal.isDismissingVulnerability).toBe(false);
});
it('shoulfd set isDissmissed on the modal vulnerability to be true', () => {
it('should set isDismissed on the modal vulnerability to be true', () => {
expect(stateCopy.modal.vulnerability.isDismissed).toBe(true);
});
});
......@@ -224,10 +215,6 @@ describe('security reports mutations', () => {
expect(stateCopy.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability in the modal data to false', () => {
expect(stateCopy.modal.isDismissingVulnerability).toBe(false);
});
it('should set the error state on the modal', () => {
expect(stateCopy.modal.error).toEqual(error);
});
......@@ -242,10 +229,6 @@ describe('security reports mutations', () => {
expect(stateCopy.isDismissingVulnerability).toBe(true);
});
it('should set isDismissingVulnerability in the modal data to true', () => {
expect(stateCopy.modal.isDismissingVulnerability).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(stateCopy.modal.error).toBeNull();
});
......@@ -267,11 +250,7 @@ describe('security reports mutations', () => {
expect(stateCopy.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability on the modal to false', () => {
expect(stateCopy.modal.isDismissingVulnerability).toBe(false);
});
it('shoulfd set isDissmissed on the modal vulnerability to be true', () => {
it('should set isDismissed on the modal vulnerability to be true', () => {
expect(stateCopy.modal.vulnerability.isDismissed).toBe(true);
});
});
......@@ -287,10 +266,6 @@ describe('security reports mutations', () => {
expect(stateCopy.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability in the modal data to false', () => {
expect(stateCopy.modal.isDismissingVulnerability).toBe(false);
});
it('should set the error state on the modal', () => {
expect(stateCopy.modal.error).toEqual(error);
});
......@@ -341,27 +316,27 @@ describe('security reports mutations', () => {
});
describe('REQUEST_CREATE_ISSUE', () => {
it('sets isCreatingNewIssue prop to true and resets error', () => {
it('sets isCreatingIssue prop to true and resets error', () => {
mutations[types.REQUEST_CREATE_ISSUE](stateCopy);
expect(stateCopy.modal.isCreatingNewIssue).toEqual(true);
expect(stateCopy.isCreatingIssue).toEqual(true);
expect(stateCopy.modal.error).toBeNull();
});
});
describe('RECEIVE_CREATE_ISSUE_SUCCESS', () => {
it('sets isCreatingNewIssue prop to false', () => {
it('sets isCreatingIssue prop to false', () => {
mutations[types.RECEIVE_CREATE_ISSUE_SUCCESS](stateCopy);
expect(stateCopy.modal.isCreatingNewIssue).toEqual(false);
expect(stateCopy.isCreatingIssue).toEqual(false);
});
});
describe('RECEIVE_CREATE_ISSUE_ERROR', () => {
it('sets isCreatingNewIssue prop to false and sets error', () => {
it('sets isCreatingIssue prop to false and sets error', () => {
mutations[types.RECEIVE_CREATE_ISSUE_ERROR](stateCopy, 'error');
expect(stateCopy.modal.isCreatingNewIssue).toEqual(false);
expect(stateCopy.isCreatingIssue).toEqual(false);
expect(stateCopy.modal.error).toEqual('error');
});
});
......@@ -370,7 +345,7 @@ describe('security reports mutations', () => {
it('sets isCreatingMergeRequest prop to true and resets error', () => {
mutations[types.REQUEST_CREATE_MERGE_REQUEST](stateCopy);
expect(stateCopy.modal.isCreatingMergeRequest).toEqual(true);
expect(stateCopy.isCreatingMergeRequest).toEqual(true);
expect(stateCopy.modal.error).toBeNull();
});
});
......@@ -388,7 +363,7 @@ describe('security reports mutations', () => {
it('sets isCreatingMergeRequest prop to false and sets error', () => {
mutations[types.RECEIVE_CREATE_MERGE_REQUEST_ERROR](stateCopy, 'error');
expect(stateCopy.modal.isCreatingMergeRequest).toEqual(false);
expect(stateCopy.isCreatingMergeRequest).toEqual(false);
expect(stateCopy.modal.error).toEqual('error');
});
});
......
......@@ -304,10 +304,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isCreatingIssue).toBe(true);
});
it('should set isCreatingNewIssue in the modal data to true', () => {
expect(state.modal.isCreatingNewIssue).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(state.modal.error).toBeNull();
});
......@@ -332,10 +328,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isCreatingIssue).toBe(false);
});
it('should set isCreatingNewIssue in the modal data to false', () => {
expect(state.modal.isCreatingNewIssue).toBe(false);
});
it('should set the error state on the modal', () => {
expect(state.modal.error).toBe('There was an error creating the issue');
});
......@@ -350,10 +342,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isCreatingMergeRequest).toBe(true);
});
it('should set isCreatingMergeRequest in the modal data to true', () => {
expect(state.modal.isCreatingMergeRequest).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(state.modal.error).toBeNull();
});
......@@ -378,10 +366,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isCreatingMergeRequest).toBe(false);
});
it('should set isCreatingMergeRequest in the modal data to false', () => {
expect(state.modal.isCreatingMergeRequest).toBe(false);
});
it('should set the error state on the modal', () => {
expect(state.modal.error).toBe('There was an error creating the merge request');
});
......@@ -396,10 +380,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(true);
});
it('should set isDismissingVulnerability in the modal data to true', () => {
expect(state.modal.isDismissingVulnerability).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(state.modal.error).toBeNull();
});
......@@ -426,11 +406,7 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability on the modal to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('shoulfd set isDissmissed on the modal vulnerability to be true', () => {
it('should set isDismissed on the modal vulnerability to be true', () => {
expect(state.modal.vulnerability.isDismissed).toBe(true);
});
});
......@@ -444,10 +420,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability in the modal data to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set the error state on the modal', () => {
expect(state.modal.error).toBe('There was an error dismissing the vulnerability.');
});
......@@ -561,10 +533,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(true);
});
it('should set isDismissingVulnerability in the modal data to true', () => {
expect(state.modal.isDismissingVulnerability).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(state.modal.error).toBeNull();
});
......@@ -591,10 +559,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability on the modal to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set isDissmissed on the modal vulnerability to be true', () => {
expect(state.modal.vulnerability.isDismissed).toBe(true);
});
......@@ -609,10 +573,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability in the modal data to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set the error state on the modal', () => {
expect(state.modal.error).toBe('There was an error deleting the comment.');
});
......@@ -647,10 +607,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(true);
});
it('should set isDismissingVulnerability in the modal data to true', () => {
expect(state.modal.isDismissingVulnerability).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(state.modal.error).toBeNull();
});
......@@ -677,10 +633,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability on the modal to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set isDissmissed on the modal vulnerability to be true', () => {
expect(state.modal.vulnerability.isDismissed).toBe(true);
});
......@@ -695,10 +647,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability in the modal data to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set the error state on the modal', () => {
expect(state.modal.error).toBe('There was an error adding the comment.');
});
......@@ -713,10 +661,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(true);
});
it('should set isDismissingVulnerability in the modal data to true', () => {
expect(state.modal.isDismissingVulnerability).toBe(true);
});
it('should nullify the error state on the modal', () => {
expect(state.modal.error).toBeNull();
});
......@@ -741,10 +685,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability on the modal to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set isDissmissed on the modal vulnerability to be false', () => {
expect(state.modal.vulnerability.isDismissed).toBe(false);
});
......@@ -759,10 +699,6 @@ describe('vulnerabilities module mutations', () => {
expect(state.isDismissingVulnerability).toBe(false);
});
it('should set isDismissingVulnerability in the modal data to false', () => {
expect(state.modal.isDismissingVulnerability).toBe(false);
});
it('should set the error state on the modal', () => {
expect(state.modal.error).toBe('There was an error reverting the dismissal.');
});
......
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