2020-04-24 09:09:44 +00:00
|
|
|
import { createLocalVue, mount } from '@vue/test-utils';
|
|
|
|
import { GlEmptyState, GlTable, GlAlert } from '@gitlab/ui';
|
|
|
|
import Vuex from 'vuex';
|
2020-04-21 15:21:10 +00:00
|
|
|
import stubChildren from 'helpers/stub_children';
|
|
|
|
import AlertManagementList from '~/alert_management/components/alert_management_list.vue';
|
|
|
|
|
2020-04-24 09:09:44 +00:00
|
|
|
const localVue = createLocalVue();
|
|
|
|
localVue.use(Vuex);
|
|
|
|
|
2020-04-21 15:21:10 +00:00
|
|
|
describe('AlertManagementList', () => {
|
|
|
|
let wrapper;
|
2020-04-24 09:09:44 +00:00
|
|
|
let store;
|
|
|
|
|
|
|
|
const findAlertsTable = () => wrapper.find(GlTable);
|
|
|
|
const findAlert = () => wrapper.find(GlAlert);
|
2020-04-21 15:21:10 +00:00
|
|
|
|
2020-04-24 09:09:44 +00:00
|
|
|
function mountComponent({ stubs = {}, alertManagementEnabled = false } = {}) {
|
2020-04-21 15:21:10 +00:00
|
|
|
wrapper = mount(AlertManagementList, {
|
2020-04-24 09:09:44 +00:00
|
|
|
localVue,
|
|
|
|
store,
|
2020-04-21 15:21:10 +00:00
|
|
|
propsData: {
|
|
|
|
indexPath: '/path',
|
|
|
|
enableAlertManagementPath: '/link',
|
|
|
|
emptyAlertSvgPath: 'illustration/path',
|
2020-04-24 09:09:44 +00:00
|
|
|
alertManagementEnabled,
|
2020-04-21 15:21:10 +00:00
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
...stubChildren(AlertManagementList),
|
|
|
|
...stubs,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-24 09:09:44 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
store = new Vuex.Store({
|
|
|
|
modules: {
|
|
|
|
list: {
|
|
|
|
namespaced: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
mountComponent();
|
|
|
|
});
|
|
|
|
|
2020-04-21 15:21:10 +00:00
|
|
|
afterEach(() => {
|
|
|
|
if (wrapper) {
|
|
|
|
wrapper.destroy();
|
2020-04-24 09:09:44 +00:00
|
|
|
store = null;
|
2020-04-21 15:21:10 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('alert management feature renders empty state', () => {
|
|
|
|
it('shows empty state', () => {
|
|
|
|
expect(wrapper.find(GlEmptyState).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
});
|
2020-04-24 09:09:44 +00:00
|
|
|
|
|
|
|
describe('Alerts table', () => {
|
|
|
|
it('shows empty list', () => {
|
|
|
|
store.state.list = {
|
|
|
|
alerts: [],
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
mountComponent({ alertManagementEnabled: true });
|
|
|
|
|
|
|
|
return wrapper.vm.$nextTick().then(() => {
|
|
|
|
expect(findAlertsTable().exists()).toBe(true);
|
|
|
|
expect(findAlert().text()).toContain('No alerts available to display');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-04-21 15:21:10 +00:00
|
|
|
});
|