Commit ca3b7038 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Address minor review comments

parent b128e665
...@@ -354,11 +354,6 @@ export const createValueStream = ({ commit, dispatch, getters }, data) => { ...@@ -354,11 +354,6 @@ export const createValueStream = ({ commit, dispatch, getters }, data) => {
}); });
}; };
export const receiveUpdateValueStreamSuccess = ({ commit, dispatch }, valueStream = {}) => {
commit(types.RECEIVE_UPDATE_VALUE_STREAM_SUCCESS, valueStream);
return dispatch('fetchCycleAnalyticsData');
};
export const updateValueStream = ( export const updateValueStream = (
{ commit, dispatch, getters }, { commit, dispatch, getters },
{ id: valueStreamId, ...data }, { id: valueStreamId, ...data },
...@@ -367,7 +362,10 @@ export const updateValueStream = ( ...@@ -367,7 +362,10 @@ export const updateValueStream = (
commit(types.REQUEST_UPDATE_VALUE_STREAM); commit(types.REQUEST_UPDATE_VALUE_STREAM);
return Api.cycleAnalyticsUpdateValueStream({ groupId: currentGroupPath, valueStreamId, data }) return Api.cycleAnalyticsUpdateValueStream({ groupId: currentGroupPath, valueStreamId, data })
.then(({ data: newValueStream }) => dispatch('receiveUpdateValueStreamSuccess', newValueStream)) .then(({ data: newValueStream }) => {
commit(types.RECEIVE_UPDATE_VALUE_STREAM_SUCCESS, newValueStream);
return dispatch('fetchCycleAnalyticsData');
})
.catch(({ response } = {}) => { .catch(({ response } = {}) => {
const { data: { message, payload: { errors } } = null } = response; const { data: { message, payload: { errors } } = null } = response;
commit(types.RECEIVE_UPDATE_VALUE_STREAM_ERROR, { message, errors, data }); commit(types.RECEIVE_UPDATE_VALUE_STREAM_ERROR, { message, errors, data });
......
...@@ -987,7 +987,7 @@ describe('Value Stream Analytics actions', () => { ...@@ -987,7 +987,7 @@ describe('Value Stream Analytics actions', () => {
{ ...hiddenStage, ...mockEvents }, { ...hiddenStage, ...mockEvents },
], ],
}; };
const createResp = { id: 'new value stream', is_custom: true, ...payload }; const updateResp = { id: 'new value stream', is_custom: true, ...payload };
beforeEach(() => { beforeEach(() => {
state = { currentGroup }; state = { currentGroup };
...@@ -995,7 +995,7 @@ describe('Value Stream Analytics actions', () => { ...@@ -995,7 +995,7 @@ describe('Value Stream Analytics actions', () => {
describe('with no errors', () => { describe('with no errors', () => {
beforeEach(() => { beforeEach(() => {
mock.onPut(endpoints.valueStreamData).replyOnce(httpStatusCodes.OK, createResp); mock.onPut(endpoints.valueStreamData).replyOnce(httpStatusCodes.OK, updateResp);
}); });
it(`commits the ${types.REQUEST_UPDATE_VALUE_STREAM} and ${types.RECEIVE_UPDATE_VALUE_STREAM_SUCCESS} actions`, () => { it(`commits the ${types.REQUEST_UPDATE_VALUE_STREAM} and ${types.RECEIVE_UPDATE_VALUE_STREAM_SUCCESS} actions`, () => {
...@@ -1004,11 +1004,10 @@ describe('Value Stream Analytics actions', () => { ...@@ -1004,11 +1004,10 @@ describe('Value Stream Analytics actions', () => {
payload, payload,
state, state,
[ [
{ { type: types.REQUEST_UPDATE_VALUE_STREAM },
type: types.REQUEST_UPDATE_VALUE_STREAM, { type: types.RECEIVE_UPDATE_VALUE_STREAM_SUCCESS, payload: updateResp },
},
], ],
[{ type: 'receiveUpdateValueStreamSuccess', payload: createResp }], [{ type: 'fetchCycleAnalyticsData' }],
); );
}); });
}); });
...@@ -1022,19 +1021,13 @@ describe('Value Stream Analytics actions', () => { ...@@ -1022,19 +1021,13 @@ describe('Value Stream Analytics actions', () => {
}); });
it(`commits the ${types.REQUEST_UPDATE_VALUE_STREAM} and ${types.RECEIVE_UPDATE_VALUE_STREAM_ERROR} actions `, () => { it(`commits the ${types.REQUEST_UPDATE_VALUE_STREAM} and ${types.RECEIVE_UPDATE_VALUE_STREAM_ERROR} actions `, () => {
return testAction( return testAction(actions.updateValueStream, payload, state, [
actions.updateValueStream, { type: types.REQUEST_UPDATE_VALUE_STREAM },
payload, {
state, type: types.RECEIVE_UPDATE_VALUE_STREAM_ERROR,
[ payload: { message, data: payload, errors },
{ type: types.REQUEST_UPDATE_VALUE_STREAM }, },
{ ]);
type: types.RECEIVE_UPDATE_VALUE_STREAM_ERROR,
payload: { message, data: payload, errors },
},
],
[],
);
}); });
}); });
}); });
......
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