2020-10-24 23:57:45 +05:30
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import JobLogControllers from '~/jobs/components/job_log_controllers.vue';
|
2018-11-20 20:47:30 +05:30
|
|
|
|
|
|
|
describe('Job log controllers', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
let wrapper;
|
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
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const defaultProps = {
|
2018-12-05 23:21:45 +05:30
|
|
|
rawPath: '/raw',
|
|
|
|
erasePath: '/erase',
|
|
|
|
size: 511952,
|
|
|
|
isScrollTopDisabled: false,
|
|
|
|
isScrollBottomDisabled: false,
|
|
|
|
isScrollingDown: true,
|
|
|
|
isTraceSizeVisible: true,
|
|
|
|
};
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const createWrapper = props => {
|
|
|
|
wrapper = mount(JobLogControllers, {
|
|
|
|
propsData: {
|
|
|
|
...defaultProps,
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const findTruncatedInfo = () => wrapper.find('[data-testid="log-truncated-info"]');
|
|
|
|
const findRawLink = () => wrapper.find('[data-testid="raw-link"]');
|
|
|
|
const findRawLinkController = () => wrapper.find('[data-testid="job-raw-link-controller"]');
|
|
|
|
const findEraseLink = () => wrapper.find('[data-testid="job-log-erase-link"]');
|
|
|
|
const findScrollTop = () => wrapper.find('[data-testid="job-controller-scroll-top"]');
|
|
|
|
const findScrollBottom = () => wrapper.find('[data-testid="job-controller-scroll-bottom"]');
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
describe('Truncate information', () => {
|
|
|
|
describe('with isTraceSizeVisible', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper();
|
2018-12-05 23:21:45 +05:30
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
it('renders size information', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findTruncatedInfo().text()).toMatch('499.95 KiB');
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
it('renders link to raw trace', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findRawLink().attributes('href')).toBe(defaultProps.rawPath);
|
2018-12-05 23:21:45 +05:30
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('links section', () => {
|
|
|
|
describe('with raw trace path', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper();
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('renders raw trace link', () => {
|
|
|
|
expect(findRawLinkController().attributes('href')).toBe(defaultProps.rawPath);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without raw trace path', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
|
|
|
rawPath: null,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
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('does not render raw trace link', () => {
|
|
|
|
expect(findRawLinkController().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when is erasable', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper();
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
it('renders erase job link', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findEraseLink().exists()).toBe(true);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when it is not erasable', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
|
|
|
erasePath: null,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
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('does not render erase button', () => {
|
|
|
|
expect(findEraseLink().exists()).toBe(false);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('scroll buttons', () => {
|
|
|
|
describe('scroll top button', () => {
|
|
|
|
describe('when user can scroll top', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
|
|
|
isScrollTopDisabled: false,
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('emits scrollJobLogTop event on click', async () => {
|
|
|
|
findScrollTop().trigger('click');
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
await wrapper.vm.$nextTick();
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(wrapper.emitted().scrollJobLogTop).toHaveLength(1);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when user can not scroll top', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
2018-12-05 23:21:45 +05:30
|
|
|
isScrollTopDisabled: true,
|
|
|
|
isScrollBottomDisabled: false,
|
|
|
|
isScrollingDown: false,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders disabled scroll top button', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findScrollTop().attributes('disabled')).toBe('disabled');
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('does not emit scrollJobLogTop event on click', async () => {
|
|
|
|
findScrollTop().trigger('click');
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
|
|
|
|
expect(wrapper.emitted().scrollJobLogTop).toBeUndefined();
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('scroll bottom button', () => {
|
|
|
|
describe('when user can scroll bottom', () => {
|
|
|
|
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('emits scrollJobLogBottom event on click', async () => {
|
|
|
|
findScrollBottom().trigger('click');
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
await wrapper.vm.$nextTick();
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(wrapper.emitted().scrollJobLogBottom).toHaveLength(1);
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when user can not scroll bottom', () => {
|
|
|
|
beforeEach(() => {
|
2020-10-24 23:57:45 +05:30
|
|
|
createWrapper({
|
2018-12-05 23:21:45 +05:30
|
|
|
isScrollTopDisabled: false,
|
|
|
|
isScrollBottomDisabled: true,
|
|
|
|
isScrollingDown: false,
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders disabled scroll bottom button', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
expect(findScrollBottom().attributes('disabled')).toEqual('disabled');
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('does not emit scrollJobLogBottom event on click', async () => {
|
|
|
|
findScrollBottom().trigger('click');
|
2018-11-20 20:47:30 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
await wrapper.vm.$nextTick();
|
|
|
|
|
|
|
|
expect(wrapper.emitted().scrollJobLogBottom).toBeUndefined();
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
2018-12-05 23:21:45 +05:30
|
|
|
|
|
|
|
describe('while isScrollingDown is true', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper();
|
|
|
|
});
|
2018-12-05 23:21:45 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
it('renders animate class for the scroll down button', () => {
|
|
|
|
expect(findScrollBottom().classes()).toContain('animate');
|
2018-12-05 23:21:45 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('while isScrollingDown is false', () => {
|
2020-10-24 23:57:45 +05:30
|
|
|
beforeEach(() => {
|
|
|
|
createWrapper({
|
2018-12-05 23:21:45 +05:30
|
|
|
isScrollTopDisabled: true,
|
|
|
|
isScrollBottomDisabled: false,
|
|
|
|
isScrollingDown: false,
|
|
|
|
});
|
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 animate class for the scroll down button', () => {
|
|
|
|
expect(findScrollBottom().classes()).not.toContain('animate');
|
2018-12-05 23:21:45 +05:30
|
|
|
});
|
|
|
|
});
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|