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

deployment_instance_spec.js « deployment_instance « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e3d8bfd22cab6ead74d22f001d807ff65aa0b02a (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
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import DeployBoardInstance from '~/vue_shared/components/deployment_instance.vue';
import { folder } from './mock_data';

describe('Deploy Board Instance', () => {
  let wrapper;

  const createComponent = (props = {}, provide) =>
    shallowMount(DeployBoardInstance, {
      propsData: {
        status: 'succeeded',
        ...props,
      },
      provide: {
        glFeatures: { monitorLogging: true },
        ...provide,
      },
    });

  describe('as a non-canary deployment', () => {
    afterEach(() => {
      wrapper.destroy();
    });

    it('should render a div with the correct css status and tooltip data', () => {
      wrapper = createComponent({
        logsPath: folder.logs_path,
        tooltipText: 'This is a pod',
      });

      expect(wrapper.classes('deployment-instance-succeeded')).toBe(true);
      expect(wrapper.attributes('title')).toEqual('This is a pod');
    });

    it('should render a div without tooltip data', async () => {
      wrapper = createComponent({
        status: 'deploying',
        tooltipText: '',
      });

      await nextTick();
      expect(wrapper.classes('deployment-instance-deploying')).toBe(true);
      expect(wrapper.attributes('title')).toEqual('');
    });

    it('should have a log path computed with a pod name as a parameter', () => {
      wrapper = createComponent({
        logsPath: folder.logs_path,
        podName: 'tanuki-1',
      });

      expect(wrapper.vm.computedLogPath).toEqual(
        '/root/review-app/-/logs?environment_name=foo&pod_name=tanuki-1',
      );
    });
  });

  describe('as a canary deployment', () => {
    afterEach(() => {
      wrapper.destroy();
    });

    it('should render a div with canary class when stable prop is provided as false', async () => {
      wrapper = createComponent({
        stable: false,
      });

      await nextTick();
      expect(wrapper.classes('deployment-instance-canary')).toBe(true);
    });
  });

  describe('as a legend item', () => {
    afterEach(() => {
      wrapper.destroy();
    });

    it('should not be a link without a logsPath prop', async () => {
      wrapper = createComponent({
        stable: false,
        logsPath: '',
      });

      await nextTick();
      expect(wrapper.vm.computedLogPath).toBeNull();
      expect(wrapper.vm.isLink).toBeFalsy();
    });

    it('should render a link without href if path is not passed', () => {
      wrapper = createComponent();

      expect(wrapper.attributes('href')).toBeUndefined();
    });

    it('should not have a tooltip', () => {
      wrapper = createComponent();

      expect(wrapper.attributes('title')).toEqual('');
    });
  });

  describe(':monitor_logging feature flag', () => {
    afterEach(() => {
      wrapper.destroy();
    });

    it.each`
      flagState | logsState  | expected
      ${true}   | ${'shows'} | ${'/root/review-app/-/logs?environment_name=foo&pod_name=tanuki-1'}
      ${false}  | ${'hides'} | ${undefined}
    `('$logsState log link when flag state is $flagState', async ({ flagState, expected }) => {
      wrapper = createComponent(
        { logsPath: folder.logs_path, podName: 'tanuki-1' },
        { glFeatures: { monitorLogging: flagState } },
      );

      expect(wrapper.attributes('href')).toEqual(expected);
    });
  });
});