diff options
Diffstat (limited to 'spec/frontend/integrations/edit/components/trigger_fields_spec.js')
-rw-r--r-- | spec/frontend/integrations/edit/components/trigger_fields_spec.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/frontend/integrations/edit/components/trigger_fields_spec.js b/spec/frontend/integrations/edit/components/trigger_fields_spec.js index c329ca8522f..082eeea30f1 100644 --- a/spec/frontend/integrations/edit/components/trigger_fields_spec.js +++ b/spec/frontend/integrations/edit/components/trigger_fields_spec.js @@ -1,5 +1,6 @@ import { GlFormGroup, GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { mountExtended } from 'helpers/vue_test_utils_helper'; +import { placeholderForType } from 'jh_else_ce/integrations/constants'; import TriggerFields from '~/integrations/edit/components/trigger_fields.vue'; @@ -28,6 +29,50 @@ describe('TriggerFields', () => { const findAllGlFormCheckboxes = () => wrapper.findAllComponents(GlFormCheckbox); const findAllGlFormInputs = () => wrapper.findAllComponents(GlFormInput); + describe('placeholder text on the event fields and default values', () => { + const dummyFieldPlaceholder = '#foo'; + const integrationTypes = { + INTEGRATION_TYPE_SLACK: 'slack', + INTEGRATION_TYPE_SLACK_APPLICATION: 'gitlab_slack_application', + INTEGRATION_TYPE_MATTERMOST: 'mattermost', + INTEGRATION_TYPE_NON_EXISTING: 'non_existing', + }; + it.each` + integrationType | fieldPlaceholder | expectedPlaceholder + ${integrationTypes.INTEGRATION_TYPE_SLACK} | ${undefined} | ${placeholderForType[integrationTypes.INTEGRATION_TYPE_SLACK]} + ${integrationTypes.INTEGRATION_TYPE_SLACK} | ${''} | ${placeholderForType[integrationTypes.INTEGRATION_TYPE_SLACK]} + ${integrationTypes.INTEGRATION_TYPE_SLACK} | ${dummyFieldPlaceholder} | ${dummyFieldPlaceholder} + ${integrationTypes.INTEGRATION_TYPE_SLACK_APPLICATION} | ${undefined} | ${placeholderForType[integrationTypes.INTEGRATION_TYPE_SLACK_APPLICATION]} + ${integrationTypes.INTEGRATION_TYPE_SLACK_APPLICATION} | ${''} | ${placeholderForType[integrationTypes.INTEGRATION_TYPE_SLACK_APPLICATION]} + ${integrationTypes.INTEGRATION_TYPE_SLACK_APPLICATION} | ${dummyFieldPlaceholder} | ${dummyFieldPlaceholder} + ${integrationTypes.INTEGRATION_TYPE_MATTERMOST} | ${undefined} | ${placeholderForType[integrationTypes.INTEGRATION_TYPE_MATTERMOST]} + ${integrationTypes.INTEGRATION_TYPE_MATTERMOST} | ${''} | ${placeholderForType[integrationTypes.INTEGRATION_TYPE_MATTERMOST]} + ${integrationTypes.INTEGRATION_TYPE_MATTERMOST} | ${dummyFieldPlaceholder} | ${dummyFieldPlaceholder} + ${integrationTypes.INTEGRATION_TYPE_NON_EXISTING} | ${undefined} | ${undefined} + ${integrationTypes.INTEGRATION_TYPE_NON_EXISTING} | ${''} | ${undefined} + ${integrationTypes.INTEGRATION_TYPE_NON_EXISTING} | ${dummyFieldPlaceholder} | ${dummyFieldPlaceholder} + `( + 'passed down correct placeholder for "$integrationType" type and "$fieldPlaceholder" placeholder on the field', + ({ integrationType, fieldPlaceholder, expectedPlaceholder }) => { + createComponent({ + type: integrationType, + events: [ + { + field: { + name: 'foo', + value: '', + placeholder: fieldPlaceholder, + }, + }, + ], + }); + const field = wrapper.findComponent(GlFormInput); + + expect(field.attributes('placeholder')).toBe(expectedPlaceholder); + }, + ); + }); + describe.each([true, false])('template, isInheriting = `%p`', (isInheriting) => { it('renders a label with text "Trigger"', () => { createComponent(); |