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

jobs_container_spec.js « job « components « jobs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2fde4d3020be056938bcf399d928460594f52d17 (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
import { GlLink } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import JobsContainer from '~/jobs/components/job/sidebar/jobs_container.vue';

describe('Jobs List block', () => {
  let wrapper;

  const retried = {
    status: {
      details_path: '/gitlab-org/gitlab-foss/pipelines/28029444',
      group: 'success',
      has_details: true,
      icon: 'status_success',
      label: 'passed',
      text: 'passed',
      tooltip: 'passed',
    },
    id: 233432756,
    tooltip: 'build - passed',
    retried: true,
  };

  const active = {
    name: 'test',
    status: {
      details_path: '/gitlab-org/gitlab-foss/pipelines/28029444',
      group: 'success',
      has_details: true,
      icon: 'status_success',
      label: 'passed',
      text: 'passed',
      tooltip: 'passed',
    },
    id: 2322756,
    tooltip: 'build - passed',
    active: true,
  };

  const job = {
    name: 'build',
    status: {
      details_path: '/gitlab-org/gitlab-foss/pipelines/28029444',
      group: 'success',
      has_details: true,
      icon: 'status_success',
      label: 'passed',
      text: 'passed',
      tooltip: 'passed',
    },
    id: 232153,
    tooltip: 'build - passed',
  };

  const findAllJobs = () => wrapper.findAllComponents(GlLink);
  const findJob = () => findAllJobs().at(0);

  const findArrowIcon = () => wrapper.findByTestId('arrow-right-icon');
  const findRetryIcon = () => wrapper.findByTestId('retry-icon');

  const createComponent = (props) => {
    wrapper = extendedWrapper(
      mount(JobsContainer, {
        propsData: {
          ...props,
        },
      }),
    );
  };

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

  it('renders a list of jobs', () => {
    createComponent({
      jobs: [job, retried, active],
      jobId: 12313,
    });

    expect(findAllJobs()).toHaveLength(3);
  });

  it('renders the arrow right icon when job id matches `jobId`', () => {
    createComponent({
      jobs: [active],
      jobId: active.id,
    });

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

  it('does not render the arrow right icon when the job is not active', () => {
    createComponent({
      jobs: [job],
      jobId: active.id,
    });

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

  it('renders the job name when present', () => {
    createComponent({
      jobs: [job],
      jobId: active.id,
    });

    expect(findJob().text()).toBe(job.name);
    expect(findJob().text()).not.toContain(job.id.toString());
  });

  it('renders job id when job name is not available', () => {
    createComponent({
      jobs: [retried],
      jobId: active.id,
    });

    expect(findJob().text()).toBe(retried.id.toString());
  });

  it('links to the job page', () => {
    createComponent({
      jobs: [job],
      jobId: active.id,
    });

    expect(findJob().attributes('href')).toBe(job.status.details_path);
  });

  it('renders retry icon when job was retried', () => {
    createComponent({
      jobs: [retried],
      jobId: active.id,
    });

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

  it('does not render retry icon when job was not retried', () => {
    createComponent({
      jobs: [job],
      jobId: active.id,
    });

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