Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-26 21:11:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-26 21:11:43 +0300
commitbc75527dca77b2b72331ac6cbd5928d5b8c0c419 (patch)
tree000196faadb05f6e2ff60c08865b1a09506e5522 /spec/frontend/blob/pipeline_tour_success_modal_spec.js
parentc82ca12a1c5a359325cb45aaf01b483d1fa0efcb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/blob/pipeline_tour_success_modal_spec.js')
-rw-r--r--spec/frontend/blob/pipeline_tour_success_modal_spec.js55
1 files changed, 50 insertions, 5 deletions
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',
+ });
+ });
});
});