diff options
Diffstat (limited to 'spec/frontend/projects/settings_service_desk/components/service_desk_setting_spec.js')
-rw-r--r-- | spec/frontend/projects/settings_service_desk/components/service_desk_setting_spec.js | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/frontend/projects/settings_service_desk/components/service_desk_setting_spec.js b/spec/frontend/projects/settings_service_desk/components/service_desk_setting_spec.js index 260fd200f03..6449f9bb68e 100644 --- a/spec/frontend/projects/settings_service_desk/components/service_desk_setting_spec.js +++ b/spec/frontend/projects/settings_service_desk/components/service_desk_setting_spec.js @@ -1,4 +1,4 @@ -import { GlButton, GlDropdown, GlLoadingIcon, GlToggle, GlAlert } from '@gitlab/ui'; +import { GlButton, GlDropdown, GlFormCheckbox, GlLoadingIcon, GlToggle, GlAlert } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import { nextTick } from 'vue'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; @@ -19,8 +19,9 @@ describe('ServiceDeskSetting', () => { const findSuffixFormGroup = () => wrapper.findByTestId('suffix-form-group'); const findIssueTrackerInfo = () => wrapper.findComponent(GlAlert); const findIssueHelpLink = () => wrapper.findByTestId('issue-help-page'); + const findAddExternalParticipantsFromCcCheckbox = () => wrapper.findComponent(GlFormCheckbox); - const createComponent = ({ props = {} } = {}) => + const createComponent = ({ props = {}, provide = {} } = {}) => extendedWrapper( mount(ServiceDeskSetting, { propsData: { @@ -28,6 +29,12 @@ describe('ServiceDeskSetting', () => { isIssueTrackerEnabled: true, ...props, }, + provide: { + glFeatures: { + issueEmailParticipants: true, + }, + ...provide, + }, }), ); @@ -205,6 +212,25 @@ describe('ServiceDeskSetting', () => { }); }); + describe('add external participants from cc checkbox', () => { + it('is rendered', () => { + wrapper = createComponent(); + expect(findAddExternalParticipantsFromCcCheckbox().exists()).toBe(true); + }); + + it('forwards the initial value to the checkbox', () => { + wrapper = createComponent({ props: { initialAddExternalParticipantsFromCc: true } }); + expect(findAddExternalParticipantsFromCcCheckbox().find('input').element.checked).toBe(true); + }); + + describe('when feature flag issue_email_participants is disabled', () => { + it('is not rendered', () => { + wrapper = createComponent({ provide: { glFeatures: { issueEmailParticipants: false } } }); + expect(findAddExternalParticipantsFromCcCheckbox().exists()).toBe(false); + }); + }); + }); + describe('save button', () => { it('renders a save button to save a template', () => { wrapper = createComponent(); @@ -223,6 +249,7 @@ describe('ServiceDeskSetting', () => { initialSelectedFileTemplateProjectId: 42, initialOutgoingName: 'GitLab Support Bot', initialProjectKey: 'key', + initialAddExternalParticipantsFromCc: false, }, }); @@ -235,6 +262,7 @@ describe('ServiceDeskSetting', () => { fileTemplateProjectId: 42, outgoingName: 'GitLab Support Bot', projectKey: 'key', + addExternalParticipantsFromCc: false, }; expect(wrapper.emitted('save')[0]).toEqual([payload]); @@ -260,6 +288,10 @@ describe('ServiceDeskSetting', () => { expect(findButton().exists()).toBe(false); }); + it('does not render add external participants from cc checkbox', () => { + expect(findAddExternalParticipantsFromCcCheckbox().exists()).toBe(false); + }); + it('emits an event to turn on Service Desk when the toggle is clicked', async () => { findToggle().vm.$emit('change', false); |