Commit 75f73a74 authored by Denys Mishunov's avatar Denys Mishunov

Merge branch '238969-Web-IDE-Rename-Job-Trace-To-Job-Logs' into 'master'

Rename job trace to job logs in IDE code

See merge request gitlab-org/gitlab!41522
parents dd778448 33c49265
......@@ -40,10 +40,10 @@ export default {
},
},
mounted() {
this.getTrace();
this.getLogs();
},
methods: {
...mapActions('pipelines', ['fetchJobTrace', 'setDetailJob']),
...mapActions('pipelines', ['fetchJobLogs', 'setDetailJob']),
scrollDown() {
if (this.$refs.buildTrace) {
this.$refs.buildTrace.scrollTo(0, this.$refs.buildTrace.scrollHeight);
......@@ -66,8 +66,8 @@ export default {
this.scrollPos = '';
}
}),
getTrace() {
return this.fetchJobTrace().then(() => this.scrollDown());
getLogs() {
return this.fetchJobLogs().then(() => this.scrollDown());
},
},
};
......
......@@ -118,31 +118,31 @@ export const setDetailJob = ({ commit, dispatch }, job) => {
});
};
export const requestJobTrace = ({ commit }) => commit(types.REQUEST_JOB_TRACE);
export const receiveJobTraceError = ({ commit, dispatch }) => {
export const requestJobLogs = ({ commit }) => commit(types.REQUEST_JOB_LOGS);
export const receiveJobLogsError = ({ commit, dispatch }) => {
dispatch(
'setErrorMessage',
{
text: __('An error occurred while fetching the job trace.'),
text: __('An error occurred while fetching the job logs.'),
action: () =>
dispatch('fetchJobTrace').then(() => dispatch('setErrorMessage', null, { root: true })),
dispatch('fetchJobLogs').then(() => dispatch('setErrorMessage', null, { root: true })),
actionText: __('Please try again'),
actionPayload: null,
},
{ root: true },
);
commit(types.RECEIVE_JOB_TRACE_ERROR);
commit(types.RECEIVE_JOB_LOGS_ERROR);
};
export const receiveJobTraceSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOB_TRACE_SUCCESS, data);
export const receiveJobLogsSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOB_LOGS_SUCCESS, data);
export const fetchJobTrace = ({ dispatch, state }) => {
dispatch('requestJobTrace');
export const fetchJobLogs = ({ dispatch, state }) => {
dispatch('requestJobLogs');
return axios
.get(`${state.detailJob.path}/trace`, { params: { format: 'json' } })
.then(({ data }) => dispatch('receiveJobTraceSuccess', data))
.catch(() => dispatch('receiveJobTraceError'));
.then(({ data }) => dispatch('receiveJobLogsSuccess', data))
.catch(() => dispatch('receiveJobLogsError'));
};
export const resetLatestPipeline = ({ commit }) => {
......
......@@ -10,6 +10,6 @@ export const TOGGLE_STAGE_COLLAPSE = 'TOGGLE_STAGE_COLLAPSE';
export const SET_DETAIL_JOB = 'SET_DETAIL_JOB';
export const REQUEST_JOB_TRACE = 'REQUEST_JOB_TRACE';
export const RECEIVE_JOB_TRACE_ERROR = 'RECEIVE_JOB_TRACE_ERROR';
export const RECEIVE_JOB_TRACE_SUCCESS = 'RECEIVE_JOB_TRACE_SUCCESS';
export const REQUEST_JOB_LOGS = 'REQUEST_JOB_LOGS';
export const RECEIVE_JOB_LOGS_ERROR = 'RECEIVE_JOB_LOGS_ERROR';
export const RECEIVE_JOB_LOGS_SUCCESS = 'RECEIVE_JOB_LOGS_SUCCESS';
......@@ -66,13 +66,13 @@ export default {
[types.SET_DETAIL_JOB](state, job) {
state.detailJob = { ...job };
},
[types.REQUEST_JOB_TRACE](state) {
[types.REQUEST_JOB_LOGS](state) {
state.detailJob.isLoading = true;
},
[types.RECEIVE_JOB_TRACE_ERROR](state) {
[types.RECEIVE_JOB_LOGS_ERROR](state) {
state.detailJob.isLoading = false;
},
[types.RECEIVE_JOB_TRACE_SUCCESS](state, data) {
[types.RECEIVE_JOB_LOGS_SUCCESS](state, data) {
state.detailJob.isLoading = false;
state.detailJob.output = data.html;
},
......
---
title: Rename job trace to job logs in IDE code
merge_request: 41522
author: Kev @KevSlashNull
type: other
......@@ -2708,7 +2708,7 @@ msgstr ""
msgid "An error occurred while fetching the job log."
msgstr ""
msgid "An error occurred while fetching the job trace."
msgid "An error occurred while fetching the job logs."
msgstr ""
msgid "An error occurred while fetching the job."
......
......@@ -24,7 +24,7 @@ describe('IDE jobs detail view', () => {
beforeEach(() => {
vm = createComponent();
jest.spyOn(vm, 'fetchJobTrace').mockResolvedValue();
jest.spyOn(vm, 'fetchJobLogs').mockResolvedValue();
});
afterEach(() => {
......@@ -36,8 +36,8 @@ describe('IDE jobs detail view', () => {
vm = vm.$mount();
});
it('calls fetchJobTrace', () => {
expect(vm.fetchJobTrace).toHaveBeenCalled();
it('calls fetchJobLogs', () => {
expect(vm.fetchJobLogs).toHaveBeenCalled();
});
it('scrolls to bottom', () => {
......@@ -96,7 +96,7 @@ describe('IDE jobs detail view', () => {
describe('scroll buttons', () => {
beforeEach(() => {
vm = createComponent();
jest.spyOn(vm, 'fetchJobTrace').mockResolvedValue();
jest.spyOn(vm, 'fetchJobLogs').mockResolvedValue();
});
afterEach(() => {
......
......@@ -15,10 +15,10 @@ import {
fetchJobs,
toggleStageCollapsed,
setDetailJob,
requestJobTrace,
receiveJobTraceError,
receiveJobTraceSuccess,
fetchJobTrace,
requestJobLogs,
receiveJobLogsError,
receiveJobLogsSuccess,
fetchJobLogs,
resetLatestPipeline,
} from '~/ide/stores/modules/pipelines/actions';
import state from '~/ide/stores/modules/pipelines/state';
......@@ -324,24 +324,24 @@ describe('IDE pipelines actions', () => {
});
});
describe('requestJobTrace', () => {
describe('requestJobLogs', () => {
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 => {
testAction(
receiveJobTraceError,
receiveJobLogsError,
null,
mockedState,
[{ type: types.RECEIVE_JOB_TRACE_ERROR }],
[{ type: types.RECEIVE_JOB_LOGS_ERROR }],
[
{
type: 'setErrorMessage',
payload: {
text: 'An error occurred while fetching the job trace.',
text: 'An error occurred while fetching the job logs.',
action: expect.any(Function),
actionText: 'Please try again',
actionPayload: null,
......@@ -353,20 +353,20 @@ describe('IDE pipelines actions', () => {
});
});
describe('receiveJobTraceSuccess', () => {
describe('receiveJobLogsSuccess', () => {
it('commits data', done => {
testAction(
receiveJobTraceSuccess,
receiveJobLogsSuccess,
'data',
mockedState,
[{ type: types.RECEIVE_JOB_TRACE_SUCCESS, payload: 'data' }],
[{ type: types.RECEIVE_JOB_LOGS_SUCCESS, payload: 'data' }],
[],
done,
);
});
});
describe('fetchJobTrace', () => {
describe('fetchJobLogs', () => {
beforeEach(() => {
mockedState.detailJob = { path: `${TEST_HOST}/project/builds` };
});
......@@ -379,20 +379,20 @@ describe('IDE pipelines actions', () => {
it('dispatches request', done => {
testAction(
fetchJobTrace,
fetchJobLogs,
null,
mockedState,
[],
[
{ type: 'requestJobTrace' },
{ type: 'receiveJobTraceSuccess', payload: { html: 'html' } },
{ type: 'requestJobLogs' },
{ type: 'receiveJobLogsSuccess', payload: { html: 'html' } },
],
done,
);
});
it('sends get request to correct URL', () => {
fetchJobTrace({
fetchJobLogs({
state: mockedState,
dispatch() {},
......@@ -410,11 +410,11 @@ describe('IDE pipelines actions', () => {
it('dispatches error', done => {
testAction(
fetchJobTrace,
fetchJobLogs,
null,
mockedState,
[],
[{ type: 'requestJobTrace' }, { type: 'receiveJobTraceError' }],
[{ type: 'requestJobLogs' }, { type: 'receiveJobLogsError' }],
done,
);
});
......
......@@ -175,37 +175,37 @@ describe('IDE pipelines mutations', () => {
});
});
describe('REQUEST_JOB_TRACE', () => {
describe('REQUEST_JOB_LOGS', () => {
beforeEach(() => {
mockedState.detailJob = { ...jobs[0] };
});
it('sets loading on detail job', () => {
mutations[types.REQUEST_JOB_TRACE](mockedState);
mutations[types.REQUEST_JOB_LOGS](mockedState);
expect(mockedState.detailJob.isLoading).toBe(true);
});
});
describe('RECEIVE_JOB_TRACE_ERROR', () => {
describe('RECEIVE_JOB_LOGS_ERROR', () => {
beforeEach(() => {
mockedState.detailJob = { ...jobs[0], isLoading: true };
});
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);
});
});
describe('RECEIVE_JOB_TRACE_SUCCESS', () => {
describe('RECEIVE_JOB_LOGS_SUCCESS', () => {
beforeEach(() => {
mockedState.detailJob = { ...jobs[0], isLoading: true };
});
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.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