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

runner_cell_spec.js « cells « components « jobs_table « admin « ci « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2f1dae71572ee71860ae6abecdc05615ba5b2eb5 (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
import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import RunnerCell from '~/ci/admin/jobs_table/components/cells/runner_cell.vue';
import { RUNNER_EMPTY_TEXT } from '~/ci/admin/jobs_table/constants';
import { allRunnersData } from 'jest/ci/runner/mock_data';

const mockRunner = allRunnersData.data.runners.nodes[0];

const mockJobWithRunner = {
  id: 'gid://gitlab/Ci::Build/2264',
  runner: mockRunner,
};

const mockJobWithoutRunner = {
  id: 'gid://gitlab/Ci::Build/2265',
};

describe('Runner Cell', () => {
  let wrapper;

  const findRunnerLink = () => wrapper.findComponent(GlLink);
  const findEmptyRunner = () => wrapper.find('[data-testid="empty-runner-text"]');

  const createComponent = (props = {}) => {
    wrapper = shallowMount(RunnerCell, {
      propsData: {
        ...props,
      },
    });
  };

  describe('Runner Link', () => {
    describe('Job with runner', () => {
      beforeEach(() => {
        createComponent({ job: mockJobWithRunner });
      });

      it('shows and links to the runner', () => {
        expect(findRunnerLink().exists()).toBe(true);
        expect(findRunnerLink().text()).toBe(mockRunner.description);
        expect(findRunnerLink().attributes('href')).toBe(mockRunner.adminUrl);
      });

      it('hides the empty runner text', () => {
        expect(findEmptyRunner().exists()).toBe(false);
      });
    });

    describe('Job without runner', () => {
      beforeEach(() => {
        createComponent({ job: mockJobWithoutRunner });
      });

      it('shows default `empty` text', () => {
        expect(findEmptyRunner().exists()).toBe(true);
        expect(findEmptyRunner().text()).toBe(RUNNER_EMPTY_TEXT);
      });

      it('hides the runner link', () => {
        expect(findRunnerLink().exists()).toBe(false);
      });
    });
  });
});