Commit cd341b33 authored by Kev's avatar Kev

Update header_spec and header.vue

parent d17168fa
...@@ -136,7 +136,7 @@ export default { ...@@ -136,7 +136,7 @@ export default {
}) })
.finally(() => { .finally(() => {
this.isLoadingVulnerability = false; this.isLoadingVulnerability = false;
this.$emit('vulnerability-state-change'); this.$emit('vulnerability-state-change', newState);
}); });
}, },
createMergeRequest() { createMergeRequest() {
...@@ -209,6 +209,15 @@ export default { ...@@ -209,6 +209,15 @@ export default {
}); });
}, },
}, },
created() {
this.$on('vulnerability-state-change', newState => {
// Indicates that the event emitter does not know the new state
if (!newState) {
this.refreshVulnerability();
}
});
},
}; };
</script> </script>
......
...@@ -9,7 +9,6 @@ import StatusDescription from 'ee/vulnerabilities/components/status_description. ...@@ -9,7 +9,6 @@ import StatusDescription from 'ee/vulnerabilities/components/status_description.
import ResolutionAlert from 'ee/vulnerabilities/components/resolution_alert.vue'; import ResolutionAlert from 'ee/vulnerabilities/components/resolution_alert.vue';
import SplitButton from 'ee/vue_shared/security_reports/components/split_button.vue'; import SplitButton from 'ee/vue_shared/security_reports/components/split_button.vue';
import VulnerabilityStateDropdown from 'ee/vulnerabilities/components/vulnerability_state_dropdown.vue'; import VulnerabilityStateDropdown from 'ee/vulnerabilities/components/vulnerability_state_dropdown.vue';
import VulnerabilitiesEventBus from 'ee/vulnerabilities/components/vulnerabilities_event_bus';
import { FEEDBACK_TYPES, VULNERABILITY_STATE_OBJECTS } from 'ee/vulnerabilities/constants'; import { FEEDBACK_TYPES, VULNERABILITY_STATE_OBJECTS } from 'ee/vulnerabilities/constants';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import { deprecatedCreateFlash as createFlash } from '~/flash';
import * as urlUtility from '~/lib/utils/url_utility'; import * as urlUtility from '~/lib/utils/url_utility';
...@@ -139,7 +138,19 @@ describe('Vulnerability Header', () => { ...@@ -139,7 +138,19 @@ describe('Vulnerability Header', () => {
const dropdown = wrapper.find(VulnerabilityStateDropdown); const dropdown = wrapper.find(VulnerabilityStateDropdown);
mockAxios.onPost().reply(400); mockAxios.onPost().reply(400);
dropdown.vm.$emit('change'); dropdown.vm.$emit('change', 'dismissed');
return waitForPromises().then(() => {
expect(mockAxios.history.post).toHaveLength(1);
expect(createFlash).toHaveBeenCalledTimes(1);
});
});
it('when the vulnerability state changes but the change is undefined, an error message is displayed', () => {
const dropdown = wrapper.find(VulnerabilityStateDropdown);
mockAxios.onPost().reply(200);
dropdown.vm.$emit('change', undefined);
return waitForPromises().then(() => { return waitForPromises().then(() => {
expect(mockAxios.history.post).toHaveLength(1); expect(mockAxios.history.post).toHaveLength(1);
......
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