diff --git a/.rubocop_todo/factory_bot/excessive_create_list.yml b/.rubocop_todo/factory_bot/excessive_create_list.yml index 5f88e22c926714e0d065c056407b993bfc1fb94c..19e999d44e94d09cd7eb28df5d4e936f4636b011 100644 --- a/.rubocop_todo/factory_bot/excessive_create_list.yml +++ b/.rubocop_todo/factory_bot/excessive_create_list.yml @@ -20,7 +20,6 @@ FactoryBot/ExcessiveCreateList: - 'spec/features/issues/user_scrolls_to_deeplinked_note_spec.rb' - 'spec/features/projects/container_registry_spec.rb' - 'spec/features/users/overview_spec.rb' - - 'spec/features/work_items/work_item_spec.rb' - 'spec/frontend/fixtures/timelogs.rb' - 'spec/lib/gitlab/database/background_migration/batched_migration_spec.rb' - 'spec/lib/gitlab/database/consistency_checker_spec.rb' diff --git a/.rubocop_todo/rspec/before_all_role_assignment.yml b/.rubocop_todo/rspec/before_all_role_assignment.yml index 87778b63c78fee004c5a341e94924d1608b63e43..6fb55a5631aeeeab71aa108957aee3a765d702af 100644 --- a/.rubocop_todo/rspec/before_all_role_assignment.yml +++ b/.rubocop_todo/rspec/before_all_role_assignment.yml @@ -822,7 +822,6 @@ RSpec/BeforeAllRoleAssignment: - 'spec/features/user_can_display_performance_bar_spec.rb' - 'spec/features/user_sorts_things_spec.rb' - 'spec/features/work_items/work_item_children_spec.rb' - - 'spec/features/work_items/work_item_spec.rb' - 'spec/finders/alert_management/alerts_finder_spec.rb' - 'spec/finders/autocomplete/deploy_keys_with_write_access_finder_spec.rb' - 'spec/finders/autocomplete/routes_finder_spec.rb' diff --git a/doc/development/work_items_widgets.md b/doc/development/work_items_widgets.md index dbd0718293c16045c570e36595a555254ee12102..86861d7b356b55a92cfa4098c7aab380a06af5cc 100644 --- a/doc/development/work_items_widgets.md +++ b/doc/development/work_items_widgets.md @@ -154,7 +154,7 @@ Now you can update tests for existing files and write tests for the new files: 1. `spec/frontend/work_items/components/work_item_attributes_wrapper_spec.js` or `ee/spec/frontend/work_items/components/work_item_attributes_wrapper_spec.js`. 1. `spec/frontend/work_items/components/work_item_<widget_name>_spec.js` or `ee/spec/frontend/work_items/components/work_item_<widget_name>_spec.js`. 1. `spec/frontend/work_items/graphql/resolvers_spec.js` or `ee/spec/frontend/work_items/graphql/resolvers_spec.js`. -1. `spec/features/work_items/work_item_spec.rb` or `ee/spec/features/work_items/work_item_spec.rb`. +1. `spec/features/work_items/work_item_detail_spec.rb` or `ee/spec/features/work_items/work_item_detail_spec.rb`. NOTE: You may find some feature specs failing because of excessive SQL queries. diff --git a/ee/spec/features/work_items/work_item_spec.rb b/ee/spec/features/work_items/work_item_detail_spec.rb similarity index 71% rename from ee/spec/features/work_items/work_item_spec.rb rename to ee/spec/features/work_items/work_item_detail_spec.rb index 266d06d8bbf3e6fa53a778aac74b8a7beb18172d..c2dc2b4a6e79442e71ad4609e0393376f5eaec13 100644 --- a/ee/spec/features/work_items/work_item_spec.rb +++ b/ee/spec/features/work_items/work_item_detail_spec.rb @@ -2,23 +2,23 @@ require 'spec_helper' -RSpec.describe 'Work item', :js, feature_category: :team_planning do +RSpec.describe 'Work item detail', :js, feature_category: :team_planning do include ListboxHelpers let_it_be_with_reload(:user) { create(:user) } let_it_be(:group) { create(:group, :nested) } - let_it_be(:project) { create(:project, :public, namespace: group) } + let_it_be(:project) { create(:project, :public, namespace: group, developers: user) } let_it_be(:work_item) { create(:work_item, project: project) } let(:work_items_path) { project_work_item_path(project, work_item.iid) } context 'for signed in user' do before do - project.add_developer(user) # rubocop:disable RSpec/BeforeAllRoleAssignment -- we can remove this when we have more ee features specs sign_in(user) visit work_items_path end + it_behaves_like 'work items weight' it_behaves_like 'work items iteration' end end diff --git a/spec/features/work_items/work_item_spec.rb b/spec/features/work_items/work_item_detail_spec.rb similarity index 69% rename from spec/features/work_items/work_item_spec.rb rename to spec/features/work_items/work_item_detail_spec.rb index 00a64efba68d3477022ce60612f524cd41004a1d..5111c91ede7d672ec81b8e2b81f795e24ee01faa 100644 --- a/spec/features/work_items/work_item_spec.rb +++ b/spec/features/work_items/work_item_detail_spec.rb @@ -2,11 +2,7 @@ require 'spec_helper' -RSpec.describe 'Work item', :js, feature_category: :team_planning do - before do - stub_feature_flags(notifications_todos_buttons: false) - end - +RSpec.describe 'Work item detail', :js, feature_category: :team_planning do include ListboxHelpers let_it_be_with_reload(:user) { create(:user) } @@ -20,18 +16,21 @@ let_it_be(:task) { create(:work_item, :task, project: project) } let_it_be(:emoji_upvote) { create(:award_emoji, :upvote, awardable: work_item, user: user2) } let_it_be(:milestone) { create(:milestone, project: project) } - let_it_be(:milestones) { create_list(:milestone, 25, project: project) } + let_it_be(:milestones) { create_list(:milestone, 10, project: project) } let_it_be(:note) { create(:note, noteable: work_item, project: work_item.project) } - let(:work_items_path) { project_work_item_path(project, work_item.iid) } - let(:list_path) { project_issues_path(project) } let_it_be(:contact) { create(:contact, group: group) } let(:contact_name) { "#{contact.first_name} #{contact.last_name}" } + let(:list_path) { project_issues_path(project) } + let(:work_items_path) { project_work_item_path(project, work_item.iid) } context 'for signed in user' do + before_all do + group.add_developer(user) + end + before do stub_feature_flags(notifications_todos_buttons: false) stub_const("AutocompleteSources::ExpiresIn::AUTOCOMPLETE_EXPIRES_IN", 0) - group.add_developer(user) sign_in(user) visit work_items_path end @@ -44,41 +43,6 @@ end end - it 'actions dropdown is displayed' do - expect(page).to have_button _('More actions') - end - - context 'when work_items_beta is enabled' do - before do - stub_feature_flags(work_items_beta: true) - stub_feature_flags(notifications_todos_buttons: false) - - page.refresh - wait_for_all_requests - end - - it 'reassigns to another user', - quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/413074' do - within_testid('work-item-assignees') do - click_button 'Edit' - end - - select_listbox_item(user.username) - - wait_for_requests - - within_testid('work-item-assignees') do - click_button 'Edit' - end - - select_listbox_item(user2.username) - - wait_for_requests - - expect(work_item.reload.assignees).to include(user2) - end - end - it_behaves_like 'work items title' it_behaves_like 'work items description' it_behaves_like 'work items award emoji' @@ -97,34 +61,43 @@ it_behaves_like 'work items crm contacts' end - context 'for signed in owner' do + context 'when item is a task' do + before_all do + project.add_developer(user) + end + before do - project.add_owner(user) sign_in(user) - visit work_items_path + visit project_work_item_path(project, task.iid) end - it_behaves_like 'work items invite members' + it_behaves_like 'work items parent', :issue end - context 'for guest users' do + context 'for signed in owner' do + before_all do + project.add_owner(user) + end + before do - project.add_guest(user) sign_in(user) visit work_items_path end - it_behaves_like 'work items comment actions for guest users' + it_behaves_like 'work items invite members' end - context 'when item is a task' do + context 'for guest users' do + before_all do + project.add_guest(user) + end + before do - project.add_developer(user) sign_in(user) - visit project_work_item_path(project, task.iid) + visit work_items_path end - it_behaves_like 'work items parent', :issue + it_behaves_like 'work items comment actions for guest users' end context 'for user not signed in' do @@ -146,26 +119,5 @@ expect(page).to have_content(note.note) end - - context 'when work_items_beta is enabled' do - before do - stub_feature_flags(work_items_beta: true) - - page.refresh - wait_for_all_requests - end - - it 'hides the assignees edit button' do - within_testid('work-item-assignees') do - expect(page).not_to have_button('Edit') - end - end - - it 'hides the labels edit button' do - within_testid('work-item-labels') do - expect(page).not_to have_button('Edit') - end - end - end end end diff --git a/spec/scripts/setup/tests-metadata_spec.rb b/spec/scripts/setup/tests-metadata_spec.rb index d602a9f59a19099aa060cf2af5a16dbfce8c315a..29b7df39e8d7b44ae45a30b8252a79fac9b839bd 100644 --- a/spec/scripts/setup/tests-metadata_spec.rb +++ b/spec/scripts/setup/tests-metadata_spec.rb @@ -383,7 +383,7 @@ def expect_system_curl_with(arguments, curl_return) let(:fast_quarantine_report) do <<~TEXT qa/specs/features/ee/browser_ui/3_create/remote_development/workspace_actions_spec.rb - spec/features/work_items/work_item_spec.rb:67 + spec/features/work_items/work_item_detail_spec.rb:67 TEXT end diff --git a/spec/support/helpers/user_with_namespace_shim.yml b/spec/support/helpers/user_with_namespace_shim.yml index b0145b16ed07854593e239e7bbe63b777762e959..8d50dc78996be33567f7cd58f4dcb5d7dae0cbf0 100644 --- a/spec/support/helpers/user_with_namespace_shim.yml +++ b/spec/support/helpers/user_with_namespace_shim.yml @@ -600,7 +600,7 @@ - spec/features/users/user_browses_projects_on_user_page_spec.rb - spec/features/webauthn_spec.rb - spec/features/whats_new_spec.rb -- spec/features/work_items/work_item_spec.rb +- spec/features/work_items/work_item_detail_spec.rb - spec/finders/admin/projects_finder_spec.rb - spec/finders/autocomplete/move_to_project_finder_spec.rb - spec/finders/autocomplete/routes_finder_spec.rb diff --git a/spec/support/shared_examples/features/work_items/work_items_shared_examples.rb b/spec/support/shared_examples/features/work_items/work_items_shared_examples.rb index b92ea6fe7807b6f31c0a62a14dca50931852b790..6c999ab9f0456510c4a18bfeb993baba0df7dc98 100644 --- a/spec/support/shared_examples/features/work_items/work_items_shared_examples.rb +++ b/spec/support/shared_examples/features/work_items/work_items_shared_examples.rb @@ -1,15 +1,5 @@ # frozen_string_literal: true -RSpec.shared_context 'with work_items_beta' do |flag| - before do - stub_feature_flags(work_items_beta: flag) - stub_feature_flags(notifications_todos_buttons: false) - - page.refresh - wait_for_all_requests - end -end - RSpec.shared_examples 'work items title' do it 'updates title' do click_button 'Edit', match: :first @@ -336,16 +326,16 @@ def click_reply_and_enter_slash it 'adds and removes milestone', :aggregate_failures do within_testid 'work-item-milestone' do click_button 'Edit' - send_keys "\"#{milestones[11].title}\"" - select_listbox_item(milestones[11].title) + send_keys "\"#{milestones[8].title}\"" + select_listbox_item(milestones[8].title) - expect(page).to have_link(milestones[11].title) + expect(page).to have_link(milestones[8].title) click_button 'Edit' click_button 'Clear' expect(page).to have_text('None') - expect(page).not_to have_link(milestones[11].title) + expect(page).not_to have_link(milestones[8].title) end end end @@ -492,6 +482,28 @@ def find_and_click_clear(selector, button_name = 'Clear') end end +RSpec.shared_examples 'work items weight' do + it 'updates and clears a weight', :aggregate_failures do + within_testid 'work-item-weight' do + click_button 'Edit' + send_keys(3, :enter) + + expect(page).to have_text(3) + + click_button 'Edit' + send_keys(:backspace, 0, :enter) + + expect(page).to have_text(0) + expect(page).not_to have_text('None') + + click_button 'Edit' + send_keys(:backspace, :enter) + + expect(page).to have_text('None') + end + end +end + RSpec.shared_examples 'work items iteration' do include Features::IterationHelpers let(:work_item_iteration_selector) { '[data-testid="work-item-iteration"]' }