Commit 2c3040ab authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '211453-value-stream-analytics-top-labels-causing-error-when-tasks_by_type_chart-feature-flag-not' into 'master'

Value stream analytics - top labels causing error when tasks_by_type_chart feature flag not enabled

Closes #211453

See merge request gitlab-org/gitlab!27478
parents 17a9db69 2592e034
......@@ -114,7 +114,7 @@ export const receiveCycleAnalyticsDataSuccess = ({ state, commit, dispatch }) =>
const { featureFlags: { hasDurationChart = false, hasTasksByTypeChart = false } = {} } = state;
const promises = [];
if (hasDurationChart) promises.push('fetchDurationData');
if (hasTasksByTypeChart) promises.push('fetchTasksByTypeData');
if (hasTasksByTypeChart) promises.push('fetchTopRankedGroupLabels');
return Promise.all(promises.map(func => dispatch(func)));
};
......@@ -132,7 +132,6 @@ export const fetchCycleAnalyticsData = ({ dispatch }) => {
dispatch('requestCycleAnalyticsData');
return Promise.resolve()
.then(() => dispatch('fetchGroupLabels'))
.then(() => dispatch('fetchTopRankedGroupLabels'))
.then(() => dispatch('fetchGroupStagesAndEvents'))
.then(() => dispatch('fetchStageMedianValues'))
.then(() => dispatch('fetchSummaryData'))
......@@ -225,8 +224,10 @@ export const fetchGroupLabels = ({ dispatch, state }) => {
);
};
export const receiveTopRankedGroupLabelsSuccess = ({ commit }, data) =>
export const receiveTopRankedGroupLabelsSuccess = ({ commit, dispatch }, data) => {
commit(types.RECEIVE_TOP_RANKED_GROUP_LABELS_SUCCESS, data);
dispatch('fetchTasksByTypeData');
};
export const receiveTopRankedGroupLabelsError = ({ commit }, error) => {
commit(types.RECEIVE_TOP_RANKED_GROUP_LABELS_ERROR, error);
......
......@@ -432,6 +432,7 @@ describe('Cycle Analytics component', () => {
mockFetchStageMedian = true,
mockFetchDurationData = true,
mockFetchTasksByTypeData = true,
mockFetchTopRankedGroupLabels = true,
}) => {
const defaultStatus = 200;
const defaultRequests = {
......@@ -453,9 +454,11 @@ describe('Cycle Analytics component', () => {
...overrides,
};
mock
.onGet(mockData.endpoints.tasksByTypeTopLabelsData)
.reply(defaultStatus, mockData.groupLabels);
if (mockFetchTopRankedGroupLabels) {
mock
.onGet(mockData.endpoints.tasksByTypeTopLabelsData)
.reply(defaultStatus, mockData.groupLabels);
}
if (mockFetchTasksByTypeData) {
mock
......@@ -565,6 +568,16 @@ describe('Cycle Analytics component', () => {
return selectGroupAndFindError('There was an error fetching data for the selected stage');
});
it('will display an error if the fetchTopRankedGroupLabels request fails', () => {
expect(findFlashError()).toBeNull();
mockRequestCycleAnalyticsData({ mockFetchTopRankedGroupLabels: false });
return selectGroupAndFindError(
'There was an error fetching the top labels for the selected group',
);
});
it('will display an error if the fetchTasksByTypeData request fails', () => {
expect(findFlashError()).toBeNull();
......
......@@ -271,6 +271,28 @@ describe('Cycle analytics actions', () => {
],
);
});
describe('receiveTopRankedGroupLabelsSuccess', () => {
beforeEach(() => {
setFixtures('<div class="flash-container"></div>');
});
it(`commits the ${types.RECEIVE_TOP_RANKED_GROUP_LABELS_SUCCESS} mutation and dispatches the 'fetchTasksByTypeData' action`, done => {
testAction(
actions.receiveTopRankedGroupLabelsSuccess,
null,
state,
[
{
type: types.RECEIVE_TOP_RANKED_GROUP_LABELS_SUCCESS,
payload: null,
},
],
[{ type: 'fetchTasksByTypeData' }],
done,
);
});
});
});
describe('with an error', () => {
......@@ -348,7 +370,6 @@ describe('Cycle analytics actions', () => {
[
{ type: 'requestCycleAnalyticsData' },
{ type: 'fetchGroupLabels' },
{ type: 'fetchTopRankedGroupLabels' },
{ type: 'fetchGroupStagesAndEvents' },
{ type: 'fetchStageMedianValues' },
{ type: 'fetchSummaryData' },
......
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