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) => {
});
};
export const receiveUpdateValueStreamSuccess = ({ commit, dispatch }, valueStream = {}) => {
commit(types.RECEIVE_UPDATE_VALUE_STREAM_SUCCESS, valueStream);
return dispatch('fetchCycleAnalyticsData');
};
export const updateValueStream = (
{ commit, dispatch, getters },
{ id: valueStreamId, ...data },
......@@ -367,7 +362,10 @@ export const updateValueStream = (
commit(types.REQUEST_UPDATE_VALUE_STREAM);
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 } = {}) => {
const { data: { message, payload: { errors } } = null } = response;
commit(types.RECEIVE_UPDATE_VALUE_STREAM_ERROR, { message, errors, data });
......
......@@ -987,7 +987,7 @@ describe('Value Stream Analytics actions', () => {
{ ...hiddenStage, ...mockEvents },
],
};
const createResp = { id: 'new value stream', is_custom: true, ...payload };
const updateResp = { id: 'new value stream', is_custom: true, ...payload };
beforeEach(() => {
state = { currentGroup };
......@@ -995,7 +995,7 @@ describe('Value Stream Analytics actions', () => {
describe('with no errors', () => {
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`, () => {
......@@ -1004,11 +1004,10 @@ describe('Value Stream Analytics actions', () => {
payload,
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', () => {
});
it(`commits the ${types.REQUEST_UPDATE_VALUE_STREAM} and ${types.RECEIVE_UPDATE_VALUE_STREAM_ERROR} actions `, () => {
return testAction(
actions.updateValueStream,
payload,
state,
[
{ type: types.REQUEST_UPDATE_VALUE_STREAM },
{
type: types.RECEIVE_UPDATE_VALUE_STREAM_ERROR,
payload: { message, data: payload, errors },
},
],
[],
);
return testAction(actions.updateValueStream, payload, state, [
{ 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