Commit 4cf5d287 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Update VSA action specs

Updates the routes used in the VSA
actions to ensure they now include
the selected value stream
parent fbe3c417
...@@ -106,7 +106,7 @@ export default { ...@@ -106,7 +106,7 @@ export default {
shouldDisplayTypeOfWorkCharts() { shouldDisplayTypeOfWorkCharts() {
return !this.hasNoAccessError && !this.isLoading; return !this.hasNoAccessError && !this.isLoading;
}, },
shouldDsiplayPathNavigation() { shouldDisplayPathNavigation() {
return this.featureFlags.hasPathNavigation && !this.hasNoAccessError && this.selectedStage; return this.featureFlags.hasPathNavigation && !this.hasNoAccessError && this.selectedStage;
}, },
shouldDisplayFilterBar() { shouldDisplayFilterBar() {
...@@ -227,7 +227,7 @@ export default { ...@@ -227,7 +227,7 @@ export default {
</div> </div>
<div class="mw-100"> <div class="mw-100">
<div class="mt-3 py-2 px-3 bg-gray-light border-top border-bottom"> <div class="mt-3 py-2 px-3 bg-gray-light border-top border-bottom">
<div v-if="shouldDsiplayPathNavigation" class="w-100 pb-2"> <div v-if="shouldDisplayPathNavigation" class="w-100 pb-2">
<path-navigation <path-navigation
class="js-path-navigation" class="js-path-navigation"
:loading="isLoading" :loading="isLoading"
......
...@@ -66,11 +66,13 @@ export const receiveStageMedianValuesError = ({ commit }) => { ...@@ -66,11 +66,13 @@ export const receiveStageMedianValuesError = ({ commit }) => {
createFlash(__('There was an error fetching median data for stages')); createFlash(__('There was an error fetching median data for stages'));
}; };
const fetchStageMedian = (currentGroupPath, stageId, params) => const fetchStageMedian = (currentGroupPath, currentValueStreamId, stageId, params) =>
Api.cycleAnalyticsStageMedian(currentGroupPath, stageId, params).then(({ data }) => ({ Api.cycleAnalyticsStageMedian(currentGroupPath, currentValueStreamId, stageId, params).then(
id: stageId, ({ data }) => ({
...data, id: stageId,
})); ...data,
}),
);
export const fetchStageMedianValues = ({ dispatch, getters }) => { export const fetchStageMedianValues = ({ dispatch, getters }) => {
const { const {
...@@ -160,13 +162,13 @@ export const fetchGroupStagesAndEvents = ({ dispatch, getters }) => { ...@@ -160,13 +162,13 @@ export const fetchGroupStagesAndEvents = ({ dispatch, getters }) => {
currentGroupPath: groupId, currentGroupPath: groupId,
cycleAnalyticsRequestParams: { created_after, project_ids }, cycleAnalyticsRequestParams: { created_after, project_ids },
} = getters; } = getters;
dispatch('requestGroupStages'); dispatch('requestGroupStages');
dispatch('customStages/setStageEvents', []); dispatch('customStages/setStageEvents', []);
return Api.cycleAnalyticsGroupStagesAndEvents({ return Api.cycleAnalyticsGroupStagesAndEvents(groupId, valueStreamId, {
groupId, start_date: created_after,
valueStreamId, project_ids,
params: { start_date: created_after, project_ids },
}) })
.then(({ data: { stages = [], events = [] } }) => { .then(({ data: { stages = [], events = [] } }) => {
dispatch('receiveGroupStagesSuccess', stages); dispatch('receiveGroupStagesSuccess', stages);
...@@ -233,14 +235,11 @@ export const receiveRemoveStageError = ({ commit }) => { ...@@ -233,14 +235,11 @@ export const receiveRemoveStageError = ({ commit }) => {
createFlash(__('There was an error removing your custom stage, please try again')); createFlash(__('There was an error removing your custom stage, please try again'));
}; };
export const removeStage = ({ dispatch, state }, stageId) => { export const removeStage = ({ dispatch, getters }, stageId) => {
const { const { currentGroupPath, currentValueStreamId } = getters;
selectedGroup: { fullPath },
} = state;
dispatch('requestRemoveStage'); dispatch('requestRemoveStage');
return Api.cycleAnalyticsRemoveStage(stageId, fullPath) return Api.cycleAnalyticsRemoveStage(currentGroupPath, currentValueStreamId, stageId)
.then(() => dispatch('receiveRemoveStageSuccess')) .then(() => dispatch('receiveRemoveStageSuccess'))
.catch(error => dispatch('receiveRemoveStageError', error)); .catch(error => dispatch('receiveRemoveStageError', error));
}; };
...@@ -303,7 +302,7 @@ export const receiveCreateValueStreamSuccess = ({ commit, dispatch }) => { ...@@ -303,7 +302,7 @@ export const receiveCreateValueStreamSuccess = ({ commit, dispatch }) => {
export const createValueStream = ({ commit, dispatch, getters }, data) => { export const createValueStream = ({ commit, dispatch, getters }, data) => {
const { currentGroupPath } = getters; const { currentGroupPath } = getters;
commit(types.REQUEST_CREATE_VALUE_STREAM);cycleAnalyticsSummaryData commit(types.REQUEST_CREATE_VALUE_STREAM);
return Api.cycleAnalyticsCreateValueStream(currentGroupPath, data) return Api.cycleAnalyticsCreateValueStream(currentGroupPath, data)
.then(() => dispatch('receiveCreateValueStreamSuccess')) .then(() => dispatch('receiveCreateValueStreamSuccess'))
......
...@@ -22,7 +22,6 @@ export const receiveDurationDataError = ({ commit }) => { ...@@ -22,7 +22,6 @@ export const receiveDurationDataError = ({ commit }) => {
export const fetchDurationData = ({ dispatch, rootGetters }) => { export const fetchDurationData = ({ dispatch, rootGetters }) => {
dispatch('requestDurationData'); dispatch('requestDurationData');
const { const {
cycleAnalyticsRequestParams, cycleAnalyticsRequestParams,
activeStages, activeStages,
......
...@@ -78,6 +78,7 @@ function createComponent({ ...@@ -78,6 +78,7 @@ function createComponent({
}, },
shallow = true, shallow = true,
withStageSelected = false, withStageSelected = false,
withValueStreamSelected = true,
featureFlags = {}, featureFlags = {},
props = {}, props = {},
} = {}) { } = {}) {
...@@ -90,7 +91,6 @@ function createComponent({ ...@@ -90,7 +91,6 @@ function createComponent({
emptyStateSvgPath, emptyStateSvgPath,
noDataSvgPath, noDataSvgPath,
noAccessSvgPath, noAccessSvgPath,
baseStagesEndpoint: mockData.endpoints.baseStagesEndpoint,
hideGroupDropDown, hideGroupDropDown,
...props, ...props,
}, },
...@@ -107,6 +107,10 @@ function createComponent({ ...@@ -107,6 +107,10 @@ function createComponent({
}, },
}); });
if (withValueStreamSelected) {
comp.vm.$store.dispatch('receiveValueStreamsSuccess', mockData.valueStreams);
}
if (withStageSelected) { if (withStageSelected) {
comp.vm.$store.commit('SET_SELECTED_GROUP', { comp.vm.$store.commit('SET_SELECTED_GROUP', {
...selectedGroup, ...selectedGroup,
...@@ -533,6 +537,7 @@ describe('Cycle Analytics component', () => { ...@@ -533,6 +537,7 @@ describe('Cycle Analytics component', () => {
describe('enabled', () => { describe('enabled', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createComponent({ wrapper = createComponent({
withValueStreamSelected: false,
withStageSelected: true, withStageSelected: true,
pathNavigationEnabled: true, pathNavigationEnabled: true,
}); });
...@@ -544,7 +549,7 @@ describe('Cycle Analytics component', () => { ...@@ -544,7 +549,7 @@ describe('Cycle Analytics component', () => {
return waitForPromises(); return waitForPromises();
}); });
it('displays the path navigation', () => { it('does not display the path navigation', () => {
displaysPathNavigation(false); displaysPathNavigation(false);
}); });
}); });
......
...@@ -29,10 +29,10 @@ export const endpoints = { ...@@ -29,10 +29,10 @@ export const endpoints = {
groupLabels: /groups\/[A-Z|a-z|\d|\-|_]+\/-\/labels.json/, groupLabels: /groups\/[A-Z|a-z|\d|\-|_]+\/-\/labels.json/,
recentActivityData: /analytics\/value_stream_analytics\/summary/, recentActivityData: /analytics\/value_stream_analytics\/summary/,
timeMetricsData: /analytics\/value_stream_analytics\/time_summary/, timeMetricsData: /analytics\/value_stream_analytics\/time_summary/,
durationData: /analytics\/value_stream_analytics\/stages\/\d+\/duration_chart/, durationData: /analytics\/value_stream_analytics\/value_streams\/\d+\/stages\/\d+\/duration_chart/,
stageData: /analytics\/value_stream_analytics\/stages\/\d+\/records/, stageData: /analytics\/value_stream_analytics\/value_streams\/\d+\/stages\/\d+\/records/,
stageMedian: /analytics\/value_stream_analytics\/stages\/\d+\/median/, stageMedian: /analytics\/value_stream_analytics\/value_streams\/\d+\/stages\/\d+\/median/,
baseStagesEndpoint: /analytics\/value_stream_analytics\/stages$/, baseStagesEndpoint: /analytics\/value_stream_analytics\/value_streams\/\d+\/stages$/,
tasksByTypeData: /analytics\/type_of_work\/tasks_by_type/, tasksByTypeData: /analytics\/type_of_work\/tasks_by_type/,
tasksByTypeTopLabelsData: /analytics\/type_of_work\/tasks_by_type\/top_labels/, tasksByTypeTopLabelsData: /analytics\/type_of_work\/tasks_by_type\/top_labels/,
valueStreamData: /analytics\/value_stream_analytics\/value_streams/, valueStreamData: /analytics\/value_stream_analytics\/value_streams/,
......
...@@ -28,8 +28,13 @@ const [selectedStage] = activeStages; ...@@ -28,8 +28,13 @@ const [selectedStage] = activeStages;
const selectedStageSlug = selectedStage.slug; const selectedStageSlug = selectedStage.slug;
const [selectedValueStream] = valueStreams; const [selectedValueStream] = valueStreams;
const mockGetters = {
currentGroupPath: () => selectedGroup.fullPath,
currentValueStreamId: () => selectedValueStream.id,
};
const stageEndpoint = ({ stageId }) => const stageEndpoint = ({ stageId }) =>
`/groups/${selectedGroup.fullPath}/-/analytics/value_stream_analytics/stages/${stageId}`; `/groups/${selectedGroup.fullPath}/-/analytics/value_stream_analytics/value_streams/${selectedValueStream.id}/stages/${stageId}`;
jest.mock('~/flash'); jest.mock('~/flash');
...@@ -52,6 +57,8 @@ describe('Cycle analytics actions', () => { ...@@ -52,6 +57,8 @@ describe('Cycle analytics actions', () => {
hasDurationChartMedian: true, hasDurationChartMedian: true,
}, },
activeStages, activeStages,
selectedValueStream,
...mockGetters,
}; };
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
}); });
...@@ -437,7 +444,6 @@ describe('Cycle analytics actions', () => { ...@@ -437,7 +444,6 @@ describe('Cycle analytics actions', () => {
beforeEach(() => { beforeEach(() => {
mock.onPut(stageEndpoint({ stageId }), payload).replyOnce(httpStatusCodes.OK, payload); mock.onPut(stageEndpoint({ stageId }), payload).replyOnce(httpStatusCodes.OK, payload);
state = { selectedGroup };
}); });
it('dispatches receiveUpdateStageSuccess and customStages/setSavingCustomStage', () => { it('dispatches receiveUpdateStageSuccess and customStages/setSavingCustomStage', () => {
...@@ -583,7 +589,6 @@ describe('Cycle analytics actions', () => { ...@@ -583,7 +589,6 @@ describe('Cycle analytics actions', () => {
beforeEach(() => { beforeEach(() => {
mock.onDelete(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.OK); mock.onDelete(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.OK);
state = { selectedGroup };
}); });
it('dispatches receiveRemoveStageSuccess with put request response data', () => { it('dispatches receiveRemoveStageSuccess with put request response data', () => {
...@@ -820,10 +825,6 @@ describe('Cycle analytics actions', () => { ...@@ -820,10 +825,6 @@ describe('Cycle analytics actions', () => {
const stageId = 'cool-stage'; const stageId = 'cool-stage';
const payload = { id: stageId, move_after_id: '2', move_before_id: '8' }; const payload = { id: stageId, move_after_id: '2', move_before_id: '8' };
beforeEach(() => {
state = { selectedGroup };
});
describe('with no errors', () => { describe('with no errors', () => {
beforeEach(() => { beforeEach(() => {
mock.onPut(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.OK); mock.onPut(stageEndpoint({ stageId })).replyOnce(httpStatusCodes.OK);
......
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
transformedDurationData, transformedDurationData,
transformedDurationMedianData, transformedDurationMedianData,
endpoints, endpoints,
valueStreams,
} from '../../../mock_data'; } from '../../../mock_data';
import { shouldFlashAMessage } from '../../../helpers'; import { shouldFlashAMessage } from '../../../helpers';
...@@ -22,26 +23,30 @@ const selectedGroup = { fullPath: group.path }; ...@@ -22,26 +23,30 @@ const selectedGroup = { fullPath: group.path };
const [stage1, stage2] = stages; const [stage1, stage2] = stages;
const hiddenStage = { ...stage1, hidden: true, id: 3, slug: 3 }; const hiddenStage = { ...stage1, hidden: true, id: 3, slug: 3 };
const activeStages = [stage1, stage2]; const activeStages = [stage1, stage2];
const [selectedValueStream] = valueStreams;
const rootState = { const rootState = {
startDate, startDate,
endDate, endDate,
stages: [...activeStages, hiddenStage], stages: [...activeStages, hiddenStage],
selectedGroup, selectedGroup,
selectedValueStream,
featureFlags: { featureFlags: {
hasDurationChart: true, hasDurationChart: true,
hasDurationChartMedian: true, hasDurationChartMedian: true,
}, },
getters,
rootGetters: {
...rootGetters,
activeStages,
},
}; };
describe('DurationChart actions', () => { describe('DurationChart actions', () => {
let state;
let mock; let mock;
const state = {
...rootState,
...getters,
...rootGetters,
activeStages,
currentGroupPath: () => selectedGroup.fullPath,
currentValueStreamId: () => selectedValueStream.id,
};
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
...@@ -60,7 +65,7 @@ describe('DurationChart actions', () => { ...@@ -60,7 +65,7 @@ describe('DurationChart actions', () => {
return testAction( return testAction(
actions.fetchDurationData, actions.fetchDurationData,
null, null,
{ activeStages }, state,
[], [],
[ [
{ type: 'requestDurationData' }, { type: 'requestDurationData' },
...@@ -77,7 +82,11 @@ describe('DurationChart actions', () => { ...@@ -77,7 +82,11 @@ describe('DurationChart actions', () => {
return actions return actions
.fetchDurationData({ .fetchDurationData({
dispatch, dispatch,
...rootState, rootState,
rootGetters: {
...rootGetters,
activeStages,
},
}) })
.then(() => { .then(() => {
const requestedUrls = mock.history.get.map(({ url }) => url); const requestedUrls = mock.history.get.map(({ url }) => url);
...@@ -98,7 +107,11 @@ describe('DurationChart actions', () => { ...@@ -98,7 +107,11 @@ describe('DurationChart actions', () => {
return actions return actions
.fetchDurationData({ .fetchDurationData({
dispatch, dispatch,
...rootState, rootState,
rootGetters: {
...rootGetters,
activeStages,
},
}) })
.then(() => { .then(() => {
expect(dispatch).toHaveBeenCalledWith('receiveDurationDataError'); expect(dispatch).toHaveBeenCalledWith('receiveDurationDataError');
...@@ -297,7 +310,7 @@ describe('DurationChart actions', () => { ...@@ -297,7 +310,7 @@ describe('DurationChart actions', () => {
return testAction( return testAction(
actions.fetchDurationMedianData, actions.fetchDurationMedianData,
null, null,
{ ...rootState, activeStages }, state,
[], [],
[ [
{ {
...@@ -319,7 +332,7 @@ describe('DurationChart actions', () => { ...@@ -319,7 +332,7 @@ describe('DurationChart actions', () => {
.fetchDurationMedianData({ .fetchDurationMedianData({
dispatch, dispatch,
rootState, rootState,
rootGetters: { activeStages }, rootGetters: { ...rootGetters, activeStages },
}) })
.then(() => { .then(() => {
const requestedUrls = mock.history.get.map(({ url }) => url); const requestedUrls = mock.history.get.map(({ url }) => url);
......
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