diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/frontend/projects/new/components/deployment_target_select_spec.js | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/frontend/projects/new/components/deployment_target_select_spec.js')
-rw-r--r-- | spec/frontend/projects/new/components/deployment_target_select_spec.js | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/frontend/projects/new/components/deployment_target_select_spec.js b/spec/frontend/projects/new/components/deployment_target_select_spec.js index 8fe4c5f1230..1c443879dc3 100644 --- a/spec/frontend/projects/new/components/deployment_target_select_spec.js +++ b/spec/frontend/projects/new/components/deployment_target_select_spec.js @@ -1,4 +1,5 @@ -import { GlFormGroup, GlFormSelect } from '@gitlab/ui'; +import { GlFormGroup, GlFormSelect, GlFormText, GlLink, GlSprintf } from '@gitlab/ui'; +import { nextTick } from 'vue'; import { shallowMount } from '@vue/test-utils'; import { mockTracking } from 'helpers/tracking_helper'; import DeploymentTargetSelect from '~/projects/new/components/deployment_target_select.vue'; @@ -6,7 +7,9 @@ import { DEPLOYMENT_TARGET_SELECTIONS, DEPLOYMENT_TARGET_LABEL, DEPLOYMENT_TARGET_EVENT, + VISIT_DOCS_EVENT, NEW_PROJECT_FORM, + K8S_OPTION, } from '~/projects/new/constants'; describe('Deployment target select', () => { @@ -15,11 +18,15 @@ describe('Deployment target select', () => { const findFormGroup = () => wrapper.findComponent(GlFormGroup); const findSelect = () => wrapper.findComponent(GlFormSelect); + const findText = () => wrapper.findComponent(GlFormText); + const findLink = () => wrapper.findComponent(GlLink); const createdWrapper = () => { wrapper = shallowMount(DeploymentTargetSelect, { stubs: { GlFormSelect, + GlFormText, + GlSprintf, }, }); }; @@ -79,4 +86,34 @@ describe('Deployment target select', () => { }); } }); + + describe.each` + selectedTarget | isTextShown + ${null} | ${false} + ${DEPLOYMENT_TARGET_SELECTIONS[0]} | ${true} + ${DEPLOYMENT_TARGET_SELECTIONS[1]} | ${false} + `('K8s education text', ({ selectedTarget, isTextShown }) => { + beforeEach(() => { + findSelect().vm.$emit('input', selectedTarget); + }); + + it(`is ${!isTextShown ? 'not ' : ''}shown when selected option is ${selectedTarget}`, () => { + expect(findText().exists()).toBe(isTextShown); + }); + }); + + describe('when user clicks on the docs link', () => { + beforeEach(async () => { + findSelect().vm.$emit('input', K8S_OPTION); + await nextTick(); + + findLink().trigger('click'); + }); + + it('sends the snowplow tracking event', () => { + expect(trackingSpy).toHaveBeenCalledWith('_category_', VISIT_DOCS_EVENT, { + label: DEPLOYMENT_TARGET_LABEL, + }); + }); + }); }); |