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