2020-10-24 23:57:45 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import EmptyState from '~/jobs/components/empty_state.vue';
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
describe('Empty State', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
let wrapper;
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const defaultProps = {
|
2018-11-20 20:47:30 +05:30
|
|
|
illustrationPath: 'illustrations/pending_job_empty.svg',
|
|
|
|
illustrationSizeClass: 'svg-430',
|
|
|
|
title: 'This job has not started yet',
|
2019-10-12 21:52:04 +05:30
|
|
|
playable: false,
|
|
|
|
variablesSettingsUrl: '',
|
2018-11-20 20:47:30 +05:30
|
|
|
};
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const createWrapper = (props) => {
|
2020-10-24 23:57:45 +05:30
|
|
|
wrapper = mount(EmptyState, {
|
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
const content = 'This job is in pending state and is waiting to be picked by a runner';
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const findEmptyStateImage = () => wrapper.find('img');
|
|
|
|
const findTitle = () => wrapper.find('[data-testid="job-empty-state-title"]');
|
|
|
|
const findContent = () => wrapper.find('[data-testid="job-empty-state-content"]');
|
|
|
|
const findAction = () => wrapper.find('[data-testid="job-empty-state-action"]');
|
|
|
|
const findManualVarsForm = () => wrapper.find('[data-testid="manual-vars-form"]');
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
afterEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
if (wrapper?.destroy) {
|
|
|
|
wrapper.destroy();
|
|
|
|
wrapper = null;
|
|
|
|
}
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('renders image and title', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper();
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('renders empty state image', () => {
|
|
|
|
expect(findEmptyStateImage().exists()).toBe(true);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders provided title', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(findTitle().text().trim()).toBe(defaultProps.title);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with content', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({ content });
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('renders content', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect(findContent().text().trim()).toBe(content);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without content', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper();
|
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('does not render content', () => {
|
|
|
|
expect(findContent().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with action', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
2018-11-20 20:47:30 +05:30
|
|
|
action: {
|
2018-12-05 23:21:45 +05:30
|
|
|
path: 'runner',
|
|
|
|
button_title: 'Check runner',
|
2018-11-20 20:47:30 +05:30
|
|
|
method: 'post',
|
|
|
|
},
|
|
|
|
});
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('renders action', () => {
|
|
|
|
expect(findAction().attributes('href')).toBe('runner');
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without action', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
2019-02-15 15:39:39 +05:30
|
|
|
action: null,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('does not render action', () => {
|
|
|
|
expect(findAction().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
it('does not render manual variables form', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findManualVarsForm().exists()).toBe(false);
|
2019-10-12 21:52:04 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe('with playable action and not scheduled job', () => {
|
2019-10-12 21:52:04 +05:30
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
2019-10-12 21:52:04 +05:30
|
|
|
content,
|
|
|
|
playable: true,
|
|
|
|
scheduled: false,
|
|
|
|
action: {
|
|
|
|
path: 'runner',
|
|
|
|
button_title: 'Check runner',
|
|
|
|
method: 'post',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders manual variables form', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findManualVarsForm().exists()).toBe(true);
|
2019-10-12 21:52:04 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render the empty state action', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findAction().exists()).toBe(false);
|
2019-10-12 21:52:04 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
describe('with playable action and scheduled job', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
|
|
|
playable: true,
|
|
|
|
scheduled: true,
|
2019-10-12 21:52:04 +05:30
|
|
|
content,
|
|
|
|
});
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
2019-10-12 21:52:04 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('does not render manual variables form', () => {
|
|
|
|
expect(findManualVarsForm().exists()).toBe(false);
|
2019-10-12 21:52:04 +05:30
|
|
|
});
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|