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
|
import { GlTable, GlIcon, GlLink } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import IntegrationsTable from '~/integrations/index/components/integrations_table.vue';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { mockActiveIntegrations, mockInactiveIntegrations } from '../mock_data';
describe('IntegrationsTable', () => {
let wrapper;
const findTable = () => wrapper.findComponent(GlTable);
const createComponent = (propsData = {}, glFeatures = {}) => {
wrapper = mount(IntegrationsTable, {
propsData: {
integrations: mockActiveIntegrations,
...propsData,
},
provide: {
glFeatures,
},
});
};
describe.each([true, false])('when `showUpdatedAt` is %p', (showUpdatedAt) => {
beforeEach(() => {
createComponent({ showUpdatedAt });
});
it(`${showUpdatedAt ? 'renders' : 'does not render'} content in "Last updated" column`, () => {
const headers = findTable().findAll('th');
expect(headers.wrappers.some((header) => header.text() === 'Last updated')).toBe(
showUpdatedAt,
);
expect(wrapper.findComponent(TimeAgoTooltip).exists()).toBe(showUpdatedAt);
});
});
describe.each`
scenario | integrations | shouldRenderActiveIcon
${'when integration is active'} | ${[mockActiveIntegrations[0]]} | ${true}
${'when integration is inactive'} | ${[mockInactiveIntegrations[0]]} | ${false}
`('$scenario', ({ shouldRenderActiveIcon, integrations }) => {
beforeEach(() => {
createComponent({ integrations });
});
it(`${shouldRenderActiveIcon ? 'renders' : 'does not render'} icon in first column`, () => {
expect(findTable().findComponent(GlIcon).exists()).toBe(shouldRenderActiveIcon);
});
});
describe.each([true, false])(
'when `remove_monitor_metrics` flag is %p',
(removeMonitorMetrics) => {
beforeEach(() => {
createComponent({ integrations: [mockInactiveIntegrations[3]] }, { removeMonitorMetrics });
});
it(`${removeMonitorMetrics ? 'does not render' : 'renders'} prometheus integration`, () => {
expect(findTable().findComponent(GlLink).exists()).toBe(!removeMonitorMetrics);
});
},
);
describe('when no integrations are received', () => {
beforeEach(() => {
createComponent({ integrations: [] });
});
it('does not display fields in the table', () => {
expect(findTable().findAll('th')).toHaveLength(0);
});
});
describe.each([true, false])('when integrations inactive property is %p', (inactive) => {
beforeEach(() => {
createComponent({ integrations: [mockInactiveIntegrations], inactive });
});
it(`${inactive ? 'does not render' : 'render'} updated_at field`, () => {
expect(findTable().find('[aria-label="Updated At"]').exists()).toBe(!inactive);
});
});
});
|