Commit 58acfc19 authored by Vitali Tatarintev's avatar Vitali Tatarintev

Merge branch '297370-persist-value-stream-feature-specs' into 'master'

Create value stream feature specs

See merge request gitlab-org/gitlab!53000
parents c00d73be 12ac01db
......@@ -2,6 +2,8 @@
require 'spec_helper'
RSpec.describe 'Value stream analytics charts', :js do
include CycleAnalyticsHelpers
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group, name: 'CA-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
let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: project, created_at: 2.days.ago) }
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)
stage.hover
......@@ -62,7 +54,7 @@ RSpec.describe 'Value stream analytics charts', :js do
end
before do
select_group
select_group(group)
end
it 'has all the default stages' 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])
end
select_group
select_group(group)
end
it 'displays the chart' do
......@@ -127,7 +119,7 @@ RSpec.describe 'Value stream analytics charts', :js do
context 'no data available' do
before do
select_group
select_group(group)
end
it 'shows the no data available message' do
......
......@@ -3,6 +3,7 @@ require 'spec_helper'
RSpec.describe 'Customizable Group Value Stream Analytics', :js do
include DragTo
include CycleAnalyticsHelpers
let_it_be(:group) { create(:group, name: 'CA-test-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
Analytics::CycleAnalytics::Stages::CreateService.new(parent: parent_group, params: params, current_user: user).execute
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)
stage.hover
......@@ -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
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)
page.find("[data-testid='#{field}'] .dropdown-menu").all('.dropdown-item')[index].click
end
......@@ -105,7 +85,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'Manual ordering' do
before do
select_group
select_group(group)
end
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
page.driver.browser.manage.window.resize_to(1650, 1150)
create_custom_stage
select_group
select_group(group)
end
it 'allows a stage to be dragged' do
......@@ -153,7 +133,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
it 'persists the order when a group is selected' do
drag_from_index_to_index(start_index, end_index)
select_group
select_group(group)
confirm_stage_order(updated_order)
end
......@@ -175,7 +155,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'Add a stage button' do
before do
select_group
select_group(group)
end
it 'displays the custom stage form when clicked' do
......@@ -332,7 +312,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'with a group' do
context 'selected' do
before do
select_group
select_group(group)
end
it_behaves_like 'can create custom stages' 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
before do
create_custom_stage
select_group
select_group(group)
expect(page).to have_text custom_stage_name
end
......@@ -391,7 +371,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
end
before do
select_group
select_group(group)
toggle_more_options(first_default_stage)
end
......@@ -443,7 +423,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
context 'custom stages' do
before do
create_custom_stage
select_group
select_group(group)
expect(page).to have_text custom_stage_name
......@@ -487,7 +467,7 @@ RSpec.describe 'Customizable Group Value Stream Analytics', :js do
end
before do
select_group
select_group(group)
end
it 'has all the default stages' do
......
......@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'Group value stream analytics filters and data', :js do
include CycleAnalyticsHelpers
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
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
let_it_be("issue_#{i}".to_sym) { create(:issue, title: "New Issue #{i}", project: sub_group_project, created_at: 2.days.ago) }
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)
string_id = "CycleAnalyticsStage|#{name}"
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
before do
stub_feature_flags(value_stream_analytics_path_navigation: false)
select_group
select_group(group)
end
it 'shows the path navigation' do
......@@ -256,7 +248,7 @@ RSpec.describe 'Group value stream analytics filters and data', :js do
let(:selected_group) { group }
before do
select_group
select_group(group)
end
it_behaves_like 'group value stream analytics'
......@@ -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)
select_group
select_group(group)
end
stages_with_data = [
......
......@@ -2,6 +2,8 @@
require 'spec_helper'
RSpec.describe 'Multiple value streams', :js do
include CycleAnalyticsHelpers
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(:user) do
......@@ -11,8 +13,9 @@ RSpec.describe 'Multiple value streams', :js do
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!(:default_value_stream) { create(:cycle_analytics_group_value_stream, group: group, name: 'default') }
......@@ -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) }
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
stub_licensed_features(cycle_analytics_for_groups: true, type_of_work_analytics: true)
......@@ -43,37 +40,83 @@ 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
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
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
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
page.find_button(_('Create new Value Stream')).click
end
fill_in 'create-value-stream-name', with: custom_value_stream_name
page.find_button(_('Create Value Stream')).click
wait_for_requests
it 'does not include additional form fields' do
expect(page).not_to have_selector(extended_form_fields_selector)
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 })
end
end
describe 'Delete value stream' do
let(:custom_value_stream_name) { "Test value stream" }
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)
select_group
wait_for_requests
select_group(group)
end
it 'can delete a value stream' do
......
......@@ -3,6 +3,32 @@
module CycleAnalyticsHelpers
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))
project.repository.add_branch(user, branch_name, 'master')
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