Commit 1b0e7896 authored by Savas Vedova's avatar Savas Vedova

Do not close modal when there are error messages

- Add changelog
- Update tests
parent 9e60cb39
...@@ -26,7 +26,9 @@ export const vulnerabilityModalMixin = (storeModule) => { ...@@ -26,7 +26,9 @@ export const vulnerabilityModalMixin = (storeModule) => {
return this.revertDismissVulnerability(payload).then(this.hideModal); return this.revertDismissVulnerability(payload).then(this.hideModal);
}, },
hideModal() { hideModal() {
this.$root.$emit(BV_HIDE_MODAL, VULNERABILITY_MODAL_ID); if (!this.modal.error) {
this.$root.$emit(BV_HIDE_MODAL, VULNERABILITY_MODAL_ID);
}
}, },
}, },
}; };
......
---
title: Do not close modal when there are error messages
merge_request: 56893
author:
type: fixed
...@@ -8,11 +8,12 @@ import LoadingError from 'ee/security_dashboard/components/loading_error.vue'; ...@@ -8,11 +8,12 @@ import LoadingError from 'ee/security_dashboard/components/loading_error.vue';
import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue'; import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue';
import SecurityDashboardTable from 'ee/security_dashboard/components/security_dashboard_table.vue'; import SecurityDashboardTable from 'ee/security_dashboard/components/security_dashboard_table.vue';
import SecurityDashboard from 'ee/security_dashboard/components/security_dashboard_vuex.vue'; import SecurityDashboard from 'ee/security_dashboard/components/security_dashboard_vuex.vue';
import { getStoreConfig } from 'ee/security_dashboard/store'; import { getStoreConfig } from 'ee/security_dashboard/store';
import { VULNERABILITY_MODAL_ID } from 'ee/vue_shared/security_reports/components/constants';
import IssueModal from 'ee/vue_shared/security_reports/components/modal.vue'; import IssueModal from 'ee/vue_shared/security_reports/components/modal.vue';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { BV_HIDE_MODAL } from '~/lib/utils/constants';
const pipelineId = 123; const pipelineId = 123;
const vulnerabilitiesEndpoint = `${TEST_HOST}/vulnerabilities`; const vulnerabilitiesEndpoint = `${TEST_HOST}/vulnerabilities`;
...@@ -21,6 +22,8 @@ jest.mock('~/lib/utils/url_utility', () => ({ ...@@ -21,6 +22,8 @@ jest.mock('~/lib/utils/url_utility', () => ({
getParameterValues: jest.fn().mockReturnValue([]), getParameterValues: jest.fn().mockReturnValue([]),
})); }));
jest.mock('~/flash');
describe('Security Dashboard component', () => { describe('Security Dashboard component', () => {
let wrapper; let wrapper;
let mock; let mock;
...@@ -28,7 +31,7 @@ describe('Security Dashboard component', () => { ...@@ -28,7 +31,7 @@ describe('Security Dashboard component', () => {
let fetchPipelineJobsSpy; let fetchPipelineJobsSpy;
let store; let store;
const createComponent = (props) => { const createComponent = ({ props } = {}) => {
setPipelineIdSpy = jest.fn(); setPipelineIdSpy = jest.fn();
fetchPipelineJobsSpy = jest.fn(); fetchPipelineJobsSpy = jest.fn();
...@@ -119,6 +122,12 @@ describe('Security Dashboard component', () => { ...@@ -119,6 +122,12 @@ describe('Security Dashboard component', () => {
); );
}, },
); );
it('emits a hide modal event when modal does not have an error and hideModal is called', async () => {
const rootEmit = jest.spyOn(wrapper.vm.$root, '$emit');
wrapper.vm.hideModal();
expect(rootEmit).toHaveBeenCalledWith(BV_HIDE_MODAL, VULNERABILITY_MODAL_ID);
});
}); });
describe('issue modal', () => { describe('issue modal', () => {
...@@ -146,6 +155,15 @@ describe('Security Dashboard component', () => { ...@@ -146,6 +155,15 @@ describe('Security Dashboard component', () => {
describe('on error', () => { describe('on error', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
store.dispatch('vulnerabilities/receiveDismissVulnerabilityError', {
flashError: 'Something went wrong',
});
});
it('does not emit a hide modal event when modal has error', () => {
const rootEmit = jest.spyOn(wrapper.vm.$root, '$emit');
wrapper.vm.hideModal();
expect(rootEmit).not.toHaveBeenCalled();
}); });
it.each([401, 403])('displays an error on error %s', async (errorCode) => { it.each([401, 403])('displays an error on error %s', async (errorCode) => {
......
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