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

stuck_block_spec.js « components « jobs « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4db73eaaaec5bde64e6b930b4d17381ec4a189fa (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
import { GlBadge, GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import StuckBlock from '~/jobs/components/stuck_block.vue';

describe('Stuck Block Job component', () => {
  let wrapper;

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

  const createWrapper = (props) => {
    wrapper = shallowMount(StuckBlock, {
      propsData: {
        ...props,
      },
    });
  };

  const tags = ['docker', 'gitlab-org'];

  const findStuckNoActiveRunners = () =>
    wrapper.find('[data-testid="job-stuck-no-active-runners"]');
  const findStuckNoRunners = () => wrapper.find('[data-testid="job-stuck-no-runners"]');
  const findStuckWithTags = () => wrapper.find('[data-testid="job-stuck-with-tags"]');
  const findRunnerPathLink = () => wrapper.find(GlLink);
  const findAllBadges = () => wrapper.findAll(GlBadge);

  describe('with no runners for project', () => {
    beforeEach(() => {
      createWrapper({
        hasNoRunnersForProject: true,
        runnersPath: '/root/project/runners#js-runners-settings',
      });
    });

    it('renders only information about project not having runners', () => {
      expect(findStuckNoRunners().exists()).toBe(true);
      expect(findStuckWithTags().exists()).toBe(false);
      expect(findStuckNoActiveRunners().exists()).toBe(false);
    });

    it('renders link to runners page', () => {
      expect(findRunnerPathLink().attributes('href')).toBe(
        '/root/project/runners#js-runners-settings',
      );
    });
  });

  describe('with tags', () => {
    beforeEach(() => {
      createWrapper({
        hasNoRunnersForProject: false,
        tags,
        runnersPath: '/root/project/runners#js-runners-settings',
      });
    });

    it('renders information about the tags not being set', () => {
      expect(findStuckWithTags().exists()).toBe(true);
      expect(findStuckNoActiveRunners().exists()).toBe(false);
      expect(findStuckNoRunners().exists()).toBe(false);
    });

    it('renders tags', () => {
      findAllBadges().wrappers.forEach((badgeElt, index) => {
        return expect(badgeElt.text()).toBe(tags[index]);
      });
    });

    it('renders link to runners page', () => {
      expect(findRunnerPathLink().attributes('href')).toBe(
        '/root/project/runners#js-runners-settings',
      );
    });
  });

  describe('without active runners', () => {
    beforeEach(() => {
      createWrapper({
        hasNoRunnersForProject: false,
        runnersPath: '/root/project/runners#js-runners-settings',
      });
    });

    it('renders information about project not having runners', () => {
      expect(findStuckNoActiveRunners().exists()).toBe(true);
      expect(findStuckNoRunners().exists()).toBe(false);
      expect(findStuckWithTags().exists()).toBe(false);
    });

    it('renders link to runners page', () => {
      expect(findRunnerPathLink().attributes('href')).toBe(
        '/root/project/runners#js-runners-settings',
      );
    });
  });
});