Commit bfba1efa authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch...

Merge branch '339173-create-jira-issue-button-does-not-show-on-pipeline-vulnerability-list-and-mr-modal-if-gitlab' into 'master'

Always show create-jira-issue button on MR-widget modal and pipeline listing when setting is enabled

See merge request gitlab-org/gitlab!68821
parents 9b52b195 e32b1107
......@@ -66,8 +66,12 @@ export default {
return Boolean(path);
},
canCreateIssue() {
const path = this.vulnerability.create_vulnerability_feedback_issue_path;
return Boolean(path) && !this.hasIssue;
const {
create_vulnerability_feedback_issue_path: createGitLabIssuePath,
create_jira_issue_url: createJiraIssueUrl,
} = this.vulnerability;
return Boolean(createGitLabIssuePath || createJiraIssueUrl) && !this.hasIssue;
},
extraIdentifierCount() {
const { identifiers } = this.vulnerability;
......
......@@ -62,7 +62,10 @@ export const coverageFuzzingStatusIcon = ({ coverageFuzzing }) =>
export const isBaseSecurityReportOutOfDate = (state) =>
state.reportTypes.some((reportType) => state[reportType].baseReportOutofDate);
export const canCreateIssue = (state) => Boolean(state.createVulnerabilityFeedbackIssuePath);
export const canCreateIssue = (state) =>
Boolean(
state.createVulnerabilityFeedbackIssuePath || state.modal?.vulnerability?.create_jira_issue_url,
);
export const canCreateMergeRequest = (state) =>
Boolean(state.createVulnerabilityFeedbackMergeRequestPath);
......
......@@ -2,6 +2,7 @@ import { GlFormCheckbox } from '@gitlab/ui';
import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import SecurityDashboardTableRow from 'ee/security_dashboard/components/pipeline/security_dashboard_table_row.vue';
import VulnerabilityActionButtons from 'ee/security_dashboard/components/pipeline/vulnerability_action_buttons.vue';
import createStore from 'ee/security_dashboard/store';
import { DASHBOARD_TYPES } from 'ee/security_dashboard/store/constants';
import { VULNERABILITY_MODAL_ID } from 'ee/vue_shared/security_reports/components/constants';
......@@ -254,4 +255,29 @@ describe('Security Dashboard Table Row', () => {
expect(findContent(2).text()).toBe(identifiers[0].name);
});
});
describe.each`
createGitLabIssuePath | createJiraIssueUrl | canCreateIssue
${''} | ${''} | ${false}
${''} | ${'http://foo.bar'} | ${true}
${'/foo/bar'} | ${''} | ${true}
${'/foo/bar'} | ${'http://foo.bar'} | ${true}
`(
'with createGitLabIssuePath set to "$createGitLabIssuePath" and createJiraIssueUrl to "$createJiraIssueUrl"',
({ createGitLabIssuePath, createJiraIssueUrl, canCreateIssue }) => {
beforeEach(() => {
const vulnerability = mockDataVulnerabilities[1];
vulnerability.create_vulnerability_feedback_issue_path = createGitLabIssuePath;
vulnerability.create_jira_issue_url = createJiraIssueUrl;
createComponent(shallowMount, { props: { vulnerability } });
});
it(`should pass "canCreateIssue" as "${canCreateIssue}" to the action-buttons component`, () => {
expect(wrapper.findComponent(VulnerabilityActionButtons).props('canCreateIssue')).toBe(
canCreateIssue,
);
});
},
);
});
......@@ -304,15 +304,25 @@ describe('Security reports getters', () => {
});
describe('canCreateIssue', () => {
it('returns false if no feedback path is defined', () => {
expect(canCreateIssue(state)).toEqual(false);
});
it('returns true if a feedback path is defined', () => {
state.createVulnerabilityFeedbackIssuePath = MOCK_PATH;
expect(canCreateIssue(state)).toEqual(true);
});
it.each`
createVulnerabilityFeedbackIssuePath | createJiraIssueUrl | expectedReturnValue
${''} | ${''} | ${false}
${'/foo/bar'} | ${''} | ${true}
${''} | ${'http://foo.bar'} | ${true}
${'/foo/bar'} | ${'http://foo.bar'} | ${true}
`(
'returns "$expectedReturnValue" with createVulnerabilityFeedbackIssuePath set to "createVulnerabilityFeedbackIssuePath" and modal.vulnerability.create_jira_issue_url to "$createJiraIssueUrl"',
({ createVulnerabilityFeedbackIssuePath, createJiraIssueUrl, expectedReturnValue }) => {
state.createVulnerabilityFeedbackIssuePath = createVulnerabilityFeedbackIssuePath;
state.modal = {
vulnerability: {
create_jira_issue_url: createJiraIssueUrl,
},
};
expect(canCreateIssue(state)).toEqual(expectedReturnValue);
},
);
});
describe('canCreateMergeRequest', () => {
......
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