debian-mirror-gitlab/spec/frontend/integrations/index/components/integrations_table_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-07-09 08:55:56 +05:30
import { GlTable, GlIcon, GlLink } from '@gitlab/ui';
2021-04-29 21:17:54 +05:30
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);
2023-07-09 08:55:56 +05:30
const createComponent = (propsData = {}, glFeatures = {}) => {
2021-04-29 21:17:54 +05:30
wrapper = mount(IntegrationsTable, {
propsData: {
integrations: mockActiveIntegrations,
...propsData,
},
2023-07-09 08:55:56 +05:30
provide: {
glFeatures,
},
2021-04-29 21:17:54 +05:30
});
};
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);
});
});
2023-07-09 08:55:56 +05:30
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);
});
},
);
2021-04-29 21:17:54 +05:30
});