2022-01-26 12:08:38 +05:30
|
|
|
import { GlEmptyState, GlSprintf, GlLink, GlButton } from '@gitlab/ui';
|
2021-11-18 22:05:49 +05:30
|
|
|
import AgentEmptyState from '~/clusters_list/components/agent_empty_state.vue';
|
2022-01-26 12:08:38 +05:30
|
|
|
import { INSTALL_AGENT_MODAL_ID } from '~/clusters_list/constants';
|
2021-11-18 22:05:49 +05:30
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
2022-01-26 12:08:38 +05:30
|
|
|
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
|
2021-12-11 22:18:48 +05:30
|
|
|
import { helpPagePath } from '~/helpers/help_page_helper';
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
const emptyStateImage = '/path/to/image';
|
2022-01-26 12:08:38 +05:30
|
|
|
const installDocsUrl = helpPagePath('user/clusters/agent/index');
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
describe('AgentEmptyStateComponent', () => {
|
|
|
|
let wrapper;
|
|
|
|
const provideData = {
|
|
|
|
emptyStateImage,
|
|
|
|
};
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
const findInstallDocsLink = () => wrapper.findComponent(GlLink);
|
|
|
|
const findIntegrationButton = () => wrapper.findComponent(GlButton);
|
2021-11-18 22:05:49 +05:30
|
|
|
const findEmptyState = () => wrapper.findComponent(GlEmptyState);
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
wrapper = shallowMountExtended(AgentEmptyState, {
|
|
|
|
provide: provideData,
|
2022-01-26 12:08:38 +05:30
|
|
|
directives: {
|
|
|
|
GlModalDirective: createMockDirective(),
|
|
|
|
},
|
2021-11-18 22:05:49 +05:30
|
|
|
stubs: { GlEmptyState, GlSprintf },
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it('renders the empty state', () => {
|
|
|
|
expect(findEmptyState().exists()).toBe(true);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it('renders button for the agent registration', () => {
|
|
|
|
expect(findIntegrationButton().exists()).toBe(true);
|
|
|
|
});
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it('renders correct href attributes for the docs link', () => {
|
|
|
|
expect(findInstallDocsLink().attributes('href')).toBe(installDocsUrl);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
it('renders correct modal id for the agent registration modal', () => {
|
|
|
|
const binding = getBinding(findIntegrationButton().element, 'gl-modal-directive');
|
|
|
|
|
|
|
|
expect(binding.value).toBe(INSTALL_AGENT_MODAL_ID);
|
2021-11-18 22:05:49 +05:30
|
|
|
});
|
|
|
|
});
|