diff options
Diffstat (limited to 'spec/frontend/jobs/store/actions_spec.js')
-rw-r--r-- | spec/frontend/jobs/store/actions_spec.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/frontend/jobs/store/actions_spec.js b/spec/frontend/jobs/store/actions_spec.js index 91bd5521f70..26547d12ac7 100644 --- a/spec/frontend/jobs/store/actions_spec.js +++ b/spec/frontend/jobs/store/actions_spec.js @@ -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'; @@ -158,6 +159,32 @@ describe('Job State actions', () => { ); }); }); + + it('fetchTrace is called only if the job has started or has a trace', done => { + mock.onGet(`${TEST_HOST}/endpoint.json`).replyOnce(200, { id: 121212, name: 'karma' }); + + mockedState.job.started = true; + + testAction( + fetchJob, + null, + mockedState, + [], + [ + { + type: 'requestJob', + }, + { + payload: { id: 121212, name: 'karma' }, + type: 'receiveJobSuccess', + }, + { + type: 'fetchTrace', + }, + ], + done, + ); + }); }); describe('receiveJobSuccess', () => { @@ -509,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, + ); + }); + }); }); |