Commit 6121509a authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Fix filters and data spec

Ensures the stages endpoint no longer returns the
unpersisted stages and updates related specs.
parent d956a648
......@@ -213,7 +213,10 @@ export default {
>
<h3>{{ __('Value Stream Analytics') }}</h3>
<div class="gl-display-flex gl-flex-direction-row gl-align-items-center gl-mt-0 gl-sm-mt-5">
<value-stream-aggregation-status v-if="isAggregationStatusAvailable" :data="aggregation" />
<value-stream-aggregation-status
v-if="isAggregationStatusAvailable"
:data="aggregation"
/>
<value-stream-select v-if="shouldDisplayCreateMultipleValueStreams" />
</div>
</div>
......
......@@ -11,8 +11,12 @@ module EE
def execute
return forbidden unless allowed?
if parent.is_a?(Group) && ::Feature.enabled?(:use_vsa_aggregated_tables, parent, default_enabled: :yaml)
success(persisted_stages)
else
success(persisted_stages.presence || build_default_stages)
end
end
private
......
......@@ -142,7 +142,10 @@ RSpec.describe 'Value stream analytics charts', :js do
context 'with a value stream' do
before do
create(:cycle_analytics_group_value_stream, group: group, name: 'First value stream')
create(:cycle_analytics_group_value_stream, group: group, name: 'First value stream', stages: [
create(:cycle_analytics_group_stage, group: group, name: "Issue", relative_position: 1),
create(:cycle_analytics_group_stage, group: group, name: "Code", relative_position: 2)
])
select_group(group)
end
......
......@@ -198,8 +198,13 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
context 'with a value stream' do
before do
create(:cycle_analytics_group_value_stream, group: group, name: 'First value stream')
create(:cycle_analytics_group_value_stream, group: sub_group, name: 'First sub group value stream')
value_stream = create(:cycle_analytics_group_value_stream, group: group, name: 'First value stream')
sub_value_stream = create(:cycle_analytics_group_value_stream, group: sub_group, name: 'First sub group value stream')
Gitlab::Analytics::CycleAnalytics::DefaultStages.all.map do |stage_params|
group.cycle_analytics_stages.create!(stage_params.merge(value_stream: value_stream))
sub_group.cycle_analytics_stages.create!(stage_params.merge(value_stream: sub_value_stream))
end
end
context 'without valid query parameters set' do
......@@ -301,6 +306,9 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
deploy_master(user, project, environment: 'staging')
deploy_master(user, project)
aggregation = Analytics::CycleAnalytics::Aggregation.safe_create_for_group(group)
Analytics::CycleAnalytics::AggregatorService.new(aggregation: aggregation).execute
select_group(group)
end
......
......@@ -21,9 +21,25 @@ RSpec.describe Analytics::CycleAnalytics::Stages::ListService do
it_behaves_like 'permission check for Value Stream Analytics Stage services', :cycle_analytics_for_groups
it 'returns only the default stages' do
context 'when the use_vsa_aggregated_tables feature is enabled' do
before do
stub_feature_flags(use_vsa_aggregated_tables: true)
end
it 'returns empty array' do
expect(stages.size).to eq(0)
end
end
context 'when the use_vsa_aggregated_tables feature is disabled' do
before do
stub_feature_flags(use_vsa_aggregated_tables: false)
end
it 'returns the default stages' do
expect(stages.size).to eq(Gitlab::Analytics::CycleAnalytics::DefaultStages.all.size)
end
end
it 'provides the default stages as non-persisted objects' do
expect(stages.map(&:id)).to all(be_nil)
......
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