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

runner_summary_cell_spec.js « cells « components « runner « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b06ab65221276cb44ba5c955f0bfbd88c52656df (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
import { __ } from '~/locale';
import { mountExtended } from 'helpers/vue_test_utils_helper';
import RunnerSummaryCell from '~/runner/components/cells/runner_summary_cell.vue';
import { INSTANCE_TYPE, PROJECT_TYPE } from '~/runner/constants';

const mockId = '1';
const mockShortSha = '2P6oDVDm';
const mockDescription = 'runner-1';
const mockIpAddress = '0.0.0.0';

describe('RunnerTypeCell', () => {
  let wrapper;

  const findLockIcon = () => wrapper.findByTestId('lock-icon');

  const createComponent = (runner, options) => {
    wrapper = mountExtended(RunnerSummaryCell, {
      propsData: {
        runner: {
          id: `gid://gitlab/Ci::Runner/${mockId}`,
          shortSha: mockShortSha,
          description: mockDescription,
          ipAddress: mockIpAddress,
          runnerType: INSTANCE_TYPE,
          ...runner,
        },
      },
      ...options,
    });
  };

  beforeEach(() => {
    createComponent();
  });

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

  it('Displays the runner name as id and short token', () => {
    expect(wrapper.text()).toContain(`#${mockId} (${mockShortSha})`);
  });

  it('Displays the runner type', () => {
    expect(wrapper.text()).toContain('shared');
  });

  it('Does not display the locked icon', () => {
    expect(findLockIcon().exists()).toBe(false);
  });

  it('Displays the locked icon for locked runners', () => {
    createComponent({
      runnerType: PROJECT_TYPE,
      locked: true,
    });

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

  it('Displays the runner description', () => {
    expect(wrapper.text()).toContain(mockDescription);
  });

  it('Displays ip address', () => {
    expect(wrapper.text()).toContain(`${__('IP Address')} ${mockIpAddress}`);
  });

  it('Displays no ip address', () => {
    createComponent({
      ipAddress: null,
    });

    expect(wrapper.text()).not.toContain(__('IP Address'));
  });

  it('Displays a custom slot', () => {
    const slotContent = 'My custom runner summary';

    createComponent(
      {},
      {
        slots: {
          'runner-name': slotContent,
        },
      },
    );

    expect(wrapper.text()).toContain(slotContent);
  });
});