diff --git a/app/assets/javascripts/integrations/edit/components/jira_issues_fields.vue b/app/assets/javascripts/integrations/edit/components/jira_issues_fields.vue index be47ea65d9df8be747da7fea123795d3ba086cab..958916fd9b0d1e769798ed98bbb113778fbe6ece 100644 --- a/app/assets/javascripts/integrations/edit/components/jira_issues_fields.vue +++ b/app/assets/javascripts/integrations/edit/components/jira_issues_fields.vue @@ -91,12 +91,11 @@ export default { }, }, i18n: { - enableCheckboxLabel: s__('JiraService|Enable Jira issues'), enableCheckboxHelp: s__( - 'JiraService|Warning: All GitLab users with access to this GitLab project can view all issues from the Jira project you select.', + 'JiraService|Warning: All users with access to this GitLab project can view all issues from the Jira project you specify.', ), projectKeyLabel: s__('JiraService|Jira project key'), - projectKeyPlaceholder: s__('JiraService|For example, AB'), + projectKeyPlaceholder: s__('JiraService|AB'), requiredFieldFeedback: __('This field is required.'), }, }; @@ -111,7 +110,7 @@ export default { :disabled="checkboxDisabled" data-testid="jira-issues-enabled-checkbox" > - {{ $options.i18n.enableCheckboxLabel }} + {{ s__('JiraService|View Jira issues') }} <template #help> {{ $options.i18n.enableCheckboxHelp }} </template> @@ -123,13 +122,19 @@ export default { v-if="multipleProjectKeys && !isIssueCreation" :label="s__('JiraService|Jira project keys')" label-for="service_project_keys" - class="gl-max-w-26" + :description=" + s__( + 'JiraService|Comma-separated list of Jira project keys. Leave blank to include all available keys.', + ) + " + data-testid="jira-project-keys" > <gl-form-input id="service_project_keys" v-model="projectKeys" name="service[project_keys]" - :placeholder="s__('JiraService|For example, AB,CD')" + width="xl" + :placeholder="s__('JiraService|AB,CD')" :readonly="isInheriting" /> </gl-form-group> @@ -140,7 +145,6 @@ export default { label-for="service_project_key" :invalid-feedback="$options.i18n.requiredFieldFeedback" :state="validProjectKey" - class="gl-max-w-26" data-testid="project-key-form-group" > <gl-form-input @@ -148,6 +152,7 @@ export default { v-model="projectKey" name="service[project_key]" data-testid="jira-project-key-field" + width="md" :placeholder="$options.i18n.projectKeyPlaceholder" :required="enableJiraIssues" :state="validProjectKey" @@ -168,29 +173,12 @@ export default { </div> <template v-if="isIssueCreation"> - <gl-form-group - :label="$options.i18n.projectKeyLabel" - label-for="service_project_key" - :invalid-feedback="$options.i18n.requiredFieldFeedback" - :state="validProjectKey" - class="gl-max-w-26" - data-testid="project-key-form-group" - > - <gl-form-input - id="service_project_key" - v-model="projectKey" - name="service[project_key]" - data-testid="jira-project-key-field" - :placeholder="$options.i18n.projectKeyPlaceholder" - :state="validProjectKey" - :readonly="isInheriting" - /> - </gl-form-group> - <jira-issue-creation-vulnerabilities :project-key="projectKey" :initial-is-enabled="initialEnableJiraVulnerabilities" + :initial-project-key="initialProjectKey" :initial-issue-type-id="initialVulnerabilitiesIssuetype" + :is-validated="isValidated" :show-full-feature="showJiraVulnerabilitiesIntegration" class="gl-mt-6" data-testid="jira-for-vulnerabilities" diff --git a/app/models/integrations/jira.rb b/app/models/integrations/jira.rb index 8e9d58ceee83784908d5b1b8ba33da72bed28972..25946174c7a53653b778bc864af8773348d7fac1 100644 --- a/app/models/integrations/jira.rb +++ b/app/models/integrations/jira.rb @@ -5,6 +5,7 @@ module Integrations class Jira < BaseIssueTracker include Gitlab::Routing include ApplicationHelper + include SafeFormatHelper include ActionView::Helpers::AssetUrlHelper include Gitlab::Utils::StrongMemoize include HasAvatar @@ -256,7 +257,7 @@ def sections # Currently, Jira issues are only configurable at the project and group levels. unless instance_level? issues_title = if Feature.enabled?(:jira_multiple_project_keys, group || project&.group) - s_('JiraService|View Jira issues (optional)') + s_('JiraService|Jira issues (optional)') else _('Issues') end @@ -271,9 +272,9 @@ def sections if Feature.enabled?(:jira_multiple_project_keys, group || project&.group) sections.push({ type: SECTION_TYPE_JIRA_ISSUE_CREATION, - title: s_('JiraService|Jira issue creation from vulnerabilities (optional)'), - description: s_('JiraService|Create a Jira issue for a vulnerability to track any action taken ' \ - 'to resolve or mitigate a vulnerability.'), + title: s_('JiraService|Jira issues for vulnerabilities (optional)'), + description: s_('JiraService|Create Jira issues from GitLab to track any action taken ' \ + 'to resolve or mitigate vulnerabilities.'), plan: 'ultimate' }) end @@ -745,24 +746,21 @@ def set_deployment_type_from_url end def jira_issues_section_description - jira_issues_link_start = format('<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe, - url: help_page_path('integration/jira/issues')) - description = format( - s_('JiraService|Work on Jira issues without leaving GitLab. Add a Jira menu to access a read-only list of ' \ - 'your Jira issues. %{jira_issues_link_start}Learn more.%{link_end}'), - jira_issues_link_start: jira_issues_link_start, - link_end: '</a>'.html_safe - ) + description = s_('JiraService|View issues from multiple Jira projects in this GitLab project. ' \ + 'Access a read-only list of your Jira issues.') if project&.issues_enabled? - gitlab_issues_link_start = format('<a href="%{url}">'.html_safe, url: edit_project_path(project, - anchor: 'js-shared-permissions')) description += '<br><br>'.html_safe - description += format( - s_("JiraService|Displaying Jira issues while leaving GitLab issues also enabled might be confusing. " \ - "Consider %{gitlab_issues_link_start}disabling GitLab issues%{link_end} if they won't otherwise be used."), - gitlab_issues_link_start: gitlab_issues_link_start, - link_end: '</a>'.html_safe + + gitlab_issues_link = ActionController::Base.helpers.link_to( + '', + edit_project_path(project, anchor: 'js-shared-permissions') + ) + tag_pair_gitlab_issues = tag_pair(gitlab_issues_link, :link_start, :link_end) + description += safe_format( + s_('JiraService|If you access Jira issues in GitLab, you might want to ' \ + '%{link_start}disable GitLab issues%{link_end}.'), + tag_pair_gitlab_issues ) end diff --git a/ee/app/assets/javascripts/integrations/edit/components/jira_issue_creation_vulnerabilities.vue b/ee/app/assets/javascripts/integrations/edit/components/jira_issue_creation_vulnerabilities.vue index cc0033407008624409ed21fe64f48154e4bc6c5a..e0c744ef5806a4fd42d6eae381ea7851c4685a4e 100644 --- a/ee/app/assets/javascripts/integrations/edit/components/jira_issue_creation_vulnerabilities.vue +++ b/ee/app/assets/javascripts/integrations/edit/components/jira_issue_creation_vulnerabilities.vue @@ -5,33 +5,38 @@ import { GlButton, GlButtonGroup, GlCollapsibleListbox, + GlFormGroup, GlFormCheckbox, + GlFormInput, GlIcon, GlTooltipDirective, } from '@gitlab/ui'; // eslint-disable-next-line no-restricted-imports import { mapGetters, mapState } from 'vuex'; import { s__ } from '~/locale'; +import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { billingPlans, billingPlanNames } from '~/integrations/constants'; import { defaultJiraIssueTypeId } from '../constants'; export const i18n = { checkbox: { - label: s__('JiraService|Enable Jira issue creation from vulnerabilities'), + label: s__('JiraService|Create Jira issues for vulnerabilities'), description: s__( - 'JiraService|Issues created from vulnerabilities in this project will be Jira issues, even if GitLab issues are enabled.', + "JiraService|Create only Jira issues for vulnerabilities in this project even if you've enabled GitLab issues.", ), }, issueTypeSelect: { - description: s__('JiraService|Create Jira issues of this type from vulnerabilities.'), + description: s__('JiraService|Create Jira issues of this type.'), defaultText: s__('JiraService|Select issue type'), }, issueTypeLabel: s__('JiraService|Jira issue type'), - fetchIssueTypesButtonLabel: s__('JiraService|Fetch issue types for this Jira project'), - fetchIssueTypesErrorMessage: s__('JiraService|An error occurred while fetching issue list'), + fetchIssueTypesButtonLabel: s__('JiraService|Fetch issue types for this project key'), + fetchIssueTypesErrorMessage: s__( + 'JiraService|An error occurred while fetching the Jira issue list', + ), projectKeyWarnings: { - missing: s__('JiraService|Project key is required to generate issue types'), - changed: s__('JiraService|Project key changed, refresh list'), + missing: s__('JiraService|Enter a Jira project key to generate issue types.'), + changed: s__('JiraService|Fetch issue types again for the new project key.'), }, }; @@ -43,12 +48,15 @@ export default { GlButton, GlButtonGroup, GlCollapsibleListbox, + GlFormGroup, GlFormCheckbox, + GlFormInput, GlIcon, }, directives: { GlTooltip: GlTooltipDirective, }, + mixins: [glFeatureFlagsMixin()], props: { showFullFeature: { type: Boolean, @@ -70,11 +78,22 @@ export default { required: false, default: false, }, + initialProjectKey: { + type: String, + required: false, + default: null, + }, + isValidated: { + type: Boolean, + required: false, + default: false, + }, }, data() { return { isLoadingErrorAlertDismissed: false, projectKeyForCurrentIssues: '', + issueCreationProjectKey: this.initialProjectKey, isJiraVulnerabilitiesEnabled: this.initialIsEnabled, selectedJiraIssueTypeId: null, }; @@ -86,6 +105,13 @@ export default { return !this.showFullFeature || this.isInheriting; }, hasProjectKeyChanged() { + if (this.multipleProjectKeys) { + return ( + this.projectKeyForCurrentIssues && + this.issueCreationProjectKey !== this.projectKeyForCurrentIssues + ); + } + return this.projectKeyForCurrentIssues && this.projectKey !== this.projectKeyForCurrentIssues; }, shouldShowLoadingErrorAlert() { @@ -98,9 +124,13 @@ export default { }, } = this; - if (!this.projectKey) { + if ( + (this.multipleProjectKeys && !this.issueCreationProjectKey) || + (!this.multipleProjectKeys && !this.projectKey) + ) { return projectKeyWarnings.missing; } + if (this.hasProjectKeyChanged) { return projectKeyWarnings.changed; } @@ -128,6 +158,16 @@ export default { this.$options.i18n.issueTypeSelect.defaultText ); }, + validProjectKey() { + return ( + !this.isJiraVulnerabilitiesEnabled || + Boolean(this.issueCreationProjectKey) || + !this.isValidated + ); + }, + multipleProjectKeys() { + return this.glFeatures.jiraMultipleProjectKeys; + }, }, watch: { jiraIssueTypes() { @@ -147,7 +187,9 @@ export default { }, handleLoadJiraIssueTypesClick() { this.requestJiraIssueTypes(); - this.projectKeyForCurrentIssues = this.projectKey; + this.projectKeyForCurrentIssues = this.multipleProjectKeys + ? this.issueCreationProjectKey + : this.projectKey; this.isLoadingErrorAlertDismissed = false; }, }, @@ -163,6 +205,7 @@ export default { > <span>{{ $options.i18n.checkbox.label }}</span ><gl-badge + v-if="!multipleProjectKeys" :href="propsSource.aboutPricingUrl" target="_blank" rel="noopener noreferrer" @@ -188,6 +231,26 @@ export default { class="gl-mt-3 gl-ml-6" data-testid="issue-type-section" > + <gl-form-group + v-if="multipleProjectKeys" + :label="s__('JiraService|Jira project key')" + label-for="service_project_key" + :invalid-feedback="__('This field is required.')" + :state="validProjectKey" + data-testid="jira-project-key" + > + <gl-form-input + id="service_project_key" + v-model="issueCreationProjectKey" + name="service[project_key]" + width="md" + :placeholder="s__('JiraService|AB')" + :required="isJiraVulnerabilitiesEnabled" + :state="validProjectKey" + :readonly="isInheriting" + /> + </gl-form-group> + <label id="issue-type-label" class="gl-mb-0">{{ $options.i18n.issueTypeLabel }}</label> <p class="gl-mb-3">{{ $options.i18n.issueTypeSelect.description }}</p> <gl-alert diff --git a/ee/spec/features/projects/integrations/user_activates_jira_spec.rb b/ee/spec/features/projects/integrations/user_activates_jira_spec.rb index e2151917d54beb1b9602e88b79458ee90053aef1..a22c643a97ff9e1745b89bc3b5a8ecdf5ac8ac34 100644 --- a/ee/spec/features/projects/integrations/user_activates_jira_spec.rb +++ b/ee/spec/features/projects/integrations/user_activates_jira_spec.rb @@ -15,14 +15,11 @@ context 'when Jira connection test succeeds' do before do stub_licensed_features(jira_issues_integration: true) - allow_next_instance_of(Integrations::Jira) do |instance| - allow(instance).to receive(:issues_enabled).and_return(true) - end visit_project_integration('Jira') fill_form - fill_in 'service_project_key', with: 'AB' - fill_in 'service_project_keys', with: 'AB,CD' + find('label', text: 'View Jira issues').click + fill_in 'Jira project keys', with: 'AB,CD' click_test_then_save_integration(expect_test_to_fail: false) end @@ -42,6 +39,7 @@ visit_project_integration('Jira') fill_form + find('label', text: 'View Jira issues').click click_save_integration end diff --git a/ee/spec/frontend/integrations/edit/components/jira_issue_creation_vulnerabilities_spec.js b/ee/spec/frontend/integrations/edit/components/jira_issue_creation_vulnerabilities_spec.js index d0f124cc62f27abedc8ee917b92789d06d70297e..1301b9be657cb3654dbede1cbc823af9f015567b 100644 --- a/ee/spec/frontend/integrations/edit/components/jira_issue_creation_vulnerabilities_spec.js +++ b/ee/spec/frontend/integrations/edit/components/jira_issue_creation_vulnerabilities_spec.js @@ -1,11 +1,10 @@ -import { GlAlert, GlBadge, GlCollapsibleListbox } from '@gitlab/ui'; +import { GlAlert, GlBadge, GlCollapsibleListbox, GlFormInput } from '@gitlab/ui'; import { within } from '@testing-library/dom'; -import { mount, shallowMount } from '@vue/test-utils'; import { nextTick } from 'vue'; +import { mountExtended, shallowMountExtended } from 'helpers/vue_test_utils_helper'; import JiraIssueCreationVulnerabilities, { i18n, } from 'ee/integrations/edit/components/jira_issue_creation_vulnerabilities.vue'; -import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { createStore } from '~/integrations/edit/store'; import { billingPlans, billingPlanNames } from '~/integrations/constants'; @@ -23,21 +22,24 @@ describe('JiraIssueCreationVulnerabilities', () => { { id: '3', name: 'epic', description: 'epic' }, ]; - const createComponent = (mountFn) => ({ isInheriting = false, props } = {}) => { + const createComponent = (mountFn) => ({ + isInheriting = false, + props = {}, + provide = {}, + } = {}) => { store = createStore({ defaultState: isInheriting ? {} : undefined, }); - return extendedWrapper( - mountFn(JiraIssueCreationVulnerabilities, { - store, - propsData: { ...defaultProps, ...props }, - }), - ); + return mountFn(JiraIssueCreationVulnerabilities, { + store, + propsData: { ...defaultProps, ...props }, + provide, + }); }; - const createShallowComponent = createComponent(shallowMount); - const createFullComponent = createComponent(mount); + const createShallowComponent = createComponent(shallowMountExtended); + const createFullComponent = createComponent(mountExtended); const withinComponent = () => within(wrapper.element); const findHiddenInput = (name) => wrapper.find(`input[name="service[${name}]"]`); @@ -46,6 +48,8 @@ describe('JiraIssueCreationVulnerabilities', () => { const findIssueTypeSection = () => wrapper.findByTestId('issue-type-section'); const findIssueTypeListbox = () => wrapper.findComponent(GlCollapsibleListbox); const findIssueTypeLabel = () => wrapper.findComponent('label'); + const findProjectKey = () => wrapper.findByTestId('jira-project-key'); + const findProjectKeyInput = () => findProjectKey().findComponent(GlFormInput); const findGlBadge = () => wrapper.findComponent(GlBadge); const findFetchIssueTypeButton = () => wrapper.findByTestId('jira-issue-types-fetch-retry-button'); @@ -268,4 +272,71 @@ describe('JiraIssueCreationVulnerabilities', () => { }); }); }); + + describe('when jira_multiple_project_keys is not enabled', () => { + beforeEach(() => { + wrapper = createShallowComponent({ + props: { + initialIsEnabled: true, + }, + }); + }); + + it('does not render "Jira project key" input', () => { + expect(findProjectKey().exists()).toBe(false); + }); + }); + + describe('when jira_multiple_project_keys is enabled', () => { + beforeEach(() => { + wrapper = createShallowComponent({ + props: { + initialIsEnabled: true, + }, + provide: { + glFeatures: { + jiraMultipleProjectKeys: true, + }, + }, + }); + }); + + it('does not render GlBadge', () => { + expect(findGlBadge().exists()).toBe(false); + }); + + it('renders "Jira project key" input', () => { + expect(findProjectKey().attributes('label')).toBe('Jira project key'); + expect(findProjectKeyInput().attributes('required')).toBe('true'); + }); + + describe('when "Jira project key" is empty', () => { + it('shows a warning message telling the user to enter a valid project key', () => { + expect(wrapper.text()).toContain('Enter a Jira project key to generate issue types.'); + }); + }); + + describe('when "Jira project key" is not empty, then is changed after fetching issue types', () => { + beforeEach(() => { + wrapper = createShallowComponent({ + props: { + initialIsEnabled: true, + initialProjectKey: 'INITIAL', + }, + provide: { + glFeatures: { + jiraMultipleProjectKeys: true, + }, + }, + }); + findFetchIssueTypeButton().vm.$emit('click'); + + findProjectKeyInput().vm.$emit('input', 'CHANGED'); + }); + + it('shows a warning message telling the user to refetch the issues list', () => { + expect(wrapper.text()).toContain('Fetch issue types again for the new project key.'); + }); + }); + }); }); diff --git a/locale/gitlab.pot b/locale/gitlab.pot index e1a369f76e765190816cddcd2143f7f922c9a5c8..14db446101c0d6d19b42736a2a9591595ef9b926 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -28830,13 +28830,19 @@ msgstr "" msgid "JiraService|%{user_link} mentioned this issue in %{entity_link} of %{project_link}%{branch}:{quote}%{entity_message}{quote}" msgstr "" +msgid "JiraService|AB" +msgstr "" + +msgid "JiraService|AB,CD" +msgstr "" + msgid "JiraService|API token for Jira Cloud or password for Jira Data Center and Jira Server" msgstr "" msgid "JiraService|API token or password" msgstr "" -msgid "JiraService|An error occurred while fetching issue list" +msgid "JiraService|An error occurred while fetching the Jira issue list" msgstr "" msgid "JiraService|Authentication type" @@ -28851,49 +28857,49 @@ msgstr "" msgid "JiraService|Basic" msgstr "" -msgid "JiraService|Create Jira issues of this type from vulnerabilities." +msgid "JiraService|Comma-separated list of Jira project keys. Leave blank to include all available keys." msgstr "" -msgid "JiraService|Create a Jira issue for a vulnerability to track any action taken to resolve or mitigate a vulnerability." +msgid "JiraService|Create Jira issues for vulnerabilities" msgstr "" -msgid "JiraService|Displaying Jira issues while leaving GitLab issues also enabled might be confusing. Consider %{gitlab_issues_link_start}disabling GitLab issues%{link_end} if they won't otherwise be used." +msgid "JiraService|Create Jira issues from GitLab to track any action taken to resolve or mitigate vulnerabilities." msgstr "" -msgid "JiraService|Email for Jira Cloud or username for Jira Data Center and Jira Server" +msgid "JiraService|Create Jira issues of this type." msgstr "" -msgid "JiraService|Email or username" +msgid "JiraService|Create only Jira issues for vulnerabilities in this project even if you've enabled GitLab issues." msgstr "" -msgid "JiraService|Enable Jira issue creation from vulnerabilities" +msgid "JiraService|Email for Jira Cloud or username for Jira Data Center and Jira Server" msgstr "" -msgid "JiraService|Enable Jira issues" +msgid "JiraService|Email or username" msgstr "" msgid "JiraService|Enable Jira transitions" msgstr "" +msgid "JiraService|Enter a Jira project key to generate issue types." +msgstr "" + msgid "JiraService|Events for %{noteable_model_name} are disabled." msgstr "" msgid "JiraService|Failed to load Jira issue. View the issue in Jira, or reload the page." msgstr "" -msgid "JiraService|Fetch issue types for this Jira project" +msgid "JiraService|Fetch issue types again for the new project key." msgstr "" -msgid "JiraService|For Jira Cloud, the authentication type must be %{basic}" +msgid "JiraService|Fetch issue types for this project key" msgstr "" -msgid "JiraService|For example, 12, 24" -msgstr "" - -msgid "JiraService|For example, AB" +msgid "JiraService|For Jira Cloud, the authentication type must be %{basic}" msgstr "" -msgid "JiraService|For example, AB,CD" +msgid "JiraService|For example, 12, 24" msgstr "" msgid "JiraService|IDs must be a list of numbers that can be split with , or ;" @@ -28902,7 +28908,7 @@ msgstr "" msgid "JiraService|If different from the Web URL" msgstr "" -msgid "JiraService|Issues created from vulnerabilities in this project will be Jira issues, even if GitLab issues are enabled." +msgid "JiraService|If you access Jira issues in GitLab, you might want to %{link_start}disable GitLab issues%{link_end}." msgstr "" msgid "JiraService|Jira API URL" @@ -28914,9 +28920,6 @@ msgstr "" msgid "JiraService|Jira comments are created when an issue is referenced in a merge request." msgstr "" -msgid "JiraService|Jira issue creation from vulnerabilities (optional)" -msgstr "" - msgid "JiraService|Jira issue prefix" msgstr "" @@ -28929,6 +28932,12 @@ msgstr "" msgid "JiraService|Jira issues" msgstr "" +msgid "JiraService|Jira issues (optional)" +msgstr "" + +msgid "JiraService|Jira issues for vulnerabilities (optional)" +msgstr "" + msgid "JiraService|Jira personal access token" msgstr "" @@ -28956,12 +28965,6 @@ msgstr "" msgid "JiraService|Open Jira" msgstr "" -msgid "JiraService|Project key changed, refresh list" -msgstr "" - -msgid "JiraService|Project key is required to generate issue types" -msgstr "" - msgid "JiraService|Recommended. Only available for Jira Data Center and Jira Server." msgstr "" @@ -28995,19 +28998,19 @@ msgstr "" msgid "JiraService|Using Jira for issue tracking?" msgstr "" -msgid "JiraService|View Jira issues (optional)" +msgid "JiraService|View Jira issues" msgstr "" -msgid "JiraService|Warning: All GitLab users with access to this GitLab project can view all issues from the Jira project you select." +msgid "JiraService|View issues from multiple Jira projects in this GitLab project. Access a read-only list of your Jira issues." msgstr "" -msgid "JiraService|Web URL" +msgid "JiraService|Warning: All users with access to this GitLab project can view all issues from the Jira project you specify." msgstr "" -msgid "JiraService|When a Jira issue is mentioned in a commit or merge request, a remote link and comment (if enabled) will be created." +msgid "JiraService|Web URL" msgstr "" -msgid "JiraService|Work on Jira issues without leaving GitLab. Add a Jira menu to access a read-only list of your Jira issues. %{jira_issues_link_start}Learn more.%{link_end}" +msgid "JiraService|When a Jira issue is mentioned in a commit or merge request, a remote link and comment (if enabled) will be created." msgstr "" msgid "JiraService|You must configure Jira before enabling this integration. %{jira_doc_link_start}Learn more.%{link_end}" diff --git a/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js b/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js index 82f70b8ede1635e3fcf969358ca1d6b9df74d530..d06a3d0a389310e2157d10be7544f2ad3973c180 100644 --- a/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js +++ b/spec/frontend/integrations/edit/components/jira_issues_fields_spec.js @@ -35,6 +35,7 @@ describe('JiraIssuesFields', () => { const findEnableCheckboxDisabled = () => findEnableCheckbox().find('[type=checkbox]').attributes('disabled'); const findProjectKey = () => wrapper.findComponent(GlFormInput); + const findProjectKeys = () => wrapper.findByTestId('jira-project-keys'); const findProjectKeyFormGroup = () => wrapper.findByTestId('project-key-form-group'); const findJiraForVulnerabilities = () => wrapper.findByTestId('jira-for-vulnerabilities'); const setEnableCheckbox = (isEnabled = true) => findEnableCheckbox().vm.$emit('input', isEnabled); @@ -107,6 +108,41 @@ describe('JiraIssuesFields', () => { }); }); + describe('when jira_multiple_project_keys is not enabled', () => { + beforeEach(() => { + createComponent({ + mountFn: shallowMountExtended, + props: { + initialEnableJiraIssues: true, + }, + }); + }); + + it('does not render "Jira project keys" input', () => { + expect(findProjectKeys().exists()).toBe(false); + }); + }); + + describe('when jira_multiple_project_keys is enabled', () => { + beforeEach(() => { + createComponent({ + mountFn: shallowMountExtended, + props: { + initialEnableJiraIssues: true, + }, + provide: { + glFeatures: { + jiraMultipleProjectKeys: true, + }, + }, + }); + }); + + it('renders "Jira project keys" input', () => { + expect(findProjectKeys().attributes('label')).toBe('Jira project keys'); + }); + }); + describe('Vulnerabilities creation', () => { beforeEach(() => { createComponent();