summaryrefslogtreecommitdiff
path: root/spec/frontend/pipelines/pipelines_ci_templates_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 09:55:51 +0000
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /spec/frontend/pipelines/pipelines_ci_templates_spec.js
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
downloadgitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/pipelines/pipelines_ci_templates_spec.js')
-rw-r--r--spec/frontend/pipelines/pipelines_ci_templates_spec.js34
1 files changed, 15 insertions, 19 deletions
diff --git a/spec/frontend/pipelines/pipelines_ci_templates_spec.js b/spec/frontend/pipelines/pipelines_ci_templates_spec.js
index 0c37bf2d84a..db66b675fb9 100644
--- a/spec/frontend/pipelines/pipelines_ci_templates_spec.js
+++ b/spec/frontend/pipelines/pipelines_ci_templates_spec.js
@@ -1,30 +1,25 @@
+import '~/commons';
import { shallowMount } from '@vue/test-utils';
-import ExperimentTracking from '~/experimentation/experiment_tracking';
+import { mockTracking } from 'helpers/tracking_helper';
import PipelinesCiTemplate from '~/pipelines/components/pipelines_list/pipelines_ci_templates.vue';
-const addCiYmlPath = "/-/new/main?commit_message='Add%20.gitlab-ci.yml'";
+const pipelineEditorPath = '/-/ci/editor';
const suggestedCiTemplates = [
{ name: 'Android', logo: '/assets/illustrations/logos/android.svg' },
{ name: 'Bash', logo: '/assets/illustrations/logos/bash.svg' },
{ name: 'C++', logo: '/assets/illustrations/logos/c_plus_plus.svg' },
];
-jest.mock('~/experimentation/experiment_tracking');
-
describe('Pipelines CI Templates', () => {
let wrapper;
-
- const GlEmoji = { template: '<img/>' };
+ let trackingSpy;
const createWrapper = () => {
return shallowMount(PipelinesCiTemplate, {
provide: {
- addCiYmlPath,
+ pipelineEditorPath,
suggestedCiTemplates,
},
- stubs: {
- GlEmoji,
- },
});
};
@@ -44,9 +39,9 @@ describe('Pipelines CI Templates', () => {
wrapper = createWrapper();
});
- it('links to the hello world template', () => {
+ it('links to the getting started template', () => {
expect(findTestTemplateLinks().at(0).attributes('href')).toBe(
- addCiYmlPath.concat('&template=Hello-World'),
+ pipelineEditorPath.concat('?template=Getting-Started'),
);
});
});
@@ -68,7 +63,7 @@ describe('Pipelines CI Templates', () => {
it('links to the correct template', () => {
expect(findTemplateLinks().at(0).attributes('href')).toBe(
- addCiYmlPath.concat('&template=Android'),
+ pipelineEditorPath.concat('?template=Android'),
);
});
@@ -88,24 +83,25 @@ describe('Pipelines CI Templates', () => {
describe('tracking', () => {
beforeEach(() => {
wrapper = createWrapper();
+ trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
});
it('sends an event when template is clicked', () => {
findTemplateLinks().at(0).vm.$emit('click');
- expect(ExperimentTracking).toHaveBeenCalledWith('pipeline_empty_state_templates', {
+ expect(trackingSpy).toHaveBeenCalledTimes(1);
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, 'template_clicked', {
label: 'Android',
});
- expect(ExperimentTracking.prototype.event).toHaveBeenCalledWith('template_clicked');
});
- it('sends an event when Hello-World template is clicked', () => {
+ it('sends an event when Getting-Started template is clicked', () => {
findTestTemplateLinks().at(0).vm.$emit('click');
- expect(ExperimentTracking).toHaveBeenCalledWith('pipeline_empty_state_templates', {
- label: 'Hello-World',
+ expect(trackingSpy).toHaveBeenCalledTimes(1);
+ expect(trackingSpy).toHaveBeenCalledWith(undefined, 'template_clicked', {
+ label: 'Getting-Started',
});
- expect(ExperimentTracking.prototype.event).toHaveBeenCalledWith('template_clicked');
});
});
});