diff options
Diffstat (limited to 'spec/frontend/jobs')
-rw-r--r-- | spec/frontend/jobs/components/job_app_spec.js | 148 | ||||
-rw-r--r-- | spec/frontend/jobs/components/job_log_spec.js | 65 | ||||
-rw-r--r-- | spec/frontend/jobs/components/log/collapsible_section_spec.js | 4 | ||||
-rw-r--r-- | spec/frontend/jobs/store/mutations_spec.js | 25 | ||||
-rw-r--r-- | spec/frontend/jobs/store/utils_spec.js | 4 |
5 files changed, 34 insertions, 212 deletions
diff --git a/spec/frontend/jobs/components/job_app_spec.js b/spec/frontend/jobs/components/job_app_spec.js index 8fa289bbe4d..d0b3d4f6247 100644 --- a/spec/frontend/jobs/components/job_app_spec.js +++ b/spec/frontend/jobs/components/job_app_spec.js @@ -6,6 +6,7 @@ import axios from '~/lib/utils/axios_utils'; import JobApp from '~/jobs/components/job_app.vue'; import createStore from '~/jobs/store'; import job from '../mock_data'; +import { TEST_HOST } from 'jest/helpers/test_constants'; describe('Job App', () => { const localVue = createLocalVue(); @@ -18,8 +19,8 @@ describe('Job App', () => { let mock; const initSettings = { - endpoint: `${gl.TEST_HOST}jobs/123.json`, - pagePath: `${gl.TEST_HOST}jobs/123`, + endpoint: `${TEST_HOST}jobs/123.json`, + pagePath: `${TEST_HOST}jobs/123`, logState: 'eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D', }; @@ -397,132 +398,31 @@ describe('Job App', () => { }); }); - describe('trace output', () => { - describe('with append flag', () => { - it('appends the log content to the existing one', () => - setupAndMount({ - traceData: { - html: '<span>More<span>', - status: 'running', - state: 'newstate', - append: true, - complete: true, - }, - }) - .then(() => { - store.state.trace = 'Update'; - - return wrapper.vm.$nextTick(); - }) - .then(() => { - expect( - wrapper - .find('.js-build-trace') - .text() - .trim(), - ).toEqual('Update'); - })); + describe('trace controls', () => { + beforeEach(() => + setupAndMount({ + traceData: { + html: '<span>Update</span>', + status: 'success', + append: false, + size: 50, + total: 100, + complete: true, + }, + }), + ); + + it('should render scroll buttons', () => { + expect(wrapper.find('.js-scroll-top').exists()).toBe(true); + expect(wrapper.find('.js-scroll-bottom').exists()).toBe(true); }); - describe('without append flag', () => { - it('replaces the trace', () => - setupAndMount({ - traceData: { - html: '<span>Different<span>', - status: 'running', - append: false, - complete: true, - }, - }).then(() => { - expect( - wrapper - .find('.js-build-trace') - .text() - .trim(), - ).toEqual('Different'); - })); - }); - - describe('truncated information', () => { - describe('when size is less than total', () => { - it('shows information about truncated log', () => { - mock.onGet(`${props.pagePath}/trace.json`).reply(200, { - html: '<span>Update</span>', - status: 'success', - append: false, - size: 50, - total: 100, - complete: true, - }); - - return setupAndMount({ - traceData: { - html: '<span>Update</span>', - status: 'success', - append: false, - size: 50, - total: 100, - complete: true, - }, - }).then(() => { - expect( - wrapper - .find('.js-truncated-info') - .text() - .trim(), - ).toContain('Showing last 50 bytes'); - }); - }); - }); - - describe('when size is equal than total', () => { - it('does not show the truncated information', () => - setupAndMount({ - traceData: { - html: '<span>Update</span>', - status: 'success', - append: false, - size: 100, - total: 100, - complete: true, - }, - }).then(() => { - expect( - wrapper - .find('.js-truncated-info') - .text() - .trim(), - ).toEqual(''); - })); - }); + it('should render link to raw ouput', () => { + expect(wrapper.find('.js-raw-link-controller').exists()).toBe(true); }); - describe('trace controls', () => { - beforeEach(() => - setupAndMount({ - traceData: { - html: '<span>Update</span>', - status: 'success', - append: false, - size: 50, - total: 100, - complete: true, - }, - }), - ); - - it('should render scroll buttons', () => { - expect(wrapper.find('.js-scroll-top').exists()).toBe(true); - expect(wrapper.find('.js-scroll-bottom').exists()).toBe(true); - }); - - it('should render link to raw ouput', () => { - expect(wrapper.find('.js-raw-link-controller').exists()).toBe(true); - }); - - it('should render link to erase job', () => { - expect(wrapper.find('.js-erase-link').exists()).toBe(true); - }); + it('should render link to erase job', () => { + expect(wrapper.find('.js-erase-link').exists()).toBe(true); }); }); }); diff --git a/spec/frontend/jobs/components/job_log_spec.js b/spec/frontend/jobs/components/job_log_spec.js deleted file mode 100644 index a167fe8a134..00000000000 --- a/spec/frontend/jobs/components/job_log_spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import Vue from 'vue'; -import { mountComponentWithStore } from 'helpers/vue_mount_component_helper'; -import component from '~/jobs/components/job_log.vue'; -import createStore from '~/jobs/store'; -import { resetStore } from '../store/helpers'; - -describe('Job Log', () => { - const Component = Vue.extend(component); - let store; - let vm; - - const trace = - '<span>Running with gitlab-runner 12.1.0 (de7731dd)<br/></span><span> on docker-auto-scale-com d5ae8d25<br/></span><div class="gl-mr-3" data-timestamp="1565502765" data-section="prepare-executor" role="button"></div><span class="section section-header js-s-prepare-executor">Using Docker executor with image ruby:2.6 ...<br/></span>'; - - beforeEach(() => { - store = createStore(); - }); - - afterEach(() => { - resetStore(store); - vm.$destroy(); - }); - - it('renders provided trace', () => { - vm = mountComponentWithStore(Component, { - props: { - trace, - isComplete: true, - }, - store, - }); - - expect(vm.$el.querySelector('code').textContent).toContain( - 'Running with gitlab-runner 12.1.0 (de7731dd)', - ); - }); - - describe('while receiving trace', () => { - it('renders animation', () => { - vm = mountComponentWithStore(Component, { - props: { - trace, - isComplete: false, - }, - store, - }); - - expect(vm.$el.querySelector('.js-log-animation')).not.toBeNull(); - }); - }); - - describe('when build trace has finishes', () => { - it('does not render animation', () => { - vm = mountComponentWithStore(Component, { - props: { - trace, - isComplete: true, - }, - store, - }); - - expect(vm.$el.querySelector('.js-log-animation')).toBeNull(); - }); - }); -}); diff --git a/spec/frontend/jobs/components/log/collapsible_section_spec.js b/spec/frontend/jobs/components/log/collapsible_section_spec.js index 3a16521a986..bf2f8c05806 100644 --- a/spec/frontend/jobs/components/log/collapsible_section_spec.js +++ b/spec/frontend/jobs/components/log/collapsible_section_spec.js @@ -1,5 +1,5 @@ import { mount } from '@vue/test-utils'; -import CollpasibleSection from '~/jobs/components/log/collapsible_section.vue'; +import CollapsibleSection from '~/jobs/components/log/collapsible_section.vue'; import { collapsibleSectionClosed, collapsibleSectionOpened } from './mock_data'; describe('Job Log Collapsible Section', () => { @@ -11,7 +11,7 @@ describe('Job Log Collapsible Section', () => { const findCollapsibleLineSvg = () => wrapper.find('.collapsible-line svg'); const createComponent = (props = {}) => { - wrapper = mount(CollpasibleSection, { + wrapper = mount(CollapsibleSection, { propsData: { ...props, }, diff --git a/spec/frontend/jobs/store/mutations_spec.js b/spec/frontend/jobs/store/mutations_spec.js index 3557d3b94b6..608abc8f7c4 100644 --- a/spec/frontend/jobs/store/mutations_spec.js +++ b/spec/frontend/jobs/store/mutations_spec.js @@ -76,28 +76,15 @@ describe('Jobs Store Mutations', () => { lines: [], }); - expect(stateCopy.trace).toEqual(html); expect(stateCopy.traceSize).toEqual(511846); expect(stateCopy.isTraceComplete).toEqual(true); }); describe('with new job log', () => { - let stateWithNewLog; - beforeEach(() => { - gon.features = gon.features || {}; - gon.features.jobLogJson = true; - - stateWithNewLog = state(); - }); - - afterEach(() => { - gon.features.jobLogJson = false; - }); - describe('log.lines', () => { describe('when append is true', () => { it('sets the parsed log ', () => { - mutations[types.RECEIVE_TRACE_SUCCESS](stateWithNewLog, { + mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { append: true, size: 511846, complete: true, @@ -109,7 +96,7 @@ describe('Jobs Store Mutations', () => { ], }); - expect(stateWithNewLog.trace).toEqual([ + expect(stateCopy.trace).toEqual([ { offset: 1, content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }], @@ -121,7 +108,7 @@ describe('Jobs Store Mutations', () => { describe('when it is defined', () => { it('sets the parsed log ', () => { - mutations[types.RECEIVE_TRACE_SUCCESS](stateWithNewLog, { + mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { append: false, size: 511846, complete: true, @@ -130,7 +117,7 @@ describe('Jobs Store Mutations', () => { ], }); - expect(stateWithNewLog.trace).toEqual([ + expect(stateCopy.trace).toEqual([ { offset: 0, content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }], @@ -142,7 +129,7 @@ describe('Jobs Store Mutations', () => { describe('when it is null', () => { it('sets the default value', () => { - mutations[types.RECEIVE_TRACE_SUCCESS](stateWithNewLog, { + mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { append: true, html, size: 511846, @@ -150,7 +137,7 @@ describe('Jobs Store Mutations', () => { lines: null, }); - expect(stateWithNewLog.trace).toEqual([]); + expect(stateCopy.trace).toEqual([]); }); }); }); diff --git a/spec/frontend/jobs/store/utils_spec.js b/spec/frontend/jobs/store/utils_spec.js index 8819f39dee0..294f88bbc74 100644 --- a/spec/frontend/jobs/store/utils_spec.js +++ b/spec/frontend/jobs/store/utils_spec.js @@ -181,7 +181,7 @@ describe('Jobs Store Utils', () => { }); }); - describe('collpasible section', () => { + describe('collapsible section', () => { it('adds a `isClosed` property', () => { expect(result[1].isClosed).toEqual(false); }); @@ -190,7 +190,7 @@ describe('Jobs Store Utils', () => { expect(result[1].isHeader).toEqual(true); }); - it('creates a lines array property with the content of the collpasible section', () => { + it('creates a lines array property with the content of the collapsible section', () => { expect(result[1].lines.length).toEqual(2); expect(result[1].lines[0].content).toEqual(utilsMockData[2].content); expect(result[1].lines[1].content).toEqual(utilsMockData[3].content); |