From bc75527dca77b2b72331ac6cbd5928d5b8c0c419 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 26 Aug 2020 18:11:43 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../blob/pipeline_tour_success_modal_spec.js | 55 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'spec/frontend/blob/pipeline_tour_success_modal_spec.js') diff --git a/spec/frontend/blob/pipeline_tour_success_modal_spec.js b/spec/frontend/blob/pipeline_tour_success_modal_spec.js index 9998cd7f91c..50db1675e13 100644 --- a/spec/frontend/blob/pipeline_tour_success_modal_spec.js +++ b/spec/frontend/blob/pipeline_tour_success_modal_spec.js @@ -10,10 +10,7 @@ describe('PipelineTourSuccessModal', () => { let cookieSpy; let trackingSpy; - beforeEach(() => { - document.body.dataset.page = 'projects:blob:show'; - trackingSpy = mockTracking('_category_', undefined, jest.spyOn); - + const createComponent = () => { wrapper = shallowMount(pipelineTourSuccess, { propsData: modalProps, stubs: { @@ -21,13 +18,49 @@ describe('PipelineTourSuccessModal', () => { GlSprintf, }, }); + }; + beforeEach(() => { + document.body.dataset.page = 'projects:blob:show'; + trackingSpy = mockTracking('_category_', undefined, jest.spyOn); cookieSpy = jest.spyOn(Cookies, 'remove'); + createComponent(); }); afterEach(() => { wrapper.destroy(); unmockTracking(); + Cookies.remove(modalProps.commitCookie); + }); + + describe('when the commitCookie contains the mr path', () => { + const expectedMrPath = 'expected_mr_path'; + + beforeEach(() => { + Cookies.set(modalProps.commitCookie, expectedMrPath); + createComponent(); + }); + + it('renders the path from the commit cookie for back to the merge request button', () => { + const goToMrBtn = wrapper.find({ ref: 'goToMergeRequest' }); + + expect(goToMrBtn.attributes('href')).toBe(expectedMrPath); + }); + }); + + describe('when the commitCookie does not contain mr path', () => { + const expectedMrPath = modalProps.projectMergeRequestsPath; + + beforeEach(() => { + Cookies.set(modalProps.commitCookie, true); + createComponent(); + }); + + it('renders the path from projectMergeRequestsPath for back to the merge request button', () => { + const goToMrBtn = wrapper.find({ ref: 'goToMergeRequest' }); + + expect(goToMrBtn.attributes('href')).toBe(expectedMrPath); + }); }); it('has expected structure', () => { @@ -58,7 +91,7 @@ describe('PipelineTourSuccessModal', () => { it('send an event when go to pipelines is clicked', () => { trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn); - const goToBtn = wrapper.find({ ref: 'goto' }); + const goToBtn = wrapper.find({ ref: 'goToPipelines' }); triggerEvent(goToBtn.element); expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', { @@ -67,5 +100,17 @@ describe('PipelineTourSuccessModal', () => { value: '10', }); }); + + it('sends an event when back to the merge request is clicked', () => { + trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn); + const goToBtn = wrapper.find({ ref: 'goToMergeRequest' }); + triggerEvent(goToBtn.element); + + expect(trackingSpy).toHaveBeenCalledWith('_category_', 'click_button', { + label: 'congratulate_first_pipeline', + property: modalProps.humanAccess, + value: '20', + }); + }); }); }); -- cgit v1.2.3