From 580622bdb3c762a8e89facd8a3946881ee480442 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 31 Mar 2020 18:07:42 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../blob/pipeline_tour_success_mock_data.js | 7 +++ .../blob/pipeline_tour_success_modal_spec.js | 51 ++++++++++++++++++++++ spec/frontend/blob/pipeline_tour_success_spec.js | 40 ----------------- 3 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 spec/frontend/blob/pipeline_tour_success_mock_data.js create mode 100644 spec/frontend/blob/pipeline_tour_success_modal_spec.js delete mode 100644 spec/frontend/blob/pipeline_tour_success_spec.js (limited to 'spec/frontend/blob') diff --git a/spec/frontend/blob/pipeline_tour_success_mock_data.js b/spec/frontend/blob/pipeline_tour_success_mock_data.js new file mode 100644 index 00000000000..7819fcce85d --- /dev/null +++ b/spec/frontend/blob/pipeline_tour_success_mock_data.js @@ -0,0 +1,7 @@ +const modalProps = { + goToPipelinesPath: 'some_pipeline_path', + commitCookie: 'some_cookie', + humanAccess: 'maintainer', +}; + +export default modalProps; diff --git a/spec/frontend/blob/pipeline_tour_success_modal_spec.js b/spec/frontend/blob/pipeline_tour_success_modal_spec.js new file mode 100644 index 00000000000..613a7ce8303 --- /dev/null +++ b/spec/frontend/blob/pipeline_tour_success_modal_spec.js @@ -0,0 +1,51 @@ +import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue'; +import { shallowMount } from '@vue/test-utils'; +import Cookies from 'js-cookie'; +import { GlSprintf, GlModal } from '@gitlab/ui'; +import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; +import modalProps from './pipeline_tour_success_mock_data'; + +describe('PipelineTourSuccessModal', () => { + let wrapper; + let cookieSpy; + let trackingSpy; + + beforeEach(() => { + document.body.dataset.page = 'projects:blob:show'; + + trackingSpy = mockTracking('_category_', undefined, jest.spyOn); + wrapper = shallowMount(pipelineTourSuccess, { + propsData: modalProps, + }); + + cookieSpy = jest.spyOn(Cookies, 'remove'); + }); + + afterEach(() => { + wrapper.destroy(); + unmockTracking(); + }); + + it('has expected structure', () => { + const modal = wrapper.find(GlModal); + const sprintf = modal.find(GlSprintf); + + expect(modal.attributes('title')).toContain("That's it, well done!"); + expect(sprintf.exists()).toBe(true); + }); + + it('calls to remove cookie', () => { + wrapper.vm.disableModalFromRenderingAgain(); + + expect(cookieSpy).toHaveBeenCalledWith(modalProps.commitCookie); + }); + + describe('tracking', () => { + it('send event for basic view of popover', () => { + expect(trackingSpy).toHaveBeenCalledWith(undefined, undefined, { + label: 'congratulate_first_pipeline', + property: modalProps.humanAccess, + }); + }); + }); +}); diff --git a/spec/frontend/blob/pipeline_tour_success_spec.js b/spec/frontend/blob/pipeline_tour_success_spec.js deleted file mode 100644 index f6783b31a73..00000000000 --- a/spec/frontend/blob/pipeline_tour_success_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import pipelineTourSuccess from '~/blob/pipeline_tour_success_modal.vue'; -import { shallowMount } from '@vue/test-utils'; -import Cookies from 'js-cookie'; -import { GlSprintf, GlModal } from '@gitlab/ui'; - -describe('PipelineTourSuccessModal', () => { - let wrapper; - let cookieSpy; - const goToPipelinesPath = 'some_pipeline_path'; - const commitCookie = 'some_cookie'; - - beforeEach(() => { - wrapper = shallowMount(pipelineTourSuccess, { - propsData: { - goToPipelinesPath, - commitCookie, - }, - }); - - cookieSpy = jest.spyOn(Cookies, 'remove'); - }); - - afterEach(() => { - wrapper.destroy(); - }); - - it('has expected structure', () => { - const modal = wrapper.find(GlModal); - const sprintf = modal.find(GlSprintf); - - expect(modal.attributes('title')).toContain("That's it, well done!"); - expect(sprintf.exists()).toBe(true); - }); - - it('calls to remove cookie', () => { - wrapper.vm.disableModalFromRenderingAgain(); - - expect(cookieSpy).toHaveBeenCalledWith(commitCookie); - }); -}); -- cgit v1.2.3