2020-03-13 15:44:24 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2020-04-22 19:07:51 +05:30
|
|
|
import { GlDeprecatedButton } from '@gitlab/ui';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { TEST_HOST } from 'helpers/test_constants';
|
2020-03-13 15:44:24 +05:30
|
|
|
import SelfMonitor from '~/self_monitor/components/self_monitor_form.vue';
|
|
|
|
import { createStore } from '~/self_monitor/store';
|
|
|
|
|
|
|
|
describe('self monitor component', () => {
|
|
|
|
let wrapper;
|
|
|
|
let store;
|
|
|
|
|
|
|
|
describe('When the self monitor project has not been created', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
store = createStore({
|
|
|
|
projectEnabled: false,
|
|
|
|
selfMonitoringProjectExists: false,
|
|
|
|
createSelfMonitoringProjectPath: '/create',
|
|
|
|
deleteSelfMonitoringProjectPath: '/delete',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper.destroy) {
|
|
|
|
wrapper.destroy();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('default state', () => {
|
|
|
|
it('to match the default snapshot', () => {
|
|
|
|
wrapper = shallowMount(SelfMonitor, { store });
|
|
|
|
|
|
|
|
expect(wrapper.element).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders header text', () => {
|
|
|
|
wrapper = shallowMount(SelfMonitor, { store });
|
|
|
|
|
|
|
|
expect(wrapper.find('.js-section-header').text()).toBe('Self monitoring');
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('expand/collapse button', () => {
|
|
|
|
it('renders as an expand button by default', () => {
|
|
|
|
wrapper = shallowMount(SelfMonitor, { store });
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
const button = wrapper.find(GlDeprecatedButton);
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
expect(button.text()).toBe('Expand');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('sub-header', () => {
|
|
|
|
it('renders descriptive text', () => {
|
|
|
|
wrapper = shallowMount(SelfMonitor, { store });
|
|
|
|
|
|
|
|
expect(wrapper.find('.js-section-sub-header').text()).toContain(
|
|
|
|
'Enable or disable instance self monitoring',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('settings-content', () => {
|
|
|
|
it('renders the form description without a link', () => {
|
|
|
|
wrapper = shallowMount(SelfMonitor, { store });
|
|
|
|
|
|
|
|
expect(wrapper.vm.selfMonitoringFormText).toContain(
|
|
|
|
'Enabling this feature creates a project that can be used to monitor the health of your instance.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the form description with a link', () => {
|
|
|
|
store = createStore({
|
|
|
|
projectEnabled: true,
|
|
|
|
selfMonitoringProjectExists: true,
|
|
|
|
createSelfMonitoringProjectPath: '/create',
|
|
|
|
deleteSelfMonitoringProjectPath: '/delete',
|
2020-04-08 14:13:33 +05:30
|
|
|
selfMonitoringProjectFullPath: 'instance-administrators-random/gitlab-self-monitoring',
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
wrapper = shallowMount(SelfMonitor, { store });
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
expect(
|
|
|
|
wrapper
|
|
|
|
.find({ ref: 'selfMonitoringFormText' })
|
|
|
|
.find('a')
|
|
|
|
.attributes('href'),
|
2020-07-28 23:09:34 +05:30
|
|
|
).toEqual(`${TEST_HOST}/instance-administrators-random/gitlab-self-monitoring`);
|
2020-03-13 15:44:24 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|