Skip to content
代码片段 群组 项目
提交 b1ed7d14 编辑于 作者: David Pisek's avatar David Pisek
浏览文件

Merge branch '386014-handle-download-patch-logic' into 'master'

No related branches found
No related tags found
无相关合并请求
...@@ -15,6 +15,7 @@ import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants'; ...@@ -15,6 +15,7 @@ import { EXTENSION_ICONS } from '~/vue_merge_request_widget/constants';
import { capitalizeFirstCharacter, convertToCamelCase } from '~/lib/utils/text_utility'; import { capitalizeFirstCharacter, convertToCamelCase } from '~/lib/utils/text_utility';
import { helpPagePath } from '~/helpers/help_page_helper'; import { helpPagePath } from '~/helpers/help_page_helper';
import { CRITICAL, HIGH } from '~/vulnerabilities/constants'; import { CRITICAL, HIGH } from '~/vulnerabilities/constants';
import download from '~/lib/utils/downloader';
import { DynamicScroller, DynamicScrollerItem } from 'vendor/vue-virtual-scroller'; import { DynamicScroller, DynamicScrollerItem } from 'vendor/vue-virtual-scroller';
import SummaryText from './summary_text.vue'; import SummaryText from './summary_text.vue';
import SummaryHighlights from './summary_highlights.vue'; import SummaryHighlights from './summary_highlights.vue';
...@@ -479,6 +480,13 @@ export default { ...@@ -479,6 +480,13 @@ export default {
}); });
}, },
downloadPatch() {
download({
fileData: this.modalData.vulnerability.remediations[0].diff,
fileName: 'remediation.patch',
});
},
hideModal() { hideModal() {
this.$root.$emit(BV_HIDE_MODAL, VULNERABILITY_MODAL_ID); this.$root.$emit(BV_HIDE_MODAL, VULNERABILITY_MODAL_ID);
}, },
...@@ -532,6 +540,7 @@ export default { ...@@ -532,6 +540,7 @@ export default {
@openDismissalCommentBox="openDismissalCommentBox" @openDismissalCommentBox="openDismissalCommentBox"
@editVulnerabilityDismissalComment="openDismissalCommentBox" @editVulnerabilityDismissalComment="openDismissalCommentBox"
@deleteDismissalComment="deleteDismissalComment" @deleteDismissalComment="deleteDismissalComment"
@downloadPatch="downloadPatch"
@revertDismissVulnerability="revertDismissVulnerability" @revertDismissVulnerability="revertDismissVulnerability"
@createNewIssue="createNewIssue" @createNewIssue="createNewIssue"
@dismissVulnerability="dismissFinding" @dismissVulnerability="dismissFinding"
......
...@@ -9,6 +9,7 @@ import SummaryHighlights from 'ee/vue_merge_request_widget/extensions/security_r ...@@ -9,6 +9,7 @@ import SummaryHighlights from 'ee/vue_merge_request_widget/extensions/security_r
import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper';
import Widget from '~/vue_merge_request_widget/components/widget/widget.vue'; import Widget from '~/vue_merge_request_widget/components/widget/widget.vue';
import toast from '~/vue_shared/plugins/global_toast'; import toast from '~/vue_shared/plugins/global_toast';
import download from '~/lib/utils/downloader';
import MrWidgetRow from '~/vue_merge_request_widget/components/widget/widget_content_row.vue'; import MrWidgetRow from '~/vue_merge_request_widget/components/widget/widget_content_row.vue';
import * as urlUtils from '~/lib/utils/url_utility'; import * as urlUtils from '~/lib/utils/url_utility';
import { BV_HIDE_MODAL } from '~/lib/utils/constants'; import { BV_HIDE_MODAL } from '~/lib/utils/constants';
...@@ -17,6 +18,7 @@ import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status ...@@ -17,6 +18,7 @@ import { HTTP_STATUS_BAD_REQUEST, HTTP_STATUS_OK } from '~/lib/utils/http_status
jest.mock('~/vue_shared/components/user_callout_dismisser.vue', () => ({ render: () => {} })); jest.mock('~/vue_shared/components/user_callout_dismisser.vue', () => ({ render: () => {} }));
jest.mock('~/vue_shared/plugins/global_toast'); jest.mock('~/vue_shared/plugins/global_toast');
jest.mock('~/lib/utils/downloader');
describe('MR Widget Security Reports', () => { describe('MR Widget Security Reports', () => {
let wrapper; let wrapper;
...@@ -406,6 +408,21 @@ describe('MR Widget Security Reports', () => { ...@@ -406,6 +408,21 @@ describe('MR Widget Security Reports', () => {
}); });
}); });
it('downloads a patch when the downloadPatch event is emitted', async () => {
await createComponentExpandWidgetAndOpenModal({
mockDataProps: {
remediations: [{ diff: 'some-diff' }],
},
});
findModal().vm.$emit('downloadPatch');
expect(download).toHaveBeenCalledWith({
fileData: 'some-diff',
fileName: 'remediation.patch',
});
});
describe('merge request creation', () => { describe('merge request creation', () => {
it('handles merge request creation - success', async () => { it('handles merge request creation - success', async () => {
const mergeRequestPath = '/merge/request/1'; const mergeRequestPath = '/merge/request/1';
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册