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

linked_pipelines_mini_list_spec.js « pipeline_mini_graph « ci « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0396029cdafa079542d49588dca3d99aebcea1dc (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import { mount } from '@vue/test-utils';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import LinkedPipelinesMiniList from '~/ci/pipeline_mini_graph/linked_pipelines_mini_list.vue';
import mockData from './linked_pipelines_mock_data';

describe('Linked pipeline mini list', () => {
  let wrapper;

  const findCiIcon = () => wrapper.findComponent(CiIcon);
  const findCiIcons = () => wrapper.findAllComponents(CiIcon);
  const findLinkedPipelineCounter = () => wrapper.find('[data-testid="linked-pipeline-counter"]');
  const findLinkedPipelineMiniItem = () =>
    wrapper.find('[data-testid="linked-pipeline-mini-item"]');
  const findLinkedPipelineMiniItems = () =>
    wrapper.findAll('[data-testid="linked-pipeline-mini-item"]');
  const findLinkedPipelineMiniList = () => wrapper.findComponent(LinkedPipelinesMiniList);

  const createComponent = (props = {}) => {
    wrapper = mount(LinkedPipelinesMiniList, {
      directives: {
        GlTooltip: createMockDirective('gl-tooltip'),
      },
      propsData: {
        ...props,
      },
    });
  };

  describe('when passed an upstream pipeline as prop', () => {
    beforeEach(() => {
      createComponent({
        triggeredBy: [mockData.triggered_by],
      });
    });

    it('should render one linked pipeline item', () => {
      expect(findLinkedPipelineMiniItem().exists()).toBe(true);
    });

    it('should render a linked pipeline with the correct href', () => {
      expect(findLinkedPipelineMiniItem().exists()).toBe(true);

      expect(findLinkedPipelineMiniItem().attributes('href')).toBe(
        '/gitlab-org/gitlab-foss/-/pipelines/129',
      );
    });

    it('should render one ci status icon', () => {
      expect(findCiIcon().exists()).toBe(true);
    });

    it('should render a borderless ci-icon', () => {
      expect(findCiIcon().exists()).toBe(true);

      expect(findCiIcon().props('isBorderless')).toBe(true);
      expect(findCiIcon().classes('borderless')).toBe(true);
    });

    it('should render a ci-icon with a custom border class', () => {
      expect(findCiIcon().exists()).toBe(true);

      expect(findCiIcon().classes('gl-border')).toBe(true);
    });

    it('should render the correct ci status icon', () => {
      expect(findCiIcon().classes('ci-status-icon-running')).toBe(true);
    });

    it('should have an activated tooltip', () => {
      expect(findLinkedPipelineMiniItem().exists()).toBe(true);
      const tooltip = getBinding(findLinkedPipelineMiniItem().element, 'gl-tooltip');

      expect(tooltip.value.title).toBe('GitLabCE - running');
    });

    it('should correctly set is-upstream', () => {
      expect(findLinkedPipelineMiniList().exists()).toBe(true);

      expect(findLinkedPipelineMiniList().classes('is-upstream')).toBe(true);
    });

    it('should correctly compute shouldRenderCounter', () => {
      expect(findLinkedPipelineMiniList().vm.shouldRenderCounter).toBe(false);
    });

    it('should not render the pipeline counter', () => {
      expect(findLinkedPipelineCounter().exists()).toBe(false);
    });
  });

  describe('when passed downstream pipelines as props', () => {
    beforeEach(() => {
      createComponent({
        triggered: mockData.triggered,
        pipelinePath: 'my/pipeline/path',
      });
    });

    it('should render three linked pipeline items', () => {
      expect(findLinkedPipelineMiniItems().exists()).toBe(true);
      expect(findLinkedPipelineMiniItems().length).toBe(3);
    });

    it('should render three ci status icons', () => {
      expect(findCiIcons().exists()).toBe(true);
      expect(findCiIcons().length).toBe(3);
    });

    it('should render the correct ci status icon', () => {
      expect(findCiIcon().classes('ci-status-icon-running')).toBe(true);
    });

    it('should have an activated tooltip', () => {
      expect(findLinkedPipelineMiniItem().exists()).toBe(true);
      const tooltip = getBinding(findLinkedPipelineMiniItem().element, 'gl-tooltip');

      expect(tooltip.value.title).toBe('GitLabCE - running');
    });

    it('should correctly set is-downstream', () => {
      expect(findLinkedPipelineMiniList().exists()).toBe(true);

      expect(findLinkedPipelineMiniList().classes('is-downstream')).toBe(true);
    });

    it('should render a borderless ci-icon', () => {
      expect(findCiIcon().exists()).toBe(true);

      expect(findCiIcon().props('isBorderless')).toBe(true);
      expect(findCiIcon().classes('borderless')).toBe(true);
    });

    it('should render a ci-icon with a custom border class', () => {
      expect(findCiIcon().exists()).toBe(true);

      expect(findCiIcon().classes('gl-border')).toBe(true);
    });

    it('should render the pipeline counter', () => {
      expect(findLinkedPipelineCounter().exists()).toBe(true);
    });

    it('should correctly compute shouldRenderCounter', () => {
      expect(findLinkedPipelineMiniList().vm.shouldRenderCounter).toBe(true);
    });

    it('should correctly trim linkedPipelines', () => {
      expect(findLinkedPipelineMiniList().props('triggered').length).toBe(6);
      expect(findLinkedPipelineMiniList().vm.linkedPipelinesTrimmed.length).toBe(3);
    });

    it('should set the correct pipeline path', () => {
      expect(findLinkedPipelineCounter().exists()).toBe(true);

      expect(findLinkedPipelineCounter().attributes('href')).toBe('my/pipeline/path');
    });

    it('should render the correct counterTooltipText', () => {
      expect(findLinkedPipelineCounter().exists()).toBe(true);
      const tooltip = getBinding(findLinkedPipelineCounter().element, 'gl-tooltip');

      expect(tooltip.value.title).toBe(findLinkedPipelineMiniList().vm.counterTooltipText);
    });
  });
});