Commit 93888b0a authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Olena Horal-Koretska

Fallback to the default value stream

When there are no value streams available
we should fall back to `default`.

Adds a `fetchValueStreamData` action
parent a2a272b0
......@@ -311,12 +311,15 @@ export const createValueStream = ({ commit, dispatch, getters }, data) => {
});
};
export const setSelectedValueStream = ({ commit, dispatch }, streamId) => {
commit(types.SET_SELECTED_VALUE_STREAM, streamId);
return Promise.resolve()
export const fetchValueStreamData = ({ dispatch }) =>
Promise.resolve()
.then(() => dispatch('fetchGroupStagesAndEvents'))
.then(() => dispatch('fetchStageMedianValues'))
.then(() => dispatch('durationChart/fetchDurationData'));
export const setSelectedValueStream = ({ commit, dispatch }, streamId) => {
commit(types.SET_SELECTED_VALUE_STREAM, streamId);
return dispatch('fetchValueStreamData');
};
export const receiveValueStreamsSuccess = ({ commit, dispatch }, data = []) => {
......@@ -344,5 +347,5 @@ export const fetchValueStreams = ({ commit, dispatch, getters, state }) => {
commit(types.RECEIVE_VALUE_STREAMS_ERROR, data);
});
}
return dispatch('fetchGroupStagesAndEvents');
return dispatch('fetchValueStreamData');
};
......@@ -3,10 +3,12 @@ import { isNumber } from 'lodash';
import httpStatus from '~/lib/utils/http_status';
import { dateFormats } from '../../shared/constants';
import { transformStagesForPathNavigation } from '../utils';
import { DEFAULT_VALUE_STREAM_ID } from '../constants';
export const hasNoAccessError = state => state.errorCode === httpStatus.FORBIDDEN;
export const currentValueStreamId = ({ selectedValueStream }) => selectedValueStream?.id || null;
export const currentValueStreamId = ({ selectedValueStream }) =>
selectedValueStream?.id || DEFAULT_VALUE_STREAM_ID;
export const currentGroupPath = ({ selectedGroup }) =>
selectedGroup && selectedGroup.fullPath ? selectedGroup.fullPath : null;
......
---
title: VSA requests fail without multiple value streams feature flag
merge_request: 38542
author:
type: fixed
......@@ -22,6 +22,7 @@ RSpec.describe 'Group Value Stream Analytics', :js do
stage_nav_selector = '.stage-nav'
path_nav_selector = '.js-path-navigation'
filter_bar_selector = '.js-filter-bar'
duration_stage_selector = '.js-dropdown-stages'
3.times do |i|
let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: project, created_at: 2.days.ago) }
......@@ -189,6 +190,25 @@ RSpec.describe 'Group Value Stream Analytics', :js do
end
end
# Adding this context as part of a fix for https://gitlab.com/gitlab-org/gitlab/-/issues/233439
# This can be removed when the feature flag is removed
context 'create multiple value streams disabled' do
before do
stub_feature_flags(value_stream_analytics_create_multiple_value_streams: false)
visit analytics_cycle_analytics_path
select_group
end
it 'displays the list of stages' do
expect(page).to have_selector(stage_nav_selector, visible: true)
end
it 'displays the duration chart' do
expect(page).to have_selector(duration_stage_selector, visible: true)
end
end
def wait_for_stages_to_load
expect(page).to have_selector '.js-stage-table'
end
......@@ -962,7 +982,7 @@ RSpec.describe 'Group Value Stream Analytics', :js do
end
context 'Duration chart' do
let(:duration_chart_dropdown) { page.find('.js-dropdown-stages') }
let(:duration_chart_dropdown) { page.find(duration_stage_selector) }
let_it_be(:translated_default_stage_names) do
Gitlab::Analytics::CycleAnalytics::DefaultStages.names.map do |name|
......
......@@ -97,11 +97,7 @@ describe('Cycle analytics actions', () => {
vs,
{ ...state, selectedValueStream: {} },
[{ type: types.SET_SELECTED_VALUE_STREAM, payload: vs }],
[
{ type: 'fetchGroupStagesAndEvents' },
{ type: 'fetchStageMedianValues' },
{ type: 'durationChart/fetchDurationData' },
],
[{ type: 'fetchValueStreamData' }],
);
});
});
......@@ -1035,13 +1031,37 @@ describe('Cycle analytics actions', () => {
});
it(`will dispatch the 'fetchGroupStagesAndEvents' request`, () =>
testAction(
actions.fetchValueStreams,
testAction(actions.fetchValueStreams, null, state, [], [{ type: 'fetchValueStreamData' }]));
});
});
describe('fetchValueStreamData', () => {
beforeEach(() => {
state = {
...state,
stages: [{ slug: selectedStageSlug }],
selectedGroup,
featureFlags: {
...state.featureFlags,
hasCreateMultipleValueStreams: true,
},
};
mock = new MockAdapter(axios);
mock.onGet(endpoints.valueStreamData).reply(httpStatusCodes.OK, { stages: [], events: [] });
});
it('dispatches fetchGroupStagesAndEvents, fetchStageMedianValues and durationChart/fetchDurationData', () => {
return testAction(
actions.fetchValueStreamData,
null,
state,
[],
[{ type: 'fetchGroupStagesAndEvents' }],
));
[
{ type: 'fetchGroupStagesAndEvents' },
{ type: 'fetchStageMedianValues' },
{ type: 'durationChart/fetchDurationData' },
],
);
});
});
});
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