Commit 053ffe1c authored by pburdette's avatar pburdette

Fix manual job polling

Manual job is polling when
it is not started. Also fetchTrace
on manual trigger action to show trace
soon.
parent 628f756f
...@@ -90,7 +90,7 @@ export const fetchJob = ({ state, dispatch }) => { ...@@ -90,7 +90,7 @@ export const fetchJob = ({ state, dispatch }) => {
if (!Visibility.hidden()) { if (!Visibility.hidden()) {
// This check is needed to ensure the loading icon // This check is needed to ensure the loading icon
// is not shown for a finished job during a visibility change // is not shown for a finished job during a visibility change
if (!isTraceReadyForRender) { if (!isTraceReadyForRender && state.job.started) {
dispatch('startPollingTrace'); dispatch('startPollingTrace');
} }
dispatch('restartPolling'); dispatch('restartPolling');
...@@ -258,7 +258,7 @@ export const receiveJobsForStageError = ({ commit }) => { ...@@ -258,7 +258,7 @@ export const receiveJobsForStageError = ({ commit }) => {
flash(__('An error occurred while fetching the jobs.')); 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 parsedVariables = variables.map(variable => {
const copyVar = { ...variable }; const copyVar = { ...variable };
delete copyVar.id; delete copyVar.id;
...@@ -269,5 +269,6 @@ export const triggerManualJob = ({ state }, variables) => { ...@@ -269,5 +269,6 @@ export const triggerManualJob = ({ state }, variables) => {
.post(state.job.status.action.path, { .post(state.job.status.action.path, {
job_variables_attributes: parsedVariables, job_variables_attributes: parsedVariables,
}) })
.then(() => dispatch('fetchTrace'))
.catch(() => flash(__('An error occurred while triggering the job.'))); .catch(() => flash(__('An error occurred while triggering the job.')));
}; };
...@@ -27,6 +27,7 @@ import { ...@@ -27,6 +27,7 @@ import {
hideSidebar, hideSidebar,
showSidebar, showSidebar,
toggleSidebar, toggleSidebar,
triggerManualJob,
} from '~/jobs/store/actions'; } from '~/jobs/store/actions';
import state from '~/jobs/store/state'; import state from '~/jobs/store/state';
import * as types from '~/jobs/store/mutation_types'; import * as types from '~/jobs/store/mutation_types';
...@@ -535,4 +536,43 @@ describe('Job State actions', () => { ...@@ -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