Commit 2580edc2 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Max Woolf

Additional feature specs for new VSA features

parent 2c9210d6
......@@ -22,14 +22,24 @@ RSpec.describe 'Value stream analytics charts', :js do
stage.find('[data-testid="more-actions-toggle"]').click
end
before_all do
group.add_owner(user)
end
before do
stub_licensed_features(cycle_analytics_for_groups: true)
group.add_owner(user)
sign_in(user)
end
shared_examples 'has all the default stages' do
it 'has all the default stages in the duration dropdown' do
toggle_duration_chart_dropdown
expect(duration_chart_stages).to eq(translated_default_stage_names + [latest_custom_stage_name])
end
end
context 'Duration chart' do
duration_stage_selector = '.js-dropdown-stages'
stage_nav_selector = '.stage-nav'
......@@ -37,7 +47,7 @@ RSpec.describe 'Value stream analytics charts', :js do
let(:duration_chart_dropdown) { page.find(duration_stage_selector) }
let(:first_default_stage) { page.find('.stage-nav-item-cell', text: 'Issue').ancestor('.stage-nav-item') }
let(:nav) { page.find(stage_nav_selector) }
let(:custom_value_stream_name) { "New created value stream" }
let_it_be(:translated_default_stage_names) do
Gitlab::Analytics::CycleAnalytics::DefaultStages.names.map do |name|
......@@ -54,31 +64,61 @@ RSpec.describe 'Value stream analytics charts', :js do
duration_chart_dropdown.click
end
def hide_vsa_stage(index = 0)
page.find_button(_('Edit')).click
page.find("[data-testid='stage-action-hide-#{index}']").click
page.find_button(_('Save Value Stream')).click
wait_for_requests
end
def latest_custom_stage_name
index = duration_chart_stages.length
"Cool custom stage - name #{index}"
end
before do
stub_feature_flags(value_stream_analytics_path_navigation: false)
select_group(group, stage_table_selector)
select_group(group)
create_custom_value_stream(custom_value_stream_name)
end
it 'has all the default stages' do
it_behaves_like 'has all the default stages'
it 'hidden stages will not appear in the duration chart dropdown' do
first_stage_name = duration_chart_stages.first
hide_vsa_stage
toggle_duration_chart_dropdown
expect(duration_chart_stages).to eq(translated_default_stage_names)
expect(duration_chart_stages).not_to include(first_stage_name)
end
context 'hidden stage' do
context 'With the path navigation feature flag disabled' do
let(:nav) { page.find(stage_nav_selector) }
before do
toggle_more_options(first_default_stage)
stub_feature_flags(value_stream_analytics_path_navigation: false)
select_group(group, stage_table_selector)
end
click_button(_('Hide stage'))
it_behaves_like 'has all the default stages'
# wait for the stage list to laod
expect(nav).to have_content(s_('CycleAnalyticsStage|Plan'))
end
context 'hidden stage' do
before do
toggle_more_options(first_default_stage)
click_button(_('Hide stage'))
end
it 'will not appear in the duration chart dropdown' do
# wait for the stage list to laod
expect(nav).to have_content(s_('CycleAnalyticsStage|Plan'))
it 'will not appear in the duration chart dropdown' do
toggle_duration_chart_dropdown
toggle_duration_chart_dropdown
expect(duration_chart_stages).not_to include(s_('CycleAnalyticsStage|Issue'))
expect(duration_chart_stages).not_to include(s_('CycleAnalyticsStage|Issue'))
end
end
end
end
......@@ -89,7 +129,6 @@ RSpec.describe 'Value stream analytics charts', :js do
before do
stub_licensed_features(cycle_analytics_for_groups: true, type_of_work_analytics: true)
group.add_owner(user)
project.add_maintainer(user)
sign_in(user)
......
......@@ -139,9 +139,17 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
expect(page).to have_selector(path_nav_selector)
end
it 'each stage will have median values' do
stage_medians = page.all('.gl-path-button span').collect(&:text)
expect(stage_medians).to eq(["-"] * 7)
end
it 'displays the default list of stages' do
path_nav = page.find(path_nav_selector)
expect(path_nav).to have_content(_("Overview"))
%w[Issue Plan Code Test Review Staging].each do |item|
string_id = "CycleAnalytics|#{item}"
expect(path_nav).to have_content(s_(string_id))
......
......@@ -13,10 +13,8 @@ RSpec.describe 'Multiple value streams', :js do
end
end
let(:value_stream_selector) { '[data-testid="dropdown-value-streams"]' }
let(:extended_form_fields_selector) { '[data-testid="extended-form-fields"]' }
let(:custom_value_stream_name) { "New created value stream" }
let(:value_stream_dropdown) { page.find(value_stream_selector) }
let!(:default_value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'default') }
3.times do |i|
......@@ -29,10 +27,6 @@ RSpec.describe 'Multiple value streams', :js do
sign_in(user)
end
def toggle_value_stream_dropdown
value_stream_dropdown.click
end
def select_value_stream(value_stream_name)
toggle_value_stream_dropdown
......@@ -40,34 +34,6 @@ RSpec.describe 'Multiple value streams', :js do
wait_for_requests
end
def add_custom_stage_to_form
page.find_button(s_('CreateValueStreamForm|Add another stage')).click
index = page.all('[data-testid="value-stream-stage-fields"]').length
last_stage = page.all('[data-testid="value-stream-stage-fields"]').last
within last_stage do
find('[name*="custom-stage-name-"]').fill_in with: "Cool custom stage - name #{index}"
select_dropdown_option_by_value "custom-stage-start-event-", :merge_request_created
select_dropdown_option_by_value "custom-stage-end-event-", :merge_request_merged
end
end
def create_value_stream
fill_in 'create-value-stream-name', with: custom_value_stream_name
page.find_button(_('Create Value Stream')).click
wait_for_requests
end
def create_custom_value_stream
toggle_value_stream_dropdown
page.find_button(_('Create new Value Stream')).click
add_custom_stage_to_form
create_value_stream
end
describe 'Create value stream' do
before do
select_group(group)
......@@ -81,7 +47,7 @@ RSpec.describe 'Multiple value streams', :js do
end
it 'can create a value stream' do
create_value_stream
save_value_stream(custom_value_stream_name)
expect(page).to have_text(_("'%{name}' Value Stream created") % { name: custom_value_stream_name })
end
......@@ -94,7 +60,7 @@ RSpec.describe 'Multiple value streams', :js do
page.find("[data-testid='stage-action-hide-3']").click
page.find("[data-testid='stage-action-hide-1']").click
create_value_stream
save_value_stream(custom_value_stream_name)
expect(page).to have_text(_("'%{name}' Value Stream created") % { name: custom_value_stream_name })
expect(page.find('[data-testid="gl-path-nav"]')).to have_text("Cool custom stage - name")
......@@ -105,7 +71,7 @@ RSpec.describe 'Multiple value streams', :js do
before do
select_group(group)
create_custom_value_stream
create_custom_value_stream(custom_value_stream_name)
page.find_button(_('Edit')).click
end
......
......@@ -9241,9 +9241,6 @@ msgstr ""
msgid "Create Project"
msgstr ""
msgid "Create Value Stream"
msgstr ""
msgid "Create a GitLab account first, and then connect it to your %{label} account."
msgstr ""
......
......@@ -3,6 +3,38 @@
module CycleAnalyticsHelpers
include GitHelpers
def toggle_value_stream_dropdown
page.find('[data-testid="dropdown-value-streams"]').click
end
def add_custom_stage_to_form
page.find_button(s_('CreateValueStreamForm|Add another stage')).click
index = page.all('[data-testid="value-stream-stage-fields"]').length
last_stage = page.all('[data-testid="value-stream-stage-fields"]').last
within last_stage do
find('[name*="custom-stage-name-"]').fill_in with: "Cool custom stage - name #{index}"
select_dropdown_option_by_value "custom-stage-start-event-", :merge_request_created
select_dropdown_option_by_value "custom-stage-end-event-", :merge_request_merged
end
end
def save_value_stream(custom_value_stream_name)
fill_in 'create-value-stream-name', with: custom_value_stream_name
page.find_button(s_('CreateValueStreamForm|Create Value Stream')).click
wait_for_requests
end
def create_custom_value_stream(custom_value_stream_name)
toggle_value_stream_dropdown
page.find_button(_('Create new Value Stream')).click
add_custom_stage_to_form
save_value_stream(custom_value_stream_name)
end
def wait_for_stages_to_load(selector = '.js-path-navigation')
expect(page).to have_selector selector
wait_for_requests
......
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