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

pipelines_ci_templates_spec.js « empty_state « components « pipelines_page « ci « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fbef4aa08eb8a8d01c9d325cc47ab1c052413794 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import '~/commons';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import PipelinesCiTemplates from '~/ci/pipelines_page/components/empty_state/pipelines_ci_templates.vue';
import CiTemplates from '~/ci/pipelines_page/components/empty_state/ci_templates.vue';

const pipelineEditorPath = '/-/ci/editor';

describe('Pipelines CI Templates', () => {
  let wrapper;
  let trackingSpy;

  const createWrapper = (propsData = {}, stubs = {}) => {
    return shallowMountExtended(PipelinesCiTemplates, {
      provide: {
        pipelineEditorPath,
        ...propsData,
      },
      stubs,
    });
  };

  const findTestTemplateLink = () => wrapper.findByTestId('test-template-link');
  const findCiTemplates = () => wrapper.findComponent(CiTemplates);

  describe('templates', () => {
    beforeEach(() => {
      wrapper = createWrapper();
    });

    it('renders test template and Ci templates', () => {
      expect(findTestTemplateLink().attributes('href')).toBe(
        pipelineEditorPath.concat('?template=Getting-Started'),
      );
      expect(findCiTemplates().exists()).toBe(true);
    });
  });

  describe('tracking', () => {
    beforeEach(() => {
      wrapper = createWrapper();
      trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn);
    });

    afterEach(() => {
      unmockTracking();
    });

    it('sends an event when Getting-Started template is clicked', () => {
      findTestTemplateLink().vm.$emit('click');

      expect(trackingSpy).toHaveBeenCalledTimes(1);
      expect(trackingSpy).toHaveBeenCalledWith(undefined, 'template_clicked', {
        label: 'Getting-Started',
      });
    });
  });
});