debian-mirror-gitlab/spec/javascripts/jobs/components/job_log_spec.js

123 lines
3.7 KiB
JavaScript
Raw Normal View History

2018-11-20 20:47:30 +05:30
import Vue from 'vue';
import component from '~/jobs/components/job_log.vue';
2018-12-13 13:39:08 +05:30
import createStore from '~/jobs/store';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import { resetStore } from '../store/helpers';
2019-09-04 21:01:54 +05:30
import { logWithCollapsibleSections } from '../mock_data';
2018-11-20 20:47:30 +05:30
describe('Job Log', () => {
const Component = Vue.extend(component);
2018-12-13 13:39:08 +05:30
let store;
2018-11-20 20:47:30 +05:30
let vm;
2018-12-13 13:39:08 +05:30
const trace =
2019-10-12 21:52:04 +05:30
'<span>Running with gitlab-runner 12.1.0 (de7731dd)<br/></span><span> on docker-auto-scale-com d5ae8d25<br/></span><div class="js-section-start fa fa-caret-down append-right-8 cursor-pointer" data-timestamp="1565502765" data-section="prepare-executor" role="button"></div><span class="section js-section-header section-header js-s-prepare-executor">Using Docker executor with image ruby:2.6 ...<br/></span>';
2018-12-13 13:39:08 +05:30
beforeEach(() => {
store = createStore();
});
2018-11-20 20:47:30 +05:30
afterEach(() => {
2018-12-13 13:39:08 +05:30
resetStore(store);
2018-11-20 20:47:30 +05:30
vm.$destroy();
});
it('renders provided trace', () => {
2018-12-13 13:39:08 +05:30
vm = mountComponentWithStore(Component, {
props: {
trace,
isComplete: true,
},
store,
2018-11-20 20:47:30 +05:30
});
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('code').textContent).toContain(
2019-10-12 21:52:04 +05:30
'Running with gitlab-runner 12.1.0 (de7731dd)',
2018-12-13 13:39:08 +05:30
);
2018-11-20 20:47:30 +05:30
});
describe('while receiving trace', () => {
it('renders animation', () => {
2018-12-13 13:39:08 +05:30
vm = mountComponentWithStore(Component, {
props: {
trace,
isComplete: false,
},
store,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-log-animation')).not.toBeNull();
});
});
describe('when build trace has finishes', () => {
it('does not render animation', () => {
2018-12-13 13:39:08 +05:30
vm = mountComponentWithStore(Component, {
props: {
trace,
isComplete: true,
},
store,
2018-11-20 20:47:30 +05:30
});
expect(vm.$el.querySelector('.js-log-animation')).toBeNull();
});
});
2019-09-04 21:01:54 +05:30
describe('Collapsible sections', () => {
beforeEach(() => {
vm = mountComponentWithStore(Component, {
props: {
trace: logWithCollapsibleSections.html,
isComplete: true,
},
store,
});
});
it('renders open arrow', () => {
expect(vm.$el.querySelector('.fa-caret-down')).not.toBeNull();
});
it('toggles hidden class to the sibilings rows when arrow is clicked', done => {
vm.$nextTick()
.then(() => {
const { section } = vm.$el.querySelector('.js-section-start').dataset;
vm.$el.querySelector('.js-section-start').click();
vm.$el.querySelectorAll(`.js-s-${section}:not(.js-section-header)`).forEach(el => {
expect(el.classList.contains('hidden')).toEqual(true);
});
vm.$el.querySelector('.js-section-start').click();
vm.$el.querySelectorAll(`.js-s-${section}:not(.js-section-header)`).forEach(el => {
expect(el.classList.contains('hidden')).toEqual(false);
});
})
.then(done)
.catch(done.fail);
});
2019-10-12 21:52:04 +05:30
it('toggles hidden class to the sibilings rows when header section is clicked', done => {
vm.$nextTick()
.then(() => {
const { section } = vm.$el.querySelector('.js-section-header').dataset;
vm.$el.querySelector('.js-section-header').click();
vm.$el.querySelectorAll(`.js-s-${section}:not(.js-section-header)`).forEach(el => {
expect(el.classList.contains('hidden')).toEqual(true);
});
vm.$el.querySelector('.js-section-header').click();
vm.$el.querySelectorAll(`.js-s-${section}:not(.js-section-header)`).forEach(el => {
expect(el.classList.contains('hidden')).toEqual(false);
});
})
.then(done)
.catch(done.fail);
});
2019-09-04 21:01:54 +05:30
});
2018-11-20 20:47:30 +05:30
});