Commit 7bde505d authored by Kev's avatar Kev

Replace 'job trace' with 'job logs' in IDE code

parent e25d35f7
...@@ -43,7 +43,7 @@ export default { ...@@ -43,7 +43,7 @@ export default {
this.getTrace(); this.getTrace();
}, },
methods: { methods: {
...mapActions('pipelines', ['fetchJobTrace', 'setDetailJob']), ...mapActions('pipelines', ['fetchJobLogs', 'setDetailJob']),
scrollDown() { scrollDown() {
if (this.$refs.buildTrace) { if (this.$refs.buildTrace) {
this.$refs.buildTrace.scrollTo(0, this.$refs.buildTrace.scrollHeight); this.$refs.buildTrace.scrollTo(0, this.$refs.buildTrace.scrollHeight);
...@@ -67,7 +67,7 @@ export default { ...@@ -67,7 +67,7 @@ export default {
} }
}), }),
getTrace() { getTrace() {
return this.fetchJobTrace().then(() => this.scrollDown()); return this.fetchJobLogs().then(() => this.scrollDown());
}, },
}, },
}; };
......
...@@ -118,31 +118,31 @@ export const setDetailJob = ({ commit, dispatch }, job) => { ...@@ -118,31 +118,31 @@ export const setDetailJob = ({ commit, dispatch }, job) => {
}); });
}; };
export const requestJobTrace = ({ commit }) => commit(types.REQUEST_JOB_TRACE); export const requestJobLogs = ({ commit }) => commit(types.REQUEST_JOB_LOGS);
export const receiveJobTraceError = ({ commit, dispatch }) => { export const receiveJobLogsError = ({ commit, dispatch }) => {
dispatch( dispatch(
'setErrorMessage', 'setErrorMessage',
{ {
text: __('An error occurred while fetching the job trace.'), text: __('An error occurred while fetching the job trace.'),
action: () => action: () =>
dispatch('fetchJobTrace').then(() => dispatch('setErrorMessage', null, { root: true })), dispatch('fetchJobLogs').then(() => dispatch('setErrorMessage', null, { root: true })),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: null, actionPayload: null,
}, },
{ root: true }, { root: true },
); );
commit(types.RECEIVE_JOB_TRACE_ERROR); commit(types.RECEIVE_JOB_LOGS_ERROR);
}; };
export const receiveJobTraceSuccess = ({ commit }, data) => export const receiveJobLogsSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOB_TRACE_SUCCESS, data); commit(types.RECEIVE_JOB_LOGS_SUCCESS, data);
export const fetchJobTrace = ({ dispatch, state }) => { export const fetchJobLogs = ({ dispatch, state }) => {
dispatch('requestJobTrace'); dispatch('requestJobLogs');
return axios return axios
.get(`${state.detailJob.path}/trace`, { params: { format: 'json' } }) .get(`${state.detailJob.path}/trace`, { params: { format: 'json' } })
.then(({ data }) => dispatch('receiveJobTraceSuccess', data)) .then(({ data }) => dispatch('receiveJobLogsSuccess', data))
.catch(() => dispatch('receiveJobTraceError')); .catch(() => dispatch('receiveJobLogsError'));
}; };
export const resetLatestPipeline = ({ commit }) => { export const resetLatestPipeline = ({ commit }) => {
......
...@@ -10,6 +10,6 @@ export const TOGGLE_STAGE_COLLAPSE = 'TOGGLE_STAGE_COLLAPSE'; ...@@ -10,6 +10,6 @@ export const TOGGLE_STAGE_COLLAPSE = 'TOGGLE_STAGE_COLLAPSE';
export const SET_DETAIL_JOB = 'SET_DETAIL_JOB'; export const SET_DETAIL_JOB = 'SET_DETAIL_JOB';
export const REQUEST_JOB_TRACE = 'REQUEST_JOB_TRACE'; export const REQUEST_JOB_LOGS = 'REQUEST_JOB_LOGS';
export const RECEIVE_JOB_TRACE_ERROR = 'RECEIVE_JOB_TRACE_ERROR'; export const RECEIVE_JOB_LOGS_ERROR = 'RECEIVE_JOB_LOGS_ERROR';
export const RECEIVE_JOB_TRACE_SUCCESS = 'RECEIVE_JOB_TRACE_SUCCESS'; export const RECEIVE_JOB_LOGS_SUCCESS = 'RECEIVE_JOB_LOGS_SUCCESS';
...@@ -66,13 +66,13 @@ export default { ...@@ -66,13 +66,13 @@ export default {
[types.SET_DETAIL_JOB](state, job) { [types.SET_DETAIL_JOB](state, job) {
state.detailJob = { ...job }; state.detailJob = { ...job };
}, },
[types.REQUEST_JOB_TRACE](state) { [types.REQUEST_JOB_LOGS](state) {
state.detailJob.isLoading = true; state.detailJob.isLoading = true;
}, },
[types.RECEIVE_JOB_TRACE_ERROR](state) { [types.RECEIVE_JOB_LOGS_ERROR](state) {
state.detailJob.isLoading = false; state.detailJob.isLoading = false;
}, },
[types.RECEIVE_JOB_TRACE_SUCCESS](state, data) { [types.RECEIVE_JOB_LOGS_SUCCESS](state, data) {
state.detailJob.isLoading = false; state.detailJob.isLoading = false;
state.detailJob.output = data.html; state.detailJob.output = data.html;
}, },
......
...@@ -24,7 +24,7 @@ describe('IDE jobs detail view', () => { ...@@ -24,7 +24,7 @@ describe('IDE jobs detail view', () => {
beforeEach(() => { beforeEach(() => {
vm = createComponent(); vm = createComponent();
jest.spyOn(vm, 'fetchJobTrace').mockResolvedValue(); jest.spyOn(vm, 'fetchJobLogs').mockResolvedValue();
}); });
afterEach(() => { afterEach(() => {
...@@ -36,8 +36,8 @@ describe('IDE jobs detail view', () => { ...@@ -36,8 +36,8 @@ describe('IDE jobs detail view', () => {
vm = vm.$mount(); vm = vm.$mount();
}); });
it('calls fetchJobTrace', () => { it('calls fetchJobLogs', () => {
expect(vm.fetchJobTrace).toHaveBeenCalled(); expect(vm.fetchJobLogs).toHaveBeenCalled();
}); });
it('scrolls to bottom', () => { it('scrolls to bottom', () => {
...@@ -96,7 +96,7 @@ describe('IDE jobs detail view', () => { ...@@ -96,7 +96,7 @@ describe('IDE jobs detail view', () => {
describe('scroll buttons', () => { describe('scroll buttons', () => {
beforeEach(() => { beforeEach(() => {
vm = createComponent(); vm = createComponent();
jest.spyOn(vm, 'fetchJobTrace').mockResolvedValue(); jest.spyOn(vm, 'fetchJobLogs').mockResolvedValue();
}); });
afterEach(() => { afterEach(() => {
......
...@@ -15,10 +15,10 @@ import { ...@@ -15,10 +15,10 @@ import {
fetchJobs, fetchJobs,
toggleStageCollapsed, toggleStageCollapsed,
setDetailJob, setDetailJob,
requestJobTrace, requestJobLogs,
receiveJobTraceError, receiveJobLogsError,
receiveJobTraceSuccess, receiveJobLogsSuccess,
fetchJobTrace, fetchJobLogs,
resetLatestPipeline, resetLatestPipeline,
} from '~/ide/stores/modules/pipelines/actions'; } from '~/ide/stores/modules/pipelines/actions';
import state from '~/ide/stores/modules/pipelines/state'; import state from '~/ide/stores/modules/pipelines/state';
...@@ -324,19 +324,19 @@ describe('IDE pipelines actions', () => { ...@@ -324,19 +324,19 @@ describe('IDE pipelines actions', () => {
}); });
}); });
describe('requestJobTrace', () => { describe('requestJobLogs', () => {
it('commits request', done => { it('commits request', done => {
testAction(requestJobTrace, null, mockedState, [{ type: types.REQUEST_JOB_TRACE }], [], done); testAction(requestJobLogs, null, mockedState, [{ type: types.REQUEST_JOB_LOGS }], [], done);
}); });
}); });
describe('receiveJobTraceError', () => { describe('receiveJobLogsError', () => {
it('commits error', done => { it('commits error', done => {
testAction( testAction(
receiveJobTraceError, receiveJobLogsError,
null, null,
mockedState, mockedState,
[{ type: types.RECEIVE_JOB_TRACE_ERROR }], [{ type: types.RECEIVE_JOB_LOGS_ERROR }],
[ [
{ {
type: 'setErrorMessage', type: 'setErrorMessage',
...@@ -353,20 +353,20 @@ describe('IDE pipelines actions', () => { ...@@ -353,20 +353,20 @@ describe('IDE pipelines actions', () => {
}); });
}); });
describe('receiveJobTraceSuccess', () => { describe('receiveJobLogsSuccess', () => {
it('commits data', done => { it('commits data', done => {
testAction( testAction(
receiveJobTraceSuccess, receiveJobLogsSuccess,
'data', 'data',
mockedState, mockedState,
[{ type: types.RECEIVE_JOB_TRACE_SUCCESS, payload: 'data' }], [{ type: types.RECEIVE_JOB_LOGS_SUCCESS, payload: 'data' }],
[], [],
done, done,
); );
}); });
}); });
describe('fetchJobTrace', () => { describe('fetchJobLogs', () => {
beforeEach(() => { beforeEach(() => {
mockedState.detailJob = { path: `${TEST_HOST}/project/builds` }; mockedState.detailJob = { path: `${TEST_HOST}/project/builds` };
}); });
...@@ -379,20 +379,20 @@ describe('IDE pipelines actions', () => { ...@@ -379,20 +379,20 @@ describe('IDE pipelines actions', () => {
it('dispatches request', done => { it('dispatches request', done => {
testAction( testAction(
fetchJobTrace, fetchJobLogs,
null, null,
mockedState, mockedState,
[], [],
[ [
{ type: 'requestJobTrace' }, { type: 'requestJobLogs' },
{ type: 'receiveJobTraceSuccess', payload: { html: 'html' } }, { type: 'receiveJobLogsSuccess', payload: { html: 'html' } },
], ],
done, done,
); );
}); });
it('sends get request to correct URL', () => { it('sends get request to correct URL', () => {
fetchJobTrace({ fetchJobLogs({
state: mockedState, state: mockedState,
dispatch() {}, dispatch() {},
...@@ -410,11 +410,11 @@ describe('IDE pipelines actions', () => { ...@@ -410,11 +410,11 @@ describe('IDE pipelines actions', () => {
it('dispatches error', done => { it('dispatches error', done => {
testAction( testAction(
fetchJobTrace, fetchJobLogs,
null, null,
mockedState, mockedState,
[], [],
[{ type: 'requestJobTrace' }, { type: 'receiveJobTraceError' }], [{ type: 'requestJobLogs' }, { type: 'receiveJobLogsError' }],
done, done,
); );
}); });
......
...@@ -175,37 +175,37 @@ describe('IDE pipelines mutations', () => { ...@@ -175,37 +175,37 @@ describe('IDE pipelines mutations', () => {
}); });
}); });
describe('REQUEST_JOB_TRACE', () => { describe('REQUEST_JOB_LOGS', () => {
beforeEach(() => { beforeEach(() => {
mockedState.detailJob = { ...jobs[0] }; mockedState.detailJob = { ...jobs[0] };
}); });
it('sets loading on detail job', () => { it('sets loading on detail job', () => {
mutations[types.REQUEST_JOB_TRACE](mockedState); mutations[types.REQUEST_JOB_LOGS](mockedState);
expect(mockedState.detailJob.isLoading).toBe(true); expect(mockedState.detailJob.isLoading).toBe(true);
}); });
}); });
describe('RECEIVE_JOB_TRACE_ERROR', () => { describe('RECEIVE_JOB_LOGS_ERROR', () => {
beforeEach(() => { beforeEach(() => {
mockedState.detailJob = { ...jobs[0], isLoading: true }; mockedState.detailJob = { ...jobs[0], isLoading: true };
}); });
it('sets loading to false on detail job', () => { it('sets loading to false on detail job', () => {
mutations[types.RECEIVE_JOB_TRACE_ERROR](mockedState); mutations[types.RECEIVE_JOB_LOGS_ERROR](mockedState);
expect(mockedState.detailJob.isLoading).toBe(false); expect(mockedState.detailJob.isLoading).toBe(false);
}); });
}); });
describe('RECEIVE_JOB_TRACE_SUCCESS', () => { describe('RECEIVE_JOB_LOGS_SUCCESS', () => {
beforeEach(() => { beforeEach(() => {
mockedState.detailJob = { ...jobs[0], isLoading: true }; mockedState.detailJob = { ...jobs[0], isLoading: true };
}); });
it('sets output on detail job', () => { it('sets output on detail job', () => {
mutations[types.RECEIVE_JOB_TRACE_SUCCESS](mockedState, { html: 'html' }); mutations[types.RECEIVE_JOB_LOGS_SUCCESS](mockedState, { html: 'html' });
expect(mockedState.detailJob.output).toBe('html'); expect(mockedState.detailJob.output).toBe('html');
expect(mockedState.detailJob.isLoading).toBe(false); expect(mockedState.detailJob.isLoading).toBe(false);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment