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);
}
......
......@@ -16,7 +16,6 @@ import {
customizableStagesAndEvents,
endpoints,
} from '../mock_data';
import { shouldFlashAMessage } from '../helpers';
const stageData = { events: [] };
const error = new Error(`Request failed with status code ${httpStatusCodes.NOT_FOUND}`);
......@@ -27,10 +26,17 @@ const selectedStageSlug = selectedStage.slug;
const stageEndpoint = ({ stageId }) =>
`/groups/${selectedGroup.fullPath}/-/analytics/value_stream_analytics/stages/${stageId}`;
jest.mock('~/flash');
describe('Cycle analytics actions', () => {
let state;
let mock;
const shouldFlashAMessage = (msg, type = null) => {
const args = type ? [msg, type] : [msg];
expect(createFlash).toHaveBeenCalledWith(...args);
};
beforeEach(() => {
state = {
startDate,
......@@ -74,14 +80,13 @@ describe('Cycle analytics actions', () => {
describe('setDateRange', () => {
const payload = { startDate, endDate };
it('dispatches the fetchCycleAnalyticsData action', done => {
testAction(
it('dispatches the fetchCycleAnalyticsData action', () => {
return testAction(
actions.setDateRange,
payload,
state,
[{ type: types.SET_DATE_RANGE, payload: { startDate, endDate } }],
[{ type: 'fetchCycleAnalyticsData' }],
done,
);
});
});
......@@ -93,8 +98,8 @@ describe('Cycle analytics actions', () => {
mock.onGet(endpoints.stageData).reply(200, { events: [] });
});
it('dispatches receiveStageDataSuccess with received data on success', done => {
testAction(
it('dispatches receiveStageDataSuccess with received data on success', () => {
return testAction(
actions.fetchStageData,
selectedStageSlug,
state,
......@@ -106,7 +111,6 @@ describe('Cycle analytics actions', () => {
payload: { events: [] },
},
],
done,
);
});
......@@ -116,8 +120,8 @@ describe('Cycle analytics actions', () => {
mock.onGet(endpoints.stageData).replyOnce(httpStatusCodes.NOT_FOUND, { error });
});
it('dispatches receiveStageDataError on error', done => {
testAction(
it('dispatches receiveStageDataError on error', () => {
return testAction(
actions.fetchStageData,
selectedStage,
state,
......@@ -131,29 +135,25 @@ describe('Cycle analytics actions', () => {
payload: error,
},
],
done,
);
});
});
describe('receiveStageDataSuccess', () => {
it(`commits the ${types.RECEIVE_STAGE_DATA_SUCCESS} mutation`, done => {
testAction(
it(`commits the ${types.RECEIVE_STAGE_DATA_SUCCESS} mutation`, () => {
return testAction(
actions.receiveStageDataSuccess,
{ ...stageData },
state,
[{ type: types.RECEIVE_STAGE_DATA_SUCCESS, payload: { events: [] } }],
[],
done,
);
});
});
});
describe('receiveStageDataError', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
beforeEach(() => {});
it(`commits the ${types.RECEIVE_STAGE_DATA_ERROR} mutation`, () => {
return testAction(
actions.receiveStageDataError,
......@@ -169,10 +169,7 @@ describe('Cycle analytics actions', () => {
});
it('will flash an error message', () => {
actions.receiveStageDataError({
commit: () => {},
});
actions.receiveStageDataError({ commit: () => {} });
shouldFlashAMessage('There was an error fetching data for the selected stage');
});
});
......@@ -200,11 +197,10 @@ describe('Cycle analytics actions', () => {
}
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
state = { ...state, selectedGroup, startDate, endDate };
});
it(`dispatches actions for required value stream analytics analytics data`, done => {
it(`dispatches actions for required value stream analytics analytics data`, () => {
testAction(
actions.fetchCycleAnalyticsData,
state,
......@@ -216,11 +212,10 @@ describe('Cycle analytics actions', () => {
{ type: 'fetchStageMedianValues' },
{ type: 'receiveCycleAnalyticsDataSuccess' },
],
done,
);
});
it(`displays an error if fetchStageMedianValues fails`, done => {
it(`displays an error if fetchStageMedianValues fails`, () => {
const { mockDispatchContext } = mockFetchCycleAnalyticsAction({
fetchStageMedianValues: actions.fetchStageMedianValues({
dispatch: jest
......@@ -233,7 +228,7 @@ describe('Cycle analytics actions', () => {
}),
});
actions
return actions
.fetchCycleAnalyticsData({
dispatch: mockDispatchContext,
state: {},
......@@ -241,12 +236,10 @@ describe('Cycle analytics actions', () => {
})
.then(() => {
shouldFlashAMessage('There was an error fetching median data for stages');
done();
})
.catch(done.fail);
});
});
it(`displays an error if fetchGroupStagesAndEvents fails`, done => {
it(`displays an error if fetchGroupStagesAndEvents fails`, () => {
const { mockDispatchContext } = mockFetchCycleAnalyticsAction({
fetchGroupStagesAndEvents: actions.fetchGroupStagesAndEvents({
dispatch: jest
......@@ -259,7 +252,7 @@ describe('Cycle analytics actions', () => {
}),
});
actions
return actions
.fetchCycleAnalyticsData({
dispatch: mockDispatchContext,
state: {},
......@@ -267,61 +260,16 @@ describe('Cycle analytics actions', () => {
})
.then(() => {
shouldFlashAMessage('There was an error fetching value stream analytics stages.');
done();
})
.catch(done.fail);
});
describe('with an existing error', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
it('removes an existing flash error if present', () => {
const { mockDispatchContext } = mockFetchCycleAnalyticsAction();
createFlash(flashErrorMessage);
const flashAlert = document.querySelector('.flash-alert');
expect(flashAlert).toBeVisible();
return actions
.fetchCycleAnalyticsData({
dispatch: mockDispatchContext,
state: {},
commit: () => {},
})
.then(() => {
expect(flashAlert.style.opacity).toBe('0');
});
});
});
});
// it('will flash an error when there are no stages', () => {
// [[], null].forEach(emptyStages => {
// actions.receiveGroupStagesSuccess(
// {
// dispatch: () => {},
// commit: () => {},
// state: { stages: emptyStages },
// getters,
// },
// {},
// );
// shouldFlashAMessage(flashErrorMessage);
// });
// });
});
describe('receiveCycleAnalyticsDataError', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
beforeEach(() => {});
it(`commits the ${types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR} mutation on a 403 response`, done => {
it(`commits the ${types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR} mutation on a 403 response`, () => {
const response = { status: 403 };
testAction(
return testAction(
actions.receiveCycleAnalyticsDataError,
{ response },
state,
......@@ -332,13 +280,12 @@ describe('Cycle analytics actions', () => {
},
],
[],
done,
);
});
it(`commits the ${types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR} mutation on a non 403 error response`, done => {
it(`commits the ${types.RECEIVE_CYCLE_ANALYTICS_DATA_ERROR} mutation on a non 403 error response`, () => {
const response = { status: 500 };
testAction(
return testAction(
actions.receiveCycleAnalyticsDataError,
{ response },
state,
......@@ -349,7 +296,6 @@ describe('Cycle analytics actions', () => {
},
],
[],
done,
);
});
......@@ -367,9 +313,7 @@ describe('Cycle analytics actions', () => {
});
describe('receiveGroupStagesSuccess', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
beforeEach(() => {});
it(`commits the ${types.RECEIVE_GROUP_STAGES_SUCCESS} mutation and dispatches 'setDefaultSelectedStage'`, () => {
return testAction(
......@@ -387,7 +331,7 @@ describe('Cycle analytics actions', () => {
});
});
describe.only('setDefaultSelectedStage', () => {
describe('setDefaultSelectedStage', () => {
it("dispatches the 'fetchStageData' action", () => {
return testAction(
actions.setDefaultSelectedStage,
......@@ -403,19 +347,30 @@ describe('Cycle analytics actions', () => {
);
});
it('will flash an error when there are no stages', () => {
[[], null].forEach(emptyStages => {
actions.setDefaultSelectedStage(
{
getters: { activeStages: emptyStages },
dispatch: () => {},
},
{},
);
});
it.each`
data
${[]}
${null}
`('with $data will flash an error', ({ data }) => {
actions.setDefaultSelectedStage({ getters: { activeStages: data }, dispatch: () => {} }, {});
shouldFlashAMessage(flashErrorMessage);
});
it('will select the first active stage', () => {
stages[0].hidden = true;
return testAction(
actions.setDefaultSelectedStage,
null,
{
activeStages: getters.activeStages({ stages }),
},
[],
[
{ type: 'setSelectedStage', payload: stages[1] },
{ type: 'fetchStageData', payload: stages[1].slug },
],
);
});
});
describe('updateStage', () => {
......@@ -427,8 +382,8 @@ describe('Cycle analytics actions', () => {
state = { selectedGroup };
});
it('dispatches receiveUpdateStageSuccess with put request response data', done => {
testAction(
it('dispatches receiveUpdateStageSuccess with put request response data', () => {
return testAction(
actions.updateStage,
{
id: stageId,
......@@ -443,24 +398,22 @@ describe('Cycle analytics actions', () => {
payload,
},
],
done,
);
});
describe('with a failed request', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
mock = new MockAdapter(axios);
mock.onPut(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.NOT_FOUND);
});
it('dispatches receiveUpdateStageError', done => {
it('dispatches receiveUpdateStageError', () => {
const data = {
id: stageId,
name: 'issue',
...payload,
};
testAction(
return testAction(
actions.updateStage,
data,
state,
......@@ -475,50 +428,49 @@ describe('Cycle analytics actions', () => {
},
},
],
done,
);
});
it('flashes an error if the stage name already exists', done => {
actions.receiveUpdateStageError(
{
commit: () => {},
state,
},
{
status: httpStatusCodes.UNPROCESSABLE_ENTITY,
responseData: {
errors: { name: ['is reserved'] },
it('flashes an error if the stage name already exists', () => {
return actions
.receiveUpdateStageError(
{
commit: () => {},
dispatch: () => Promise.resolve(),
state,
},
data: {
name: stageId,
{
status: httpStatusCodes.UNPROCESSABLE_ENTITY,
responseData: {
errors: { name: ['is reserved'] },
},
data: {
name: stageId,
},
},
},
);
shouldFlashAMessage(`'${stageId}' stage already exists`);
done();
)
.then(() => {
shouldFlashAMessage(`'${stageId}' stage already exists`);
});
});
it('flashes an error message', done => {
actions.receiveUpdateStageError(
{
commit: () => {},
state,
},
{ status: httpStatusCodes.BAD_REQUEST },
);
shouldFlashAMessage('There was a problem saving your custom stage, please try again');
done();
it('flashes an error message', () => {
return actions
.receiveUpdateStageError(
{
dispatch: () => Promise.resolve(),
commit: () => {},
state,
},
{ status: httpStatusCodes.BAD_REQUEST },
)
.then(() => {
shouldFlashAMessage('There was a problem saving your custom stage, please try again');
});
});
});
describe('receiveUpdateStageSuccess', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
const response = {
title: 'NEW - COOL',
};
......@@ -532,8 +484,8 @@ describe('Cycle analytics actions', () => {
[{ type: 'fetchGroupStagesAndEvents' }, { type: 'setSelectedStage', payload: response }],
));
it('will flash a success message', () =>
actions
it('will flash a success message', () => {
return actions
.receiveUpdateStageSuccess(
{
dispatch: () => {},
......@@ -542,8 +494,9 @@ describe('Cycle analytics actions', () => {
response,
)
.then(() => {
shouldFlashAMessage('Stage data updated');
}));
shouldFlashAMessage('Stage data updated', 'notice');
});
});
describe('with an error', () => {
it('will flash an error message', () =>
......@@ -566,13 +519,12 @@ describe('Cycle analytics actions', () => {
const stageId = 'cool-stage';
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
mock.onDelete(stageEndpoint({ stageId })).replyOnce(200);
state = { selectedGroup };
});
it('dispatches receiveRemoveStageSuccess with put request response data', done => {
testAction(
it('dispatches receiveRemoveStageSuccess with put request response data', () => {
return testAction(
actions.removeStage,
stageId,
state,
......@@ -583,7 +535,6 @@ describe('Cycle analytics actions', () => {
type: 'receiveRemoveStageSuccess',
},
],
done,
);
});
......@@ -593,8 +544,8 @@ describe('Cycle analytics actions', () => {
mock.onDelete(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.NOT_FOUND);
});
it('dispatches receiveRemoveStageError', done => {
testAction(
it('dispatches receiveRemoveStageError', () => {
return testAction(
actions.removeStage,
stageId,
state,
......@@ -606,21 +557,12 @@ describe('Cycle analytics actions', () => {
payload: error,
},
],
done,
);
});
it('flashes an error message', done => {
actions.receiveRemoveStageError(
{
commit: () => {},
state,
},
{},
);
it('flashes an error message', () => {
actions.receiveRemoveStageError({ commit: () => {}, state }, {});
shouldFlashAMessage('There was an error removing your custom stage, please try again');
done();
});
});
});
......@@ -629,34 +571,31 @@ describe('Cycle analytics actions', () => {
const stageId = 'cool-stage';
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
mock.onDelete(stageEndpoint({ stageId })).replyOnce(200);
state = { selectedGroup };
});
it('dispatches fetchCycleAnalyticsData', done => {
testAction(
it('dispatches fetchCycleAnalyticsData', () => {
return testAction(
actions.receiveRemoveStageSuccess,
stageId,
state,
[{ type: 'RECEIVE_REMOVE_STAGE_RESPONSE' }],
[{ type: 'fetchCycleAnalyticsData' }],
done,
);
});
it('flashes a success message', done => {
actions.receiveRemoveStageSuccess(
{
dispatch: () => {},
commit: () => {},
state,
},
{},
);
shouldFlashAMessage('Stage removed');
done();
it('flashes a success message', () => {
return actions
.receiveRemoveStageSuccess(
{
dispatch: () => Promise.resolve(),
commit: () => {},
state,
},
{},
)
.then(() => shouldFlashAMessage('Stage removed', 'notice'));
});
});
......@@ -669,8 +608,8 @@ describe('Cycle analytics actions', () => {
mockDispatch = jest.fn();
});
it('dispatches receiveStageMedianValuesSuccess with received data on success', done => {
actions
it('dispatches receiveStageMedianValuesSuccess with received data on success', () => {
return actions
.fetchStageMedianValues({
state,
getters,
......@@ -682,9 +621,7 @@ describe('Cycle analytics actions', () => {
expect(mockDispatch).toHaveBeenCalledWith('receiveStageMedianValuesSuccess', [
{ events: [], id: selectedStageSlug },
]);
done();
})
.catch(done.fail);
});
});
describe('with a failing request', () => {
......@@ -692,8 +629,8 @@ describe('Cycle analytics actions', () => {
mock.onGet(endpoints.stageMedian).reply(httpStatusCodes.NOT_FOUND, { error });
});
it('will dispatch receiveStageMedianValuesError', done => {
actions
it('will dispatch receiveStageMedianValuesError', () => {
return actions
.fetchStageMedianValues({
state,
getters,
......@@ -703,19 +640,15 @@ describe('Cycle analytics actions', () => {
.then(() => {
expect(mockDispatch).toHaveBeenCalledWith('requestStageMedianValues');
expect(mockDispatch).toHaveBeenCalledWith('receiveStageMedianValuesError', error);
done();
})
.catch(done.fail);
});
});
});
});
describe('receiveStageMedianValuesError', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
beforeEach(() => {});
it(`commits the ${types.RECEIVE_STAGE_MEDIANS_ERROR} mutation`, done => {
it(`commits the ${types.RECEIVE_STAGE_MEDIANS_ERROR} mutation`, () => {
testAction(
actions.receiveStageMedianValuesError,
null,
......@@ -726,28 +659,23 @@ describe('Cycle analytics actions', () => {
},
],
[],
done,
);
});
it('will flash an error message', () => {
actions.receiveStageMedianValuesError({
commit: () => {},
});
actions.receiveStageMedianValuesError({ commit: () => {} });
shouldFlashAMessage('There was an error fetching median data for stages');
});
});
describe('receiveStageMedianValuesSuccess', () => {
it(`commits the ${types.RECEIVE_STAGE_MEDIANS_SUCCESS} mutation`, done => {
testAction(
it(`commits the ${types.RECEIVE_STAGE_MEDIANS_SUCCESS} mutation`, () => {
return testAction(
actions.receiveStageMedianValuesSuccess,
{ ...stageData },
state,
[{ type: types.RECEIVE_STAGE_MEDIANS_SUCCESS, payload: { events: [] } }],
[],
done,
);
});
});
......@@ -829,42 +757,48 @@ describe('Cycle analytics actions', () => {
data: { name: 'uh oh' },
};
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
beforeEach(() => {});
it('will commit the RECEIVE_CREATE_STAGE_ERROR mutation', () =>
testAction(customStageActions.receiveCreateStageError, response, state, [
{ type: customStageTypes.RECEIVE_CREATE_STAGE_ERROR, payload: { errors: {} } },
]));
it('will flash an error message', done => {
customStageActions.receiveCreateStageError(
{
commit: () => {},
},
testAction(
customStageActions.receiveCreateStageError,
response,
);
shouldFlashAMessage('There was a problem saving your custom stage, please try again');
done();
});
state,
[{ type: customStageTypes.RECEIVE_CREATE_STAGE_ERROR }],
[{ type: 'setStageFormErrors', payload: {} }],
));
describe('with a stage name error', () => {
it('will flash an error message', done => {
customStageActions.receiveCreateStageError(
it('will flash an error message', () => {
return customStageActions
.receiveCreateStageError(
{
dispatch: () => Promise.resolve(),
commit: () => {},
},
{
...response,
status: httpStatusCodes.UNPROCESSABLE_ENTITY,
errors: { name: ['is reserved'] },
},
);
response,
)
.then(() => {
shouldFlashAMessage('There was a problem saving your custom stage, please try again');
});
});
shouldFlashAMessage("'uh oh' stage already exists");
done();
describe('with a stage name error', () => {
it('will flash an error message', () => {
return customStageActions
.receiveCreateStageError(
{
dispatch: () => Promise.resolve(),
commit: () => {},
},
{
...response,
status: httpStatusCodes.UNPROCESSABLE_ENTITY,
errors: { name: ['is reserved'] },
},
)
.then(() => {
shouldFlashAMessage("'uh oh' stage already exists");
});
});
});
});
......@@ -941,14 +875,10 @@ describe('Cycle analytics actions', () => {
response,
state,
[{ type: customStageTypes.RECEIVE_CREATE_STAGE_SUCCESS }],
[{ type: 'fetchGroupStagesAndEvents' }],
[{ type: 'fetchGroupStagesAndEvents', payload: null }],
));
describe('with an error', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
it('will flash an error message', () =>
customStageActions
.receiveCreateStageSuccess(
......@@ -977,14 +907,13 @@ describe('Cycle analytics actions', () => {
mock.onPut(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.OK);
});
it(`dispatches the ${types.REQUEST_REORDER_STAGE} and ${types.RECEIVE_REORDER_STAGE_SUCCESS} actions`, done => {
testAction(
it(`dispatches the ${types.REQUEST_REORDER_STAGE} and ${types.RECEIVE_REORDER_STAGE_SUCCESS} actions`, () => {
return testAction(
actions.reorderStage,
payload,
state,
[],
[{ type: 'requestReorderStage' }, { type: 'receiveReorderStageSuccess' }],
done,
);
});
});
......@@ -994,8 +923,8 @@ describe('Cycle analytics actions', () => {
mock.onPut(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.NOT_FOUND);
});
it(`dispatches the ${types.REQUEST_REORDER_STAGE} and ${types.RECEIVE_REORDER_STAGE_ERROR} actions `, done => {
testAction(
it(`dispatches the ${types.REQUEST_REORDER_STAGE} and ${types.RECEIVE_REORDER_STAGE_ERROR} actions `, () => {
return testAction(
actions.reorderStage,
payload,
state,
......@@ -1004,19 +933,16 @@ describe('Cycle analytics actions', () => {
{ type: 'requestReorderStage' },
{ type: 'receiveReorderStageError', payload: { status: httpStatusCodes.NOT_FOUND } },
],
done,
);
});
});
});
describe('receiveReorderStageError', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
beforeEach(() => {});
it(`commits the ${types.RECEIVE_REORDER_STAGE_ERROR} mutation and flashes an error`, () => {
testAction(
return testAction(
actions.receiveReorderStageError,
null,
state,
......@@ -1026,23 +952,22 @@ describe('Cycle analytics actions', () => {
},
],
[],
);
shouldFlashAMessage(
'There was an error updating the stage order. Please try reloading the page.',
);
).then(() => {
shouldFlashAMessage(
'There was an error updating the stage order. Please try reloading the page.',
);
});
});
});
describe('receiveReorderStageSuccess', () => {
it(`commits the ${types.RECEIVE_REORDER_STAGE_SUCCESS} mutation`, done => {
testAction(
it(`commits the ${types.RECEIVE_REORDER_STAGE_SUCCESS} mutation`, () => {
return testAction(
actions.receiveReorderStageSuccess,
null,
state,
[{ type: types.RECEIVE_REORDER_STAGE_SUCCESS }],
[],
done,
);
});
});
......
......@@ -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