2023-03-04 22:38:38 +05:30
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
2022-10-11 01:57:18 +05:30
|
|
|
import EmptyState from '~/jobs/components/job/empty_state.vue';
|
2023-03-04 22:38:38 +05:30
|
|
|
import ManualVariablesForm from '~/jobs/components/job/manual_variables_form.vue';
|
|
|
|
import { mockFullPath, mockId } from './mock_data';
|
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',
|
2023-03-04 22:38:38 +05:30
|
|
|
jobId: mockId,
|
2018-11-20 20:47:30 +05:30
|
|
|
title: 'This job has not started yet',
|
2019-10-12 21:52:04 +05:30
|
|
|
playable: false,
|
2023-03-04 22:38:38 +05:30
|
|
|
isRetryable: true,
|
2018-11-20 20:47:30 +05:30
|
|
|
};
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const createWrapper = (props) => {
|
2023-03-04 22:38:38 +05:30
|
|
|
wrapper = shallowMountExtended(EmptyState, {
|
2020-10-24 23:57:45 +05:30
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
...props,
|
|
|
|
},
|
2023-03-04 22:38:38 +05:30
|
|
|
provide: {
|
|
|
|
projectPath: mockFullPath,
|
|
|
|
},
|
2020-10-24 23:57:45 +05:30
|
|
|
});
|
|
|
|
};
|
|
|
|
|
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');
|
2023-03-04 22:38:38 +05:30
|
|
|
const findTitle = () => wrapper.findByTestId('job-empty-state-title');
|
|
|
|
const findContent = () => wrapper.findByTestId('job-empty-state-content');
|
|
|
|
const findAction = () => wrapper.findByTestId('job-empty-state-action');
|
|
|
|
const findManualVarsForm = () => wrapper.findComponent(ManualVariablesForm);
|
2020-10-24 23:57:45 +05:30
|
|
|
|
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
|
|
|
});
|