Commit 7942ba3e authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Additional clean up for existing specs

Minor fixes and cleanup for the
cycle analytics store specs

Fix base_spec tests
parent 13d0fd61
......@@ -133,16 +133,19 @@ export const setDefaultSelectedStage = ({ dispatch, getters }) => {
const { activeStages = [] } = getters;
if (activeStages && activeStages.length) {
const [firstActiveStage] = activeStages;
dispatch('setSelectedStage', firstActiveStage);
dispatch('fetchStageData', firstActiveStage.slug);
} else {
createFlash(__('There was an error while fetching value stream analytics data.'));
return Promise.all([
dispatch('setSelectedStage', firstActiveStage),
dispatch('fetchStageData', firstActiveStage.slug),
]);
}
createFlash(__('There was an error while fetching value stream analytics data.'));
return Promise.resolve();
};
export const receiveGroupStagesSuccess = ({ commit, dispatch }, stages) => {
commit(types.RECEIVE_GROUP_STAGES_SUCCESS, stages);
dispatch('setDefaultSelectedStage');
return dispatch('setDefaultSelectedStage');
};
export const fetchGroupStagesAndEvents = ({ state, dispatch, getters }) => {
......@@ -197,8 +200,8 @@ export const receiveUpdateStageError = (
? sprintf(__(`'%{name}' stage already exists`), { name })
: __('There was a problem saving your custom stage, please try again');
dispatch('customStages/setStageFormErrors', errors);
createFlash(__(message));
return dispatch('customStages/setStageFormErrors', errors);
};
export const updateStage = ({ dispatch, state }, { id, ...rest }) => {
......@@ -219,7 +222,7 @@ export const requestRemoveStage = ({ commit }) => commit(types.REQUEST_REMOVE_ST
export const receiveRemoveStageSuccess = ({ commit, dispatch }) => {
commit(types.RECEIVE_REMOVE_STAGE_RESPONSE);
createFlash(__('Stage removed'), 'notice');
dispatch('fetchCycleAnalyticsData');
return dispatch('fetchCycleAnalyticsData');
};
export const receiveRemoveStageError = ({ commit }) => {
......
......@@ -60,9 +60,8 @@ export const receiveCreateStageSuccess = ({ commit, dispatch }, { data: { title
createFlash(sprintf(__(`Your custom stage '%{title}' was created`), { title }), 'notice');
return Promise.resolve()
.then(() => dispatch('fetchGroupStagesAndEvents'))
.catch(err => {
console.log('err', err);
.then(() => dispatch('fetchGroupStagesAndEvents', null, { root: true }))
.catch(() => {
createFlash(__('There was a problem refreshing the data, please try again'));
});
};
......@@ -78,14 +77,15 @@ export const receiveCreateStageError = (
? sprintf(__(`'%{name}' stage already exists`), { name })
: __('There was a problem saving your custom stage, please try again');
dispatch('setStageFormErrors', errors);
createFlash(flashMessage);
return dispatch('setStageFormErrors', errors);
};
export const createStage = ({ dispatch, state }, data) => {
export const createStage = ({ dispatch, rootState }, data) => {
const {
selectedGroup: { fullPath },
} = state;
} = rootState;
dispatch('requestCreateStage');
return Api.cycleAnalyticsCreateStage(fullPath, data)
......
......@@ -85,9 +85,10 @@ function createComponent({
...selectedGroup,
});
comp.vm.$store.dispatch('receiveGroupStagesSuccess', {
...mockData.customizableStagesAndEvents.stages,
});
comp.vm.$store.dispatch(
'receiveGroupStagesSuccess',
mockData.customizableStagesAndEvents.stages,
);
comp.vm.$store.dispatch('receiveStageDataSuccess', mockData.issueEvents);
}
......
......@@ -5,8 +5,6 @@ import * as customStageTypes from 'ee/analytics/cycle_analytics/store/modules/cu
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import {
rawIssueEvents,
issueEvents as transformedEvents,
issueStage,
planStage,
codeStage,
......
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