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

pipeline_editor_header_spec.js « header « components « pipeline_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 27652bb268bc24e3205a972d2d776a00e416aa6b (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { shallowMount } from '@vue/test-utils';
import PipelineEditorHeader from '~/pipeline_editor/components/header/pipeline_editor_header.vue';
import PipelineStatus from '~/pipeline_editor/components/header/pipeline_status.vue';
import ValidationSegment from '~/pipeline_editor/components/header/validation_segment.vue';

import { mockCiYml, mockLintResponse } from '../../mock_data';

describe('Pipeline editor header', () => {
  let wrapper;
  const mockProvide = {
    glFeatures: {
      pipelineStatusForPipelineEditor: true,
    },
  };

  const createComponent = ({ provide = {}, props = {} } = {}) => {
    wrapper = shallowMount(PipelineEditorHeader, {
      provide: {
        ...mockProvide,
        ...provide,
      },
      propsData: {
        ciConfigData: mockLintResponse,
        ciFileContent: mockCiYml,
        isCiConfigDataLoading: false,
        isNewCiConfigFile: false,
        ...props,
      },
    });
  };

  const findPipelineStatus = () => wrapper.findComponent(PipelineStatus);
  const findValidationSegment = () => wrapper.findComponent(ValidationSegment);

  afterEach(() => {
    wrapper.destroy();
    wrapper = null;
  });

  describe('template', () => {
    it('hides the pipeline status for new projects without a CI file', () => {
      createComponent({ props: { isNewCiConfigFile: true } });

      expect(findPipelineStatus().exists()).toBe(false);
    });

    it('renders the pipeline status when CI file exists', () => {
      createComponent({ props: { isNewCiConfigFile: false } });

      expect(findPipelineStatus().exists()).toBe(true);
    });

    it('renders the validation segment', () => {
      createComponent();

      expect(findValidationSegment().exists()).toBe(true);
    });
  });

  describe('with pipeline status feature flag off', () => {
    beforeEach(() => {
      createComponent({
        provide: {
          glFeatures: { pipelineStatusForPipelineEditor: false },
        },
      });
    });

    it('does not render the pipeline status', () => {
      expect(findPipelineStatus().exists()).toBe(false);
    });
  });
});