Commit 13522720 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'pb-job-trace-poll-manual-job' into 'master'

Fix manual job trace polling

See merge request gitlab-org/gitlab!49752
parents 10ece9b2 053ffe1c
......@@ -90,7 +90,7 @@ export const fetchJob = ({ state, dispatch }) => {
if (!Visibility.hidden()) {
// This check is needed to ensure the loading icon
// is not shown for a finished job during a visibility change
if (!isTraceReadyForRender) {
if (!isTraceReadyForRender && state.job.started) {
dispatch('startPollingTrace');
}
dispatch('restartPolling');
......@@ -258,7 +258,7 @@ export const receiveJobsForStageError = ({ commit }) => {
flash(__('An error occurred while fetching the jobs.'));
};
export const triggerManualJob = ({ state }, variables) => {
export const triggerManualJob = ({ state, dispatch }, variables) => {
const parsedVariables = variables.map(variable => {
const copyVar = { ...variable };
delete copyVar.id;
......@@ -269,5 +269,6 @@ export const triggerManualJob = ({ state }, variables) => {
.post(state.job.status.action.path, {
job_variables_attributes: parsedVariables,
})
.then(() => dispatch('fetchTrace'))
.catch(() => flash(__('An error occurred while triggering the job.')));
};
......@@ -27,6 +27,7 @@ import {
hideSidebar,
showSidebar,
toggleSidebar,
triggerManualJob,
} from '~/jobs/store/actions';
import state from '~/jobs/store/state';
import * as types from '~/jobs/store/mutation_types';
......@@ -535,4 +536,43 @@ describe('Job State actions', () => {
);
});
});
describe('triggerManualJob', () => {
let mock;
beforeEach(() => {
mock = new MockAdapter(axios);
});
afterEach(() => {
mock.restore();
});
it('should dispatch fetchTrace', done => {
const playManualJobEndpoint = `${TEST_HOST}/manual-job/jobs/1000/play`;
mock.onPost(playManualJobEndpoint).reply(200);
mockedState.job = {
status: {
action: {
path: playManualJobEndpoint,
},
},
};
testAction(
triggerManualJob,
[{ id: '1', key: 'test_var', secret_value: 'test_value' }],
mockedState,
[],
[
{
type: 'fetchTrace',
},
],
done,
);
});
});
});
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