Commit 12ac01db authored by Ezekiel Kigbo's avatar Ezekiel Kigbo Committed by Vitali Tatarintev

Updates feature specs for creating value streams

Adds specs to test when the extended form
fields feature flag is disabled
parent b44fe05c
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Value stream analytics charts', :js do RSpec.describe 'Value stream analytics charts', :js do
include CycleAnalyticsHelpers
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, name: 'CA-test-group') } let_it_be(:group) { create(:group, name: 'CA-test-group') }
let_it_be(:group2) { create(:group, name: 'CA-bad-test-group') } let_it_be(:group2) { create(:group, name: 'CA-bad-test-group') }
...@@ -14,16 +16,6 @@ RSpec.describe 'Value stream analytics charts', :js do ...@@ -14,16 +16,6 @@ RSpec.describe 'Value stream analytics charts', :js do
let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: project, created_at: 2.days.ago) } let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: project, created_at: 2.days.ago) }
end end
def wait_for_stages_to_load
expect(page).to have_selector '.js-stage-table'
end
def select_group(target_group = group)
visit group_analytics_cycle_analytics_path(target_group)
wait_for_stages_to_load
end
def toggle_more_options(stage) def toggle_more_options(stage)
stage.hover stage.hover
...@@ -62,7 +54,7 @@ RSpec.describe 'Value stream analytics charts', :js do ...@@ -62,7 +54,7 @@ RSpec.describe 'Value stream analytics charts', :js do
end end
before do before do
select_group select_group(group)
end end
it 'has all the default stages' do it 'has all the default stages' do
...@@ -107,7 +99,7 @@ RSpec.describe 'Value stream analytics charts', :js do ...@@ -107,7 +99,7 @@ RSpec.describe 'Value stream analytics charts', :js do
create(:labeled_issue, created_at: i.days.ago, project: create(:project, group: group), labels: [group_label2]) create(:labeled_issue, created_at: i.days.ago, project: create(:project, group: group), labels: [group_label2])
end end
select_group select_group(group)
end end
it 'displays the chart' do it 'displays the chart' do
...@@ -127,7 +119,7 @@ RSpec.describe 'Value stream analytics charts', :js do ...@@ -127,7 +119,7 @@ RSpec.describe 'Value stream analytics charts', :js do
context 'no data available' do context 'no data available' do
before do before do
select_group select_group(group)
end end
it 'shows the no data available message' do it 'shows the no data available message' do
......
...@@ -3,6 +3,7 @@ require 'spec_helper' ...@@ -3,6 +3,7 @@ require 'spec_helper'
RSpec.describe 'Customizable Group Value Stream Analytics', :js do RSpec.describe 'Customizable Group Value Stream Analytics', :js do
include DragTo include DragTo
include CycleAnalyticsHelpers
let_it_be(:group) { create(:group, name: 'CA-test-group') } let_it_be(:group) { create(:group, name: 'CA-test-group') }
let_it_be(:sub_group) { create(:group, name: 'CA-sub-group', parent: group) } let_it_be(:sub_group) { create(:group, name: 'CA-sub-group', parent: group) }
...@@ -51,12 +52,6 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -51,12 +52,6 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
Analytics::CycleAnalytics::Stages::CreateService.new(parent: parent_group, params: params, current_user: user).execute Analytics::CycleAnalytics::Stages::CreateService.new(parent: parent_group, params: params, current_user: user).execute
end end
def select_group(target_group = group)
visit group_analytics_cycle_analytics_path(target_group)
expect(page).to have_selector '.js-stage-table' # wait_for_stages_to_load
end
def toggle_more_options(stage) def toggle_more_options(stage)
stage.hover stage.hover
...@@ -68,21 +63,6 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -68,21 +63,6 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
page.find("[data-testid='#{name}'] .dropdown-menu").all('.dropdown-item').find { |item| item.value == value.to_s }.click page.find("[data-testid='#{name}'] .dropdown-menu").all('.dropdown-item').find { |item| item.value == value.to_s }.click
end end
def select_dropdown_option_by_value(name, value, elem = '.dropdown-item')
toggle_dropdown name
page.find("[data-testid='#{name}'] .dropdown-menu").find("#{elem}[value='#{value}']").click
end
def toggle_dropdown(field)
page.within("[data-testid='#{field}']") do
find('.dropdown-toggle').click
wait_for_requests
expect(find('.dropdown-menu')).to have_selector('.dropdown-item')
end
end
def select_dropdown_label(field, index = 1) def select_dropdown_label(field, index = 1)
page.find("[data-testid='#{field}'] .dropdown-menu").all('.dropdown-item')[index].click page.find("[data-testid='#{field}'] .dropdown-menu").all('.dropdown-item')[index].click
end end
...@@ -105,7 +85,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -105,7 +85,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'Manual ordering' do context 'Manual ordering' do
before do before do
select_group select_group(group)
end end
let(:default_stage_order) { %w[Issue Plan Code Test Review Staging].freeze } let(:default_stage_order) { %w[Issue Plan Code Test Review Staging].freeze }
...@@ -139,7 +119,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -139,7 +119,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
page.driver.browser.manage.window.resize_to(1650, 1150) page.driver.browser.manage.window.resize_to(1650, 1150)
create_custom_stage create_custom_stage
select_group select_group(group)
end end
it 'allows a stage to be dragged' do it 'allows a stage to be dragged' do
...@@ -153,7 +133,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -153,7 +133,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
it 'persists the order when a group is selected' do it 'persists the order when a group is selected' do
drag_from_index_to_index(start_index, end_index) drag_from_index_to_index(start_index, end_index)
select_group select_group(group)
confirm_stage_order(updated_order) confirm_stage_order(updated_order)
end end
...@@ -175,7 +155,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -175,7 +155,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'Add a stage button' do context 'Add a stage button' do
before do before do
select_group select_group(group)
end end
it 'displays the custom stage form when clicked' do it 'displays the custom stage form when clicked' do
...@@ -332,7 +312,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -332,7 +312,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'with a group' do context 'with a group' do
context 'selected' do context 'selected' do
before do before do
select_group select_group(group)
end end
it_behaves_like 'can create custom stages' do it_behaves_like 'can create custom stages' do
...@@ -345,7 +325,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -345,7 +325,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'with a custom stage created', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/273045' do context 'with a custom stage created', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/273045' do
before do before do
create_custom_stage create_custom_stage
select_group select_group(group)
expect(page).to have_text custom_stage_name expect(page).to have_text custom_stage_name
end end
...@@ -391,7 +371,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -391,7 +371,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
end end
before do before do
select_group select_group(group)
toggle_more_options(first_default_stage) toggle_more_options(first_default_stage)
end end
...@@ -443,7 +423,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -443,7 +423,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'custom stages' do context 'custom stages' do
before do before do
create_custom_stage create_custom_stage
select_group select_group(group)
expect(page).to have_text custom_stage_name expect(page).to have_text custom_stage_name
...@@ -487,7 +467,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do ...@@ -487,7 +467,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
end end
before do before do
select_group select_group(group)
end end
it 'has all the default stages' do it 'has all the default stages' do
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Group value stream analytics filters and data', :js do RSpec.describe 'Group value stream analytics filters and data', :js do
include CycleAnalyticsHelpers
let_it_be(:group) { create(:group) } let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository, namespace: group, group: group, name: 'Cool fun project') } let_it_be(:project) { create(:project, :repository, namespace: group, group: group, name: 'Cool fun project') }
...@@ -25,16 +27,6 @@ RSpec.describe 'Group value stream analytics filters and data', :js do ...@@ -25,16 +27,6 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: sub_group_project, created_at: 2.days.ago) } let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: sub_group_project, created_at: 2.days.ago) }
end end
def wait_for_stages_to_load
expect(page).to have_selector '.js-stage-table'
end
def select_group(target_group = group)
visit group_analytics_cycle_analytics_path(target_group)
wait_for_stages_to_load
end
def select_stage(name) def select_stage(name)
string_id = "CycleAnalyticsStage|#{name}" string_id = "CycleAnalyticsStage|#{name}"
page.find('.stage-nav .stage-nav-item .stage-name', text: s_(string_id), match: :prefer_exact).click page.find('.stage-nav .stage-nav-item .stage-name', text: s_(string_id), match: :prefer_exact).click
...@@ -195,7 +187,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do ...@@ -195,7 +187,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
before do before do
stub_feature_flags(value_stream_analytics_path_navigation: false) stub_feature_flags(value_stream_analytics_path_navigation: false)
select_group select_group(group)
end end
it 'shows the path navigation' do it 'shows the path navigation' do
...@@ -256,7 +248,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do ...@@ -256,7 +248,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
let(:selected_group) { group } let(:selected_group) { group }
before do before do
select_group select_group(group)
end end
it_behaves_like 'group value stream analytics' it_behaves_like 'group value stream analytics'
...@@ -299,7 +291,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do ...@@ -299,7 +291,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
deploy_master(user, project, environment: 'staging') deploy_master(user, project, environment: 'staging')
deploy_master(user, project) deploy_master(user, project)
select_group select_group(group)
end end
stages_with_data = [ stages_with_data = [
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe 'Multiple value streams', :js do RSpec.describe 'Multiple value streams', :js do
include CycleAnalyticsHelpers
let_it_be(:group) { create(:group, name: 'CA-test-group') } 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(:project) { create(:project, :repository, namespace: group, group: group, name: 'Cool fun project') }
let_it_be(:user) do let_it_be(:user) do
...@@ -11,8 +13,9 @@ RSpec.describe 'Multiple value streams', :js do ...@@ -11,8 +13,9 @@ RSpec.describe 'Multiple value streams', :js do
end end
end end
value_stream_selector = '[data-testid="dropdown-value-streams"]' 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(:value_stream_dropdown) { page.find(value_stream_selector) }
let!(:default_value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'default') } let!(:default_value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'default') }
...@@ -20,12 +23,6 @@ RSpec.describe 'Multiple value streams', :js do ...@@ -20,12 +23,6 @@ RSpec.describe 'Multiple value streams', :js do
let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: project, created_at: 2.days.ago) } let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: project, created_at: 2.days.ago) }
end end
def select_group(target_group = group)
visit group_analytics_cycle_analytics_path(target_group)
expect(page).to have_selector '.js-stage-table' # wait_for_stages_to_load
end
before do before do
stub_licensed_features(cycle_analytics_for_groups: true, type_of_work_analytics: true) stub_licensed_features(cycle_analytics_for_groups: true, type_of_work_analytics: true)
...@@ -43,37 +40,83 @@ RSpec.describe 'Multiple value streams', :js do ...@@ -43,37 +40,83 @@ RSpec.describe 'Multiple value streams', :js do
wait_for_requests wait_for_requests
end end
def add_custom_stage_to_form
page.find_button(s_('CreateValueStreamForm|Add another stage')).click
fill_in "custom-stage-name-6", with: "Cool custom stage - name"
select_dropdown_option_by_value "custom-stage-start-event-6", :merge_request_created
select_dropdown_option_by_value "custom-stage-end-event-6", :merge_request_merged
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
describe 'Create value stream' do describe 'Create value stream' do
before do before do
select_group select_group(group)
wait_for_requests toggle_value_stream_dropdown
page.find_button(_('Create new Value Stream')).click
end
it 'includes additional form fields' do
expect(page).to have_selector(extended_form_fields_selector)
end end
it 'can create a value stream' do it 'can create a value stream' do
custom_value_stream_name = "New created value stream" create_value_stream
expect(page).to have_text(_("'%{name}' Value Stream created") % { name: custom_value_stream_name })
end
it 'can create a value stream with a custom stage and hidden defaults' 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
create_value_stream
expect(page).to have_text(_("'%{name}' Value Stream created") % { name: custom_value_stream_name })
expect(page.all("[data-testid='gl-path-nav'] .gl-path-button").count).to eq(4)
end
end
describe 'with the `value_stream_analytics_extended_form` feature flag disabled' do
before do
stub_licensed_features(cycle_analytics_for_groups: true, type_of_work_analytics: true)
stub_feature_flags(value_stream_analytics_extended_form: false)
sign_in(user)
select_group(group)
toggle_value_stream_dropdown toggle_value_stream_dropdown
page.find_button(_('Create new Value Stream')).click page.find_button(_('Create new Value Stream')).click
end
fill_in 'create-value-stream-name', with: custom_value_stream_name it 'does not include additional form fields' do
page.find_button(_('Create Value Stream')).click expect(page).not_to have_selector(extended_form_fields_selector)
wait_for_requests end
it 'can create a value stream' do
create_value_stream
expect(page).to have_text(_("'%{name}' Value Stream created") % { name: custom_value_stream_name }) expect(page).to have_text(_("'%{name}' Value Stream created") % { name: custom_value_stream_name })
end end
end end
describe 'Delete value stream' do describe 'Delete value stream' do
let(:custom_value_stream_name) { "Test value stream" }
before do before do
value_stream = create(:cycle_analytics_group_value_stream, name: custom_value_stream_name, group: group) value_stream = create(:cycle_analytics_group_value_stream, name: custom_value_stream_name, group: group)
create(:cycle_analytics_group_stage, value_stream: value_stream) create(:cycle_analytics_group_stage, value_stream: value_stream)
select_group select_group(group)
wait_for_requests
end end
it 'can delete a value stream' do it 'can delete a value stream' do
......
...@@ -3,6 +3,32 @@ ...@@ -3,6 +3,32 @@
module CycleAnalyticsHelpers module CycleAnalyticsHelpers
include GitHelpers include GitHelpers
def wait_for_stages_to_load
expect(page).to have_selector '.js-stage-table'
wait_for_requests
end
def select_group(target_group)
visit group_analytics_cycle_analytics_path(target_group)
wait_for_stages_to_load
end
def toggle_dropdown(field)
page.within("[data-testid='#{field}']") do
find('.dropdown-toggle').click
wait_for_requests
expect(find('.dropdown-menu')).to have_selector('.dropdown-item')
end
end
def select_dropdown_option_by_value(name, value, elem = '.dropdown-item')
toggle_dropdown name
page.find("[data-testid='#{name}'] .dropdown-menu").find("#{elem}[value='#{value}']").click
end
def create_commit_referencing_issue(issue, branch_name: generate(:branch)) def create_commit_referencing_issue(issue, branch_name: generate(:branch))
project.repository.add_branch(user, branch_name, 'master') project.repository.add_branch(user, branch_name, 'master')
create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name) create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name)
......
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