Commit 1304ef05 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by charlie ablett

Update vsa navigation specs for the horizontal flow

parent c6e57e5a
......@@ -6,6 +6,7 @@ RSpec.describe 'Multiple value streams', :js do
let_it_be(:group) { create(:group, name: 'CA-test-group') }
let_it_be(:project) { create(:project, :repository, namespace: group, group: group, name: 'Cool fun project') }
let_it_be(:sub_group) { create(:group, name: 'CA-sub-group', parent: group) }
let_it_be(:user) do
create(:user).tap do |u|
group.add_owner(u)
......@@ -14,7 +15,6 @@ RSpec.describe 'Multiple value streams', :js do
end
let(:extended_form_fields_selector) { '[data-testid="extended-form-fields"]' }
let(:custom_value_stream_name) { "New created value stream" }
let!(:default_value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'default') }
3.times do |i|
......@@ -34,10 +34,16 @@ RSpec.describe 'Multiple value streams', :js do
wait_for_requests
end
describe 'Create value stream' do
before do
select_group(group)
def path_nav_elem
page.find('[data-testid="gl-path-nav"]')
end
def click_action_button(action, index)
page.find("[data-testid='stage-action-#{action}-#{index}']").click
end
shared_examples 'create a value stream' do |custom_value_stream_name|
before do
toggle_value_stream_dropdown
page.find_button(_('Create new Value Stream')).click
end
......@@ -56,52 +62,95 @@ RSpec.describe 'Multiple value streams', :js do
add_custom_stage_to_form
# Hide some default stages
page.find("[data-testid='stage-action-hide-5']").click
page.find("[data-testid='stage-action-hide-3']").click
page.find("[data-testid='stage-action-hide-1']").click
click_action_button('hide', 5)
click_action_button('hide', 3)
click_action_button('hide', 1)
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")
expect(path_nav_elem).to have_text("Cool custom stage - name")
end
end
describe 'Edit value stream' do
shared_examples 'update a value stream' do |custom_value_stream_name|
before do
select_group(group)
create_custom_value_stream(custom_value_stream_name)
page.find_button(_('Edit')).click
end
it 'includes additional form fields' do
expect(page).to have_selector(extended_form_fields_selector)
expect(page).to have_button("Save Value Stream")
end
it 'can reorder stages' do
expect(path_nav_stage_names_without_median).to eq(["Overview", "Issue", "Plan", "Code", "Test", "Review", "Staging", "Cool custom stage - name 7"])
it 'can update the value stream name' do
edited_name = "Edit new value stream"
fill_in 'create-value-stream-name', with: edited_name
page.find_button(_('Edit')).click
# Re-arrange a few stages
page.all("[data-testid*='stage-action-move-down-']").first.click
page.all("[data-testid*='stage-action-move-up-']").last.click
page.find_button(_('Save Value Stream')).click
wait_for_requests
expect(page).to have_text(_("'%{name}' Value Stream saved") % { name: edited_name })
expect(path_nav_stage_names_without_median).to eq(["Overview", "Plan", "Issue", "Code", "Test", "Review", "Cool custom stage - name 7", "Staging"])
end
it 'can add a custom stage' do
add_custom_stage_to_form
context 'updating' do
before do
page.find_button(_('Edit')).click
end
page.find_button(_('Save Value Stream')).click
wait_for_requests
it 'includes additional form fields' do
expect(page).to have_selector(extended_form_fields_selector)
expect(page).to have_button("Save Value Stream")
end
it 'can update the value stream name' do
edited_name = "Edit new value stream"
fill_in 'create-value-stream-name', with: edited_name
page.find_button(_('Save Value Stream')).click
wait_for_requests
expect(page).to have_text(_("'%{name}' Value Stream saved") % { name: edited_name })
end
it 'can add and remove custom stages' do
add_custom_stage_to_form
page.find_button(_('Save Value Stream')).click
wait_for_requests
expect(page).to have_text(_("'%{name}' Value Stream saved") % { name: custom_value_stream_name })
expect(path_nav_elem).to have_text("Cool custom stage - name")
page.find_button(_('Edit')).click
# Delete the custom stages, delete the last one first since the list gets reordered after a deletion
click_action_button('remove', 7)
click_action_button('remove', 6)
page.find_button(_('Save Value Stream')).click
wait_for_requests
expect(path_nav_elem).not_to have_text("Cool custom stage - name")
end
it 'can hide default stages' do
click_action_button('hide', 5)
click_action_button('hide', 4)
click_action_button('hide', 3)
page.find_button(_('Save Value Stream')).click
wait_for_requests
expect(page).to have_text(_("'%{name}' Value Stream saved") % { name: custom_value_stream_name })
expect(path_nav_elem).not_to have_text("Staging")
expect(path_nav_elem).not_to have_text("Review")
expect(path_nav_elem).not_to have_text("Test")
end
end
end
describe 'Delete value stream' do
shared_examples 'delete a value stream' do |custom_value_stream_name|
before do
value_stream = create(:cycle_analytics_group_value_stream, name: custom_value_stream_name, group: group)
create(:cycle_analytics_group_stage, value_stream: value_stream)
......@@ -121,4 +170,28 @@ RSpec.describe 'Multiple value streams', :js do
expect(page).to have_text(_("'%{name}' Value Stream deleted") % { name: custom_value_stream_name })
end
end
describe 'With a group' do
name = 'group value stream'
before do
select_group(group)
end
it_behaves_like 'create a value stream', name
it_behaves_like 'update a value stream', name
it_behaves_like 'delete a value stream', name
end
describe 'With a sub group' do
name = 'sub group value stream'
before do
select_group(sub_group)
end
it_behaves_like 'create a value stream', name
it_behaves_like 'update a value stream', name
it_behaves_like 'delete a value stream', name
end
end
......@@ -7,6 +7,11 @@ module CycleAnalyticsHelpers
page.find('[data-testid="dropdown-value-streams"]').click
end
def path_nav_stage_names_without_median
# Returns the path names with the median value stripped out
page.all('.gl-path-button').collect(&:text).map {|name_with_median| name_with_median.split("\n")[0] }
end
def add_custom_stage_to_form
page.find_button(s_('CreateValueStreamForm|Add another stage')).click
......
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