diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 11:41:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 11:41:52 +0300 |
commit | 585826cb22ecea5998a2c2a4675735c94bdeedac (patch) | |
tree | 5b05f0b30d33cef48963609e8a18a4dff260eab3 /spec/features | |
parent | df221d036e5d0c6c0ee4d55b9c97f481ee05dee8 (diff) |
Add latest changes from gitlab-org/gitlab@16-6-stable-eev16.6.0-rc42
Diffstat (limited to 'spec/features')
218 files changed, 1996 insertions, 2594 deletions
diff --git a/spec/features/abuse_report_spec.rb b/spec/features/abuse_report_spec.rb index f1df5c2d6f0..eac29b0b741 100644 --- a/spec/features/abuse_report_spec.rb +++ b/spec/features/abuse_report_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe 'Abuse reports', :js, feature_category: :insider_threat do - let_it_be(:abusive_user) { create(:user, :no_super_sidebar) } + let_it_be(:abusive_user) { create(:user) } - let_it_be(:reporter1) { create(:user, :no_super_sidebar) } + let_it_be(:reporter1) { create(:user) } let_it_be(:project) { create(:project, :public, :repository) } let_it_be(:issue) { create(:issue, project: project, author: abusive_user) } @@ -55,103 +55,53 @@ RSpec.describe 'Abuse reports', :js, feature_category: :insider_threat do it_behaves_like 'reports the user with an abuse category' end - describe 'when user_profile_overflow_menu FF turned on' do - context 'when reporting a user profile for abuse' do - let_it_be(:reporter2) { create(:user, :no_super_sidebar) } + context 'when reporting a user profile for abuse' do + let_it_be(:reporter2) { create(:user) } - before do - visit user_path(abusive_user) - find_by_testid('base-dropdown-toggle').click - end - - it_behaves_like 'reports the user with an abuse category' - - it 'allows the reporter to report the same user for different abuse categories' do - visit user_path(abusive_user) - - find_by_testid('base-dropdown-toggle').click - fill_and_submit_abuse_category_form - fill_and_submit_report_abuse_form - - expect(page).to have_content 'Thank you for your report' - - visit user_path(abusive_user) - - find_by_testid('base-dropdown-toggle').click - fill_and_submit_abuse_category_form("They're being offensive or abusive.") - fill_and_submit_report_abuse_form - - expect(page).to have_content 'Thank you for your report' - end - - it 'allows multiple users to report the same user' do - fill_and_submit_abuse_category_form - fill_and_submit_report_abuse_form - - expect(page).to have_content 'Thank you for your report' - - gitlab_sign_out - gitlab_sign_in(reporter2) - - visit user_path(abusive_user) - - find_by_testid('base-dropdown-toggle').click - fill_and_submit_abuse_category_form - fill_and_submit_report_abuse_form - - expect(page).to have_content 'Thank you for your report' - end - - it_behaves_like 'cancel report' + before do + visit user_path(abusive_user) + find_by_testid('user-profile-actions').click end - end - - describe 'when user_profile_overflow_menu FF turned off' do - context 'when reporting a user profile for abuse' do - let_it_be(:reporter2) { create(:user, :no_super_sidebar) } - before do - stub_feature_flags(user_profile_overflow_menu_vue: false) - visit user_path(abusive_user) - end - - it_behaves_like 'reports the user with an abuse category' - - it 'allows the reporter to report the same user for different abuse categories' do - visit user_path(abusive_user) + it_behaves_like 'reports the user with an abuse category' - fill_and_submit_abuse_category_form - fill_and_submit_report_abuse_form + it 'allows the reporter to report the same user for different abuse categories' do + visit user_path(abusive_user) - expect(page).to have_content 'Thank you for your report' + find_by_testid('user-profile-actions').click + fill_and_submit_abuse_category_form + fill_and_submit_report_abuse_form - visit user_path(abusive_user) + expect(page).to have_content 'Thank you for your report' - fill_and_submit_abuse_category_form("They're being offensive or abusive.") - fill_and_submit_report_abuse_form + visit user_path(abusive_user) - expect(page).to have_content 'Thank you for your report' - end + find_by_testid('user-profile-actions').click + fill_and_submit_abuse_category_form("They're being offensive or abusive.") + fill_and_submit_report_abuse_form - it 'allows multiple users to report the same user' do - fill_and_submit_abuse_category_form - fill_and_submit_report_abuse_form + expect(page).to have_content 'Thank you for your report' + end - expect(page).to have_content 'Thank you for your report' + it 'allows multiple users to report the same user', :js do + fill_and_submit_abuse_category_form + fill_and_submit_report_abuse_form - gitlab_sign_out - gitlab_sign_in(reporter2) + expect(page).to have_content 'Thank you for your report' - visit user_path(abusive_user) + gitlab_sign_out + gitlab_sign_in(reporter2) - fill_and_submit_abuse_category_form - fill_and_submit_report_abuse_form + visit user_path(abusive_user) - expect(page).to have_content 'Thank you for your report' - end + find_by_testid('user-profile-actions').click + fill_and_submit_abuse_category_form + fill_and_submit_report_abuse_form - it_behaves_like 'cancel report' + expect(page).to have_content 'Thank you for your report' end + + it_behaves_like 'cancel report' end context 'when reporting an merge request for abuse' do @@ -180,10 +130,6 @@ RSpec.describe 'Abuse reports', :js, feature_category: :insider_threat do end end - # TODO: implement tests before the FF "user_profile_overflow_menu_vue" is turned on - # See: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122971 - # Related Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/416983 - private def fill_and_submit_abuse_category_form(category = "They're posting spam.") diff --git a/spec/features/admin/admin_browse_spam_logs_spec.rb b/spec/features/admin/admin_browse_spam_logs_spec.rb index c272a8630b7..f781e2adf07 100644 --- a/spec/features/admin/admin_browse_spam_logs_spec.rb +++ b/spec/features/admin/admin_browse_spam_logs_spec.rb @@ -4,9 +4,9 @@ require 'spec_helper' RSpec.describe 'Admin browse spam logs', feature_category: :shared do let!(:spam_log) { create(:spam_log, description: 'abcde ' * 20) } + let(:admin) { create(:admin) } before do - admin = create(:admin) sign_in(admin) gitlab_enable_admin_mode_sign_in(admin) end @@ -22,6 +22,7 @@ RSpec.describe 'Admin browse spam logs', feature_category: :shared do expect(page).to have_content("#{spam_log.description[0...97]}...") expect(page).to have_link('Remove user') expect(page).to have_link('Block user') + expect(page).to have_link('Trust user') end it 'does not perform N+1 queries' do @@ -30,4 +31,15 @@ RSpec.describe 'Admin browse spam logs', feature_category: :shared do expect { visit admin_spam_logs_path }.not_to exceed_query_limit(control_queries) end + + context 'when user is trusted' do + before do + UserCustomAttribute.set_trusted_by(user: spam_log.user, trusted_by: admin) + end + + it 'allows admin to untrust the user' do + visit admin_spam_logs_path + expect(page).to have_link('Untrust user') + end + end end diff --git a/spec/features/admin/admin_deploy_keys_spec.rb b/spec/features/admin/admin_deploy_keys_spec.rb index f59b4db5cc2..f9510ef296a 100644 --- a/spec/features/admin/admin_deploy_keys_spec.rb +++ b/spec/features/admin/admin_deploy_keys_spec.rb @@ -18,7 +18,7 @@ RSpec.describe 'admin deploy keys', :js, feature_category: :system_access do it 'show all public deploy keys' do visit admin_deploy_keys_path - page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do + within_testid('deploy-keys-list', match: :first) do expect(page).to have_content(deploy_key.title) expect(page).to have_content(another_deploy_key.title) end @@ -29,7 +29,7 @@ RSpec.describe 'admin deploy keys', :js, feature_category: :system_access do visit admin_deploy_keys_path - page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do + within_testid('deploy-keys-list', match: :first) do expect(page).to have_content(write_key.project.full_name) end end @@ -49,7 +49,7 @@ RSpec.describe 'admin deploy keys', :js, feature_category: :system_access do expect(page).to have_current_path admin_deploy_keys_path, ignore_query: true - page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do + within_testid('deploy-keys-list', match: :first) do expect(page).to have_content('laptop') end end @@ -69,7 +69,7 @@ RSpec.describe 'admin deploy keys', :js, feature_category: :system_access do expect(page).to have_current_path admin_deploy_keys_path, ignore_query: true - page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do + within_testid('deploy-keys-list', match: :first) do expect(page).to have_content('new-title') end end @@ -88,7 +88,7 @@ RSpec.describe 'admin deploy keys', :js, feature_category: :system_access do end expect(page).to have_current_path admin_deploy_keys_path, ignore_query: true - page.within(find('[data-testid="deploy-keys-list"]', match: :first)) do + within_testid('deploy-keys-list', match: :first) do expect(page).not_to have_content(deploy_key.title) end end diff --git a/spec/features/admin/admin_dev_ops_reports_spec.rb b/spec/features/admin/admin_dev_ops_reports_spec.rb index f290464b043..99d43e6b0da 100644 --- a/spec/features/admin/admin_dev_ops_reports_spec.rb +++ b/spec/features/admin/admin_dev_ops_reports_spec.rb @@ -19,8 +19,8 @@ RSpec.describe 'DevOps Report page', :js, feature_category: :devops_reports do expect(page).to have_content 'Introducing Your DevOps Report' - page.within(find('[data-testid="devops-score-container"]')) do - find('[data-testid="close-icon"]').click + within_testid('devops-score-container') do + find_by_testid('close-icon').click end expect(page).not_to have_content 'Introducing Your DevOps Report' diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index 1e3dbd7fea4..f071da1835a 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -138,7 +138,7 @@ RSpec.describe 'Admin Groups', feature_category: :groups_and_projects do it 'shows access requests with link to manage access' do visit admin_group_path(group) - page.within '[data-testid="access-requests"]' do + within_testid('access-requests') do expect(page).to have_content access_request.user.name expect(page).to have_link 'Manage access', href: group_group_members_path(group, tab: 'access_requests') end diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb index a5acba1fe4a..2aec5baf351 100644 --- a/spec/features/admin/admin_hooks_spec.rb +++ b/spec/features/admin/admin_hooks_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Admin::Hooks', feature_category: :webhooks do include Spec::Support::Helpers::ModalHelpers - let_it_be(:user) { create(:admin, :no_super_sidebar) } + let_it_be(:user) { create(:admin) } before do sign_in(user) @@ -13,10 +13,10 @@ RSpec.describe 'Admin::Hooks', feature_category: :webhooks do end describe 'GET /admin/hooks' do - it 'is ok' do + it 'is ok', :js do visit admin_root_path - page.within '.nav-sidebar' do + within_testid('super-sidebar') do click_on 'System Hooks', match: :first end diff --git a/spec/features/admin/admin_jobs_spec.rb b/spec/features/admin/admin_jobs_spec.rb index b125974532b..b3e21d02354 100644 --- a/spec/features/admin/admin_jobs_spec.rb +++ b/spec/features/admin/admin_jobs_spec.rb @@ -132,7 +132,7 @@ RSpec.describe 'Admin Jobs', :js, feature_category: :continuous_integration do within_testid('jobs-table') do expect(page).to have_selector('[data-testid="jobs-table-row"]', count: 1) - expect(find_by_testid('ci-badge-text')).to have_content('Failed') + expect(find_by_testid('ci-icon-text')).to have_content('Failed') end end end diff --git a/spec/features/admin/admin_mode/logout_spec.rb b/spec/features/admin/admin_mode/logout_spec.rb index 5d9106fea02..7a33256e7a8 100644 --- a/spec/features/admin/admin_mode/logout_spec.rb +++ b/spec/features/admin/admin_mode/logout_spec.rb @@ -5,9 +5,8 @@ require 'spec_helper' RSpec.describe 'Admin Mode Logout', :js, feature_category: :system_access do include TermsHelper include UserLoginHelper - include Features::TopNavSpecHelpers - let(:user) { create(:admin, :no_super_sidebar) } + let(:user) { create(:admin) } before do # TODO: This used to use gitlab_sign_in, instead of sign_in, but that is buggy. See @@ -22,11 +21,9 @@ RSpec.describe 'Admin Mode Logout', :js, feature_category: :system_access do expect(page).to have_current_path root_path, ignore_query: true - open_top_nav + click_button 'Search or go to…' - within_top_nav do - expect(page).to have_link(href: new_admin_session_path) - end + expect(page).to have_link(href: new_admin_session_path) end it 'disable shows flash notice' do @@ -45,11 +42,9 @@ RSpec.describe 'Admin Mode Logout', :js, feature_category: :system_access do expect(page).to have_current_path root_path, ignore_query: true - open_top_nav + click_button 'Search or go to…' - within_top_nav do - expect(page).to have_link(href: new_admin_session_path) - end + expect(page).to have_link(href: new_admin_session_path) end end end diff --git a/spec/features/admin/admin_mode/workers_spec.rb b/spec/features/admin/admin_mode/workers_spec.rb index 2a862c750d7..124c43eef9d 100644 --- a/spec/features/admin/admin_mode/workers_spec.rb +++ b/spec/features/admin/admin_mode/workers_spec.rb @@ -6,8 +6,8 @@ require 'spec_helper' RSpec.describe 'Admin mode for workers', :request_store, feature_category: :system_access do include Features::AdminUsersHelpers - let(:user) { create(:user, :no_super_sidebar) } - let(:user_to_delete) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } + let(:user_to_delete) { create(:user) } before do sign_in(user) @@ -22,7 +22,7 @@ RSpec.describe 'Admin mode for workers', :request_store, feature_category: :syst end context 'as an admin user' do - let(:user) { create(:admin, :no_super_sidebar) } + let(:user) { create(:admin) } context 'when admin mode disabled' do it 'cannot delete user', :js do diff --git a/spec/features/admin/admin_mode_spec.rb b/spec/features/admin/admin_mode_spec.rb index edfa58567ad..b1b44ce143f 100644 --- a/spec/features/admin/admin_mode_spec.rb +++ b/spec/features/admin/admin_mode_spec.rb @@ -4,10 +4,9 @@ require 'spec_helper' RSpec.describe 'Admin mode', :js, feature_category: :shared do include MobileHelpers - include Features::TopNavSpecHelpers include StubENV - let(:admin) { create(:admin, :no_super_sidebar) } + let(:admin) { create(:admin) } before do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') @@ -21,20 +20,16 @@ RSpec.describe 'Admin mode', :js, feature_category: :shared do context 'when not in admin mode' do it 'has no leave admin mode button' do visit new_admin_session_path - open_top_nav + open_search_modal - page.within('.navbar-sub-nav') do - expect(page).not_to have_link(href: destroy_admin_session_path) - end + expect(page).not_to have_link(href: destroy_admin_session_path) end it 'can open pages not in admin scope' do visit new_admin_session_path - open_top_nav_projects + open_search_modal - within_top_nav do - click_link('View all projects') - end + click_link('View all my projects') expect(page).to have_current_path(dashboard_projects_path) end @@ -78,29 +73,23 @@ RSpec.describe 'Admin mode', :js, feature_category: :shared do end it 'contains link to leave admin mode' do - open_top_nav + open_search_modal - within_top_nav do - expect(page).to have_link(href: destroy_admin_session_path) - end + expect(page).to have_link(href: destroy_admin_session_path) end it 'can leave admin mode using main dashboard link' do gitlab_disable_admin_mode - open_top_nav + open_search_modal - within_top_nav do - expect(page).to have_link(href: new_admin_session_path) - end + expect(page).to have_link(href: new_admin_session_path) end it 'can open pages not in admin scope' do - open_top_nav_projects + open_search_modal - within_top_nav do - click_link('View all projects') - end + click_link('View all my projects') expect(page).to have_current_path(dashboard_projects_path) end @@ -108,7 +97,7 @@ RSpec.describe 'Admin mode', :js, feature_category: :shared do context 'nav bar' do it 'shows admin dashboard links on bigger screen' do visit root_dashboard_path - open_top_nav + open_search_modal expect(page).to have_link(text: 'Admin', href: admin_root_path, visible: true) expect(page).to have_link(text: 'Leave admin mode', href: destroy_admin_session_path, visible: true) @@ -123,11 +112,9 @@ RSpec.describe 'Admin mode', :js, feature_category: :shared do it 'can leave admin mode' do gitlab_disable_admin_mode - open_top_nav + open_search_modal - within_top_nav do - expect(page).to have_link(href: new_admin_session_path) - end + expect(page).to have_link(href: new_admin_session_path) end end end @@ -141,10 +128,14 @@ RSpec.describe 'Admin mode', :js, feature_category: :shared do it 'shows no admin mode buttons in navbar' do visit admin_root_path - open_top_nav + open_search_modal expect(page).not_to have_link(href: new_admin_session_path) expect(page).not_to have_link(href: destroy_admin_session_path) end end + + def open_search_modal + click_button 'Search or go to…' + end end diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index 3454b7af962..b793299e253 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -95,7 +95,7 @@ RSpec.describe "Admin::Projects", feature_category: :groups_and_projects do context 'when project has open access requests' do it 'shows access requests with link to manage access' do - page.within '[data-testid="access-requests"]' do + within_testid('access-requests') do expect(page).to have_content access_request.user.name expect(page).to have_link 'Manage access', href: project_project_members_path(project, tab: 'access_requests') end diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index 9edd970532e..750f5f8d4b9 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -100,7 +100,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do visit admin_runners_path within_runner_row(runner.id) do - expect(find("[data-testid='job-count']")).to have_content '2' + expect(find_by_testid('job-count')).to have_content '2' end end @@ -116,8 +116,8 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do expect(current_url).to match(admin_runner_path(runner)) - expect(find("[data-testid='td-status']")).to have_content "Running" - expect(find("[data-testid='td-job']")).to have_content "##{job.id}" + expect(find_by_testid('td-status')).to have_content "Running" + expect(find_by_testid('td-job')).to have_content "##{job.id}" end describe 'search' do @@ -202,6 +202,36 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do end end + describe 'filter by version prefix' do + before_all do + runner_v15 = create(:ci_runner, :instance, description: 'runner-v15') + runner_v14 = create(:ci_runner, :instance, description: 'runner-v14') + + create(:ci_runner_machine, runner: runner_v15, version: '15.0.0') + create(:ci_runner_machine, runner: runner_v14, version: '14.0.0') + end + + before do + visit admin_runners_path + end + + it 'shows all runners' do + expect(page).to have_link('All 2') + + expect(page).to have_content 'runner-v15' + expect(page).to have_content 'runner-v14' + end + + it 'shows filtered runner based on supplied prefix' do + input_filtered_search_filter_is_only(s_('Runners|Version starts with'), '15.0') + + expect(page).to have_link('All 1') + + expect(page).not_to have_content 'runner-v14' + expect(page).to have_content 'runner-v15' + end + end + describe 'filter by status' do let_it_be(:never_contacted) do create(:ci_runner, :instance, description: 'runner-never-contacted', contacted_at: nil) @@ -291,7 +321,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do expect(page).to have_link('Group 1') expect(page).to have_link('Project 1') - page.within('[data-testid="runner-type-tabs"]') do + within_testid('runner-type-tabs') do expect(page).to have_link('All', class: 'active') end end @@ -302,7 +332,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do expect(page).to have_content 'runner-project' expect(page).to have_content 'runner-group' - page.within('[data-testid="runner-type-tabs"]') do + within_testid('runner-type-tabs') do click_on('Project') expect(page).to have_link('Project', class: 'active') @@ -315,7 +345,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do it 'show the same counts after selecting another tab' do visit admin_runners_path - page.within('[data-testid="runner-type-tabs"]') do + within_testid('runner-type-tabs') do click_on('Project') expect(page).to have_link('All 2') @@ -329,7 +359,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do visit admin_runners_path - page.within('[data-testid="runner-type-tabs"]') do + within_testid('runner-type-tabs') do click_on 'Project' end @@ -355,7 +385,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do expect(page).to have_content 'runner-group' expect(page).not_to have_content 'runner-paused-project' - page.within('[data-testid="runner-type-tabs"]') do + within_testid('runner-type-tabs') do click_on 'Project' end @@ -367,7 +397,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do context 'when type does not match' do before do visit admin_runners_path - page.within('[data-testid="runner-type-tabs"]') do + within_testid('runner-type-tabs') do click_on 'Instance' end end @@ -440,24 +470,28 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do visit admin_runners_path - within '[data-testid="runner-list"] tbody tr:nth-child(1)' do - expect(page).to have_content 'runner-2' - end + within_testid('runner-list') do + within('tbody tr:nth-child(1)') do + expect(page).to have_content 'runner-2' + end - within '[data-testid="runner-list"] tbody tr:nth-child(2)' do - expect(page).to have_content 'runner-1' + within('tbody tr:nth-child(2)') do + expect(page).to have_content 'runner-1' + end end click_on 'Created date' # Open "sort by" dropdown click_on 'Last contact' click_on 'Sort direction: Descending' - within '[data-testid="runner-list"] tbody tr:nth-child(1)' do - expect(page).to have_content 'runner-1' - end + within_testid('runner-list') do + within('tbody tr:nth-child(1)') do + expect(page).to have_content 'runner-1' + end - within '[data-testid="runner-list"] tbody tr:nth-child(2)' do - expect(page).to have_content 'runner-2' + within('tbody tr:nth-child(2)') do + expect(page).to have_content 'runner-2' + end end end end @@ -522,8 +556,8 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do describe 'runner show page breadcrumbs' do it 'contains the current runner id and token' do - page.within '[data-testid="breadcrumb-links"]' do - expect(page.find('[data-testid="breadcrumb-current-link"]')).to have_link( + within_testid('breadcrumb-links') do + expect(find_by_testid('breadcrumb-current-link')).to have_link( "##{runner.id} (#{runner.short_sha})" ) end @@ -555,7 +589,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do end it 'deletes runner and redirects to runner list' do - expect(page.find('[data-testid="alert-success"]')).to have_content('deleted') + expect(find_by_testid('alert-success')).to have_content('deleted') expect(current_url).to match(admin_runners_path) end end @@ -581,9 +615,9 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do describe 'breadcrumbs' do it 'contains the current runner id and token' do - page.within '[data-testid="breadcrumb-links"]' do + within_testid('breadcrumb-links') do expect(page).to have_link("##{project_runner.id} (#{project_runner.short_sha})") - expect(page.find('[data-testid="breadcrumb-current-link"]')).to have_content("Edit") + expect(find_by_testid('breadcrumb-current-link')).to have_content("Edit") end end end @@ -591,7 +625,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do describe 'runner header', :js do it 'contains the runner status, type and id' do expect(page).to have_content( - "##{project_runner.id} (#{project_runner.short_sha}) #{s_('Runners|Never contacted')} Project created" + "##{project_runner.id} (#{project_runner.short_sha}) #{s_('Runners|Never contacted')} Project Created" ) end end @@ -604,7 +638,7 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do it 'show success alert and redirects to runner page' do expect(current_url).to match(admin_runner_path(project_runner)) - expect(page.find('[data-testid="alert-success"]')).to have_content('saved') + expect(find_by_testid('alert-success')).to have_content('saved') end end @@ -631,11 +665,13 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do describe 'enable/create' do shared_examples 'assignable runner' do it 'enables a runner for a project' do - within find('[data-testid="unassigned-projects"] tr', text: project2.full_name) do - click_on 'Enable' + within_testid('unassigned-projects') do + within('tr', text: project2.full_name) do + click_on 'Enable' + end end - assigned_project = page.find('[data-testid="assigned-projects"]') + assigned_project = find_by_testid('assigned-projects') expect(page).to have_content('Runner assigned to project.') expect(assigned_project).to have_content(project2.name) @@ -671,11 +707,11 @@ RSpec.describe "Admin Runners", feature_category: :runner_fleet do end it 'removed project runner from project' do - within '[data-testid="assigned-projects"]' do + within_testid('assigned-projects') do click_on 'Disable' end - new_runner_project = page.find('[data-testid="unassigned-projects"]') + new_runner_project = find_by_testid('unassigned-projects') expect(page).to have_content('Runner unassigned from project.') expect(new_runner_project).to have_content(project1.name) diff --git a/spec/features/admin/admin_sees_background_migrations_spec.rb b/spec/features/admin/admin_sees_background_migrations_spec.rb index 7423e74bf3a..ae307b8038c 100644 --- a/spec/features/admin/admin_sees_background_migrations_spec.rb +++ b/spec/features/admin/admin_sees_background_migrations_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe "Admin > Admin sees background migrations", feature_category: :database do include ListboxHelpers - let_it_be(:admin) { create(:admin, :no_super_sidebar) } + let_it_be(:admin) { create(:admin) } let(:job_class) { Gitlab::BackgroundMigration::CopyColumnUsingBackgroundMigrationJob } let_it_be(:active_migration) { create(:batched_background_migration, :active, table_name: 'active') } @@ -21,16 +21,18 @@ RSpec.describe "Admin > Admin sees background migrations", feature_category: :da gitlab_enable_admin_mode_sign_in(admin) end - it 'can navigate to background migrations' do + it 'can navigate to background migrations', :js do visit admin_root_path - within '.nav-sidebar' do - link = find_link 'Background Migrations' + within_testid('super-sidebar') do + click_on 'Monitoring' + click_on 'Background Migrations' + end - link.click + expect(page).to have_current_path(admin_background_migrations_path) - expect(page).to have_current_path(admin_background_migrations_path) - expect(link).to have_ancestor(:css, 'li.active') + within_testid('super-sidebar') do + expect(page).to have_css('a[aria-current="page"]', text: 'Background Migrations') end end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 1b10ea81333..4e0198b1f2b 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do include TermsHelper include UsageDataHelpers - let_it_be(:admin) { create(:admin, :no_super_sidebar) } + let_it_be(:admin) { create(:admin) } context 'application setting :admin_mode is enabled', :request_store do before do @@ -22,7 +22,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'change visibility settings' do - page.within('[data-testid="admin-visibility-access-settings"]') do + within_testid('admin-visibility-access-settings') do choose "application_setting_default_project_visibility_20" click_button 'Save changes' end @@ -31,19 +31,19 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'uncheck all restricted visibility levels' do - page.within('[data-testid="restricted-visibility-levels"]') do + within_testid('restricted-visibility-levels') do uncheck s_('VisibilityLevel|Public') uncheck s_('VisibilityLevel|Internal') uncheck s_('VisibilityLevel|Private') end - page.within('[data-testid="admin-visibility-access-settings"]') do + within_testid('admin-visibility-access-settings') do click_button 'Save changes' end expect(page).to have_content "Application settings saved successfully" - page.within('[data-testid="restricted-visibility-levels"]') do + within_testid('restricted-visibility-levels') do expect(find_field(s_('VisibilityLevel|Public'))).not_to be_checked expect(find_field(s_('VisibilityLevel|Internal'))).not_to be_checked expect(find_field(s_('VisibilityLevel|Private'))).not_to be_checked @@ -53,7 +53,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do it 'modify import sources' do expect(current_settings.import_sources).to be_empty - page.within('[data-testid="admin-import-export-settings"]') do + within_testid('admin-import-export-settings') do check "Repository by URL" click_button 'Save changes' end @@ -63,12 +63,12 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'change Visibility and Access Controls' do - page.within('[data-testid="admin-import-export-settings"]') do - page.within('[data-testid="project-export"]') do + within_testid('admin-import-export-settings') do + within_testid('project-export') do uncheck 'Enabled' end - page.within('[data-testid="bulk-import"]') do + within_testid('bulk-import') do check 'Enabled' end @@ -81,7 +81,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'change Keys settings' do - page.within('[data-testid="admin-visibility-access-settings"]') do + within_testid('admin-visibility-access-settings') do select 'Are forbidden', from: 'RSA SSH keys' select 'Are allowed', from: 'DSA SSH keys' select 'Must be at least 384 bits', from: 'ECDSA SSH keys' @@ -103,7 +103,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'change Account and Limit Settings' do - page.within(find('[data-testid="account-and-limit-settings-content"]')) do + within_testid('account-and-limit-settings-content') do uncheck 'Gravatar enabled' click_button 'Save changes' end @@ -113,7 +113,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'change Maximum export size' do - page.within(find('[data-testid="admin-import-export-settings"]')) do + within_testid('admin-import-export-settings') do fill_in 'Maximum export size (MiB)', with: 25 click_button 'Save changes' end @@ -123,7 +123,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end it 'change Maximum import size' do - page.within(find('[data-testid="admin-import-export-settings"]')) do + within_testid('admin-import-export-settings') do fill_in 'Maximum import size (MiB)', with: 15 click_button 'Save changes' end @@ -169,7 +169,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do expect(page).to have_unchecked_field(_('Deactivate dormant users after a period of inactivity')) expect(current_settings.deactivate_dormant_users).to be_falsey - page.within(find('[data-testid="account-and-limit-settings-content"]')) do + within_testid('account-and-limit-settings-content') do check _('Deactivate dormant users after a period of inactivity') click_button _('Save changes') end @@ -185,7 +185,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do it 'change dormant users period', :js do expect(page).to have_field(_('Days of inactivity before deactivation'), disabled: true) - page.within(find('[data-testid="account-and-limit-settings-content"]')) do + within_testid('account-and-limit-settings-content') do check _('Deactivate dormant users after a period of inactivity') fill_in _('Days of inactivity before deactivation'), with: '180' click_button _('Save changes') @@ -202,7 +202,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do selector = '#application_setting_deactivate_dormant_users_period_error' expect(page).not_to have_selector(selector, visible: :visible) - page.within(find('[data-testid="account-and-limit-settings-content"]')) do + within_testid('account-and-limit-settings-content') do check 'application_setting_deactivate_dormant_users' fill_in _('application_setting_deactivate_dormant_users_period'), with: '30' click_button 'Save changes' @@ -666,28 +666,47 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do expect(find_field('Allow access to members of the following group').value).to be_nil end - it 'loads togglable usage ping payload on click', :js do - allow(Gitlab::Usage::ServicePingReport).to receive(:for).and_return({ uuid: '12345678', hostname: '127.0.0.1' }) + context 'Service usage data', :with_license do + before do + stub_usage_data_connections + stub_database_flavor_check + end - stub_usage_data_connections - stub_database_flavor_check + context 'when service data cached' do + before_all do + create(:raw_usage_data) + end - page.within('#js-usage-settings') do - expected_payload_content = /(?=.*"uuid")(?=.*"hostname")/m + it 'loads usage ping payload on click', :js do + expected_payload_content = /(?=.*"test")/m - expect(page).not_to have_content expected_payload_content + expect(page).not_to have_content expected_payload_content - click_button('Preview payload') + click_button('Preview payload') - wait_for_requests + wait_for_requests + + expect(page).to have_button 'Hide payload' + expect(page).to have_content expected_payload_content + end - expect(page).to have_selector '.js-service-ping-payload' - expect(page).to have_button 'Hide payload' - expect(page).to have_content expected_payload_content + it 'generates usage ping payload on button click', :js do + expect_next_instance_of(Admin::ApplicationSettingsController) do |instance| + expect(instance).to receive(:usage_data).and_call_original + end - click_button('Hide payload') + click_button('Download payload') - expect(page).not_to have_content expected_payload_content + wait_for_requests + end + end + + context 'when service data not cached' do + it 'renders missing cache information' do + visit metrics_and_profiling_admin_application_settings_path + + expect(page).to have_text('Service Ping payload not found in the application cache') + end end end end @@ -799,7 +818,7 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do it 'changes gitlab shell operation limits settings' do visit network_admin_application_settings_path - page.within('[data-testid="gitlab-shell-operation-limits"]') do + within_testid('gitlab-shell-operation-limits') do fill_in 'Maximum number of Git operations per minute', with: 100 click_button 'Save changes' end @@ -971,15 +990,14 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do end end - context 'Nav bar' do + context 'Nav bar', :js do it 'shows default help links in nav' do default_support_url = "https://#{ApplicationHelper.promo_host}/get-help/" visit root_dashboard_path - find('.header-help-dropdown-toggle').click - - page.within '.header-help' do + within_testid('super-sidebar') do + click_on 'Help' expect(page).to have_link(text: 'Help', href: help_path) expect(page).to have_link(text: 'Support', href: default_support_url) end @@ -991,68 +1009,12 @@ RSpec.describe 'Admin updates settings', feature_category: :shared do visit root_dashboard_path - find('.header-help-dropdown-toggle').click - - page.within '.header-help' do + within_testid('super-sidebar') do + click_on 'Help' expect(page).to have_link(text: 'Support', href: new_support_url) end end end - - context 'Service usage data page', :with_license do - before do - stub_usage_data_connections - stub_database_flavor_check - end - - context 'when service data cached', :use_clean_rails_memory_store_caching do - let(:usage_data) { { uuid: "1111", hostname: "localhost", counts: { issue: 0 } }.deep_stringify_keys } - - before do - # We are mocking Gitlab::Usage::ServicePingReport because this dataset generation - # takes a very long time, and is not what we're testing in this context. - # - # See https://gitlab.com/gitlab-org/gitlab/-/issues/414929 - allow(Gitlab::UsageData).to receive(:data).and_return(usage_data) - allow(Gitlab::Usage::ServicePingReport).to receive(:with_instrumentation_classes) - .with(usage_data, :with_value).and_return(usage_data) - - visit usage_data_admin_application_settings_path - visit service_usage_data_admin_application_settings_path - end - - it 'loads usage ping payload on click', :js do - expected_payload_content = /(?=.*"uuid")(?=.*"hostname")/m - - expect(page).not_to have_content expected_payload_content - - click_button('Preview payload') - - wait_for_requests - - expect(page).to have_button 'Hide payload' - expect(page).to have_content expected_payload_content - end - - it 'generates usage ping payload on button click', :js do - expect_next_instance_of(Admin::ApplicationSettingsController) do |instance| - expect(instance).to receive(:usage_data).and_call_original - end - - click_button('Download payload') - - wait_for_requests - end - end - - context 'when service data not cached' do - it 'renders missing cache information' do - visit service_usage_data_admin_application_settings_path - - expect(page).to have_text('Service Ping payload not found in the application cache') - end - end - end end context 'application setting :admin_mode is disabled' do diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb index ca08bc9e577..9ab5b1fd3bb 100644 --- a/spec/features/admin/admin_users_spec.rb +++ b/spec/features/admin/admin_users_spec.rb @@ -82,4 +82,12 @@ RSpec.describe "Admin::Users", feature_category: :user_management do end end end + + it 'does not perform N+1 queries' do + control_queries = ActiveRecord::QueryRecorder.new { visit admin_users_path } + + expect { create(:user) }.to change { User.count }.by(1) + + expect { visit admin_users_path }.not_to exceed_query_limit(control_queries) + end end diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb index d9d36ec3bae..05232de35e5 100644 --- a/spec/features/admin/admin_uses_repository_checks_spec.rb +++ b/spec/features/admin/admin_uses_repository_checks_spec.rb @@ -47,7 +47,7 @@ RSpec.describe 'Admin uses repository checks', :request_store, feature_category: ) visit_admin_project_page(project) - page.within('[data-testid="last-repository-check-failed-alert"]') do + within_testid('last-repository-check-failed-alert') do expect(page.text).to match(/Last repository check \(just now\) failed/) end end diff --git a/spec/features/admin/broadcast_messages_spec.rb b/spec/features/admin/broadcast_messages_spec.rb index b89ebc34d6a..e4a2e31ee1c 100644 --- a/spec/features/admin/broadcast_messages_spec.rb +++ b/spec/features/admin/broadcast_messages_spec.rb @@ -36,12 +36,12 @@ RSpec.describe 'Admin Broadcast Messages', :js, feature_category: :onboarding do # edit page.within(first_message_container) do - find('[data-testid="edit-message"]').click + find_by_testid('edit-message').click end wait_for_requests - expect(find('[data-testid="message-input"]').value).to eq('test message') + expect(find_by_testid('message-input').value).to eq('test message') fill_in 'Message', with: 'changed test message' @@ -61,11 +61,11 @@ RSpec.describe 'Admin Broadcast Messages', :js, feature_category: :onboarding do end def preview_container - find('[data-testid="preview-broadcast-message"]') + find_by_testid('preview-broadcast-message') end def first_message_container - find('[data-testid="message-row"]', match: :first) + find_by_testid('message-row', match: :first) end end end diff --git a/spec/features/admin/users/user_spec.rb b/spec/features/admin/users/user_spec.rb index 7dc329e6909..b8dc725c17f 100644 --- a/spec/features/admin/users/user_spec.rb +++ b/spec/features/admin/users/user_spec.rb @@ -6,8 +6,8 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do include Features::AdminUsersHelpers include Spec::Support::Helpers::ModalHelpers - let_it_be(:user) { create(:omniauth_user, :no_super_sidebar, provider: 'twitter', extern_uid: '123456') } - let_it_be(:current_user) { create(:admin, :no_super_sidebar) } + let_it_be(:user) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') } + let_it_be(:current_user) { create(:admin) } before do sign_in(current_user) @@ -145,7 +145,7 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do end describe 'Impersonation' do - let_it_be(:another_user) { create(:user, :no_super_sidebar) } + let_it_be(:another_user) { create(:user) } context 'before impersonating' do subject { visit admin_user_path(user_to_visit) } @@ -156,7 +156,7 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do it 'disables impersonate button' do subject - impersonate_btn = find('[data-testid="impersonate-user-link"]') + impersonate_btn = find_by_testid('impersonate-user-link') expect(impersonate_btn).not_to be_nil expect(impersonate_btn['disabled']).not_to be_nil @@ -174,7 +174,7 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do subject expect(page).to have_content('Impersonate') - impersonate_btn = find('[data-testid="impersonate-user-link"]') + impersonate_btn = find_by_testid('impersonate-user-link') expect(impersonate_btn['disabled']).to be_nil end end @@ -257,15 +257,13 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do visit admin_user_path(another_user) end - it 'logs in as the user when impersonate is clicked' do + it 'logs in as the user when impersonate is clicked', :js do subject - find('[data-testid="user-dropdown"]').click - - expect(page.find(:css, '[data-testid="user-profile-link"]')['data-user']).to eql(another_user.username) + expect(page).to have_button("#{another_user.name} user’s menu") end - it 'sees impersonation log out icon' do + it 'sees impersonation log out icon', :js do subject icon = first('[data-testid="incognito-icon"]') @@ -306,8 +304,8 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do end end - context 'ending impersonation' do - subject { find(:css, 'li.impersonation a').click } + context 'ending impersonation', :js do + subject { click_on 'Stop impersonating' } before do visit admin_user_path(another_user) @@ -317,9 +315,7 @@ RSpec.describe 'Admin::Users::User', feature_category: :user_management do it 'logs out of impersonated user back to original user' do subject - find('[data-testid="user-dropdown"]').click - - expect(page.find(:css, '[data-testid="user-profile-link"]')['data-user']).to eq(current_user.username) + expect(page).to have_button("#{current_user.name} user’s menu") end it 'is redirected back to the impersonated users page in the admin after stopping' do diff --git a/spec/features/admin/users/users_spec.rb b/spec/features/admin/users/users_spec.rb index 8ee30c50a7d..4e988674858 100644 --- a/spec/features/admin/users/users_spec.rb +++ b/spec/features/admin/users/users_spec.rb @@ -43,7 +43,7 @@ RSpec.describe 'Admin::Users', feature_category: :user_management do end it 'clicking edit user takes us to edit page', :aggregate_failures do - page.within("[data-testid='user-actions-#{user.id}']") do + within_testid("user-actions-#{user.id}") do click_link 'Edit' end @@ -71,7 +71,7 @@ RSpec.describe 'Admin::Users', feature_category: :user_management do it 'displays count of users projects' do visit admin_users_path - expect(page.find("[data-testid='user-project-count-#{current_user.id}']").text).to eq("1") + expect(find_by_testid("user-project-count-#{current_user.id}").text).to eq("1") end end @@ -321,7 +321,7 @@ RSpec.describe 'Admin::Users', feature_category: :user_management do click_user_dropdown_toggle(user.id) - find('[data-testid="approve"]').click + find_by_testid('approve').click expect(page).to have_content("Approve user #{user.name}?") @@ -378,7 +378,7 @@ RSpec.describe 'Admin::Users', feature_category: :user_management do wait_for_requests - expect(page.find("[data-testid='user-group-count-#{current_user.id}']").text).to eq("2") + expect(find_by_testid("user-group-count-#{current_user.id}").text).to eq("2") end end end @@ -542,7 +542,7 @@ RSpec.describe 'Admin::Users', feature_category: :user_management do it 'allows group membership to be revoked', :js do page.within(first('.group_member')) do - find('.btn[data-testid="remove-user"]').click + find_by_testid('remove-user').click end accept_gl_confirm(button_text: 'Remove') @@ -587,7 +587,7 @@ RSpec.describe 'Admin::Users', feature_category: :user_management do end def check_breadcrumb(content) - expect(find('[data-testid="breadcrumb-current-link"]')).to have_content(content) + expect(find_by_testid('breadcrumb-current-link')).to have_content(content) end end diff --git a/spec/features/admin_variables_spec.rb b/spec/features/admin_variables_spec.rb index 91e7a46849c..caa94209e50 100644 --- a/spec/features/admin_variables_spec.rb +++ b/spec/features/admin_variables_spec.rb @@ -13,13 +13,12 @@ RSpec.describe 'Instance variables', :js, feature_category: :secrets_management sign_in(admin) gitlab_enable_admin_mode_sign_in(admin) - stub_feature_flags(ci_variable_drawer: false) visit page_path wait_for_requests end context 'when ci_variables_pages FF is enabled' do - it_behaves_like 'variable list', is_admin: true + it_behaves_like 'variable list drawer', is_admin: true it_behaves_like 'variable list pagination', :ci_instance_variable end @@ -28,16 +27,6 @@ RSpec.describe 'Instance variables', :js, feature_category: :secrets_management stub_feature_flags(ci_variables_pages: false) end - it_behaves_like 'variable list', is_admin: true - end - - context 'when ci_variable_drawer FF is enabled' do - before do - stub_feature_flags(ci_variable_drawer: true) - visit page_path - wait_for_requests - end - it_behaves_like 'variable list drawer', is_admin: true end end diff --git a/spec/features/alert_management/alert_details_spec.rb b/spec/features/alert_management/alert_details_spec.rb index 66b7a9ca46c..58ce9e68468 100644 --- a/spec/features/alert_management/alert_details_spec.rb +++ b/spec/features/alert_management/alert_details_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Alert details', :js, feature_category: :incident_management do let_it_be(:project) { create(:project) } - let_it_be(:developer) { create(:user, :no_super_sidebar) } + let_it_be(:developer) { create(:user) } let_it_be(:alert) { create(:alert_management_alert, project: project, status: 'triggered', title: 'Alert') } before_all do @@ -27,7 +27,7 @@ RSpec.describe 'Alert details', :js, feature_category: :incident_management do it 'shows the alert tabs' do page.within('.alert-management-details') do - alert_tabs = find('[data-testid="alertDetailsTabs"]') + alert_tabs = find_by_testid('alertDetailsTabs') expect(alert_tabs).to have_content('Alert details') expect(alert_tabs).to have_content('Metrics') @@ -47,10 +47,10 @@ RSpec.describe 'Alert details', :js, feature_category: :incident_management do it 'updates the alert todo button from the right sidebar' do expect(page).to have_selector('[data-testid="alert-todo-button"]') - todo_button = find('[data-testid="alert-todo-button"]') + todo_button = find_by_testid('alert-todo-button') expect(todo_button).to have_content('Add a to do') - find('[data-testid="alert-todo-button"]').click + find_by_testid('alert-todo-button').click wait_for_requests expect(todo_button).to have_content('Mark as done') @@ -58,7 +58,7 @@ RSpec.describe 'Alert details', :js, feature_category: :incident_management do it 'updates the alert status from the right sidebar' do page.within('.alert-status') do - alert_status = find('[data-testid="status"]') + alert_status = find_by_testid('status') expect(alert_status).to have_content('Triggered') @@ -77,7 +77,7 @@ RSpec.describe 'Alert details', :js, feature_category: :incident_management do expect(alert_assignee).to have_content('None - assign yourself') - find('[data-testid="unassigned-users"]').click + find_by_testid('unassigned-users').click wait_for_requests diff --git a/spec/features/alert_management/alert_management_list_spec.rb b/spec/features/alert_management/alert_management_list_spec.rb index cc54af249e1..058447b3be3 100644 --- a/spec/features/alert_management/alert_management_list_spec.rb +++ b/spec/features/alert_management/alert_management_list_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Alert Management index', :js, feature_category: :incident_management do let_it_be(:project) { create(:project) } - let_it_be(:developer) { create(:user, :no_super_sidebar) } + let_it_be(:developer) { create(:user) } before_all do project.add_developer(developer) @@ -22,7 +22,7 @@ RSpec.describe 'Alert Management index', :js, feature_category: :incident_manage expect(page).to have_content('Alerts') expect(page).to have_content('Surface alerts in GitLab') expect(page).not_to have_selector('.gl-table') - page.within('.layout-page') do + page.within('.content-wrapper') do expect(page).not_to have_css('[data-testid="search-icon"]') end end @@ -31,7 +31,7 @@ RSpec.describe 'Alert Management index', :js, feature_category: :incident_manage it 'renders correctly' do expect(page).to have_content('Alerts') expect(page).to have_selector('.gl-table') - page.within('.layout-page') do + page.within('.content-wrapper') do expect(page).to have_css('[data-testid="search-icon"]') end end diff --git a/spec/features/boards/board_filters_spec.rb b/spec/features/boards/board_filters_spec.rb index 1ee02de9a66..a6d5d4926ff 100644 --- a/spec/features/boards/board_filters_spec.rb +++ b/spec/features/boards/board_filters_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Issue board filters', :js, feature_category: :team_planning do let_it_be(:issue_2) { create(:labeled_issue, project: project, milestone: milestone_2, assignees: [user], labels: [project_label], confidential: true) } let_it_be(:award_emoji1) { create(:award_emoji, name: 'thumbsup', user: user, awardable: issue_1) } - let(:filtered_search) { find('[data-testid="issue-board-filtered-search"]') } + let(:filtered_search) { find_by_testid('issue-board-filtered-search') } let(:filter_input) { find('.gl-filtered-search-term-input') } let(:filter_dropdown) { find('.gl-filtered-search-suggestion-list') } let(:filter_first_suggestion) { find('.gl-filtered-search-suggestion-list').first('.gl-filtered-search-suggestion') } @@ -25,7 +25,6 @@ RSpec.describe 'Issue board filters', :js, feature_category: :team_planning do let_it_be(:board) { create(:board, project: project) } before do - stub_feature_flags(apollo_boards: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index 85e54c0f451..48b978f7245 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -28,13 +28,12 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do let_it_be(:user, reload: true) { create(:user) } let_it_be(:user2, reload: true) { create(:user) } - let(:filtered_search) { find('[data-testid="issue-board-filtered-search"]') } + let(:filtered_search) { find_by_testid('issue-board-filtered-search') } let(:filter_input) { find('.gl-filtered-search-term-input') } let(:filter_submit) { find('.gl-search-box-by-click-search-button') } context 'signed in user' do before do - stub_feature_flags(apollo_boards: false) project.add_maintainer(user) project.add_maintainer(user2) @@ -296,7 +295,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do it 'shows issue count on the list' do page.within(find(".board:nth-child(2)")) do - expect(page.find('[data-testid="board-items-count"]')).to have_text(total_planning_issues) + expect(find_by_testid('board-items-count')).to have_text(total_planning_issues) expect(page).not_to have_selector('.max-issue-size') end end @@ -389,7 +388,7 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do wait_for_board_cards(2, 1) - find('[data-testid="filtered-search-clear-button"]').click + find_by_testid('filtered-search-clear-button').click filter_submit.click end @@ -518,7 +517,6 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do context 'signed out user' do before do - stub_feature_flags(apollo_boards: false) visit project_board_path(project, board) wait_for_requests end @@ -540,7 +538,6 @@ RSpec.describe 'Project issue boards', :js, feature_category: :team_planning do let_it_be(:user_guest, reload: true) { create(:user) } before do - stub_feature_flags(apollo_boards: false) project.add_guest(user_guest) sign_in(user_guest) visit project_board_path(project, board) diff --git a/spec/features/boards/issue_ordering_spec.rb b/spec/features/boards/issue_ordering_spec.rb index 35e387c9d8a..625a8ddad84 100644 --- a/spec/features/boards/issue_ordering_spec.rb +++ b/spec/features/boards/issue_ordering_spec.rb @@ -15,7 +15,6 @@ RSpec.describe 'Issue Boards', :js, feature_category: :team_planning do let!(:issue3) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label], relative_position: 1) } before do - stub_feature_flags(apollo_boards: false) project.add_maintainer(user) sign_in(user) @@ -131,7 +130,7 @@ RSpec.describe 'Issue Boards', :js, feature_category: :team_planning do end context 'ordering in list using move to position' do - let(:move_to_position) { find('[data-testid="board-move-to-position"]') } + let(:move_to_position) { find_by_testid('board-move-to-position') } before do visit project_board_path(project, board) diff --git a/spec/features/boards/multiple_boards_spec.rb b/spec/features/boards/multiple_boards_spec.rb index 9d59d3dd02a..e9d34c6f87f 100644 --- a/spec/features/boards/multiple_boards_spec.rb +++ b/spec/features/boards/multiple_boards_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Multiple Issue Boards', :js, feature_category: :team_planning do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public) } let_it_be(:planning) { create(:label, project: project, name: 'Planning') } let_it_be(:board) { create(:board, name: 'board1', project: project) } diff --git a/spec/features/boards/new_issue_spec.rb b/spec/features/boards/new_issue_spec.rb index 682ccca38bd..1e44e1d35f9 100644 --- a/spec/features/boards/new_issue_spec.rb +++ b/spec/features/boards/new_issue_spec.rb @@ -11,11 +11,7 @@ RSpec.describe 'Issue Boards new issue', :js, feature_category: :team_planning d let_it_be(:existing_issue) { create(:issue, project: project, title: 'other issue', relative_position: 50) } let(:board_list_header) { first('[data-testid="board-list-header"]') } - let(:project_select_dropdown) { find('[data-testid="project-select-dropdown"]') } - - before do - stub_feature_flags(apollo_boards: false) - end + let(:project_select_dropdown) { find_by_testid('project-select-dropdown') } context 'authorized user' do before do @@ -100,7 +96,7 @@ RSpec.describe 'Issue Boards new issue', :js, feature_category: :team_planning d wait_for_requests - page.within('[data-testid="sidebar-labels"]') do + within_testid('sidebar-labels') do click_button 'Edit' wait_for_requests diff --git a/spec/features/boards/reload_boards_on_browser_back_spec.rb b/spec/features/boards/reload_boards_on_browser_back_spec.rb index 036daee7655..0ca680c5ed5 100644 --- a/spec/features/boards/reload_boards_on_browser_back_spec.rb +++ b/spec/features/boards/reload_boards_on_browser_back_spec.rb @@ -9,8 +9,6 @@ RSpec.describe 'Ensure Boards do not show stale data on browser back', :js, feat context 'authorized user' do before do - stub_feature_flags(apollo_boards: false) - project.add_maintainer(user) sign_in(user) diff --git a/spec/features/boards/sidebar_assignee_spec.rb b/spec/features/boards/sidebar_assignee_spec.rb index 899ab5863e1..93e45b3e3f8 100644 --- a/spec/features/boards/sidebar_assignee_spec.rb +++ b/spec/features/boards/sidebar_assignee_spec.rb @@ -65,7 +65,7 @@ RSpec.describe 'Project issue boards sidebar assignee', :js, wait_for_requests page.within('.dropdown-menu-user') do - find('[data-testid="unassign"]').click + find_by_testid('unassign').click end expect(page).to have_content('None') diff --git a/spec/features/boards/sidebar_labels_in_namespaces_spec.rb b/spec/features/boards/sidebar_labels_in_namespaces_spec.rb index 68c2b2587e7..da3dd6ba071 100644 --- a/spec/features/boards/sidebar_labels_in_namespaces_spec.rb +++ b/spec/features/boards/sidebar_labels_in_namespaces_spec.rb @@ -14,8 +14,6 @@ RSpec.describe 'Issue boards sidebar labels select', :js, feature_category: :tea let_it_be(:group_board) { create(:board, group: group) } before do - stub_feature_flags(apollo_boards: false) - load_board group_board_path(group, group_board) end diff --git a/spec/features/boards/sidebar_labels_spec.rb b/spec/features/boards/sidebar_labels_spec.rb index 460d0d232b3..0560cbbfae7 100644 --- a/spec/features/boards/sidebar_labels_spec.rb +++ b/spec/features/boards/sidebar_labels_spec.rb @@ -20,7 +20,6 @@ RSpec.describe 'Project issue boards sidebar labels', :js, feature_category: :te let(:card) { find('.board:nth-child(2)').first('.board-card') } before do - stub_feature_flags(apollo_boards: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb index 71cc9a28575..893f1c246a0 100644 --- a/spec/features/boards/sidebar_spec.rb +++ b/spec/features/boards/sidebar_spec.rb @@ -15,7 +15,6 @@ RSpec.describe 'Project issue boards sidebar', :js, feature_category: :team_plan let_it_be(:issue, reload: true) { create(:issue, project: project, relative_position: 1) } before do - stub_feature_flags(apollo_boards: false) project.add_maintainer(user) sign_in(user) diff --git a/spec/features/boards/user_adds_lists_to_board_spec.rb b/spec/features/boards/user_adds_lists_to_board_spec.rb index cc2afca7657..d202c2a1f7d 100644 --- a/spec/features/boards/user_adds_lists_to_board_spec.rb +++ b/spec/features/boards/user_adds_lists_to_board_spec.rb @@ -29,7 +29,6 @@ RSpec.describe 'User adds lists', :js, feature_category: :team_planning do with_them do before do - stub_feature_flags(apollo_boards: false) sign_in(user) set_cookie('sidebar_collapsed', 'true') diff --git a/spec/features/boards/user_visits_board_spec.rb b/spec/features/boards/user_visits_board_spec.rb index 4741f58d883..cf8709b3a76 100644 --- a/spec/features/boards/user_visits_board_spec.rb +++ b/spec/features/boards/user_visits_board_spec.rb @@ -44,7 +44,6 @@ RSpec.describe 'User visits issue boards', :js, feature_category: :team_planning with_them do before do - stub_feature_flags(apollo_boards: false) visit board_path wait_for_requests @@ -60,7 +59,6 @@ RSpec.describe 'User visits issue boards', :js, feature_category: :team_planning end context "project boards" do - stub_feature_flags(apollo_boards: false) let_it_be(:board) { create_default(:board, project: project) } let(:board_path) { project_boards_path(project, params) } @@ -69,7 +67,6 @@ RSpec.describe 'User visits issue boards', :js, feature_category: :team_planning end context "group boards" do - stub_feature_flags(apollo_boards: false) let_it_be(:board) { create_default(:board, group: group) } let(:board_path) { group_boards_path(group, params) } diff --git a/spec/features/broadcast_messages_spec.rb b/spec/features/broadcast_messages_spec.rb index 98f87face15..f887242384c 100644 --- a/spec/features/broadcast_messages_spec.rb +++ b/spec/features/broadcast_messages_spec.rb @@ -125,8 +125,8 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do visit admin_broadcast_messages_path - page.within('[data-testid="message-row"]', match: :first) do - find("[data-testid='delete-message-#{message.id}']").click + within_testid('message-row', match: :first) do + find_by_testid("delete-message-#{message.id}").click end accept_gl_confirm(button_text: 'Delete message') @@ -145,7 +145,7 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do end def expect_broadcast_message(text) - page.within('[data-testid="banner-broadcast-message"]') do + within_testid('banner-broadcast-message') do expect(page).to have_content text end end @@ -157,7 +157,7 @@ RSpec.describe 'Broadcast Messages', feature_category: :onboarding do end def expect_to_be_on_explore_projects_page - page.within('[data-testid="explore-projects-title"]') do + within_testid('explore-projects-title') do expect(page).to have_content 'Explore projects' end end diff --git a/spec/features/calendar_spec.rb b/spec/features/calendar_spec.rb index e22ae4f51fb..291c40f0f6b 100644 --- a/spec/features/calendar_spec.rb +++ b/spec/features/calendar_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Contributions Calendar', :js, feature_category: :user_profile do include MobileHelpers - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:contributed_project) { create(:project, :public, :repository) } let(:issue_note) { create(:note, project: contributed_project) } @@ -83,7 +83,6 @@ RSpec.describe 'Contributions Calendar', :js, feature_category: :user_profile do shared_context 'when user page is visited' do before do visit user.username - page.click_link('Overview') wait_for_requests end end diff --git a/spec/features/callouts/registration_enabled_spec.rb b/spec/features/callouts/registration_enabled_spec.rb index 3282a40854d..4cd5cb9a857 100644 --- a/spec/features/callouts/registration_enabled_spec.rb +++ b/spec/features/callouts/registration_enabled_spec.rb @@ -43,7 +43,7 @@ RSpec.describe 'Registration enabled callout', feature_category: :system_access before do visit admin_root_path - find('[data-testid="close-registration-enabled-callout"]').click + find_by_testid('close-registration-enabled-callout').click wait_for_requests diff --git a/spec/features/clusters/create_agent_spec.rb b/spec/features/clusters/create_agent_spec.rb index d90c43f452c..79eaecdf582 100644 --- a/spec/features/clusters/create_agent_spec.rb +++ b/spec/features/clusters/create_agent_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Cluster agent registration', :js, feature_category: :deployment_ end it 'allows the user to select an agent to install, and displays the resulting agent token' do - find('[data-testid="clusters-default-action-button"]').click + find_by_testid('clusters-default-action-button').click expect(page).to have_content('Register') diff --git a/spec/features/commit_spec.rb b/spec/features/commit_spec.rb index 61792ea5a58..739a070f423 100644 --- a/spec/features/commit_spec.rb +++ b/spec/features/commit_spec.rb @@ -66,12 +66,4 @@ RSpec.describe 'Commit', feature_category: :source_code_management do end it_behaves_like "single commit view" - - context "when super sidebar is enabled" do - before do - user.update!(use_new_navigation: true) - end - - it_behaves_like "single commit view" - end end diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 5f880af37dc..8f6c1c28872 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -41,13 +41,13 @@ RSpec.describe 'Commits', feature_category: :source_code_management do end it 'contains commit short id' do - page.within('[data-testid="pipeline-details-header"]') do + within_testid('pipeline-details-header') do expect(page).to have_content pipeline.sha[0..7] end end it 'contains generic commit status build' do - page.within('[data-testid="jobs-tab-table"]') do + within_testid('jobs-tab-table') do expect(page).to have_content "##{status.id}" # build id expect(page).to have_content 'generic' # build name end @@ -81,8 +81,8 @@ RSpec.describe 'Commits', feature_category: :source_code_management do it 'shows correct build status from default branch' do page.within("//li[@id='commit-#{pipeline.short_sha}']") do - expect(page).to have_css("[data-testid='ci-status-badge-legacy']") - expect(page).to have_css('.ci-status-icon-success') + expect(page).to have_css("[data-testid='ci-icon']") + expect(page).to have_css('[data-testid="status_success_borderless-icon"]') end end end @@ -122,7 +122,7 @@ RSpec.describe 'Commits', feature_category: :source_code_management do describe 'Cancel build' do it 'cancels build', :js, :sidekiq_might_not_need_inline do visit pipeline_path(pipeline) - find('[data-testid="cancel-pipeline"]').click + find_by_testid('cancel-pipeline').click expect(page).to have_content 'Canceled' end end diff --git a/spec/features/contextual_sidebar_spec.rb b/spec/features/contextual_sidebar_spec.rb index ab322f18240..dffc87c2028 100644 --- a/spec/features/contextual_sidebar_spec.rb +++ b/spec/features/contextual_sidebar_spec.rb @@ -4,39 +4,19 @@ require 'spec_helper' RSpec.describe 'Contextual sidebar', :js, feature_category: :remote_development do context 'when context is a project' do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } before do sign_in(user) + visit project_path(project) end - context 'when analyzing the menu' do - before do - visit project_path(project) - end + it 'shows flyout menu on other section on hover' do + expect(page).not_to have_link('Pipelines', href: project_pipelines_path(project)) - it 'shows flyout navs when collapsed or expanded apart from on the active item when expanded', :aggregate_failures do - expect(page).not_to have_selector('.js-sidebar-collapsed') - - find('.rspec-link-pipelines').hover - - expect(page).to have_selector('.is-showing-fly-out') - - find('.rspec-project-link').hover - - expect(page).not_to have_selector('.is-showing-fly-out') - - find('.rspec-toggle-sidebar').click - - find('.rspec-link-pipelines').hover - - expect(page).to have_selector('.is-showing-fly-out') - - find('.rspec-project-link').hover - - expect(page).to have_selector('.is-showing-fly-out') - end + find_button('Build').hover + expect(page).to have_link('Pipelines', href: project_pipelines_path(project)) end end end diff --git a/spec/features/dashboard/activity_spec.rb b/spec/features/dashboard/activity_spec.rb index 61631d28aa9..fd1e5a34f05 100644 --- a/spec/features/dashboard/activity_spec.rb +++ b/spec/features/dashboard/activity_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe 'Dashboard > Activity', feature_category: :user_profile do - let(:user) { create(:user, :no_super_sidebar) } +RSpec.describe 'Dashboard > Activity', :js, feature_category: :user_profile do + let(:user) { create(:user) } before do sign_in(user) @@ -46,7 +46,7 @@ RSpec.describe 'Dashboard > Activity', feature_category: :user_profile do it_behaves_like "an autodiscoverable RSS feed with current_user's feed token" end - context 'event filters', :js do + context 'event filters' do let(:project) { create(:project, :repository) } let(:merge_request) do diff --git a/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb b/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb deleted file mode 100644 index a00666c2376..00000000000 --- a/spec/features/dashboard/group_dashboard_with_external_authorization_service_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'The group dashboard', :js, feature_category: :groups_and_projects do - include ExternalAuthorizationServiceHelpers - include Features::TopNavSpecHelpers - - let(:user) { create(:user, :no_super_sidebar) } - - before do - sign_in user - end - - describe 'The top navigation' do - it 'has all the expected links' do - visit dashboard_groups_path - - open_top_nav - - within_top_nav do - expect(page).to have_button('Projects') - expect(page).to have_button('Groups') - expect(page).to have_link('Your work') - expect(page).to have_link('Explore') - end - end - - it 'hides some links when an external authorization service is enabled' do - enable_external_authorization_service_check - visit dashboard_groups_path - - open_top_nav - - within_top_nav do - expect(page).to have_button('Projects') - expect(page).to have_button('Groups') - expect(page).to have_link('Your work') - expect(page).to have_link('Explore') - end - end - end -end diff --git a/spec/features/dashboard/group_spec.rb b/spec/features/dashboard/group_spec.rb index ea600758607..7510a92e19b 100644 --- a/spec/features/dashboard/group_spec.rb +++ b/spec/features/dashboard/group_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Dashboard Group', feature_category: :groups_and_projects do it 'creates new group', :js do visit dashboard_groups_path - find('[data-testid="new-group-button"]').click + find_by_testid('new-group-button').click click_link 'Create group' new_name = 'Samurai' diff --git a/spec/features/dashboard/groups_list_spec.rb b/spec/features/dashboard/groups_list_spec.rb index e1da163cdf5..745e45478d1 100644 --- a/spec/features/dashboard/groups_list_spec.rb +++ b/spec/features/dashboard/groups_list_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Dashboard Groups page', :js, feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:group) { create(:group) } let(:nested_group) { create(:group, :nested) } let(:another_group) { create(:group) } diff --git a/spec/features/dashboard/issuables_counter_spec.rb b/spec/features/dashboard/issuables_counter_spec.rb index 501405c5662..d34f8cb3e18 100644 --- a/spec/features/dashboard/issuables_counter_spec.rb +++ b/spec/features/dashboard/issuables_counter_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching, feature_category: :team_planning do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } let(:issue) { create(:issue, project: project) } let(:merge_request) { create(:merge_request, source_project: project) } @@ -17,33 +17,29 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching, it 'reflects dashboard issues count', :js do visit issues_path - expect_counters('issues', '1', n_("%d assigned issue", "%d assigned issues", 1) % 1) + expect_issue_count(1) issue.update!(assignees: []) - Users::AssignedIssuesCountService.new(current_user: user).delete_cache + user.invalidate_cache_counts - travel_to(3.minutes.from_now) do - visit issues_path + visit issues_path - expect_counters('issues', '0', n_("%d assigned issue", "%d assigned issues", 0) % 0) - end + expect_issue_count(0) end it 'reflects dashboard merge requests count', :js do visit merge_requests_path - expect_counters('merge_requests', '1', n_("%d merge request", "%d merge requests", 1) % 1) + expect_merge_request_count(1) merge_request.update!(assignees: []) user.invalidate_cache_counts - travel_to(3.minutes.from_now) do - visit merge_requests_path + visit merge_requests_path - expect_counters('merge_requests', '0', n_("%d merge request", "%d merge requests", 0) % 0) - end + expect_merge_request_count(0) end def issues_path @@ -54,11 +50,21 @@ RSpec.describe 'Navigation bar counter', :use_clean_rails_memory_store_caching, merge_requests_dashboard_path(assignee_username: user.username) end - def expect_counters(issuable_type, count, badge_label) + def expect_issue_count(count) dashboard_count = find('.gl-tabs-nav li a.active') + expect(dashboard_count).to have_content(count) + within_testid('super-sidebar') do + expect(page).to have_link("Issues #{count}") + end + end + + def expect_merge_request_count(count) + dashboard_count = find('.gl-tabs-nav li a.active') expect(dashboard_count).to have_content(count) - expect(page).to have_css(".dashboard-shortcuts-#{issuable_type}", visible: :all, text: count) - expect(page).to have_css("span[aria-label='#{badge_label}']", visible: :all, text: count) + + within_testid('super-sidebar') do + expect(page).to have_button("Merge requests #{count}") + end end end diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 69b32113bba..7008f702622 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -RSpec.describe 'Dashboard Issues', feature_category: :team_planning do +RSpec.describe 'Dashboard Issues', :js, feature_category: :team_planning do include FilteredSearchHelpers - let_it_be(:current_user) { create(:user, :no_super_sidebar) } + let_it_be(:current_user) { create(:user) } let_it_be(:user) { current_user } # Shared examples depend on this being available let_it_be(:public_project) { create(:project, :public) } let_it_be(:project) { create(:project) } @@ -23,7 +23,7 @@ RSpec.describe 'Dashboard Issues', feature_category: :team_planning do it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :issues_dashboard_path, :issues - describe 'issues', :js do + describe 'issues' do it 'shows issues assigned to current user' do expect(page).to have_content(assigned_issue.title) expect(page).not_to have_content(authored_issue.title) @@ -59,23 +59,25 @@ RSpec.describe 'Dashboard Issues', feature_category: :team_planning do end describe 'new issue dropdown' do - it 'shows projects only with issues feature enabled', :js do + it 'shows projects only with issues feature enabled' do click_button _('Select project to create issue') - page.within('[data-testid="new-resource-dropdown"] [role="menu"]') do - expect(page).to have_content(project.full_name) - expect(page).not_to have_content(project_with_issues_disabled.full_name) + within_testid('new-resource-dropdown') do + within('[role="menu"]') do + expect(page).to have_content(project.full_name) + expect(page).not_to have_content(project_with_issues_disabled.full_name) + end end end - it 'shows the new issue page', :js do + it 'shows the new issue page' do click_button _('Select project to create issue') wait_for_requests project_path = "/#{project.full_path}" - page.within('[data-testid="new-resource-dropdown"]') do + within_testid('new-resource-dropdown') do find_button(project.full_name).click end diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index 4bb04f4ff80..8a7652858b8 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workflow do +RSpec.describe 'Dashboard Merge Requests', :js, feature_category: :code_review_workflow do include Features::SortingHelpers include FilteredSearchHelpers include ProjectForksHelper - let(:current_user) { create(:user, :no_super_sidebar) } + let(:current_user) { create(:user) } let(:user) { current_user } let(:project) { create(:project) } @@ -19,7 +19,21 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl sign_in(current_user) end - it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :merge_requests_dashboard_path, :merge_requests + describe 'sidebar' do + it 'has nav items for assigned MRs and review requests' do + visit merge_requests_dashboard_path(assignee_username: user) + + within('#super-sidebar') do + expect(page).to have_css("a[data-track-label='merge_requests_assigned'][aria-current='page']") + end + + click_link 'Review requests' + + within('#super-sidebar') do + expect(page).to have_css("a[data-track-label='merge_requests_to_review'][aria-current='page']") + end + end + end it 'disables target branch filter' do visit merge_requests_dashboard_path @@ -35,11 +49,11 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl visit merge_requests_dashboard_path end - it 'shows projects only with merge requests feature enabled', :js do + it 'shows projects only with merge requests feature enabled' do click_button 'Select project to create merge request' wait_for_requests - page.within('[data-testid="new-resource-dropdown"]') do + within_testid('new-resource-dropdown') do expect(page).to have_content(project.full_name) expect(page).not_to have_content(project_with_disabled_merge_requests.full_name) @@ -132,14 +146,10 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl end it 'includes assigned and reviewers in badge' do - within("span[aria-label='#{n_("%d merge request", "%d merge requests", 3) % 3}']") do - expect(page).to have_content('3') + within('#merge-requests') do + expect(page).to have_css("a", text: 'Assigned 2') + expect(page).to have_css("a", text: 'Review requests 1') end - - find('.dashboard-shortcuts-merge_requests').click - - expect(find('.js-assigned-mr-count')).to have_content('2') - expect(find('.js-reviewer-mr-count')).to have_content('1') end it 'shows assigned merge requests' do @@ -156,7 +166,7 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl expect(page).not_to have_content(review_requested_merge_request.title) end - it 'shows authored merge requests', :js do + it 'shows authored merge requests' do reset_filters input_filtered_search("author:=#{current_user.to_reference}") @@ -169,7 +179,7 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl expect(page).not_to have_content(other_merge_request.title) end - it 'shows labeled merge requests', :js do + it 'shows labeled merge requests' do reset_filters input_filtered_search("label:=#{label.name}") @@ -182,13 +192,13 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl expect(page).not_to have_content(other_merge_request.title) end - it 'shows error message without filter', :js do + it 'shows error message without filter' do reset_filters expect(page).to have_content('Please select at least one filter to see results') end - it 'shows sorted merge requests', :js do + it 'shows sorted merge requests' do pajamas_sort_by(s_('SortOptions|Created date')) visit merge_requests_dashboard_path(assignee_username: current_user.username) @@ -196,7 +206,7 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl expect(find('.issues-filters')).to have_content('Created date') end - it 'keeps sorting merge requests after visiting Projects MR page', :js do + it 'keeps sorting merge requests after visiting Projects MR page' do pajamas_sort_by(s_('SortOptions|Created date')) visit project_merge_requests_path(project) @@ -205,7 +215,7 @@ RSpec.describe 'Dashboard Merge Requests', feature_category: :code_review_workfl end end - context 'merge request review', :js do + context 'merge request review' do let_it_be(:author_user) { create(:user) } let!(:review_requested_merge_request) do diff --git a/spec/features/dashboard/milestones_spec.rb b/spec/features/dashboard/milestones_spec.rb index 38637115246..915626de33c 100644 --- a/spec/features/dashboard/milestones_spec.rb +++ b/spec/features/dashboard/milestones_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Dashboard > Milestones', feature_category: :team_planning do +RSpec.describe 'Dashboard > Milestones', :js, feature_category: :team_planning do describe 'as anonymous user' do before do visit dashboard_milestones_path @@ -14,7 +14,7 @@ RSpec.describe 'Dashboard > Milestones', feature_category: :team_planning do end describe 'as logged-in user' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, namespace: user.namespace) } let!(:milestone) { create(:milestone, project: project) } @@ -35,11 +35,11 @@ RSpec.describe 'Dashboard > Milestones', feature_category: :team_planning do expect(first('.milestone')).to have_content('Merge requests') end - describe 'new milestones dropdown', :js do - it 'takes user to a new milestone page', :js do + describe 'new milestones dropdown' do + it 'takes user to a new milestone page' do click_button 'Select project to create milestone' - page.within('[data-testid="new-resource-dropdown"]') do + within_testid('new-resource-dropdown') do click_button group.name click_link "New milestone in #{group.name}" end @@ -50,7 +50,7 @@ RSpec.describe 'Dashboard > Milestones', feature_category: :team_planning do end describe 'with merge requests disabled' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) } let!(:milestone) { create(:milestone, project: project) } diff --git a/spec/features/dashboard/navbar_spec.rb b/spec/features/dashboard/navbar_spec.rb index 30e7f2d2e4e..2ce9eba309d 100644 --- a/spec/features/dashboard/navbar_spec.rb +++ b/spec/features/dashboard/navbar_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -RSpec.describe '"Your work" navbar', feature_category: :navigation do +RSpec.describe '"Your work" navbar', :js, feature_category: :navigation do include_context 'dashboard navbar structure' - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } it_behaves_like 'verified navigation bar' do before do diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index 90ad6fcea25..5379dabc713 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe 'Dashboard Projects', feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } +RSpec.describe 'Dashboard Projects', :js, feature_category: :groups_and_projects do + let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, :repository, creator: build(:user)) } # ensure creator != owner to avoid N+1 false-positive let_it_be(:project2) { create(:project, :public) } @@ -91,7 +91,7 @@ RSpec.describe 'Dashboard Projects', feature_category: :groups_and_projects do expect(find('.gl-tabs-nav li:nth-child(1) .badge-pill')).to have_content(1) end - it 'shows personal projects on personal projects tab', :js do + it 'shows personal projects on personal projects tab' do project3 = create(:project, namespace: user.namespace) visit dashboard_projects_path @@ -111,7 +111,7 @@ RSpec.describe 'Dashboard Projects', feature_category: :groups_and_projects do end end - context 'when on Starred projects tab', :js do + context 'when on Starred projects tab' do it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :starred_dashboard_projects_path, :projects it 'shows the empty state when there are no starred projects' do @@ -153,8 +153,8 @@ RSpec.describe 'Dashboard Projects', feature_category: :groups_and_projects do page.within('[data-testid="project_controls"]') do expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']") - expect(page).to have_css("[data-testid='ci-status-badge']") - expect(page).to have_css('.ci-status-icon-success') + expect(page).to have_css("[data-testid='ci-icon']") + expect(page).to have_css('[data-testid="status_success_borderless-icon"]') expect(page).to have_link('Pipeline: passed') end end @@ -165,8 +165,8 @@ RSpec.describe 'Dashboard Projects', feature_category: :groups_and_projects do page.within('[data-testid="project_controls"]') do expect(page).not_to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']") - expect(page).not_to have_css("[data-testid='ci-status-badge']") - expect(page).not_to have_css('.ci-status-icon-success') + expect(page).not_to have_css("[data-testid='ci-icon']") + expect(page).not_to have_css('[data-testid="status_success_borderless-icon"]') expect(page).not_to have_link('Pipeline: passed') end end diff --git a/spec/features/dashboard/shortcuts_spec.rb b/spec/features/dashboard/shortcuts_spec.rb index c8013d364e3..976dcc5a027 100644 --- a/spec/features/dashboard/shortcuts_spec.rb +++ b/spec/features/dashboard/shortcuts_spec.rb @@ -50,7 +50,6 @@ RSpec.describe 'Dashboard shortcuts', :js, feature_category: :shared do context 'logged out' do before do - stub_feature_flags(super_sidebar_logged_out: false) visit explore_root_path end diff --git a/spec/features/dashboard/snippets_spec.rb b/spec/features/dashboard/snippets_spec.rb index f9284f9479e..5ab5a27171c 100644 --- a/spec/features/dashboard/snippets_spec.rb +++ b/spec/features/dashboard/snippets_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe 'Dashboard snippets', feature_category: :source_code_management do - let_it_be(:user) { create(:user, :no_super_sidebar) } +RSpec.describe 'Dashboard snippets', :js, feature_category: :source_code_management do + let_it_be(:user) { create(:user) } it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets @@ -32,7 +32,7 @@ RSpec.describe 'Dashboard snippets', feature_category: :source_code_management d end end - context 'when there are no project snippets', :js do + context 'when there are no project snippets' do let(:project) { create(:project, :public, creator: user) } before do @@ -55,7 +55,7 @@ RSpec.describe 'Dashboard snippets', feature_category: :source_code_management d it 'shows documentation button in main comment area' do parent_element = page.find('.row.empty-state') - expect(parent_element).to have_link('Documentation', href: help_page_path('user/snippets.md')) + expect(parent_element).to have_link('Documentation', href: help_page_path('user/snippets')) end end diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index ade7da0cb49..59ce873905a 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' -RSpec.describe 'Dashboard Todos', feature_category: :team_planning do +RSpec.describe 'Dashboard Todos', :js, feature_category: :team_planning do include DesignManagementTestHelpers - let_it_be(:user) { create(:user, :no_super_sidebar, username: 'john') } - let_it_be(:user2) { create(:user, :no_super_sidebar, username: 'diane') } + let_it_be(:user) { create(:user, username: 'john') } + let_it_be(:user2) { create(:user, username: 'diane') } let_it_be(:user3) { create(:user) } - let_it_be(:author) { create(:user, :no_super_sidebar) } + let_it_be(:author) { create(:user) } let_it_be(:project) { create(:project, :public) } let_it_be(:issue) { create(:issue, project: project, due_date: Date.today, title: "Fix bug") } @@ -73,7 +73,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do end end - context 'User has a todo', :js do + context 'User has a todo' do let_it_be(:user_todo) { create(:todo, :mentioned, user: user, project: project, target: issue, author: author) } before do @@ -287,7 +287,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do end end - context 'User has done todos', :js do + context 'User has done todos' do before do create(:todo, :mentioned, :done, user: user, project: project, target: issue, author: author) sign_in(user) @@ -359,7 +359,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do expect(page).to have_selector('.gl-pagination .js-pagination-page', count: 2) end - describe 'mark all as done', :js do + describe 'mark all as done' do before do visit dashboard_todos_path find('.js-todos-mark-all').click @@ -377,7 +377,7 @@ RSpec.describe 'Dashboard Todos', feature_category: :team_planning do end end - describe 'undo mark all as done', :js do + describe 'undo mark all as done' do before do visit dashboard_todos_path end diff --git a/spec/features/explore/catalog_spec.rb b/spec/features/explore/catalog_spec.rb new file mode 100644 index 00000000000..52ce52e43fe --- /dev/null +++ b/spec/features/explore/catalog_spec.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Global Catalog', :js, feature_category: :pipeline_composition do + let_it_be(:namespace) { create(:group) } + let_it_be(:user) { create(:user) } + + before_all do + namespace.add_developer(user) + end + + before do + sign_in(user) + end + + describe 'GET explore/catalog' do + let_it_be(:project) { create(:project, :repository, namespace: namespace) } + let_it_be(:ci_resource_projects) do + create_list( + :project, + 3, + :repository, + description: 'A simple component', + namespace: namespace + ) + end + + before do + ci_resource_projects.each do |current_project| + create(:ci_catalog_resource, project: current_project) + end + + visit explore_catalog_index_path + wait_for_requests + end + + it 'shows CI Catalog title and description', :aggregate_failures do + expect(page).to have_content('CI/CD Catalog') + expect(page).to have_content('Discover CI configuration resources for a seamless CI/CD experience.') + end + + it 'renders CI Catalog resources list' do + expect(find_all('[data-testid="catalog-resource-item"]').length).to be(3) + end + + context 'for a single CI/CD catalog resource' do + it 'renders resource details', :aggregate_failures do + within_testid('catalog-resource-item', match: :first) do + expect(page).to have_content(ci_resource_projects[2].name) + expect(page).to have_content(ci_resource_projects[2].description) + expect(page).to have_content(namespace.name) + end + end + + context 'when clicked' do + before do + find_by_testid('ci-resource-link', match: :first).click + end + + it 'navigate to the details page' do + expect(page).to have_content('Go to the project') + end + end + end + end + + describe 'GET explore/catalog/:id' do + let_it_be(:project) { create(:project, :repository, namespace: namespace) } + let_it_be(:new_ci_resource) { create(:ci_catalog_resource, project: project) } + + before do + visit explore_catalog_path(id: new_ci_resource["id"]) + end + + it 'navigates to the details page' do + expect(page).to have_content('Go to the project') + end + end +end diff --git a/spec/features/explore/navbar_spec.rb b/spec/features/explore/navbar_spec.rb index 853d66ed4d1..c172760eb2c 100644 --- a/spec/features/explore/navbar_spec.rb +++ b/spec/features/explore/navbar_spec.rb @@ -2,13 +2,24 @@ require 'spec_helper' -RSpec.describe '"Explore" navbar', feature_category: :navigation do +RSpec.describe '"Explore" navbar', :js, feature_category: :navigation do include_context '"Explore" navbar structure' it_behaves_like 'verified navigation bar' do before do - stub_feature_flags(super_sidebar_logged_out: false) + stub_feature_flags(global_ci_catalog: false) visit explore_projects_path end end + + context "with 'global_ci_catalog' enabled" do + include_context '"Explore" navbar structure with global_ci_catalog FF' + + it_behaves_like 'verified navigation bar', global_ci_catalog: true do + before do + stub_feature_flags(global_ci_catalog: true) + visit explore_projects_path + end + end + end end diff --git a/spec/features/explore/user_explores_projects_spec.rb b/spec/features/explore/user_explores_projects_spec.rb index 43d464e0c9f..e1341824bfd 100644 --- a/spec/features/explore/user_explores_projects_spec.rb +++ b/spec/features/explore/user_explores_projects_spec.rb @@ -3,20 +3,45 @@ require 'spec_helper' RSpec.describe 'User explores projects', feature_category: :user_profile do - before do - stub_feature_flags(super_sidebar_logged_out: false) + shared_examples 'an "Explore > Projects" page with sidebar and breadcrumbs' do |page_path| + before do + visit send(page_path) + end + + describe "sidebar", :js do + it 'shows the "Explore" sidebar' do + has_testid?('super-sidebar') + within_testid('super-sidebar') do + expect(page).to have_css('#super-sidebar-context-header', text: 'Explore') + end + end + + it 'shows the "Projects" menu item as active' do + within_testid('super-sidebar') do + expect(page).to have_css("[aria-current='page']", text: "Projects") + end + end + end + + describe 'breadcrumbs' do + it 'has "Explore" as its root breadcrumb' do + within '.breadcrumbs-list li:first' do + expect(page).to have_link('Explore', href: explore_root_path) + end + end + end end describe '"All" tab' do - it_behaves_like 'an "Explore" page with sidebar and breadcrumbs', :explore_projects_path, :projects + it_behaves_like 'an "Explore > Projects" page with sidebar and breadcrumbs', :explore_projects_path end describe '"Most starred" tab' do - it_behaves_like 'an "Explore" page with sidebar and breadcrumbs', :starred_explore_projects_path, :projects + it_behaves_like 'an "Explore > Projects" page with sidebar and breadcrumbs', :starred_explore_projects_path end describe '"Trending" tab' do - it_behaves_like 'an "Explore" page with sidebar and breadcrumbs', :trending_explore_projects_path, :projects + it_behaves_like 'an "Explore > Projects" page with sidebar and breadcrumbs', :trending_explore_projects_path end context 'when some projects exist' do diff --git a/spec/features/global_search_spec.rb b/spec/features/global_search_spec.rb index dfafacf48e2..7d6d1648ff5 100644 --- a/spec/features/global_search_spec.rb +++ b/spec/features/global_search_spec.rb @@ -3,9 +3,7 @@ require 'spec_helper' RSpec.describe 'Global search', :js, feature_category: :global_search do - include AfterNextHelpers - - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: user.namespace) } before do @@ -18,17 +16,18 @@ RSpec.describe 'Global search', :js, feature_category: :global_search do visit dashboard_projects_path end - it 'renders updated search bar' do - expect(page).to have_no_selector('.search-form') - expect(page).to have_selector('#js-header-search') + it 'renders search button' do + expect(page).to have_button('Search or go to…') end - it 'focuses search input when shortcut "s" is pressed' do - expect(page).not_to have_selector('#search:focus') + it 'opens search modal when shortcut "s" is pressed' do + search_selector = 'input[type="search"]:focus' + + expect(page).not_to have_selector(search_selector) find('body').native.send_key('s') - expect(page).to have_selector('#search:focus') + expect(page).to have_selector(search_selector) end end end diff --git a/spec/features/group_variables_spec.rb b/spec/features/group_variables_spec.rb index b4a0678cb5f..841cc1726a0 100644 --- a/spec/features/group_variables_spec.rb +++ b/spec/features/group_variables_spec.rb @@ -12,13 +12,13 @@ RSpec.describe 'Group variables', :js, feature_category: :secrets_management do group.add_owner(user) gitlab_sign_in(user) - stub_feature_flags(ci_variable_drawer: false) visit page_path wait_for_requests end context 'when ci_variables_pages FF is enabled' do - it_behaves_like 'variable list' + it_behaves_like 'variable list drawer' + it_behaves_like 'variable list env scope' it_behaves_like 'variable list pagination', :ci_group_variable end @@ -27,16 +27,7 @@ RSpec.describe 'Group variables', :js, feature_category: :secrets_management do stub_feature_flags(ci_variables_pages: false) end - it_behaves_like 'variable list' - end - - context 'when ci_variable_drawer FF is enabled' do - before do - stub_feature_flags(ci_variable_drawer: true) - visit page_path - wait_for_requests - end - it_behaves_like 'variable list drawer' + it_behaves_like 'variable list env scope' end end diff --git a/spec/features/groups/board_sidebar_spec.rb b/spec/features/groups/board_sidebar_spec.rb index 6a1b7d20a25..3fe520ea2ea 100644 --- a/spec/features/groups/board_sidebar_spec.rb +++ b/spec/features/groups/board_sidebar_spec.rb @@ -19,7 +19,6 @@ RSpec.describe 'Group Issue Boards', :js, feature_category: :groups_and_projects let(:card) { find('.board:nth-child(1)').first('.board-card') } before do - stub_feature_flags(apollo_boards: false) sign_in(user) visit group_board_path(group, board) diff --git a/spec/features/groups/board_spec.rb b/spec/features/groups/board_spec.rb index c2d6b80b4c0..e6dc6055e27 100644 --- a/spec/features/groups/board_spec.rb +++ b/spec/features/groups/board_spec.rb @@ -14,8 +14,6 @@ RSpec.describe 'Group Boards', feature_category: :team_planning do let_it_be(:project) { create(:project_empty_repo, group: group) } before do - stub_feature_flags(apollo_boards: false) - group.add_maintainer(user) sign_in(user) @@ -61,8 +59,6 @@ RSpec.describe 'Group Boards', feature_category: :team_planning do let_it_be(:issue2) { create(:issue, title: 'issue2', project: project2) } before do - stub_feature_flags(apollo_boards: false) - project1.add_guest(user) project2.add_reporter(user) diff --git a/spec/features/groups/container_registry_spec.rb b/spec/features/groups/container_registry_spec.rb index 953a8e27547..65edeb0798f 100644 --- a/spec/features/groups/container_registry_spec.rb +++ b/spec/features/groups/container_registry_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Container Registry', :js, feature_category: :container_registry do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, namespace: group) } @@ -28,8 +28,8 @@ RSpec.describe 'Container Registry', :js, feature_category: :container_registry it 'sidebar menu is open' do visit_container_registry - sidebar = find('.nav-sidebar') - expect(sidebar).to have_link _('Container Registry') + expect(page).to have_active_navigation('Deploy') + expect(page).to have_active_sub_navigation('Container Registry') end context 'when there are no image repositories' do diff --git a/spec/features/groups/dependency_proxy_spec.rb b/spec/features/groups/dependency_proxy_spec.rb index 2d4f6d4fbf2..12c480a46b0 100644 --- a/spec/features/groups/dependency_proxy_spec.rb +++ b/spec/features/groups/dependency_proxy_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' RSpec.describe 'Group Dependency Proxy', feature_category: :dependency_proxy do - let(:owner) { create(:user, :no_super_sidebar) } - let(:reporter) { create(:user, :no_super_sidebar) } + let(:owner) { create(:user) } + let(:reporter) { create(:user) } let(:group) { create(:group) } let(:path) { group_dependency_proxy_path(group) } let(:settings_path) { group_settings_packages_and_registries_path(group) } @@ -36,8 +36,8 @@ RSpec.describe 'Group Dependency Proxy', feature_category: :dependency_proxy do it 'sidebar menu is open' do visit path - sidebar = find('.nav-sidebar') - expect(sidebar).to have_link _('Dependency Proxy') + expect(page).to have_active_navigation('Operate') + expect(page).to have_active_sub_navigation('Dependency Proxy') end it 'toggles defaults to enabled' do diff --git a/spec/features/groups/group_page_with_external_authorization_service_spec.rb b/spec/features/groups/group_page_with_external_authorization_service_spec.rb index 4cc0fe4171d..fe1a685899f 100644 --- a/spec/features/groups/group_page_with_external_authorization_service_spec.rb +++ b/spec/features/groups/group_page_with_external_authorization_service_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -RSpec.describe 'The group page', feature_category: :groups_and_projects do +RSpec.describe 'The group page', :js, feature_category: :groups_and_projects do include ExternalAuthorizationServiceHelpers - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:group) { create(:group) } before do @@ -14,8 +14,9 @@ RSpec.describe 'The group page', feature_category: :groups_and_projects do end def expect_all_sidebar_links - within('.nav-sidebar') do - expect(page).to have_link('Group information') + within('#super-sidebar .contextual-nav') do + click_button 'Manage' + click_button 'Plan' expect(page).to have_link('Activity') expect(page).to have_link('Issues') expect(page).to have_link('Merge requests') @@ -42,8 +43,11 @@ RSpec.describe 'The group page', feature_category: :groups_and_projects do enable_external_authorization_service_check visit group_path(group) - within('.nav-sidebar') do - expect(page).to have_link('Group information') + within('#super-sidebar .contextual-nav') do + expect(page).not_to have_button('Plan') + + click_button 'Manage' + expect(page).not_to have_link('Activity') expect(page).not_to have_link('Contribution') diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb index a248a2b471a..0437e5df6e9 100644 --- a/spec/features/groups/group_settings_spec.rb +++ b/spec/features/groups/group_settings_spec.rb @@ -329,7 +329,7 @@ RSpec.describe 'Edit group settings', feature_category: :groups_and_projects do end def updated_emails_disabled? - group.reload.clear_memoization(:emails_disabled_memoized) + group.reload.clear_memoization(:emails_enabled_memoized) group.emails_disabled? end end diff --git a/spec/features/groups/members/request_access_spec.rb b/spec/features/groups/members/request_access_spec.rb index c04b84be90e..2d0b2e483c5 100644 --- a/spec/features/groups/members/request_access_spec.rb +++ b/spec/features/groups/members/request_access_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' RSpec.describe 'Groups > Members > Request access', feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } - let(:owner) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } + let(:owner) { create(:user) } let(:group) { create(:group, :public) } let!(:project) { create(:project, :private, namespace: group) } @@ -48,12 +48,15 @@ RSpec.describe 'Groups > Members > Request access', feature_category: :groups_an expect(page).not_to have_content group.name end - it 'user is not listed in the group members page' do + it 'user is not listed in the group members page', :js do click_link 'Request Access' expect(group.requesters.exists?(user_id: user)).to be_truthy - first(:link, 'Members').click + within_testid 'super-sidebar' do + click_button 'Manage' + first(:link, 'Members').click + end page.within('.content') do expect(page).not_to have_content(user.name) diff --git a/spec/features/groups/members/sort_members_spec.rb b/spec/features/groups/members/sort_members_spec.rb index fd367b8e763..ea6f3ae1966 100644 --- a/spec/features/groups/members/sort_members_spec.rb +++ b/spec/features/groups/members/sort_members_spec.rb @@ -19,7 +19,7 @@ RSpec.describe 'Groups > Members > Sort members', :js, feature_category: :groups def expect_sort_by(text, sort_direction) within('[data-testid="members-sort-dropdown"]') do expect(page).to have_css('button[aria-haspopup="menu"]', text: text) - expect(page).to have_button("Sorting Direction: #{sort_direction == :asc ? 'Ascending' : 'Descending'}") + expect(page).to have_button("Sort direction: #{sort_direction == :asc ? 'Ascending' : 'Descending'}") end end diff --git a/spec/features/groups/merge_requests_spec.rb b/spec/features/groups/merge_requests_spec.rb index bbb7d322b9a..0a830e6715c 100644 --- a/spec/features/groups/merge_requests_spec.rb +++ b/spec/features/groups/merge_requests_spec.rb @@ -26,8 +26,10 @@ RSpec.describe 'Group merge requests page', feature_category: :code_review_workf expect(page).not_to have_content(issuable_archived.title) end - it 'ignores archived merge request count badges in navbar' do - expect(first(:link, text: 'Merge requests').find('.badge').text).to eq("1") + it 'ignores archived merge request count badges in navbar', :js do + within_testid('super-sidebar') do + expect(find_link(text: 'Merge requests').find('.badge').text).to eq("1") + end end it 'ignores archived merge request count badges in state-filters' do diff --git a/spec/features/groups/navbar_spec.rb b/spec/features/groups/navbar_spec.rb index 76e4e32d138..7d5cc704f9c 100644 --- a/spec/features/groups/navbar_spec.rb +++ b/spec/features/groups/navbar_spec.rb @@ -2,19 +2,19 @@ require 'spec_helper' -RSpec.describe 'Group navbar', :with_license, feature_category: :navigation do +RSpec.describe 'Group navbar', :with_license, :js, feature_category: :navigation do include NavbarStructureHelper include WikiHelpers include_context 'group navbar structure' - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let(:group) { create(:group) } before do - insert_package_nav(_('Kubernetes')) - insert_after_nav_item(_('Analytics'), new_nav_item: settings_for_maintainer_nav_item) if Gitlab.ee? + create_package_nav(_('Operate')) + insert_after_nav_item(_('Analyze'), new_nav_item: settings_for_maintainer_nav_item) if Gitlab.ee? stub_config(dependency_proxy: { enabled: false }) stub_config(registry: { enabled: false }) @@ -46,9 +46,9 @@ RSpec.describe 'Group navbar', :with_license, feature_category: :navigation do before do if Gitlab.ee? - insert_customer_relations_nav(_('Analytics')) + insert_customer_relations_nav(_('Iterations')) else - insert_customer_relations_nav(_('Packages and registries')) + insert_customer_relations_nav(_('Milestones')) end visit group_path(group) @@ -85,7 +85,7 @@ RSpec.describe 'Group navbar', :with_license, feature_category: :navigation do before do group.update!(harbor_integration: harbor_integration) - insert_harbor_registry_nav(_('Package Registry')) + insert_harbor_registry_nav(_('Kubernetes')) visit group_path(group) end diff --git a/spec/features/groups/new_group_page_spec.rb b/spec/features/groups/new_group_page_spec.rb index e1034f2bb9d..f86430ae617 100644 --- a/spec/features/groups/new_group_page_spec.rb +++ b/spec/features/groups/new_group_page_spec.rb @@ -12,42 +12,17 @@ RSpec.describe 'New group page', :js, feature_category: :groups_and_projects do end describe 'sidebar' do - context 'in the current navigation' do - before do - user.update!(use_new_navigation: false) - end - - context 'for a new top-level group' do - it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :new_group_path, :groups - end - - context 'for a new subgroup' do - it 'shows the group sidebar of the parent group' do - visit new_group_path(parent_id: parent_group.id, anchor: 'create-group-pane') - expect(page).to have_selector( - ".nav-sidebar[aria-label=\"Group navigation\"] .context-header[title=\"#{parent_group.name}\"]" - ) - end + context 'for a new top-level group' do + it 'shows the "Your work" navigation' do + visit new_group_path + expect(page).to have_selector(".super-sidebar", text: "Your work") end end - context 'in the new navigation' do - before do - user.update!(use_new_navigation: true) - end - - context 'for a new top-level group' do - it 'shows the "Your work" navigation' do - visit new_group_path - expect(page).to have_selector(".super-sidebar", text: "Your work") - end - end - - context 'for a new subgroup' do - it 'shows the group navigation of the parent group' do - visit new_group_path(parent_id: parent_group.id, anchor: 'create-group-pane') - expect(page).to have_selector(".super-sidebar", text: parent_group.name) - end + context 'for a new subgroup' do + it 'shows the group navigation of the parent group' do + visit new_group_path(parent_id: parent_group.id, anchor: 'create-group-pane') + expect(page).to have_selector(".super-sidebar", text: parent_group.name) end end end diff --git a/spec/features/groups/packages_spec.rb b/spec/features/groups/packages_spec.rb index 1d9269501be..7819b1f0ab6 100644 --- a/spec/features/groups/packages_spec.rb +++ b/spec/features/groups/packages_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Group Packages', feature_category: :package_registry do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group) } let_it_be(:project) { create(:project, group: group) } @@ -32,7 +32,7 @@ RSpec.describe 'Group Packages', feature_category: :package_registry do end it 'sidebar menu is open' do - sidebar = find('.nav-sidebar') + sidebar = find_by_testid('super-sidebar') expect(sidebar).to have_link _('Package Registry') end diff --git a/spec/features/groups/settings/packages_and_registries_spec.rb b/spec/features/groups/settings/packages_and_registries_spec.rb index fa310722860..cbd26441e2b 100644 --- a/spec/features/groups/settings/packages_and_registries_spec.rb +++ b/spec/features/groups/settings/packages_and_registries_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Group Package and registry settings', feature_category: :package_registry do include WaitForRequests - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:group) { create(:group) } let(:sub_group) { create(:group, parent: group) } @@ -20,12 +20,13 @@ RSpec.describe 'Group Package and registry settings', feature_category: :package stub_packages_setting(enabled: false) end - it 'the menu item is not visible' do + it 'the menu item is not visible', :js do visit group_path(group) - settings_menu = find_settings_menu - - expect(settings_menu).not_to have_content 'Packages and registries' + within_testid('super-sidebar') do + click_button 'Settings' + expect(page).not_to have_content 'Packages and registries' + end end it 'renders 404 when navigating to page' do @@ -36,11 +37,13 @@ RSpec.describe 'Group Package and registry settings', feature_category: :package end context 'when packages feature is enabled on the group' do - it 'the menu item is visible' do + it 'the menu item is visible', :js do visit group_path(group) - settings_menu = find_settings_menu - expect(settings_menu).to have_content 'Packages and registries' + within_testid('super-sidebar') do + click_button 'Settings' + expect(page).to have_content 'Packages and registries' + end end it 'has a page title set' do @@ -49,11 +52,12 @@ RSpec.describe 'Group Package and registry settings', feature_category: :package expect(page).to have_title _('Packages and registries settings') end - it 'sidebar menu is open' do + it 'sidebar menu is open', :js do visit_settings_page - sidebar = find('.nav-sidebar') - expect(sidebar).to have_link _('Packages and registries') + within_testid('super-sidebar') do + expect(page).to have_link _('Packages and registries') + end end it 'passes axe automated accessibility testing', :js do @@ -62,7 +66,7 @@ RSpec.describe 'Group Package and registry settings', feature_category: :package wait_for_requests expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-group-settings"]') - .skipping :'link-in-text-block' + .skipping :'link-in-text-block', :'heading-order' end it 'has a Duplicate packages section', :js do @@ -124,10 +128,6 @@ RSpec.describe 'Group Package and registry settings', feature_category: :package end end - def find_settings_menu - find('.shortcuts-settings ul') - end - def visit_settings_page visit group_settings_packages_and_registries_path(group) end diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb index 8450322945c..cf18f3cb4e5 100644 --- a/spec/features/groups/show_spec.rb +++ b/spec/features/groups/show_spec.rb @@ -276,7 +276,7 @@ RSpec.describe 'Group show page', feature_category: :groups_and_projects do end it 'is disabled if emails are disabled' do - group.update!(emails_disabled: true) + group.update!(emails_enabled: false) visit path diff --git a/spec/features/groups/user_sees_package_sidebar_spec.rb b/spec/features/groups/user_sees_package_sidebar_spec.rb index 4efb9ff7608..8985b602eb7 100644 --- a/spec/features/groups/user_sees_package_sidebar_spec.rb +++ b/spec/features/groups/user_sees_package_sidebar_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe 'Groups > sidebar', feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } +RSpec.describe 'Groups > sidebar', :js, feature_category: :groups_and_projects do + let(:user) { create(:user) } let(:group) { create(:group) } before do @@ -19,13 +19,15 @@ RSpec.describe 'Groups > sidebar', feature_category: :groups_and_projects do end it 'shows main menu' do - within '.nav-sidebar' do - expect(page).to have_link(_('Packages')) + within_testid 'super-sidebar' do + click_button 'Deploy' + expect(page).to have_link(_('Package Registry')) end end it 'has container registry link' do - within '.nav-sidebar' do + within_testid 'super-sidebar' do + click_button 'Deploy' expect(page).to have_link(_('Container Registry')) end end @@ -38,7 +40,8 @@ RSpec.describe 'Groups > sidebar', feature_category: :groups_and_projects do end it 'does not have container registry link' do - within '.nav-sidebar' do + within_testid 'super-sidebar' do + click_button 'Deploy' expect(page).not_to have_link(_('Container Registry')) end end diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index bcbfdf487ac..578f39181d1 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Group', feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in(user) @@ -441,21 +441,30 @@ RSpec.describe 'Group', feature_category: :groups_and_projects do expect(page).to have_content(nested_group.name) expect(page).to have_content(project.name) - expect(page).to have_link('Group information') end - it 'renders subgroup page with the text "Subgroup information"' do + it 'renders group page with the text "Group" in the sidebar header' do + visit group_path(group) + + within('#super-sidebar-context-header') do + expect(page).to have_text('Group') + end + end + + it 'renders subgroup page with the text "Group" in the sidebar header' do visit group_path(nested_group) - wait_for_requests - expect(page).to have_link('Subgroup information') + within('#super-sidebar-context-header') do + expect(page).to have_text('Group') + end end - it 'renders project page with the text "Project information"' do + it 'renders project page with the text "Project" in the sidebar header' do visit project_path(project) - wait_for_requests - expect(page).to have_link('Project information') + within('#super-sidebar-context-header') do + expect(page).to have_text('Project') + end end end diff --git a/spec/features/help_dropdown_spec.rb b/spec/features/help_dropdown_spec.rb index 08d7dba4d79..3e4c0bc55fe 100644 --- a/spec/features/help_dropdown_spec.rb +++ b/spec/features/help_dropdown_spec.rb @@ -3,24 +3,19 @@ require 'spec_helper' RSpec.describe "Help Dropdown", :js, feature_category: :shared do - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:admin) { create(:admin, :no_super_sidebar) } + let_it_be(:user) { create(:user) } + let_it_be(:admin) { create(:admin) } before do stub_application_setting(version_check_enabled: true) end - context 'when logged in as non-admin' do - before do - sign_in(user) - visit root_path - end - - it 'does not render version data' do - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + shared_examples 'no version check badge' do + it 'does not render version check badge' do + within_testid('super-sidebar') do + click_on 'Help' - expect(page).not_to have_text('Your GitLab Version') + expect(page).not_to have_text('Your GitLab version') expect(page).not_to have_text("#{Gitlab.version_info.major}.#{Gitlab.version_info.minor}") expect(page).not_to have_selector('.version-check-badge') expect(page).not_to have_text('Up to date') @@ -28,45 +23,53 @@ RSpec.describe "Help Dropdown", :js, feature_category: :shared do end end - context 'when logged in as admin' do - before do - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end + shared_examples 'correct version check badge' do |ui_text, severity| + context "when severity is #{severity}" do + before do + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) - describe 'does render version data' do - where(:response, :ui_text) do - [ - [{ "severity" => "success" }, 'Up to date'], - [{ "severity" => "warning" }, 'Update available'], - [{ "severity" => "danger" }, 'Update ASAP'] - ] + allow_next_instance_of(VersionCheck) do |instance| + allow(instance).to receive(:response).and_return({ "severity" => severity }) + end + visit root_path end - with_them do - before do - allow_next_instance_of(VersionCheck) do |instance| - allow(instance).to receive(:response).and_return(response) - end - visit root_path - end + it 'renders correct version check badge variant' do + within_testid('super-sidebar') do + click_on 'Help' - it 'renders correct version badge variant', - quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/369850' do - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + expect(page).to have_text('Your GitLab version') + expect(page).to have_text("#{Gitlab.version_info.major}.#{Gitlab.version_info.minor}") - expect(page).to have_text('Your GitLab Version') - expect(page).to have_text("#{Gitlab.version_info.major}.#{Gitlab.version_info.minor}") - expect(page).to have_selector('.version-check-badge') - expect(page).to have_selector( - 'a[data-testid="gitlab-version-container"][href="/help/update/index"]' - ) - expect(page).to have_selector('.version-check-badge[href="/help/update/index"]') - expect(page).to have_text(ui_text) + within page.find_link(href: help_page_path('update/index')) do + expect(page).to have_selector(".version-check-badge.badge-#{severity}", text: ui_text) end end end end end + + context 'when anonymous user' do + before do + visit user_path(user) + end + + include_examples 'no version check badge' + end + + context 'when logged in as non-admin' do + before do + sign_in(user) + visit root_path + end + + include_examples 'no version check badge' + end + + context 'when logged in as admin' do + include_examples 'correct version check badge', 'Up to date', 'success' + include_examples 'correct version check badge', 'Update available', 'warning' + include_examples 'correct version check badge', 'Update ASAP', 'danger' + end end diff --git a/spec/features/ide/user_opens_merge_request_spec.rb b/spec/features/ide/user_opens_merge_request_spec.rb index 1d3cada57db..a8a56ffe310 100644 --- a/spec/features/ide/user_opens_merge_request_spec.rb +++ b/spec/features/ide/user_opens_merge_request_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'IDE merge request', :js, feature_category: :web_ide do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, namespace: user.namespace) } let_it_be(:merge_request) { create(:merge_request, :simple, source_project: project) } @@ -16,7 +16,9 @@ RSpec.describe 'IDE merge request', :js, feature_category: :web_ide do end it 'user opens merge request' do - click_button 'Code' + within '.merge-request' do + click_button 'Code' + end click_link 'Open in Web IDE' wait_for_requests diff --git a/spec/features/invites_spec.rb b/spec/features/invites_spec.rb index c86d4c260ee..bc6efb63f6f 100644 --- a/spec/features/invites_spec.rb +++ b/spec/features/invites_spec.rb @@ -59,7 +59,7 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate end context 'when invite is sent before account is created;ldap or service sign in for manual acceptance edge case' do - let(:user) { create(:user, :no_super_sidebar, email: 'user@example.com') } + let(:user) { create(:user, email: 'user@example.com') } context 'when invite clicked and not signed in' do before do @@ -85,7 +85,6 @@ RSpec.describe 'Group or Project invitations', :aggregate_failures, feature_cate it 'shows message user already a member' do expect(page).to have_current_path(invite_path(group_invite.raw_invite_token), ignore_query: true) - expect(page).to have_link(user.name, href: user_path(user)) expect(page).to have_content('You are already a member of this group.') end end diff --git a/spec/features/issuables/shortcuts_issuable_spec.rb b/spec/features/issuables/shortcuts_issuable_spec.rb index 06387c14ee2..6bb453c34e6 100644 --- a/spec/features/issuables/shortcuts_issuable_spec.rb +++ b/spec/features/issuables/shortcuts_issuable_spec.rb @@ -58,14 +58,13 @@ RSpec.describe 'Blob shortcuts', :js, feature_category: :team_planning do it "opens assignee dropdown for editing" do find('body').native.send_key('a') - expect(find('.block.assignee')).to have_selector('.js-sidebar-assignee-data') + expect(find('.block.assignee')).to have_selector('.dropdown-menu-user') end end describe 'pressing "a"' do describe 'On an Issue' do before do - stub_feature_flags(issue_assignees_widget: false) visit project_issue_path(project, issue) wait_for_requests end @@ -75,7 +74,6 @@ RSpec.describe 'Blob shortcuts', :js, feature_category: :team_planning do describe 'On a Merge Request' do before do - stub_feature_flags(issue_assignees_widget: false) visit project_merge_request_path(project, merge_request) wait_for_requests end diff --git a/spec/features/issues/discussion_lock_spec.rb b/spec/features/issues/discussion_lock_spec.rb index fb9addff1a2..04d59854ddc 100644 --- a/spec/features/issues/discussion_lock_spec.rb +++ b/spec/features/issues/discussion_lock_spec.rb @@ -28,7 +28,7 @@ RSpec.describe 'Discussion Lock', :js, feature_category: :team_planning do click_button('Lock') end - expect(find('#notes')).to have_content('locked this issue') + expect(find('#notes')).to have_content('locked the discussion in this issue') end end @@ -46,7 +46,7 @@ RSpec.describe 'Discussion Lock', :js, feature_category: :team_planning do click_button('Unlock') end - expect(find('#notes')).to have_content('unlocked this issue') + expect(find('#notes')).to have_content('unlocked the discussion in this issue') expect(find('.issuable-sidebar')).to have_content('Unlocked') end @@ -101,7 +101,7 @@ RSpec.describe 'Discussion Lock', :js, feature_category: :team_planning do page.within('#notes') do expect(page).not_to have_selector('js-main-target-form') expect(page.find('.disabled-comments')) - .to have_content('This issue is locked. Only project members can comment.') + .to have_content('The discussion in this issue is locked. Only project members can comment.') end end end diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb index e51c82081ff..ca1a822fd88 100644 --- a/spec/features/issues/filtered_search/visual_tokens_spec.rb +++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb @@ -6,8 +6,8 @@ RSpec.describe 'Visual tokens', :js, feature_category: :team_planning do include FilteredSearchHelpers let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user, :no_super_sidebar, name: 'administrator', username: 'root') } - let_it_be(:user_rock) { create(:user, :no_super_sidebar, name: 'The Rock', username: 'rock') } + let_it_be(:user) { create(:user, name: 'administrator', username: 'root') } + let_it_be(:user_rock) { create(:user, name: 'The Rock', username: 'rock') } let_it_be(:milestone_nine) { create(:milestone, title: '9.0', project: project) } let_it_be(:milestone_ten) { create(:milestone, title: '10.0', project: project) } let_it_be(:label) { create(:label, project: project, title: 'abc') } @@ -41,7 +41,7 @@ RSpec.describe 'Visual tokens', :js, feature_category: :team_planning do end it 'ends editing mode when document is clicked' do - find('.js-navbar').click + find('body').click(x: 0, y: 0) expect_empty_search_term expect_hidden_suggestions_list diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 73c53e855b2..2fb30469691 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -7,9 +7,9 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do include ListboxHelpers let_it_be(:project) { create(:project, :repository) } - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:user2) { create(:user, :no_super_sidebar) } - let_it_be(:guest) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } + let_it_be(:guest) { create(:user) } let_it_be(:milestone) { create(:milestone, project: project) } let_it_be(:label) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) } @@ -526,7 +526,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do find('body').send_keys('e') - click_link 'Boards' + click_link 'Homepage' expect(page).not_to have_content(expected_content) end @@ -539,7 +539,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do find('body').send_keys('e') fill_in 'issue-description', with: content - click_link 'Boards' do + click_link 'Homepage' do page.driver.browser.switch_to.alert.dismiss end @@ -554,8 +554,8 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do find('body').send_keys('e') fill_in 'issue-description', with: content - click_link 'Boards' do - page.driver.browser.switch_to.alert.accept + click_link 'Homepage' do + page.driver.browser.switch_to.alert.dismiss end expect(page).not_to have_content(content) @@ -601,14 +601,4 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do end end end - - def before_for_selector(selector) - js = <<-JS.strip_heredoc - (function(selector) { - var el = document.querySelector(selector); - return window.getComputedStyle(el, '::before').getPropertyValue('content'); - })("#{escape_javascript(selector)}") - JS - page.evaluate_script(js) - end end diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index a015a83c793..e4df106de07 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -26,179 +26,66 @@ RSpec.describe 'Issue Sidebar', feature_category: :team_planning do let(:user2) { create(:user) } let(:issue2) { create(:issue, project: project, author: user2) } - context 'when GraphQL assignees widget feature flag is disabled' do - before do - stub_feature_flags(issue_assignees_widget: false) - end + include_examples 'issuable invite members' do + let(:issuable_path) { project_issue_path(project, issue2) } + end - include_examples 'issuable invite members' do - let(:issuable_path) { project_issue_path(project, issue2) } + context 'when user is a developer' do + before do + project.add_developer(user) + visit_issue(project, issue2) end - context 'when user is a developer' do - before do - project.add_developer(user) - visit_issue(project, issue2) - - find('.block.assignee .edit-link').click - wait_for_requests - end - - it 'shows author in assignee dropdown' do - page.within '.dropdown-menu-user' do - expect(page).to have_content(user2.name) - end - end - - it 'shows author when filtering assignee dropdown' do - page.within '.dropdown-menu-user' do - find('.dropdown-input-field').set(user2.name) - - wait_for_requests - - expect(page).to have_content(user2.name) - end - end - - it 'assigns yourself' do - find('.block.assignee .dropdown-menu-toggle').click - - click_button 'assign yourself' - - wait_for_requests - - find('.block.assignee .edit-link').click - - page.within '.dropdown-menu-user' do - expect(page.find('.dropdown-header')).to be_visible - expect(page.find('.dropdown-menu-user-link.is-active')).to have_content(user.name) - end - end - - it 'keeps your filtered term after filtering and dismissing the dropdown' do - find('.dropdown-input-field').set(user2.name) - - wait_for_requests - - page.within '.dropdown-menu-user' do - expect(page).not_to have_content 'Unassigned' - click_link user2.name - end - - within '.js-right-sidebar' do - find('.block.assignee').click(x: 0, y: 0, offset: 0) - find('.block.assignee .edit-link').click - end - - expect(page.all('.dropdown-menu-user li').length).to eq(6) - expect(find('.dropdown-input-field').value).to eq('') - end - - it 'shows label text as "Apply" when assignees are changed' do - project.add_developer(user) - visit_issue(project, issue2) - - find('.block.assignee .edit-link').click - wait_for_requests + it 'shows author in assignee dropdown' do + open_assignees_dropdown - click_on 'Unassigned' - - expect(page).to have_link('Apply') + page.within '.dropdown-menu-user' do + expect(page).to have_content(user2.name) end end - end - - context 'when GraphQL assignees widget feature flag is enabled' do - # TODO: Move to shared examples when feature flag is removed: https://gitlab.com/gitlab-org/gitlab/-/issues/328185 - context 'when a privileged user can invite' do - it 'shows a link for inviting members and launches invite modal' do - project.add_maintainer(user) - visit_issue(project, issue2) - open_assignees_dropdown + it 'shows author when filtering assignee dropdown' do + open_assignees_dropdown - page.within '.dropdown-menu-user' do - expect(page).to have_link('Invite members') + page.within '.dropdown-menu-user' do + find('[data-testid="user-search-input"]').set(user2.name) - click_link 'Invite members' - end + wait_for_requests - page.within invite_modal_selector do - expect(page).to have_content("You're inviting members to the #{project.name} project") - end + expect(page).to have_content(user2.name) end end - context 'when user cannot invite members in assignee dropdown' do - it 'shows author in assignee dropdown and no invite link' do - project.add_developer(user) - visit_issue(project, issue2) - - open_assignees_dropdown + it 'assigns yourself' do + click_button 'assign yourself' + wait_for_requests - page.within '.dropdown-menu-user' do - expect(page).not_to have_link('Invite members') - end + page.within '.assignee' do + expect(page).to have_content(user.name) end end - context 'when user is a developer' do - before do - project.add_developer(user) - visit_issue(project, issue2) - end + it 'keeps your filtered term after filtering and dismissing the dropdown' do + open_assignees_dropdown - it 'shows author in assignee dropdown' do - open_assignees_dropdown + find('[data-testid="user-search-input"]').set(user2.name) + wait_for_requests - page.within '.dropdown-menu-user' do - expect(page).to have_content(user2.name) - end + page.within '.dropdown-menu-user' do + expect(page).not_to have_content 'Unassigned' + click_button user2.name end - it 'shows author when filtering assignee dropdown' do - open_assignees_dropdown - - page.within '.dropdown-menu-user' do - find('[data-testid="user-search-input"]').set(user2.name) - - wait_for_requests + find('.participants').click + wait_for_requests - expect(page).to have_content(user2.name) - end - end - - it 'assigns yourself' do - click_button 'assign yourself' - wait_for_requests + open_assignees_dropdown - page.within '.assignee' do - expect(page).to have_content(user.name) - end + page.within('.assignee') do + expect(page.all('[data-testid="selected-participant"]').length).to eq(1) end - it 'keeps your filtered term after filtering and dismissing the dropdown' do - open_assignees_dropdown - - find('[data-testid="user-search-input"]').set(user2.name) - wait_for_requests - - page.within '.dropdown-menu-user' do - expect(page).not_to have_content 'Unassigned' - click_button user2.name - end - - find('.participants').click - wait_for_requests - - open_assignees_dropdown - - page.within('.assignee') do - expect(page.all('[data-testid="selected-participant"]').length).to eq(1) - end - - expect(find('[data-testid="user-search-input"]').value).to eq(user2.name) - end + expect(find('[data-testid="user-search-input"]').value).to eq(user2.name) end end end diff --git a/spec/features/issues/issue_state_spec.rb b/spec/features/issues/issue_state_spec.rb index 3fe49ff7080..125329764c6 100644 --- a/spec/features/issues/issue_state_spec.rb +++ b/spec/features/issues/issue_state_spec.rb @@ -51,7 +51,7 @@ RSpec.describe 'issue state', :js, feature_category: :team_planning do find('#new-actions-header-dropdown > button').click end - it_behaves_like 'issue closed', '.dropdown-menu-right' + it_behaves_like 'issue closed', '.gl-new-dropdown-contents' end context 'when clicking the bottom `Close issue` button', :aggregate_failures do @@ -74,7 +74,7 @@ RSpec.describe 'issue state', :js, feature_category: :team_planning do find('#new-actions-header-dropdown > button').click end - it_behaves_like 'issue reopened', '.dropdown-menu-right' + it_behaves_like 'issue reopened', '.gl-new-dropdown-contents' end context 'when clicking the bottom `Reopen issue` button', :aggregate_failures do diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb index 4a38373db71..eca52a3a2c3 100644 --- a/spec/features/issues/move_spec.rb +++ b/spec/features/issues/move_spec.rb @@ -44,7 +44,7 @@ RSpec.describe 'issue move to another project', feature_category: :team_planning it 'moving issue to another project', :js do click_button _('Move issue') wait_for_requests - all('.gl-dropdown-item')[0].click + all('.gl-new-dropdown-item')[0].click click_button _('Move') expect(page).to have_content("Text with #{cross_reference}#{mr.to_reference}") @@ -116,7 +116,7 @@ RSpec.describe 'issue move to another project', feature_category: :team_planning click_button _('Move issue') wait_for_requests - find('.gl-dropdown-item', text: project_title).click + find('.gl-new-dropdown-item', text: project_title).click click_button _('Move') end diff --git a/spec/features/issues/service_desk_spec.rb b/spec/features/issues/service_desk_spec.rb index 8e952a23f05..8662f0f98f5 100644 --- a/spec/features/issues/service_desk_spec.rb +++ b/spec/features/issues/service_desk_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Service Desk Issue Tracker', :js, feature_category: :service_desk do let(:project) { create(:project, :private, service_desk_enabled: true) } - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:support_bot) { Users::Internal.support_bot } before do @@ -21,8 +21,10 @@ RSpec.describe 'Service Desk Issue Tracker', :js, feature_category: :service_des describe 'navigation to service desk' do before do visit project_path(project) - find('.sidebar-top-level-items .shortcuts-issues').click - find('.sidebar-sub-level-items a', text: 'Service Desk').click + find('#menu-section-button-monitor').click + within('#monitor') do + click_link('Service Desk') + end end it 'can navigate to the service desk from link in the sidebar' do diff --git a/spec/features/issues/todo_spec.rb b/spec/features/issues/todo_spec.rb index 2095453ac29..458e3fac517 100644 --- a/spec/features/issues/todo_spec.rb +++ b/spec/features/issues/todo_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Manually create a todo item from issue', :js, feature_category: :team_planning do let!(:project) { create(:project) } let!(:issue) { create(:issue, project: project) } - let!(:user) { create(:user, :no_super_sidebar) } + let!(:user) { create(:user) } before do stub_feature_flags(notifications_todos_buttons: false) @@ -20,13 +20,13 @@ RSpec.describe 'Manually create a todo item from issue', :js, feature_category: expect(page).to have_content 'Mark as done' end - page.within ".header-content span[aria-label='#{_('Todos count')}']" do + within_testid 'todos-shortcut-button' do expect(page).to have_content '1' end visit project_issue_path(project, issue) - page.within ".header-content span[aria-label='#{_('Todos count')}']" do + within_testid 'todos-shortcut-button' do expect(page).to have_content '1' end end @@ -37,10 +37,10 @@ RSpec.describe 'Manually create a todo item from issue', :js, feature_category: click_button 'Mark as done' end - expect(page).to have_selector(".header-content span[aria-label='#{_('Todos count')}']", visible: false) + expect(page).to have_selector("[data-testid='todos-shortcut-button']", text: '') visit project_issue_path(project, issue) - expect(page).to have_selector(".header-content span[aria-label='#{_('Todos count')}']", visible: false) + expect(page).to have_selector("[data-testid='todos-shortcut-button']", text: '') end end diff --git a/spec/features/issues/user_comments_on_issue_spec.rb b/spec/features/issues/user_comments_on_issue_spec.rb index a81a99771cc..d27f3ffebe6 100644 --- a/spec/features/issues/user_comments_on_issue_spec.rb +++ b/spec/features/issues/user_comments_on_issue_spec.rb @@ -33,7 +33,9 @@ RSpec.describe "User comments on issue", :js, feature_category: :team_planning d end end - it_behaves_like 'edits content using the content editor' + # do not test quick actions here since guest users don't have permission + # to execute all quick actions + it_behaves_like 'edits content using the content editor', { with_quick_actions: false } it "adds comment with code block" do code_block_content = "Command [1]: /usr/local/bin/git , see [text](doc/text)" diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb index 29b44bf165d..a407e7fd112 100644 --- a/spec/features/issues/user_creates_issue_spec.rb +++ b/spec/features/issues/user_creates_issue_spec.rb @@ -139,8 +139,6 @@ RSpec.describe "User creates issue", feature_category: :team_planning do end end - it_behaves_like 'edits content using the content editor' - context 'dropzone upload file', :js do before do visit new_project_issue_path(project) @@ -308,6 +306,21 @@ RSpec.describe "User creates issue", feature_category: :team_planning do end end + context 'when signed in as a maintainer', :js do + let_it_be(:project) { create(:project) } + + before_all do + project.add_maintainer(user) + end + + before do + sign_in(user) + visit(new_project_issue_path(project)) + end + + it_behaves_like 'edits content using the content editor' + end + context "when signed in as user with special characters in their name" do let(:user_special) { create(:user, name: "Jon O'Shea") } diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb index 7919e8f7ed4..e9bf1ef542b 100644 --- a/spec/features/issues/user_edits_issue_spec.rb +++ b/spec/features/issues/user_edits_issue_spec.rb @@ -210,166 +210,79 @@ RSpec.describe "Issues > User edits issue", :js, feature_category: :team_plannin end describe 'update assignee' do - context 'when GraphQL assignees widget feature flag is disabled' do - before do - stub_feature_flags(issue_assignees_widget: false) - end - - context 'by authorized user' do - def close_dropdown_menu_if_visible - find('.dropdown-menu-toggle', visible: :all).tap do |toggle| - toggle.click if toggle.visible? - end - end - - it 'allows user to select unassigned' do - visit project_issue_path(project, issue) - - page.within('.assignee') do - expect(page).to have_content user.name.to_s - - click_link 'Edit' - click_link 'Unassigned' - - close_dropdown_menu_if_visible - - expect(page).to have_content 'None - assign yourself' - end - end - - it 'allows user to select an assignee' do - issue2 = create(:issue, project: project, author: user) - visit project_issue_path(project, issue2) - - page.within('.assignee') do - expect(page).to have_content "None" - end - - page.within '.assignee' do - click_link 'Edit' - end - - page.within '.dropdown-menu-user' do - click_link user.name - end - - page.within('.assignee') do - expect(page).to have_content user.name - end - end - - it 'allows user to unselect themselves' do - issue2 = create(:issue, project: project, author: user, assignees: [user]) - - visit project_issue_path(project, issue2) + context 'by authorized user' do + it 'allows user to select unassigned' do + visit project_issue_path(project, issue) - page.within '.assignee' do - expect(page).to have_content user.name + page.within('.assignee') do + expect(page).to have_content user.name.to_s - click_link 'Edit' - click_link user.name + click_button('Edit') + wait_for_requests - close_dropdown_menu_if_visible + find('[data-testid="unassign"]').click + find('[data-testid="title"]').click + wait_for_requests - page.within '[data-testid="no-value"]' do - expect(page).to have_content "None" - end - end + expect(page).to have_content 'None - assign yourself' end end - context 'by unauthorized user' do - let(:guest) { create(:user) } - - before do - project.add_guest(guest) - end - - it 'shows assignee text' do - sign_out(:user) - sign_in(guest) + it 'allows user to select an assignee' do + issue2 = create(:issue, project: project, author: user) + visit project_issue_path(project, issue2) - visit project_issue_path(project, issue) - expect(page).to have_content issue.assignees.first.name + page.within('.assignee') do + expect(page).to have_content "None" + click_button('Edit') + wait_for_requests end - end - end - - context 'when GraphQL assignees widget feature flag is enabled' do - context 'by authorized user' do - it 'allows user to select unassigned' do - visit project_issue_path(project, issue) - - page.within('.assignee') do - expect(page).to have_content user.name.to_s - - click_button('Edit') - wait_for_requests - - find('[data-testid="unassign"]').click - find('[data-testid="title"]').click - wait_for_requests - expect(page).to have_content 'None - assign yourself' - end + page.within '.dropdown-menu-user' do + click_button user.name end - it 'allows user to select an assignee' do - issue2 = create(:issue, project: project, author: user) - visit project_issue_path(project, issue2) - - page.within('.assignee') do - expect(page).to have_content "None" - click_button('Edit') - wait_for_requests - end - - page.within '.dropdown-menu-user' do - click_button user.name - end - - page.within('.assignee') do - find('[data-testid="title"]').click - wait_for_requests + page.within('.assignee') do + find('[data-testid="title"]').click + wait_for_requests - expect(page).to have_content user.name - end + expect(page).to have_content user.name end + end - it 'allows user to unselect themselves' do - issue2 = create(:issue, project: project, author: user, assignees: [user]) + it 'allows user to unselect themselves' do + issue2 = create(:issue, project: project, author: user, assignees: [user]) - visit project_issue_path(project, issue2) + visit project_issue_path(project, issue2) - page.within '.assignee' do - expect(page).to have_content user.name + page.within '.assignee' do + expect(page).to have_content user.name - click_button('Edit') - wait_for_requests - click_button user.name + click_button('Edit') + wait_for_requests + click_button user.name - find('[data-testid="title"]').click - wait_for_requests + find('[data-testid="title"]').click + wait_for_requests - expect(page).to have_content "None" - end + expect(page).to have_content "None" end end + end - context 'by unauthorized user' do - let(:guest) { create(:user) } + context 'by unauthorized user' do + let(:guest) { create(:user) } - before do - project.add_guest(guest) - end + before do + project.add_guest(guest) + end - it 'shows assignee text' do - sign_out(:user) - sign_in(guest) + it 'shows assignee text' do + sign_out(:user) + sign_in(guest) - visit project_issue_path(project, issue) - expect(page).to have_content issue.assignees.first.name - end + visit project_issue_path(project, issue) + expect(page).to have_content issue.assignees.first.name end end end diff --git a/spec/features/issues/user_interacts_with_awards_spec.rb b/spec/features/issues/user_interacts_with_awards_spec.rb index 539e429534e..813fdeea0a1 100644 --- a/spec/features/issues/user_interacts_with_awards_spec.rb +++ b/spec/features/issues/user_interacts_with_awards_spec.rb @@ -57,7 +57,7 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do end page.within('.emoji-picker') do - emoji_button = page.first('gl-emoji[data-name="8ball"]') + emoji_button = page.first('gl-emoji[data-name="grinning"]') emoji_button.hover emoji_button.click end @@ -65,7 +65,7 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do page.within('.awards') do expect(page).to have_selector('[data-testid="award-button"]') expect(page.find('[data-testid="award-button"].selected .js-counter')).to have_content('1') - expect(page).to have_css('[data-testid="award-button"].selected[title="You reacted with :8ball:"]') + expect(page).to have_css('[data-testid="award-button"].selected[title="You reacted with :grinning:"]') wait_for_requests @@ -114,17 +114,17 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do context 'User interacts with awards on a note' do let!(:note) { create(:note, noteable: issue, project: issue.project) } - let!(:award_emoji) { create(:award_emoji, awardable: note, name: '100') } + let!(:award_emoji) { create(:award_emoji, awardable: note, name: 'grinning') } it 'shows the award on the note' do page.within('.note-awards') do - expect(page).to have_emoji('100') + expect(page).to have_emoji('grinning') end end it 'allows adding a vote to an award' do page.within('.note-awards') do - find('gl-emoji[data-name="100"]').click + find('gl-emoji[data-name="grinning"]').click end wait_for_requests @@ -140,11 +140,11 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do # make sure emoji popup is visible execute_script("window.scrollBy(0, 200)") - find('gl-emoji[data-name="8ball"]').click + find('gl-emoji[data-name="laughing"]').click wait_for_requests page.within('.note-awards') do - expect(page).to have_emoji('8ball') + expect(page).to have_emoji('laughing') end expect(note.reload.award_emoji.size).to eq(2) restore_window_size @@ -165,7 +165,7 @@ RSpec.describe 'User interacts with awards', feature_category: :team_planning do it 'does not allow toggling existing emoji' do page.within('.note-awards') do - find('gl-emoji[data-name="100"]').click + find('gl-emoji[data-name="grinning"]').click end wait_for_requests diff --git a/spec/features/issues/user_uses_quick_actions_spec.rb b/spec/features/issues/user_uses_quick_actions_spec.rb index d3552b87fea..937a0683794 100644 --- a/spec/features/issues/user_uses_quick_actions_spec.rb +++ b/spec/features/issues/user_uses_quick_actions_spec.rb @@ -12,8 +12,8 @@ RSpec.describe 'Issues > User uses quick actions', :js, feature_category: :team_ context "issuable common quick actions" do let(:new_url_opts) { {} } - let(:maintainer) { create(:user, :no_super_sidebar) } - let(:project) { create(:project, :public) } + let(:maintainer) { create(:user) } + let_it_be(:project) { create(:project, :public) } let!(:label_bug) { create(:label, project: project, title: 'bug') } let!(:label_feature) { create(:label, project: project, title: 'feature') } let!(:milestone) { create(:milestone, project: project, title: 'ASAP') } @@ -25,7 +25,7 @@ RSpec.describe 'Issues > User uses quick actions', :js, feature_category: :team_ end describe 'issue-only commands' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, :public, :repository) } let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) } diff --git a/spec/features/jira_connect/branches_spec.rb b/spec/features/jira_connect/branches_spec.rb index ae1dd551c47..25dc14a1dc9 100644 --- a/spec/features/jira_connect/branches_spec.rb +++ b/spec/features/jira_connect/branches_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'Create GitLab branches from Jira', :js, feature_category: :integrations do include ListboxHelpers - let_it_be(:alice) { create(:user, :no_super_sidebar, name: 'Alice') } - let_it_be(:bob) { create(:user, :no_super_sidebar, name: 'Bob') } + let_it_be(:alice) { create(:user, name: 'Alice') } + let_it_be(:bob) { create(:user, name: 'Bob') } let_it_be(:project1) { create(:project, :repository, namespace: alice.namespace, title: 'foo') } let_it_be(:project2) { create(:project, :repository, namespace: alice.namespace, title: 'bar') } diff --git a/spec/features/jira_oauth_provider_authorize_spec.rb b/spec/features/jira_oauth_provider_authorize_spec.rb deleted file mode 100644 index e873d9c219f..00000000000 --- a/spec/features/jira_oauth_provider_authorize_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'JIRA OAuth Provider', feature_category: :integrations do - describe 'JIRA DVCS OAuth Authorization' do - let_it_be(:application) do - create(:oauth_application, redirect_uri: oauth_jira_dvcs_callback_url, scopes: 'read_user') - end - - let(:authorize_path) do - oauth_jira_dvcs_authorize_path(client_id: application.uid, - redirect_uri: oauth_jira_dvcs_callback_url, - response_type: 'code', - state: 'my_state', - scope: 'read_user') - end - - before do - sign_in(user) - end - - it_behaves_like 'Secure OAuth Authorizations' do - before do - visit authorize_path - end - end - - context 'when the flag is disabled' do - let_it_be(:user) { create(:user) } - - before do - stub_feature_flags(jira_dvcs_end_of_life_amnesty: false) - visit authorize_path - end - - it 'presents as an endpoint that does not exist' do - expect(page).to have_gitlab_http_status(:not_found) - end - end - end -end diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb index 72f5b46c3ad..c6c7342325b 100644 --- a/spec/features/labels_hierarchy_spec.rb +++ b/spec/features/labels_hierarchy_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do include FilteredSearchHelpers - let!(:user) { create(:user, :no_super_sidebar) } + let!(:user) { create(:user) } let!(:grandparent) { create(:group) } let!(:parent) { create(:group, parent: grandparent) } let!(:child) { create(:group, parent: parent) } @@ -179,7 +179,7 @@ RSpec.describe 'Labels Hierarchy', :js, feature_category: :team_planning do wait_for_requests end - find('.btn-confirm').click + click_button 'Create issue' expect(page.find('.issue-details h1.title')).to have_content('new created issue') expect(page).to have_selector('span.gl-label-text', text: grandparent_group_label.title) diff --git a/spec/features/markdown/keyboard_shortcuts_spec.rb b/spec/features/markdown/keyboard_shortcuts_spec.rb index 6f128e16041..ba88278199a 100644 --- a/spec/features/markdown/keyboard_shortcuts_spec.rb +++ b/spec/features/markdown/keyboard_shortcuts_spec.rb @@ -97,8 +97,8 @@ RSpec.describe 'Markdown keyboard shortcuts', :js, feature_category: :team_plann context 'Vue.js markdown editor' do let(:path_to_visit) { new_project_release_path(project) } - let(:markdown_field) { find_field('Release notes') } - let(:non_markdown_field) { find_field('Release title') } + let(:markdown_field) { find_field('release-notes') } + let(:non_markdown_field) { find_field('release-title') } it_behaves_like 'keyboard shortcuts' it_behaves_like 'no side effects' diff --git a/spec/features/merge_request/maintainer_edits_fork_spec.rb b/spec/features/merge_request/maintainer_edits_fork_spec.rb index 7603696c60c..8618dca5873 100644 --- a/spec/features/merge_request/maintainer_edits_fork_spec.rb +++ b/spec/features/merge_request/maintainer_edits_fork_spec.rb @@ -50,7 +50,10 @@ RSpec.describe 'a maintainer edits files on a source-branch of an MR from a fork click_button 'Commit changes' wait_for_requests - expect(page).to have_content('Your changes have been successfully committed') + expect(page).to have_content('Your changes have been committed successfully') + page.within '.flash-container' do + expect(page).to have_link 'changes' + end expect(page).to have_content(content) end end diff --git a/spec/features/merge_request/merge_request_discussion_lock_spec.rb b/spec/features/merge_request/merge_request_discussion_lock_spec.rb index 782c4af58ac..7e01063816f 100644 --- a/spec/features/merge_request/merge_request_discussion_lock_spec.rb +++ b/spec/features/merge_request/merge_request_discussion_lock_spec.rb @@ -92,7 +92,7 @@ RSpec.describe 'Merge Request Discussion Lock', :js, feature_category: :code_rev it 'the user can lock the merge_request' do find('#new-actions-header-dropdown button').click - expect(page).to have_content('Lock merge request') + expect(page).to have_content('Lock discussion') end end @@ -105,7 +105,7 @@ RSpec.describe 'Merge Request Discussion Lock', :js, feature_category: :code_rev it 'the user can unlock the merge_request' do find('#new-actions-header-dropdown button').click - expect(page).to have_content('Unlock merge request') + expect(page).to have_content('Unlock discussion') end end end diff --git a/spec/features/merge_request/user_awards_emoji_spec.rb b/spec/features/merge_request/user_awards_emoji_spec.rb index f43672942ff..63e1cffed23 100644 --- a/spec/features/merge_request/user_awards_emoji_spec.rb +++ b/spec/features/merge_request/user_awards_emoji_spec.rb @@ -50,7 +50,7 @@ RSpec.describe 'Merge request > User awards emoji', :js, feature_category: :code # make sure emoji popup is visible execute_script("window.scrollBy(0, 200)") - find('gl-emoji[data-name="8ball"]').click + find('gl-emoji[data-name="grinning"]').click end wait_for_requests diff --git a/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb b/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb index 2fcbb4e70c3..ae95bc3e11f 100644 --- a/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb +++ b/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb @@ -34,202 +34,81 @@ RSpec.describe 'Merge request > User edits assignees sidebar', :js, feature_cate let(:sidebar_assignee_tooltip) { sidebar_assignee_avatar_link['title'] || '' } let(:sidebar_assignee_merge_ability) { sidebar_assignee_avatar_link['data-cannot-merge'] || '' } - context 'when GraphQL assignees widget feature flag is disabled' do - let(:sidebar_assignee_dropdown_item) do - sidebar_assignee_block.find(".dropdown-menu li[data-user-id=\"#{assignee.id}\"]") - end - - let(:sidebar_assignee_dropdown_tooltip) { sidebar_assignee_dropdown_item.find('a')['data-title'] || '' } + let(:sidebar_assignee_dropdown_item) { sidebar_assignee_block.find(".dropdown-item", text: assignee.username) } + let(:sidebar_assignee_dropdown_tooltip) { sidebar_assignee_dropdown_item['title'] } + context 'when user is an owner' do before do - stub_feature_flags(issue_assignees_widget: false) - end + stub_const('Autocomplete::UsersFinder::LIMIT', users_find_limit) - context 'when user is an owner' do - before do - stub_const('Autocomplete::UsersFinder::LIMIT', users_find_limit) + sign_in(owner) - sign_in(owner) + merge_request.assignees << assignee - merge_request.assignees << assignee + visit project_merge_request_path(project, merge_request) - visit project_merge_request_path(project, merge_request) + wait_for_requests + end - wait_for_requests + shared_examples 'when assigned' do |expected_tooltip: '', expected_cannot_merge: ''| + it 'shows assignee name' do + expect(sidebar_assignee_block).to have_text(assignee.name) end - shared_examples 'when assigned' do |expected_tooltip: '', expected_cannot_merge: ''| - it 'shows assignee name' do - expect(sidebar_assignee_block).to have_text(assignee.name) - end + it "sets data-cannot-merge to '#{expected_cannot_merge}'" do + expect(sidebar_assignee_merge_ability).to eql(expected_cannot_merge) + end - it "sets data-cannot-merge to '#{expected_cannot_merge}'" do - expect(sidebar_assignee_merge_ability).to eql(expected_cannot_merge) + context 'when edit is clicked' do + before do + open_assignees_dropdown end - context 'when edit is clicked' do - before do - sidebar_assignee_block.click_link('Edit') - - wait_for_requests - end - - it "shows assignee tooltip '#{expected_tooltip}" do - expect(sidebar_assignee_dropdown_tooltip).to eql(expected_tooltip) - end + it "shows assignee tooltip '#{expected_tooltip}" do + expect(sidebar_assignee_dropdown_tooltip).to eql(expected_tooltip) end end - - context 'when assigned to maintainer' do - let(:assignee) { project_maintainers.last } - - it_behaves_like 'when assigned', expected_tooltip: '' - end - - context 'when assigned to developer' do - let(:assignee) { project_developers.last } - - it_behaves_like 'when assigned', expected_tooltip: 'Cannot merge', expected_cannot_merge: 'true' - end end - context 'with members shared into ancestors of the project' do - before do - sign_in(owner) - - visit project_merge_request_path(project, merge_request) - wait_for_requests + context 'when assigned to maintainer' do + let(:assignee) { project_maintainers.last } - sidebar_assignee_block.click_link('Edit') - wait_for_requests - end - - it 'contains the members shared into ancestors of the projects' do - page.within '.dropdown-menu-user' do - expect(page).to have_content shared_into_ancestor_user.name - end - end + it_behaves_like 'when assigned', expected_tooltip: '' end - context 'with invite members considerations' do - let_it_be(:user) { create(:user) } + context 'when assigned to developer' do + let(:assignee) { project_developers.last } - before do - sign_in(user) - end - - include_examples 'issuable invite members' do - let(:issuable_path) { project_merge_request_path(project, merge_request) } - end + it_behaves_like 'when assigned', expected_tooltip: 'Cannot merge', expected_cannot_merge: 'true' end end - context 'when GraphQL assignees widget feature flag is enabled' do - let(:sidebar_assignee_dropdown_item) { sidebar_assignee_block.find(".dropdown-item", text: assignee.username) } - let(:sidebar_assignee_dropdown_tooltip) { sidebar_assignee_dropdown_item['title'] } - - context 'when user is an owner' do - before do - stub_const('Autocomplete::UsersFinder::LIMIT', users_find_limit) - - sign_in(owner) - - merge_request.assignees << assignee - - visit project_merge_request_path(project, merge_request) - - wait_for_requests - end - - shared_examples 'when assigned' do |expected_tooltip: '', expected_cannot_merge: ''| - it 'shows assignee name' do - expect(sidebar_assignee_block).to have_text(assignee.name) - end - - it "sets data-cannot-merge to '#{expected_cannot_merge}'" do - expect(sidebar_assignee_merge_ability).to eql(expected_cannot_merge) - end - - context 'when edit is clicked' do - before do - open_assignees_dropdown - end - - it "shows assignee tooltip '#{expected_tooltip}" do - expect(sidebar_assignee_dropdown_tooltip).to eql(expected_tooltip) - end - end - end - - context 'when assigned to maintainer' do - let(:assignee) { project_maintainers.last } - - it_behaves_like 'when assigned', expected_tooltip: '' - end + context 'with members shared into ancestors of the project' do + before do + sign_in(owner) - context 'when assigned to developer' do - let(:assignee) { project_developers.last } + visit project_merge_request_path(project, merge_request) + wait_for_requests - it_behaves_like 'when assigned', expected_tooltip: 'Cannot merge', expected_cannot_merge: 'true' - end + open_assignees_dropdown end - context 'with members shared into ancestors of the project' do - before do - sign_in(owner) - - visit project_merge_request_path(project, merge_request) - wait_for_requests - - open_assignees_dropdown - end - - it 'contains the members shared into ancestors of the projects' do - page.within '.dropdown-menu-user' do - expect(page).to have_content shared_into_ancestor_user.name - end + it 'contains the members shared into ancestors of the projects' do + page.within '.dropdown-menu-user' do + expect(page).to have_content shared_into_ancestor_user.name end end + end - context 'with invite members considerations' do - let_it_be(:user) { create(:user) } - - before do - sign_in(user) - end - - # TODO: Move to shared examples when feature flag is removed: https://gitlab.com/gitlab-org/gitlab/-/issues/328185 - context 'when a privileged user can invite' do - it 'shows a link for inviting members and launches invite modal' do - project.add_maintainer(user) - visit project_merge_request_path(project, merge_request) - - open_assignees_dropdown - - page.within '.dropdown-menu-user' do - expect(page).to have_link('Invite members') - - click_link 'Invite members' - end - - page.within invite_modal_selector do - expect(page).to have_content("You're inviting members to the #{project.name} project") - end - end - end - - context 'when user cannot invite members in assignee dropdown' do - it 'shows author in assignee dropdown and no invite link' do - project.add_developer(user) - visit project_merge_request_path(project, merge_request) + context 'with invite members considerations' do + let_it_be(:user) { create(:user) } - open_assignees_dropdown + before do + sign_in(user) + end - page.within '.dropdown-menu-user' do - expect(page).not_to have_link('Invite members') - end - end - end + include_examples 'issuable invite members' do + let(:issuable_path) { project_merge_request_path(project, merge_request) } end end diff --git a/spec/features/merge_request/user_locks_discussion_spec.rb b/spec/features/merge_request/user_locks_discussion_spec.rb index a603a5c1e0b..d4cc6c9410c 100644 --- a/spec/features/merge_request/user_locks_discussion_spec.rb +++ b/spec/features/merge_request/user_locks_discussion_spec.rb @@ -43,7 +43,7 @@ RSpec.describe 'Merge request > User locks discussion', :js, feature_category: : page.within('.js-vue-notes-event') do expect(page).not_to have_selector('js-main-target-form') expect(page.find('.issuable-note-warning')) - .to have_content('This merge request is locked. Only project members can comment.') + .to have_content('The discussion in this merge request is locked. Only project members can comment.') end end end diff --git a/spec/features/merge_request/user_merges_immediately_spec.rb b/spec/features/merge_request/user_merges_immediately_spec.rb index 71af2045bab..ae229651579 100644 --- a/spec/features/merge_request/user_merges_immediately_spec.rb +++ b/spec/features/merge_request/user_merges_immediately_spec.rb @@ -37,7 +37,7 @@ RSpec.describe 'Merge requests > User merges immediately', :js, feature_category wait_for_requests page.within '[data-testid="ready_to_merge_state"]' do - find('.dropdown-toggle').click + find('.gl-new-dropdown-toggle').click Sidekiq::Testing.fake! do click_button 'Merge immediately' diff --git a/spec/features/merge_request/user_merges_merge_request_spec.rb b/spec/features/merge_request/user_merges_merge_request_spec.rb index ede686cc700..111204a7105 100644 --- a/spec/features/merge_request/user_merges_merge_request_spec.rb +++ b/spec/features/merge_request/user_merges_merge_request_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" RSpec.describe "User merges a merge request", :js, feature_category: :code_review_workflow do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } before do sign_in(user) @@ -21,7 +21,8 @@ RSpec.describe "User merges a merge request", :js, feature_category: :code_revie end end - context 'sidebar merge requests counter' do + # Pending re-implementation: https://gitlab.com/gitlab-org/gitlab/-/issues/429268 + xcontext 'sidebar merge requests counter' do let_it_be(:project) { create(:project, :public, :repository, namespace: user.namespace) } let!(:merge_request) { create(:merge_request, source_project: project) } diff --git a/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb b/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb index 230111fe439..111e8574bac 100644 --- a/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb +++ b/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_category: :code_review_workflow do include ProjectForksHelper - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, namespace: user.namespace) } before do @@ -13,7 +13,7 @@ RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_ end describe 'for fork' do - let(:author) { create(:user, :no_super_sidebar) } + let(:author) { create(:user) } let(:source_project) { fork_project(project, author, repository: true) } let(:merge_request) do @@ -31,8 +31,10 @@ RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_ it 'shows instructions' do visit project_merge_request_path(project, merge_request) - click_button 'Code' - click_button 'Check out branch' + page.within 'main' do + click_button 'Code' + click_button 'Check out branch' + end expect(page).to have_content(source_project.http_url_to_repo) end diff --git a/spec/features/merge_request/user_reverts_merge_request_spec.rb b/spec/features/merge_request/user_reverts_merge_request_spec.rb index 8c782056aa4..c2f82039f0b 100644 --- a/spec/features/merge_request/user_reverts_merge_request_spec.rb +++ b/spec/features/merge_request/user_reverts_merge_request_spec.rb @@ -3,23 +3,28 @@ require 'spec_helper' RSpec.describe 'User reverts a merge request', :js, feature_category: :code_review_workflow do + include Spec::Support::Helpers::ModalHelpers + let(:merge_request) { create(:merge_request, :simple, source_project: project) } let(:project) { create(:project, :public, :repository) } let(:user) { create(:user) } before do - stub_feature_flags(unbatch_graphql_queries: false) project.add_developer(user) sign_in(user) + set_cookie('new-actions-popover-viewed', 'true') visit(merge_request_path(merge_request)) page.within('.mr-state-widget') do click_button 'Merge' end - wait_for_requests + wait_for_all_requests + page.refresh + + wait_for_requests # do not reload the page by visiting, let javascript update the page as it will validate we have loaded the modal # code correctly on page update that adds the `revert` button end @@ -55,11 +60,11 @@ RSpec.describe 'User reverts a merge request', :js, feature_category: :code_revi end def revert_commit(create_merge_request: false) - click_button('Revert') + click_button 'Revert' - page.within('[data-testid="modal-commit"]') do + within_modal do uncheck('create_merge_request') unless create_merge_request - click_button('Revert') + click_button 'Revert' end end end diff --git a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb index 921c12134a9..da290f59736 100644 --- a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb +++ b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User sees check out branch modal', :js, feature_category: :code_review_workflow do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, creator: user) } let_it_be(:merge_request) { create(:merge_request, source_project: project) } let(:modal_window_title) { 'Check out, review, and resolve locally' } @@ -13,8 +13,10 @@ RSpec.describe 'Merge request > User sees check out branch modal', :js, feature_ visit project_merge_request_path(project, merge_request) wait_for_requests - click_button 'Code' - click_button('Check out branch') + page.within 'main' do + click_button 'Code' + click_button('Check out branch') + end end it 'shows the check out branch modal' do diff --git a/spec/features/merge_request/user_sees_merge_request_file_tree_sidebar_spec.rb b/spec/features/merge_request/user_sees_merge_request_file_tree_sidebar_spec.rb index c385def6762..8caa13c6297 100644 --- a/spec/features/merge_request/user_sees_merge_request_file_tree_sidebar_spec.rb +++ b/spec/features/merge_request/user_sees_merge_request_file_tree_sidebar_spec.rb @@ -15,48 +15,56 @@ RSpec.describe 'Merge request > User sees merge request file tree sidebar', :js, sign_in(user) visit diffs_project_merge_request_path(project, merge_request) wait_for_requests - scroll_into_view end it 'sees file tree sidebar' do expect(page).to have_selector('.file-row[role=button]') end - # TODO: fix this test - # For some reason the browser in CI doesn't update the file tree sidebar when review bar is shown - # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/118378#note_1403906356 - # - # it 'has last entry visible with discussions enabled' do - # add_diff_line_draft_comment('foo', find('.line_holder', match: :first)) - # scroll_into_view - # scroll_to_end - # button = find_all('.file-row[role=button]').last - # expect(button.obscured?).to be_falsy - # end - - shared_examples 'shows last visible file in sidebar' do - it 'shows last file' do - scroll_to_end + shared_examples 'last entry clickable' do + specify do + sidebar_scroller.execute_script('this.scrollBy(0,99999)') button = find_all('.file-row[role=button]').last title = button.find('[data-testid=file-row-name-container]')[:title] + expect(button.obscured?).to be_falsy button.click expect(page).to have_selector(".file-title-name[title*=\"#{title}\"]") end end - it_behaves_like 'shows last visible file in sidebar' + it_behaves_like 'last entry clickable' + + context 'when has started a review' do + before do + add_diff_line_draft_comment('foo', find('.line_holder', match: :first)) + # wait for review bar to appear + find_by_testid('review_bar_component') + # wait for sidebar to adjust + sleep(1) + end + + it_behaves_like 'last entry clickable' + + context 'when scrolled into full view' do + before do + sidebar.execute_script("this.scrollIntoView({ block: 'end' })") + end + + it_behaves_like 'last entry clickable' + end + end context 'when viewing using file-by-file mode' do let(:user) { create(:user, view_diffs_file_by_file: true) } - it_behaves_like 'shows last visible file in sidebar' - end + it_behaves_like 'last entry clickable' - def scroll_into_view - sidebar.execute_script("this.scrollIntoView({ block: 'end' })") - end + context 'when navigating to the next file' do + before do + click_link 'Next' + end - def scroll_to_end - sidebar_scroller.execute_script('this.scrollBy(0,99999)') + it_behaves_like 'last entry clickable' + end end end diff --git a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb index 69eb6b0dc17..5e683ddf7ba 100644 --- a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb @@ -86,7 +86,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees branch pipelines and detached merge request pipelines in correct order' do page.within('.ci-table') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Created', count: 2) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Created', count: 2) expect(first('[data-testid="pipeline-url-link"]')).to have_content("##{detached_merge_request_pipeline.id}") end end @@ -122,7 +122,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees branch pipelines and detached merge request pipelines in correct order' do page.within('.ci-table') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending', count: 4) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending', count: 4) expect(all('[data-testid="pipeline-url-link"]')[0]) .to have_content("##{detached_merge_request_pipeline_2.id}") @@ -220,7 +220,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees a branch pipeline in pipeline tab' do page.within('.ci-table') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Created', count: 1) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Created', count: 1) expect(first('[data-testid="pipeline-url-link"]')).to have_content("##{push_pipeline.id}") end end @@ -273,7 +273,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees branch pipelines and detached merge request pipelines in correct order' do page.within('.ci-table') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending', count: 2) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending', count: 2) expect(first('[data-testid="pipeline-url-link"]')).to have_content("##{detached_merge_request_pipeline.id}") end end @@ -289,7 +289,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees pipeline list in forked project' do visit project_pipelines_path(forked_project) - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending', count: 2) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending', count: 2) end context 'when a user updated a merge request from a forked project to the parent project' do @@ -315,7 +315,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees branch pipelines and detached merge request pipelines in correct order' do page.within('.ci-table') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending', count: 4) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending', count: 4) expect(all('[data-testid="pipeline-url-link"]')[0]) .to have_content("##{detached_merge_request_pipeline_2.id}") @@ -358,7 +358,7 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees pipeline list in forked project' do visit project_pipelines_path(forked_project) - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending', count: 4) + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending', count: 4) end end diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb index 96cad397441..c18b2c97f96 100644 --- a/spec/features/merge_request/user_sees_merge_widget_spec.rb +++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb @@ -53,7 +53,6 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: let!(:deployment) { build.deployment } before do - stub_feature_flags(unbatch_graphql_queries: false) merge_request.update!(head_pipeline: pipeline) deployment.update!(status: :success) visit project_merge_request_path(project, merge_request) @@ -84,6 +83,8 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: wait_for_requests + page.refresh + click_button 'Cherry-pick' page.within(modal_selector) do @@ -175,7 +176,7 @@ RSpec.describe 'Merge request > User sees merge widget', :js, feature_category: expect(page).to have_content("Merge blocked") expect(page).to have_content( "pipeline must succeed. It's waiting for a manual action to continue.") - expect(page).to have_css('.ci-status-icon-manual') + expect(page).to have_css('[data-testid="status_manual_borderless-icon"]') end end diff --git a/spec/features/merge_request/user_sees_pipelines_spec.rb b/spec/features/merge_request/user_sees_pipelines_spec.rb index a68b3c444fe..a06d1808b6b 100644 --- a/spec/features/merge_request/user_sees_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_pipelines_spec.rb @@ -49,9 +49,8 @@ RSpec.describe 'Merge request > User sees pipelines', :js, feature_category: :co wait_for_requests page.within(find('[data-testid="pipeline-table-row"]', match: :first)) do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Passed') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Passed') expect(page).to have_content(pipeline.id) - expect(page).to have_content('API') expect(page).to have_css('[data-testid="pipeline-mini-graph"]') expect(page).to have_css('[data-testid="pipelines-manual-actions-dropdown"]') expect(page).to have_css('[data-testid="pipeline-multi-actions-dropdown"]') diff --git a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb index 654c71c87e0..daa84227adc 100644 --- a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb +++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_category: :code_review_workflow do include ListboxHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, namespace: user.namespace) } def select_source_branch(branch_name) @@ -64,8 +64,10 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_ fill_in "merge_request_title", with: "Orphaned MR test" click_button "Create merge request" - click_button 'Code' - click_button "Check out branch" + page.within 'main' do + click_button 'Code' + click_button "Check out branch" + end expect(page).to have_content 'git checkout -b \'orphaned-branch\' \'origin/orphaned-branch\'' end diff --git a/spec/features/merge_request/user_uses_quick_actions_spec.rb b/spec/features/merge_request/user_uses_quick_actions_spec.rb index b2cc25f1c34..a89f533c9dd 100644 --- a/spec/features/merge_request/user_uses_quick_actions_spec.rb +++ b/spec/features/merge_request/user_uses_quick_actions_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Merge request > User uses quick actions', :js, :use_clean_rails_ context "issuable common quick actions" do let!(:new_url_opts) { { merge_request: { source_branch: 'feature', target_branch: 'master' } } } - let(:maintainer) { create(:user, :no_super_sidebar) } + let(:maintainer) { create(:user) } let(:project) { create(:project, :public, :repository) } let!(:label_bug) { create(:label, project: project, title: 'bug') } let!(:label_feature) { create(:label, project: project, title: 'feature') } @@ -26,8 +26,8 @@ RSpec.describe 'Merge request > User uses quick actions', :js, :use_clean_rails_ end describe 'merge-request-only commands' do - let(:user) { create(:user, :no_super_sidebar) } - let(:guest) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } + let(:guest) { create(:user) } let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } let!(:milestone) { create(:milestone, project: project, title: 'ASAP') } diff --git a/spec/features/merge_requests/user_filters_by_source_branch_spec.rb b/spec/features/merge_requests/user_filters_by_source_branch_spec.rb new file mode 100644 index 00000000000..7eade94de2a --- /dev/null +++ b/spec/features/merge_requests/user_filters_by_source_branch_spec.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Merge Requests > User filters by source branch', :js, feature_category: :code_review_workflow do + include FilteredSearchHelpers + + def create_mr(source_branch, target_branch, status) + create(:merge_request, status, source_project: project, + target_branch: target_branch, source_branch: source_branch) + end + + let_it_be(:project) { create(:project, :public, :repository) } + let_it_be(:user) { project.creator } + + let_it_be(:mr1) { create_mr('source1', 'target1', :opened) } + let_it_be(:mr2) { create_mr('source2', 'target1', :opened) } + let_it_be(:mr3) { create_mr('source1', 'target2', :merged) } + let_it_be(:mr4) { create_mr('source1', 'target2', :closed) } + + before do + sign_in(user) + visit project_merge_requests_path(project) + end + + context 'when filtering by source-branch:source1' do + it 'applies the filter' do + input_filtered_search('source-branch:=source1') + + expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3) + expect(page).to have_content mr1.title + expect(page).not_to have_content mr2.title + end + end + + context 'when filtering by source-branch:source2' do + it 'applies the filter' do + input_filtered_search('source-branch:=source2') + + expect(page).to have_issuable_counts(open: 1, merged: 0, closed: 0, all: 1) + expect(page).not_to have_content mr1.title + expect(page).to have_content mr2.title + end + end + + context 'when filtering by source-branch:non-exists-branch' do + it 'applies the filter' do + input_filtered_search('source-branch:=non-exists-branch') + + expect(page).to have_issuable_counts(open: 0, merged: 0, closed: 0, all: 0) + expect(page).not_to have_content mr1.title + expect(page).not_to have_content mr2.title + end + end + + context 'when filtering by source-branch:!=source1' do + it 'applies the filter' do + input_filtered_search('source-branch:!=source1') + + expect(page).to have_issuable_counts(open: 1, merged: 0, closed: 0, all: 1) + expect(page).not_to have_content mr1.title + expect(page).to have_content mr2.title + end + end +end diff --git a/spec/features/monitor_sidebar_link_spec.rb b/spec/features/monitor_sidebar_link_spec.rb index 1d39f749ca7..1855379825b 100644 --- a/spec/features/monitor_sidebar_link_spec.rb +++ b/spec/features/monitor_sidebar_link_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' -RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures, feature_category: :shared do +RSpec.describe 'Monitor dropdown sidebar', :js, feature_category: :shared do let_it_be_with_reload(:project) { create(:project, :internal, :repository) } - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let(:role) { nil } @@ -13,7 +13,7 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures, feature_category sign_in(user) end - shared_examples 'shows Monitor menu based on the access level' do + shared_examples 'shows common Monitor menu item based on the access level' do using RSpec::Parameterized::TableSyntax let(:enabled) { Featurable::PRIVATE } @@ -30,10 +30,14 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures, feature_category visit project_issues_path(project) - if render - expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') - else - expect(page).not_to have_selector('a.shortcuts-monitor') + click_button('Monitor') + + within_testid('super-sidebar') do + if render + expect(page).to have_link('Incidents') + else + expect(page).not_to have_link('Incidents', visible: :all) + end end end end @@ -44,32 +48,35 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures, feature_category before do project.project_feature.update_attribute(:monitor_access_level, access_level) + visit project_issues_path(project) + click_button('Monitor') end - it 'has the correct `Monitor` menu items', :aggregate_failures do - visit project_issues_path(project) - expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') + it 'has the correct `Monitor` and `Operate` menu items' do expect(page).to have_link('Incidents', href: project_incidents_path(project)) + + click_button('Operate') + expect(page).to have_link('Environments', href: project_environments_path(project)) - expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project)) - expect(page).not_to have_link('Error Tracking', href: project_error_tracking_index_path(project)) - expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project)) + expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project), visible: :all) + expect(page).not_to have_link('Error Tracking', href: project_error_tracking_index_path(project), visible: :all) + expect(page).not_to have_link('Kubernetes clusters', href: project_clusters_path(project), visible: :all) end context 'when monitor project feature is PRIVATE' do let(:access_level) { ProjectFeature::PRIVATE } - it 'does not show the `Monitor` menu' do - expect(page).not_to have_selector('a.shortcuts-monitor') + it 'does not show common items of the `Monitor` menu' do + expect(page).not_to have_link('Error Tracking', href: project_incidents_path(project), visible: :all) end end context 'when monitor project feature is DISABLED' do let(:access_level) { ProjectFeature::DISABLED } - it 'does not show the `Monitor` menu' do - expect(page).not_to have_selector('a.shortcuts-monitor') + it 'does not show the `Incidents` menu' do + expect(page).not_to have_link('Error Tracking', href: project_incidents_path(project), visible: :all) end end end @@ -77,63 +84,86 @@ RSpec.describe 'Monitor dropdown sidebar', :aggregate_failures, feature_category context 'when user has guest role' do let(:role) { :guest } - it 'has the correct `Monitor` menu items' do + it 'has the correct `Monitor` and `Operate` menu items' do visit project_issues_path(project) - expect(page).to have_selector('a.shortcuts-monitor', text: 'Monitor') + + click_button('Monitor') + expect(page).to have_link('Incidents', href: project_incidents_path(project)) + + click_button('Operate') + expect(page).to have_link('Environments', href: project_environments_path(project)) - expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project)) - expect(page).not_to have_link('Error Tracking', href: project_error_tracking_index_path(project)) - expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project)) + expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project), visible: :all) + expect(page).not_to have_link('Error Tracking', href: project_error_tracking_index_path(project), visible: :all) + expect(page).not_to have_link('Kubernetes clusters', href: project_clusters_path(project), visible: :all) end - it_behaves_like 'shows Monitor menu based on the access level' + it_behaves_like 'shows common Monitor menu item based on the access level' end context 'when user has reporter role' do let(:role) { :reporter } - it 'has the correct `Monitor` menu items' do + it 'has the correct `Monitor` and `Operate` menu items' do visit project_issues_path(project) + + click_button('Monitor') + expect(page).to have_link('Incidents', href: project_incidents_path(project)) - expect(page).to have_link('Environments', href: project_environments_path(project)) expect(page).to have_link('Error Tracking', href: project_error_tracking_index_path(project)) - expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project)) - expect(page).not_to have_link('Kubernetes', href: project_clusters_path(project)) + click_button('Operate') + + expect(page).to have_link('Environments', href: project_environments_path(project)) + + expect(page).not_to have_link('Alerts', href: project_alert_management_index_path(project), visible: :all) + expect(page).not_to have_link('Kubernetes clusters', href: project_clusters_path(project), visible: :all) end - it_behaves_like 'shows Monitor menu based on the access level' + it_behaves_like 'shows common Monitor menu item based on the access level' end context 'when user has developer role' do let(:role) { :developer } - it 'has the correct `Monitor` menu items' do + it 'has the correct `Monitor` and `Operate` menu items' do visit project_issues_path(project) + + click_button('Monitor') + expect(page).to have_link('Alerts', href: project_alert_management_index_path(project)) expect(page).to have_link('Incidents', href: project_incidents_path(project)) - expect(page).to have_link('Environments', href: project_environments_path(project)) expect(page).to have_link('Error Tracking', href: project_error_tracking_index_path(project)) - expect(page).to have_link('Kubernetes', href: project_clusters_path(project)) + + click_button('Operate') + + expect(page).to have_link('Environments', href: project_environments_path(project)) + expect(page).to have_link('Kubernetes clusters', href: project_clusters_path(project)) end - it_behaves_like 'shows Monitor menu based on the access level' + it_behaves_like 'shows common Monitor menu item based on the access level' end context 'when user has maintainer role' do let(:role) { :maintainer } - it 'has the correct `Monitor` menu items' do + it 'has the correct `Monitor` and `Operate` menu items' do visit project_issues_path(project) + + click_button('Monitor') + expect(page).to have_link('Alerts', href: project_alert_management_index_path(project)) expect(page).to have_link('Incidents', href: project_incidents_path(project)) - expect(page).to have_link('Environments', href: project_environments_path(project)) expect(page).to have_link('Error Tracking', href: project_error_tracking_index_path(project)) - expect(page).to have_link('Kubernetes', href: project_clusters_path(project)) + + click_button('Operate') + + expect(page).to have_link('Environments', href: project_environments_path(project)) + expect(page).to have_link('Kubernetes clusters', href: project_clusters_path(project)) end - it_behaves_like 'shows Monitor menu based on the access level' + it_behaves_like 'shows common Monitor menu item based on the access level' end end diff --git a/spec/features/nav/new_nav_callout_spec.rb b/spec/features/nav/new_nav_callout_spec.rb deleted file mode 100644 index 22e7fd6b9f9..00000000000 --- a/spec/features/nav/new_nav_callout_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'new navigation callout', :js, feature_category: :navigation do - let_it_be(:callout_title) { _('Welcome to a new navigation experience') } - let(:dot_com) { false } - - before do - allow(Gitlab).to receive(:com?).and_return(dot_com) - sign_in(user) - visit root_path - end - - context 'with new navigation toggled on' do - let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 1), use_new_navigation: true) } - - it 'shows a callout about the new navigation' do - expect(page).to have_content callout_title - end - - context 'when user dismisses callout' do - it 'hides callout' do - expect(page).to have_content callout_title - - page.within(find('[data-feature-id="new_navigation_callout"]')) do - find('[data-testid="close-icon"]').click - end - - wait_for_requests - - visit root_path - - expect(page).not_to have_content callout_title - end - end - end - - context 'when user registered on or after June 2nd 2023' do - let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 2), use_new_navigation: true) } - - context 'when on GitLab.com' do - let(:dot_com) { true } - - it 'does not show the callout about the new navigation' do - expect(page).not_to have_content callout_title - end - end - - context 'when on a self-managed instance' do - it 'shows the callout about the new navigation' do - expect(page).to have_content callout_title - end - end - end - - context 'with new navigation toggled off' do - let_it_be(:user) { create(:user, created_at: Date.new(2023, 6, 1), use_new_navigation: false) } - - it 'does not show the callout' do - expect(page).not_to have_content callout_title - end - end -end diff --git a/spec/features/nav/new_nav_for_everyone_callout_spec.rb b/spec/features/nav/new_nav_for_everyone_callout_spec.rb new file mode 100644 index 00000000000..ad0b57298d7 --- /dev/null +++ b/spec/features/nav/new_nav_for_everyone_callout_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'new navigation for everyone callout', :js, feature_category: :navigation do + let_it_be(:callout_title) { _('GitLab has redesigned the left sidebar to address customer feedback') } + + before do + sign_in(user) + visit root_path + end + + context 'with new navigation previously toggled on' do + let_it_be(:user) { create(:user, use_new_navigation: true) } + + it 'does not show the callout' do + expect(page).to have_css('[data-testid="super-sidebar"]') + expect(page).not_to have_content callout_title + end + end + + context 'with new navigation previously toggled off' do + let_it_be(:user) { create(:user, use_new_navigation: false) } + + it 'shows a callout about the new navigation now being active for everyone' do + expect(page).to have_css('[data-testid="super-sidebar"]') + expect(page).to have_content callout_title + end + + context 'when user dismisses callout' do + it 'hides callout' do + expect(page).to have_content callout_title + + page.within(find('[data-feature-id="new_nav_for_everyone_callout"]')) do + find_by_testid('close-icon').click + end + + wait_for_requests + + visit root_path + + expect(page).not_to have_content callout_title + end + end + end + + context 'with new navigation never toggled on or off' do + let_it_be(:user) { create(:user, use_new_navigation: nil) } + + it 'does not show the callout' do + expect(page).to have_css('[data-testid="super-sidebar"]') + expect(page).not_to have_content callout_title + end + end +end diff --git a/spec/features/nav/new_nav_invite_members_spec.rb b/spec/features/nav/new_nav_invite_members_spec.rb index 4c37d6b4760..7501745ec55 100644 --- a/spec/features/nav/new_nav_invite_members_spec.rb +++ b/spec/features/nav/new_nav_invite_members_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'new navigation toggle', :js, feature_category: :navigation do include Features::InviteMembersModalHelpers - let_it_be(:user) { create(:user, use_new_navigation: true) } + let_it_be(:user) { create(:user) } before do sign_in(user) diff --git a/spec/features/nav/new_nav_toggle_spec.rb b/spec/features/nav/new_nav_toggle_spec.rb deleted file mode 100644 index 6872058be8e..00000000000 --- a/spec/features/nav/new_nav_toggle_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'new navigation toggle', :js, feature_category: :navigation do - let_it_be(:user) { create(:user) } - - before do - user.update!(use_new_navigation: user_preference) - sign_in(user) - visit explore_projects_path - end - - context 'when user has new nav disabled' do - let(:user_preference) { false } - - it 'allows to enable new nav', :aggregate_failures do - within '.js-nav-user-dropdown' do - find('a[data-toggle="dropdown"]').click - expect(page).to have_content('Navigation redesign') - - toggle = page.find('.gl-toggle:not(.is-checked)') - toggle.click # reloads the page - end - - wait_for_requests - - expect(user.reload.use_new_navigation).to eq true - end - - it 'shows the old navigation' do - expect(page).to have_selector('.js-navbar') - expect(page).not_to have_selector('[data-testid="super-sidebar"]') - end - end - - context 'when user has new nav enabled' do - let(:user_preference) { true } - - it 'allows to disable new nav', :aggregate_failures do - within '[data-testid="super-sidebar"] [data-testid="user-dropdown"]' do - click_button "#{user.name} user’s menu" - expect(page).to have_content('Navigation redesign') - - toggle = page.find('.gl-toggle.is-checked') - toggle.click # reloads the page - end - - wait_for_requests - - expect(user.reload.use_new_navigation).to eq false - end - - it 'shows the new navigation' do - expect(page).not_to have_selector('.js-navbar') - expect(page).to have_selector('[data-testid="super-sidebar"]') - end - end -end diff --git a/spec/features/nav/pinned_nav_items_spec.rb b/spec/features/nav/pinned_nav_items_spec.rb index b4d6464ec50..a2428048a1a 100644 --- a/spec/features/nav/pinned_nav_items_spec.rb +++ b/spec/features/nav/pinned_nav_items_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Navigation menu item pinning', :js, feature_category: :navigation do - let_it_be(:user) { create(:user, use_new_navigation: true) } + let_it_be(:user) { create(:user) } before do sign_in(user) diff --git a/spec/features/nav/top_nav_responsive_spec.rb b/spec/features/nav/top_nav_responsive_spec.rb deleted file mode 100644 index 2a07742c91e..00000000000 --- a/spec/features/nav/top_nav_responsive_spec.rb +++ /dev/null @@ -1,101 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'top nav responsive', :js, feature_category: :navigation do - include MobileHelpers - include Features::InviteMembersModalHelpers - - let_it_be(:user) { create(:user, :no_super_sidebar) } - - before do - sign_in(user) - - resize_screen_xs - end - - context 'when outside groups and projects' do - before do - visit explore_projects_path - end - - context 'when menu is closed' do - it 'has page content and hides responsive menu', :aggregate_failures do - expect(page).to have_css('.page-title', text: 'Explore projects') - expect(page).to have_link('Homepage', id: 'logo') - - expect(page).to have_no_css('.top-nav-responsive') - end - end - - context 'when menu is opened' do - before do - click_button('Menu') - end - - it 'hides everything and shows responsive menu', :aggregate_failures do - expect(page).to have_no_css('.page-title', text: 'Explore projects') - expect(page).to have_no_link('Homepage', id: 'logo') - - within '.top-nav-responsive' do - expect(page).to have_link(nil, href: search_path) - expect(page).to have_button('Projects') - expect(page).to have_button('Groups') - expect(page).to have_link('Your work', href: dashboard_projects_path) - expect(page).to have_link('Explore', href: explore_projects_path) - end - end - - it 'has new dropdown', :aggregate_failures do - create_new_button.click - - expect(page).to have_link('New project', href: new_project_path) - expect(page).to have_link('New group', href: new_group_path) - expect(page).to have_link('New snippet', href: new_snippet_path) - end - end - end - - context 'when inside a project' do - let_it_be(:project) { create(:project).tap { |record| record.add_owner(user) } } - - before do - visit project_path(project) - end - - it 'the add menu contains invite members dropdown option and opens invite modal' do - invite_members_from_menu - - page.within invite_modal_selector do - expect(page).to have_content("You're inviting members to the #{project.name} project") - end - end - end - - context 'when inside a group' do - let_it_be(:group) { create(:group).tap { |record| record.add_owner(user) } } - - before do - visit group_path(group) - end - - it 'the add menu contains invite members dropdown option and opens invite modal' do - invite_members_from_menu - - page.within invite_modal_selector do - expect(page).to have_content("You're inviting members to the #{group.name} group") - end - end - end - - def invite_members_from_menu - click_button('Menu') - create_new_button.click - - click_button('Invite members') - end - - def create_new_button - find('[data-testid="plus-icon"]') - end -end diff --git a/spec/features/nav/top_nav_spec.rb b/spec/features/nav/top_nav_spec.rb deleted file mode 100644 index bf91897eb26..00000000000 --- a/spec/features/nav/top_nav_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'top nav responsive', :js, feature_category: :navigation do - include Features::InviteMembersModalHelpers - - let_it_be(:user) { create(:user, :no_super_sidebar) } - - before do - sign_in(user) - end - - context 'when inside a project' do - let_it_be(:project) { create(:project).tap { |record| record.add_owner(user) } } - - before do - visit project_path(project) - end - - it 'the add menu contains invite members dropdown option and opens invite modal' do - invite_members_from_menu - - page.within invite_modal_selector do - expect(page).to have_content("You're inviting members to the #{project.name} project") - end - end - end - - context 'when inside a group' do - let_it_be(:group) { create(:group).tap { |record| record.add_owner(user) } } - - before do - visit group_path(group) - end - - it 'the add menu contains invite members dropdown option and opens invite modal' do - invite_members_from_menu - - page.within invite_modal_selector do - expect(page).to have_content("You're inviting members to the #{group.name} group") - end - end - end - - def invite_members_from_menu - find('[data-testid="new-menu-toggle"]').click - - click_link('Invite members') - end -end diff --git a/spec/features/nav/top_nav_tooltip_spec.rb b/spec/features/nav/top_nav_tooltip_spec.rb deleted file mode 100644 index 1afd1981a86..00000000000 --- a/spec/features/nav/top_nav_tooltip_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'top nav tooltips', :js, feature_category: :navigation do - let_it_be(:user) { create(:user) } - - before do - sign_in(user) - visit explore_projects_path - end - - it 'clicking new dropdown hides tooltip', :aggregate_failures, - quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/382786' do - btn = '#js-onboarding-new-project-link' - - page.find(btn).hover - - expect(page).to have_content('Create new...') - - page.find(btn).click - - expect(page).not_to have_content('Create new...') - end -end diff --git a/spec/features/profiles/two_factor_auths_spec.rb b/spec/features/profiles/two_factor_auths_spec.rb index b52f66cfcee..15ab79684d9 100644 --- a/spec/features/profiles/two_factor_auths_spec.rb +++ b/spec/features/profiles/two_factor_auths_spec.rb @@ -59,7 +59,7 @@ RSpec.describe 'Two factor auths', feature_category: :user_profile do fill_in 'pin_code', with: '123' click_button 'Register with two-factor app' - expect(page).to have_link('Try the troubleshooting steps here.', href: help_page_path('user/profile/account/two_factor_authentication.md', anchor: 'troubleshooting')) + expect(page).to have_link('Try the troubleshooting steps here.', href: help_page_path('user/profile/account/two_factor_authentication', anchor: 'troubleshooting')) end end diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb index 697ad4c87f7..439839cfad5 100644 --- a/spec/features/profiles/user_edit_profile_spec.rb +++ b/spec/features/profiles/user_edit_profile_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'User edit profile', feature_category: :user_profile do include Features::NotesHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be_with_reload(:user) { create(:user) } before do stub_feature_flags(edit_user_profile_vue: false) @@ -18,17 +18,6 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do wait_for_requests if respond_to?(:wait_for_requests) end - def update_user_email - fill_in 'user_email', with: 'new-email@example.com' - click_button 'Update profile settings' - end - - def confirm_password(password) - fill_in 'password-confirmation', with: password - click_button 'Confirm password' - wait_for_requests if respond_to?(:wait_for_requests) - end - def visit_user visit user_path(user) wait_for_requests @@ -119,6 +108,18 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do end describe 'when I change my email', :js do + def update_user_email + fill_in 'user_email', with: '' # Clearing the email field + fill_in 'user_email', with: 'new-email@example.com' + submit_settings + end + + def confirm_password(password) + fill_in 'password-confirmation', with: password + click_button 'Confirm password' + wait_for_requests if respond_to?(:wait_for_requests) + end + before do user.send_reset_password_instructions end @@ -194,13 +195,20 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do emoji_button.click end + after do + if user.status + user.status.destroy! + user.reload_status + end + end + context 'profile edit form' do it 'shows the user status form' do expect(page).to have_content('Current status') end it 'adds emoji to user status' do - emoji = 'basketball' + emoji = 'laughing' select_emoji(emoji) submit_settings @@ -225,7 +233,7 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do end it 'adds message and emoji to user status' do - emoji = '8ball' + emoji = 'grinning' message = 'Playing outside' select_emoji(emoji) fill_in s_("SetStatusModal|What's your status?"), with: message @@ -319,9 +327,9 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do let(:project) { create(:project) } def open_modal(button_text) - find('.header-user-dropdown-toggle').click + find_by_testid('user-dropdown').click - page.within ".header-user" do + within_testid('user-dropdown') do find('.js-set-status-modal-trigger.ready') click_button button_text @@ -348,9 +356,9 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do end it 'shows the "Set status" menu item in the user menu' do - find('.header-user-dropdown-toggle').click + find_by_testid('user-dropdown').click - page.within ".header-user" do + within_testid('user-dropdown') do expect(page).to have_content('Set status') end end @@ -359,9 +367,9 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread') visit root_path(user) - find('.header-user-dropdown-toggle').click + find_by_testid('user-dropdown').click - page.within ".header-user" do + within_testid('user-dropdown') do expect(page).to have_emoji(user_status.emoji) expect(page).to have_content user_status.message expect(page).to have_content('Edit status') @@ -376,7 +384,7 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do end it 'adds emoji to user status' do - emoji = '8ball' + emoji = 'grinning' open_user_status_modal select_emoji(emoji, true) set_user_status_in_modal @@ -407,7 +415,7 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do it 'opens the emoji modal again after closing it' do open_user_status_modal - select_emoji('8ball', true) + select_emoji('grinning', true) find('.emoji-menu-toggle-button').click @@ -418,7 +426,7 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do project.add_maintainer(user) visit(project_issue_path(project, issue)) - emoji = '8ball' + emoji = 'grinning' open_user_status_modal select_emoji(emoji, true) @@ -440,7 +448,7 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do end it 'adds message and emoji to user status' do - emoji = '8ball' + emoji = 'grinning' message = 'Playing outside' open_user_status_modal select_emoji(emoji, true) @@ -478,8 +486,6 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do end context 'Remove status button' do - let(:user) { create(:user, :no_super_sidebar) } - before do user.status = UserStatus.new(message: 'Eating bread', emoji: 'stuffed_flatbread') @@ -504,9 +510,9 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do it 'shows the "Set status" menu item in the user menu' do visit root_path(user) - find('.header-user-dropdown-toggle').click + find_by_testid('user-dropdown').click - page.within ".header-user" do + within_testid('user-dropdown') do expect(page).to have_content('Set status') end end @@ -520,30 +526,30 @@ RSpec.describe 'User edit profile', feature_category: :user_profile do expect(page).to have_emoji('speech_balloon') end end + end - context 'User time preferences', :js do - let(:issue) { create(:issue, project: project) } - let(:project) { create(:project) } + context 'User time preferences', :js do + let(:issue) { create(:issue, project: project) } + let(:project) { create(:project) } - it 'shows the user time preferences form' do - expect(page).to have_content('Time settings') - end + it 'shows the user time preferences form' do + expect(page).to have_content('Time settings') + end - it 'allows the user to select a time zone from a dropdown list of options' do - expect(page).not_to have_selector('.user-time-preferences [data-testid="base-dropdown-menu"]') + it 'allows the user to select a time zone from a dropdown list of options' do + expect(page).not_to have_selector('.user-time-preferences [data-testid="base-dropdown-menu"]') - page.find('.user-time-preferences .gl-new-dropdown-toggle').click + page.find('.user-time-preferences .gl-new-dropdown-toggle').click - expect(page.find('.user-time-preferences [data-testid="base-dropdown-menu"]')).to be_visible + expect(page.find('.user-time-preferences [data-testid="base-dropdown-menu"]')).to be_visible - page.find("li", text: "Arizona").click + page.find("li", text: "Arizona").click - expect(page).to have_field(:user_timezone, with: 'America/Phoenix', type: :hidden) - end + expect(page).to have_field(:user_timezone, with: 'America/Phoenix', type: :hidden) + end - it 'timezone defaults to empty' do - expect(page).to have_field(:user_timezone, with: '', type: :hidden) - end + it 'timezone defaults to empty' do + expect(page).to have_field(:user_timezone, with: '', type: :hidden) end end diff --git a/spec/features/profiles/user_visits_profile_account_page_spec.rb b/spec/features/profiles/user_visits_profile_account_page_spec.rb deleted file mode 100644 index 8569cefd1f4..00000000000 --- a/spec/features/profiles/user_visits_profile_account_page_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'User visits the profile account page', feature_category: :user_profile do - let(:user) { create(:user, :no_super_sidebar) } - - before do - sign_in(user) - - visit(profile_account_path) - end - - it 'shows correct menu item' do - expect(page).to have_active_navigation('Account') - end -end diff --git a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb index f92b8e2e751..c081f4a3ec9 100644 --- a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb +++ b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb @@ -3,19 +3,7 @@ require 'spec_helper' RSpec.describe 'User visits the authentication log', feature_category: :user_profile do - let(:user) { create(:user, :no_super_sidebar) } - - context 'when user signed in' do - before do - sign_in(user) - end - - it 'shows correct menu item' do - visit(audit_log_profile_path) - - expect(page).to have_active_navigation('Authentication Log') - end - end + let(:user) { create(:user) } context 'when user has activity' do before do diff --git a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb index 4da1a7ba81a..033d69d29b9 100644 --- a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb +++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'User visits the profile preferences page', :js, feature_category: :user_profile do include ListboxHelpers - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in(user) @@ -13,10 +13,6 @@ RSpec.describe 'User visits the profile preferences page', :js, feature_category visit(profile_preferences_path) end - it 'shows correct menu item' do - expect(page).to have_active_navigation('Preferences') - end - describe 'User changes their syntax highlighting theme', :js do it 'updates their preference' do choose 'user_color_scheme_id_5' @@ -44,7 +40,7 @@ RSpec.describe 'User visits the profile preferences page', :js, feature_category wait_for_requests - find('#logo').click + find('[data-track-label="gitlab_logo_link"]').click expect(page).to have_content("You don't have starred projects yet") expect(page).to have_current_path starred_dashboard_projects_path, ignore_query: true diff --git a/spec/features/profiles/user_visits_profile_spec.rb b/spec/features/profiles/user_visits_profile_spec.rb index 821c3d5ef2b..37a19ecadb8 100644 --- a/spec/features/profiles/user_visits_profile_spec.rb +++ b/spec/features/profiles/user_visits_profile_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User visits their profile', feature_category: :user_profile do - let_it_be_with_refind(:user) { create(:user, :no_super_sidebar) } + let_it_be_with_refind(:user) { create(:user) } before do stub_feature_flags(profile_tabs_vue: false) @@ -11,12 +11,6 @@ RSpec.describe 'User visits their profile', feature_category: :user_profile do sign_in(user) end - it 'shows correct menu item' do - visit(profile_path) - - expect(page).to have_active_navigation('Profile') - end - it 'shows profile info' do visit(profile_path) @@ -59,7 +53,7 @@ RSpec.describe 'User visits their profile', feature_category: :user_profile do expect(page).to have_content user.username end - page.within ".content" do + within_testid('super-sidebar') do click_link link end diff --git a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb deleted file mode 100644 index 728fe1a3172..00000000000 --- a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'User visits the profile SSH keys page', feature_category: :user_profile do - let(:user) { create(:user, :no_super_sidebar) } - - before do - sign_in(user) - - visit(profile_keys_path) - end - - it 'shows correct menu item' do - expect(page).to have_active_navigation('SSH Keys') - end -end diff --git a/spec/features/project_variables_spec.rb b/spec/features/project_variables_spec.rb index e2fa924af67..9a1aa41b982 100644 --- a/spec/features/project_variables_spec.rb +++ b/spec/features/project_variables_spec.rb @@ -13,13 +13,13 @@ RSpec.describe 'Project variables', :js, feature_category: :secrets_management d project.add_maintainer(user) project.variables << variable - stub_feature_flags(ci_variable_drawer: false) visit page_path wait_for_requests end context 'when ci_variables_pages FF is enabled' do - it_behaves_like 'variable list' + it_behaves_like 'variable list drawer' + it_behaves_like 'variable list env scope' it_behaves_like 'variable list pagination', :ci_variable end @@ -28,37 +28,7 @@ RSpec.describe 'Project variables', :js, feature_category: :secrets_management d stub_feature_flags(ci_variables_pages: false) end - it_behaves_like 'variable list' - end - - it 'adds a new variable with an environment scope' do - click_button('Add variable') - - page.within('#add-ci-variable') do - fill_in 'Key', with: 'akey' - find('#ci-variable-value').set('akey_value') - - click_button('All (default)') - fill_in 'Search', with: 'review/*' - find('[data-testid="create-wildcard-button"]').click - - click_button('Add variable') - end - - wait_for_requests - - page.within('[data-testid="ci-variable-table"]') do - expect(find('.js-ci-variable-row:first-child [data-label="Environments"]').text).to eq('review/*') - end - end - - context 'when ci_variable_drawer FF is enabled' do - before do - stub_feature_flags(ci_variable_drawer: true) - visit page_path - wait_for_requests - end - it_behaves_like 'variable list drawer' + it_behaves_like 'variable list env scope' end end diff --git a/spec/features/projects/active_tabs_spec.rb b/spec/features/projects/active_tabs_spec.rb index 8879636e4dc..199ea638f61 100644 --- a/spec/features/projects/active_tabs_spec.rb +++ b/spec/features/projects/active_tabs_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe 'Project active tab', feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } +RSpec.describe 'Project active tab', :js, feature_category: :groups_and_projects do + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, :with_namespace_settings, namespace: user.namespace) } before do @@ -11,7 +11,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do end def click_tab(title) - page.within '.sidebar-top-level-items > .active' do + within_testid('super-sidebar') do click_link(title) end end @@ -20,66 +20,68 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do it 'activates Project scope menu' do visit project_path(project) - expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1) - expect(find('.sidebar-top-level-items > li.active')).to have_content(project.name) + expect(page).to have_selector('a[aria-current="page"]', count: 1) + expect(find('a[aria-current="page"]')).to have_content(project.name) end end - context 'on Project information' do - context 'default link' do - before do - visit project_path(project) - - click_link('Project information', match: :first) - end - - it_behaves_like 'page has active tab', 'Project' - it_behaves_like 'page has active sub tab', 'Activity' - end + context 'on Project Manage' do + %w[Activity Members Labels].each do |sub_menu| + context "on project Manage/#{sub_menu}" do + before do + visit project_path(project) + within_testid('super-sidebar') do + click_button("Manage") + end + click_tab(sub_menu) + end - context 'on Project information/Activity' do - before do - visit activity_project_path(project) + it_behaves_like 'page has active tab', 'Manage' + it_behaves_like 'page has active sub tab', sub_menu end - - it_behaves_like 'page has active tab', 'Project' - it_behaves_like 'page has active sub tab', 'Activity' end end - context 'on project Repository' do + context 'on project Code' do before do root_ref = project.repository.root_ref visit project_tree_path(project, root_ref) + + # Enabling Js in here causes more SQL queries to be caught by the query limiter. + # We are increasing the limit here so that the tests pass. + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(110) end - it_behaves_like 'page has active tab', 'Repository' + it_behaves_like 'page has active tab', 'Code' - %w[Files Commits Graph Compare Branches Tags].each do |sub_menu| - context "on project Repository/#{sub_menu}" do + ["Repository", "Branches", "Commits", "Tags", "Repository graph", "Compare revisions"].each do |sub_menu| + context "on project Code/#{sub_menu}" do before do click_tab(sub_menu) end - it_behaves_like 'page has active tab', 'Repository' + it_behaves_like 'page has active tab', 'Code' it_behaves_like 'page has active sub tab', sub_menu end end end - context 'on project Issues' do + context 'on project Plan' do before do visit project_issues_path(project) end - it_behaves_like 'page has active tab', 'Issues' + it_behaves_like 'page has active tab', 'Pinned' - context "on project Issues/Milestones" do + context "on project Code/Milestones" do before do + within_testid('super-sidebar') do + click_button("Plan") + end click_tab('Milestones') end - it_behaves_like 'page has active tab', 'Issues' + it_behaves_like 'page has active tab', 'Plan' it_behaves_like 'page has active sub tab', 'Milestones' end end @@ -89,7 +91,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit project_merge_requests_path(project) end - it_behaves_like 'page has active tab', 'Merge requests' + it_behaves_like 'page has active tab', 'Pinned' end context 'on project Wiki' do @@ -97,7 +99,8 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit wiki_path(project.wiki) end - it_behaves_like 'page has active tab', 'Wiki' + it_behaves_like 'page has active tab', 'Plan' + it_behaves_like 'page has active sub tab', 'Wiki' end context 'on project Members' do @@ -105,7 +108,8 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit project_project_members_path(project) end - it_behaves_like 'page has active tab', 'Members' + it_behaves_like 'page has active tab', 'Manage' + it_behaves_like 'page has active sub tab', 'Members' end context 'on project Settings' do @@ -132,23 +136,23 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do end end - context 'on project Analytics' do + context 'on project Analyze' do before do visit project_cycle_analytics_path(project) end - context 'on project Analytics/Value stream Analytics' do - it_behaves_like 'page has active tab', _('Analytics') + context 'on project Analyze/Value stream Analyze' do + it_behaves_like 'page has active tab', _('Analyze') it_behaves_like 'page has active sub tab', _('Value stream') end - context 'on project Analytics/"CI/CD"' do + context 'on project Analyze/"CI/CD"' do before do click_tab(_('CI/CD')) end - it_behaves_like 'page has active tab', _('Analytics') - it_behaves_like 'page has active sub tab', _('CI/CD') + it_behaves_like 'page has active tab', _('Analyze') + it_behaves_like 'page has active sub tab', _('CI/CD analytics') end end @@ -161,7 +165,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit project_pipeline_path(project, pipeline) end - it_behaves_like 'page has active tab', _('CI/CD') + it_behaves_like 'page has active tab', _('Build') it_behaves_like 'page has active sub tab', _('Pipelines') end @@ -170,7 +174,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit dag_project_pipeline_path(project, pipeline) end - it_behaves_like 'page has active tab', _('CI/CD') + it_behaves_like 'page has active tab', _('Build') it_behaves_like 'page has active sub tab', _('Pipelines') end @@ -179,7 +183,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit builds_project_pipeline_path(project, pipeline) end - it_behaves_like 'page has active tab', _('CI/CD') + it_behaves_like 'page has active tab', _('Build') it_behaves_like 'page has active sub tab', _('Pipelines') end @@ -188,7 +192,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit failures_project_pipeline_path(project, pipeline) end - it_behaves_like 'page has active tab', _('CI/CD') + it_behaves_like 'page has active tab', _('Build') it_behaves_like 'page has active sub tab', _('Pipelines') end @@ -197,7 +201,7 @@ RSpec.describe 'Project active tab', feature_category: :groups_and_projects do visit test_report_project_pipeline_path(project, pipeline) end - it_behaves_like 'page has active tab', _('CI/CD') + it_behaves_like 'page has active tab', _('Build') it_behaves_like 'page has active sub tab', _('Pipelines') end end diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index 30a81ccc071..36665f2b77d 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -941,9 +941,7 @@ RSpec.describe 'File blob', :js, feature_category: :groups_and_projects do it 'shows the realtime pipeline status' do page.within('.commit-actions') do - expect(page).to have_css('.ci-status-icon') - expect(page).to have_css('.ci-status-icon-running') - expect(page).to have_selector('[data-testid="status_running-icon"]') + expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') end end end diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb index e8a9edcc0cc..9c4f70a68b8 100644 --- a/spec/features/projects/blobs/edit_spec.rb +++ b/spec/features/projects/blobs/edit_spec.rb @@ -120,7 +120,7 @@ RSpec.describe 'Editing file blob', :js, feature_category: :groups_and_projects it 'updates content' do edit_and_commit - expect(page).to have_content 'successfully committed' + expect(page).to have_content 'committed successfully.' expect(page).to have_content 'NextFeature' end diff --git a/spec/features/projects/branches/user_creates_branch_spec.rb b/spec/features/projects/branches/user_creates_branch_spec.rb index eafb75d75ac..8d636dacb75 100644 --- a/spec/features/projects/branches/user_creates_branch_spec.rb +++ b/spec/features/projects/branches/user_creates_branch_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'User creates branch', :js, feature_category: :groups_and_project include Features::BranchesHelpers let_it_be(:group) { create(:group, :public) } - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } shared_examples 'creates new branch' do specify do diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index 79e9ca7998e..7915f446ee0 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -299,13 +299,13 @@ RSpec.describe 'Branches', feature_category: :groups_and_projects do it 'shows pipeline status when available' do page.within first('.all-branches li') do - expect(page).to have_css 'a.gl-badge .ci-status-icon-success' + expect(page).to have_css '[data-testid="status_success_borderless-icon"]' end end it 'displays a placeholder when not available' do page.all('.all-branches li') do |li| - expect(li).to have_css '.pipeline-status svg.s16' + expect(li).to have_css '.pipeline-status svg.s24' end end end @@ -317,7 +317,7 @@ RSpec.describe 'Branches', feature_category: :groups_and_projects do it 'does not show placeholder or pipeline status' do page.all('.all-branches') do |branches| - expect(branches).not_to have_css '.pipeline-status svg.s16' + expect(branches).not_to have_css '.pipeline-status svg.s24' end end end diff --git a/spec/features/projects/ci/editor_spec.rb b/spec/features/projects/ci/editor_spec.rb index adaa5e48967..22cc5c67987 100644 --- a/spec/features/projects/ci/editor_spec.rb +++ b/spec/features/projects/ci/editor_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' RSpec.describe 'Pipeline Editor', :js, feature_category: :pipeline_composition do include Features::SourceEditorSpecHelpers + include ListboxHelpers let(:project) { create(:project_empty_repo, :public) } let(:user) { create(:user) } @@ -216,12 +217,13 @@ RSpec.describe 'Pipeline Editor', :js, feature_category: :pipeline_composition d def switch_to_branch(branch) # close button for the popover find('[data-testid="close-button"]').click - find('[data-testid="branch-selector"]').click page.within '[data-testid="branch-selector"]' do - click_button branch - wait_for_requests + toggle_listbox + select_listbox_item(branch, exact_text: true) end + + wait_for_requests end before do diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index b16f43a16b6..c223053606b 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'Gcp Cluster', :js, feature_category: :deployment_management do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do project.add_maintainer(user) @@ -54,7 +54,7 @@ RSpec.describe 'Gcp Cluster', :js, feature_category: :deployment_management do before do visit project_clusters_path(project) - click_button(class: 'gl-new-dropdown-toggle') + click_button(class: 'gl-new-dropdown-toggle', text: 'Connect a cluster (agent)') click_link 'Connect a cluster (certificate - deprecated)' end diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb index 1393cc6db15..e256b44c4dc 100644 --- a/spec/features/projects/clusters/user_spec.rb +++ b/spec/features/projects/clusters/user_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'User Cluster', :js, feature_category: :deployment_management do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do project.add_maintainer(user) @@ -25,7 +25,7 @@ RSpec.describe 'User Cluster', :js, feature_category: :deployment_management do before do visit project_clusters_path(project) - click_button(class: 'gl-new-dropdown-toggle') + click_button(class: 'gl-new-dropdown-toggle', text: 'Connect a cluster (agent)') click_link 'Connect a cluster (certificate - deprecated)' end diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb index c5d960f2308..d799fbc49ef 100644 --- a/spec/features/projects/clusters_spec.rb +++ b/spec/features/projects/clusters_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'Clusters', :js, feature_category: :groups_and_projects do include GoogleApi::CloudPlatformHelpers let(:project) { create(:project) } - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do project.add_maintainer(user) @@ -125,12 +125,12 @@ RSpec.describe 'Clusters', :js, feature_category: :groups_and_projects do def visit_create_cluster_page visit project_clusters_path(project) - click_button(class: 'gl-new-dropdown-toggle') + click_button(class: 'gl-new-dropdown-toggle', text: 'Connect a cluster (agent)') click_link 'Create a cluster' end def visit_connect_cluster_page - click_button(class: 'gl-new-dropdown-toggle') + click_button(class: 'gl-new-dropdown-toggle', text: 'Connect a cluster (agent)') click_link 'Connect a cluster (certificate - deprecated)' end end diff --git a/spec/features/projects/commit/comments/user_adds_comment_spec.rb b/spec/features/projects/commit/comments/user_adds_comment_spec.rb index b0cb57f158d..d9225192f6b 100644 --- a/spec/features/projects/commit/comments/user_adds_comment_spec.rb +++ b/spec/features/projects/commit/comments/user_adds_comment_spec.rb @@ -112,7 +112,7 @@ RSpec.describe "User adds a comment on a commit", :js, feature_category: :source click_button("Comment") end - expect(page).to have_button("Reply...").and have_no_css("form.new_note") + expect(page).to have_css(".reply-placeholder-text-field").and have_no_css("form.new_note") end # A comment should be added and visible. diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 5bb3d1af924..c0a8dabf648 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -52,7 +52,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js, feature_category: :sou end it 'display icon with status' do - expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') end it 'displays a mini pipeline graph' do @@ -63,7 +63,7 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js, feature_category: :sou wait_for_requests page.within '.js-builds-dropdown-list' do - expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') expect(page).to have_content(build.stage_name) end diff --git a/spec/features/projects/commit/user_sees_pipelines_tab_spec.rb b/spec/features/projects/commit/user_sees_pipelines_tab_spec.rb index 00cb5474ea0..5d722ddbedb 100644 --- a/spec/features/projects/commit/user_sees_pipelines_tab_spec.rb +++ b/spec/features/projects/commit/user_sees_pipelines_tab_spec.rb @@ -36,9 +36,8 @@ RSpec.describe 'Commit > Pipelines tab', :js, feature_category: :source_code_man wait_for_requests page.within('[data-testid="pipeline-table-row"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Passed') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Passed') expect(page).to have_content(pipeline.id) - expect(page).to have_content('API') expect(page).to have_css('[data-testid="pipeline-mini-graph"]') expect(page).to have_css('[data-testid="pipelines-manual-actions-dropdown"]') expect(page).to have_css('[data-testid="pipeline-multi-actions-dropdown"]') diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb index eff538513c1..ccf5c6996f1 100644 --- a/spec/features/projects/compare_spec.rb +++ b/spec/features/projects/compare_spec.rb @@ -185,13 +185,4 @@ RSpec.describe "Compare", :js, feature_category: :groups_and_projects do it_behaves_like "compare view of branches" it_behaves_like "compare view of tags" - - context "when super sidebar is enabled" do - before do - user.update!(use_new_navigation: true) - end - - it_behaves_like "compare view of branches" - it_behaves_like "compare view of tags" - end end diff --git a/spec/features/projects/confluence/user_views_confluence_page_spec.rb b/spec/features/projects/confluence/user_views_confluence_page_spec.rb index 216bea74c09..9c036f35887 100644 --- a/spec/features/projects/confluence/user_views_confluence_page_spec.rb +++ b/spec/features/projects/confluence/user_views_confluence_page_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User views the Confluence page', feature_category: :integrations do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let(:project) { create(:project, :public) } @@ -11,12 +11,14 @@ RSpec.describe 'User views the Confluence page', feature_category: :integrations sign_in(user) end - it 'shows the page when the Confluence integration is enabled' do + it 'shows the page when the Confluence integration is enabled', :js do service = create(:confluence_integration, project: project) visit project_wikis_confluence_path(project) - expect(page).to have_css('.nav-sidebar li.active', text: 'Confluence', match: :first) + within_testid('super-sidebar') do + expect(page).to have_css('a[aria-current="page"]', text: 'Confluence') + end element = page.find('.row.empty-state') diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 3a2c7f0ac7b..0a54f5923f2 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -34,16 +34,16 @@ RSpec.describe 'Environments page', :js, feature_category: :continuous_delivery describe 'with one available environment' do let!(:environment) { create(:environment, project: project, state: :available) } - it 'shows "Available" and "Stopped" tab with links' do + it 'shows "Active" and "Stopped" tab with links' do visit_environments(project) - expect(page).to have_link(_('Available')) + expect(page).to have_link(_('Active')) expect(page).to have_link(_('Stopped')) end - describe 'in available tab page' do + describe 'in active tab page' do it 'shows one environment' do - visit_environments(project, scope: 'available') + visit_environments(project, scope: 'active') expect(page).to have_link(environment.name, href: project_environment_path(project, environment)) end @@ -56,7 +56,7 @@ RSpec.describe 'Environments page', :js, feature_category: :continuous_delivery end it 'renders second page of pipelines' do - visit_environments(project, scope: 'available') + visit_environments(project, scope: 'active') find('.page-link.next-page-item').click wait_for_requests @@ -85,7 +85,7 @@ RSpec.describe 'Environments page', :js, feature_category: :continuous_delivery end it 'shows one environment without error' do - visit_environments(project, scope: 'available') + visit_environments(project, scope: 'active') expect(page).to have_link(environment.name, href: project_environment_path(project, environment)) end @@ -95,9 +95,9 @@ RSpec.describe 'Environments page', :js, feature_category: :continuous_delivery describe 'with one stopped environment' do let!(:environment) { create(:environment, project: project, state: :stopped) } - describe 'in available tab page' do + describe 'in active tab page' do it 'shows no environments' do - visit_environments(project, scope: 'available') + visit_environments(project, scope: 'active') expect(page).to have_content(s_('Environments|Get started with environments')) end @@ -122,7 +122,7 @@ RSpec.describe 'Environments page', :js, feature_category: :continuous_delivery it 'does not show environments and tabs' do expect(page).to have_content(s_('Environments|Get started with environments')) - expect(page).not_to have_link(_('Available')) + expect(page).not_to have_link(_('Active')) expect(page).not_to have_link(_('Stopped')) end end @@ -142,7 +142,7 @@ RSpec.describe 'Environments page', :js, feature_category: :continuous_delivery it 'shows environments names and counters' do expect(page).to have_link(environment.name, href: project_environment_path(project, environment)) - expect(page).to have_link("#{_('Available')} 1") + expect(page).to have_link("#{_('Active')} 1") expect(page).to have_link("#{_('Stopped')} 0") end diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 8f66b722ead..c6a770cee9e 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -3,10 +3,15 @@ require 'spec_helper' RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects do - let(:member) { create(:user, :no_super_sidebar) } + let(:member) { create(:user) } let!(:project) { create(:project, :public, :repository) } let!(:issue) { create(:issue, project: project) } - let(:non_member) { create(:user, :no_super_sidebar) } + let(:non_member) { create(:user) } + + # Sidebar nav links are only visible after hovering over or expanding the + # section that contains them (if it exists). Finding visible and hidden + # nav links allows us to avoid doing that. + let(:visibility_all) { { visible: :all } } describe 'project features visibility selectors', :js do before do @@ -14,7 +19,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d sign_in(member) end - tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests", analytics: "analytics" } + tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests", analytics: "project-cycle-analytics" } tools.each do |tool_name, shortcut_name| describe "feature #{tool_name}" do @@ -22,20 +27,16 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit edit_project_path(project) # disable by clicking toggle - toggle_feature_off("project[project_feature_attributes][#{tool_name}_access_level]") - page.within('.sharing-permissions') do - find('[data-testid="project-features-save-button"]').click - end + toggle_feature_off(tool_name) + click_save_changes wait_for_requests - expect(page).not_to have_selector(".shortcuts-#{shortcut_name}") + expect(page).not_to have_selector(".shortcuts-#{shortcut_name}", **visibility_all) # re-enable by clicking toggle again - toggle_feature_on("project[project_feature_attributes][#{tool_name}_access_level]") - page.within('.sharing-permissions') do - find('[data-testid="project-features-save-button"]').click - end + toggle_feature_on(tool_name) + click_save_changes wait_for_requests - expect(page).to have_selector(".shortcuts-#{shortcut_name}") + expect(page).to have_selector(".shortcuts-#{shortcut_name}", **visibility_all) end end end @@ -48,8 +49,8 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit project_path(project) - expect(page).to have_selector('.shortcuts-issues') - expect(page).not_to have_selector('.shortcuts-labels') + expect(page).to have_selector('.shortcuts-issues', **visibility_all) + expect(page).not_to have_selector('.shortcuts-labels', **visibility_all) end end @@ -65,8 +66,8 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d it 'hides issues tab' do visit project_path(project) - expect(page).not_to have_selector('.shortcuts-issues') - expect(page).not_to have_selector('.shortcuts-labels') + expect(page).not_to have_selector('.shortcuts-issues', **visibility_all) + expect(page).not_to have_selector('.shortcuts-labels', **visibility_all) end end @@ -74,7 +75,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d it "shows builds when enabled" do visit project_pipelines_path(project) - expect(page).to have_selector(".shortcuts-builds") + expect(page).to have_selector(".shortcuts-builds", **visibility_all) end it "hides builds when disabled" do @@ -83,7 +84,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit project_pipelines_path(project) - expect(page).not_to have_selector(".shortcuts-builds") + expect(page).not_to have_selector(".shortcuts-builds", **visibility_all) end end end @@ -183,23 +184,19 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end it "disables repository related features" do - toggle_feature_off('project[project_feature_attributes][repository_access_level]') + toggle_feature_off('repository') - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes expect(find(".sharing-permissions")).to have_selector(".gl-toggle.is-disabled", minimum: 3) end it "shows empty features project homepage" do - toggle_feature_off('project[project_feature_attributes][repository_access_level]') - toggle_feature_off('project[project_feature_attributes][issues_access_level]') - toggle_feature_off('project[project_feature_attributes][wiki_access_level]') + toggle_feature_off('repository') + toggle_feature_off('issues') + toggle_feature_off('wiki') - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes wait_for_requests visit project_path(project) @@ -208,13 +205,11 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end it "hides project activity tabs" do - toggle_feature_off('project[project_feature_attributes][repository_access_level]') - toggle_feature_off('project[project_feature_attributes][issues_access_level]') - toggle_feature_off('project[project_feature_attributes][wiki_access_level]') + toggle_feature_off('repository') + toggle_feature_off('issues') + toggle_feature_off('wiki') - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes wait_for_requests visit activity_project_path(project) @@ -229,7 +224,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d # Regression spec for https://gitlab.com/gitlab-org/gitlab-foss/issues/25272 it "hides comments activity tab only on disabled issues, merge requests and repository" do - toggle_feature_off('project[project_feature_attributes][issues_access_level]') + toggle_feature_off('issues') save_changes_and_check_activity_tab do expect(page).to have_content("Comments") @@ -237,7 +232,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit edit_project_path(project) - toggle_feature_off('project[project_feature_attributes][merge_requests_access_level]') + toggle_feature_off('merge_requests') save_changes_and_check_activity_tab do expect(page).to have_content("Comments") @@ -245,7 +240,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit edit_project_path(project) - toggle_feature_off('project[project_feature_attributes][repository_access_level]') + toggle_feature_off('repository') save_changes_and_check_activity_tab do expect(page).not_to have_content("Comments") @@ -255,9 +250,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end def save_changes_and_check_activity_tab - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes wait_for_requests visit activity_project_path(project) @@ -284,10 +277,16 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end def toggle_feature_off(feature_name) - find(".project-feature-controls[data-for=\"#{feature_name}\"] .gl-toggle.is-checked").click + find(".project-feature-controls[data-for=\"project[project_feature_attributes][#{feature_name}_access_level]\"] .gl-toggle.is-checked").click end def toggle_feature_on(feature_name) - find(".project-feature-controls[data-for=\"#{feature_name}\"] .gl-toggle:not(.is-checked)").click + find(".project-feature-controls[data-for=\"project[project_feature_attributes][#{feature_name}_access_level]\"] .gl-toggle:not(.is-checked)").click + end + + def click_save_changes + page.within('.sharing-permissions') do + click_button 'Save changes' + end end end diff --git a/spec/features/projects/files/project_owner_creates_license_file_spec.rb b/spec/features/projects/files/project_owner_creates_license_file_spec.rb index 595aad0144b..18041bbb00a 100644 --- a/spec/features/projects/files/project_owner_creates_license_file_spec.rb +++ b/spec/features/projects/files/project_owner_creates_license_file_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Projects > Files > Project owner creates a license file', :js, feature_category: :groups_and_projects do - let_it_be(:project_maintainer) { create(:user, :no_super_sidebar) } + let_it_be(:project_maintainer) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: project_maintainer.namespace) } before do @@ -59,7 +59,7 @@ RSpec.describe 'Projects > Files > Project owner creates a license file', :js, f end def select_template(template) - page.within('.gl-new-dropdown') do + within_testid('template-selector') do click_button 'Apply a template' find('.gl-new-dropdown-contents li', text: template).click wait_for_requests diff --git a/spec/features/projects/files/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb index 10fa4a21359..5612f6a53b2 100644 --- a/spec/features/projects/files/user_edits_files_spec.rb +++ b/spec/features/projects/files/user_edits_files_spec.rb @@ -79,6 +79,25 @@ RSpec.describe 'Projects > Files > User edits files', :js, feature_category: :gr expect(page).to have_content('*.rbca') end + it 'displays a flash message with a link when an edited file was committed' do + click_link('.gitignore') + edit_in_single_file_editor + find('.file-editor', match: :first) + + editor_set_value('*.rbca') + fill_in(:commit_message, with: 'New commit message', visible: true) + click_button('Commit changes') + + expect(page).to have_current_path(project_blob_path(project, 'master/.gitignore'), ignore_query: true) + + wait_for_requests + + expect(page).to have_content('Your changes have been committed successfully') + page.within '.flash-container' do + expect(page).to have_link 'changes' + end + end + it 'commits an edited file to a new branch' do click_link('.gitignore') edit_in_single_file_editor diff --git a/spec/features/projects/files/user_find_file_spec.rb b/spec/features/projects/files/user_find_file_spec.rb index 005a870bea0..b6e739e8082 100644 --- a/spec/features/projects/files/user_find_file_spec.rb +++ b/spec/features/projects/files/user_find_file_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'User find project file', feature_category: :groups_and_projects do include ListboxHelpers - let(:user) { create :user, :no_super_sidebar } + let(:user) { create :user } let(:project) { create :project, :repository } before do @@ -15,29 +15,25 @@ RSpec.describe 'User find project file', feature_category: :groups_and_projects visit project_tree_path(project, project.repository.root_ref) end - def active_main_tab - find('.sidebar-top-level-items > li.active') - end - def find_file(text) fill_in 'file_find', with: text end def ref_selector_dropdown - find('.gl-button-text') + find('.ref-selector .gl-button-text') end it 'navigates to find file by shortcut', :js do find('body').native.send_key('t') - expect(active_main_tab).to have_content('Repository') + expect(page).to have_active_sub_navigation('Repository') expect(page).to have_selector('.file-finder-holder', count: 1) end - it 'navigates to find file' do + it 'navigates to find file', :js do click_link 'Find file' - expect(active_main_tab).to have_content('Repository') + expect(page).to have_active_sub_navigation('Repository') expect(page).to have_selector('.file-finder-holder', count: 1) end diff --git a/spec/features/projects/files/user_reads_pipeline_status_spec.rb b/spec/features/projects/files/user_reads_pipeline_status_spec.rb index ce3f0541139..24dd673501c 100644 --- a/spec/features/projects/files/user_reads_pipeline_status_spec.rb +++ b/spec/features/projects/files/user_reads_pipeline_status_spec.rb @@ -25,7 +25,7 @@ RSpec.describe 'user reads pipeline status', :js, feature_category: :groups_and_ page.within('.commit-detail') do expect(page).to have_link('', href: project_pipeline_path(project, expected_pipeline)) - expect(page).to have_selector(".ci-status-icon-#{expected_pipeline.status}") + expect(page).to have_selector("[data-testid='status_#{expected_pipeline.status}_borderless-icon']") end end end diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb index 627912df408..030d5a8ec40 100644 --- a/spec/features/projects/files/user_searches_for_files_spec.rb +++ b/spec/features/projects/files/user_searches_for_files_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User searches for files', feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } before do @@ -18,7 +18,7 @@ RSpec.describe 'Projects > Files > User searches for files', feature_category: : visit project_path(project) end - it 'does not show any result' do + it 'does not show any result', :js do submit_search('coffee') expect(page).to have_content("We couldn't find any") @@ -41,7 +41,7 @@ RSpec.describe 'Projects > Files > User searches for files', feature_category: : visit project_tree_path(project, project.default_branch) end - it 'shows found files' do + it 'shows found files', :js do expect(page).to have_selector('.tree-controls .shortcuts-find-file') submit_search('coffee') diff --git a/spec/features/projects/forks/fork_list_spec.rb b/spec/features/projects/forks/fork_list_spec.rb index 86e4e03259e..966147637f5 100644 --- a/spec/features/projects/forks/fork_list_spec.rb +++ b/spec/features/projects/forks/fork_list_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'listing forks of a project', feature_category: :groups_and_proje let(:source) { create(:project, :public, :repository) } let!(:fork) { fork_project(source, nil, repository: true) } - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do source.add_maintainer(user) diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb index 9b0803e4b0c..e9c05fd7f7f 100644 --- a/spec/features/projects/graph_spec.rb +++ b/spec/features/projects/graph_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Project Graph', :js, feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, :repository, namespace: user.namespace) } let(:branch_name) { 'master' } @@ -59,7 +59,7 @@ RSpec.describe 'Project Graph', :js, feature_category: :groups_and_projects do it 'HTML escapes branch name' do expect(page.body).to include("Commit statistics for <strong>#{ERB::Util.html_escape(branch_name)}</strong>") - expect(page.find('.gl-new-dropdown-button-text')['innerHTML']).to include(ERB::Util.html_escape(branch_name)) + expect(page).to have_button(branch_name) end end diff --git a/spec/features/projects/integrations/user_activates_issue_tracker_spec.rb b/spec/features/projects/integrations/user_activates_issue_tracker_spec.rb index 9fc91e03c94..944a2c164d5 100644 --- a/spec/features/projects/integrations/user_activates_issue_tracker_spec.rb +++ b/spec/features/projects/integrations/user_activates_issue_tracker_spec.rb @@ -38,7 +38,8 @@ RSpec.describe 'User activates issue tracker', :js, feature_category: :integrati end it 'shows the link in the menu' do - page.within('.nav-sidebar') do + within_testid('super-sidebar') do + click_button 'Plan' expect(page).to have_link(tracker, href: url) end end @@ -77,7 +78,8 @@ RSpec.describe 'User activates issue tracker', :js, feature_category: :integrati end it 'does not show the external tracker link in the menu' do - page.within('.nav-sidebar') do + within_testid('super-sidebar') do + click_button 'Plan' expect(page).not_to have_link(tracker, href: url) end end diff --git a/spec/features/projects/integrations/user_activates_jira_spec.rb b/spec/features/projects/integrations/user_activates_jira_spec.rb index 0bd5020e9bf..cc0d4c6f564 100644 --- a/spec/features/projects/integrations/user_activates_jira_spec.rb +++ b/spec/features/projects/integrations/user_activates_jira_spec.rb @@ -25,10 +25,11 @@ RSpec.describe 'User activates Jira', :js, feature_category: :integrations do unless Gitlab.ee? it 'adds Jira link to sidebar menu' do - page.within('.nav-sidebar') do - expect(page).not_to have_link('Jira issues', visible: false) - expect(page).not_to have_link('Open Jira', href: url, visible: false) - expect(page).to have_link('Jira', href: url) + within_testid('super-sidebar') do + click_button 'Plan' + expect(page).not_to have_link('Jira issues') + expect(page).not_to have_link('Open Jira') + expect(page).to have_link(exact_text: 'Jira', href: url) end end end @@ -76,8 +77,9 @@ RSpec.describe 'User activates Jira', :js, feature_category: :integrations do end it 'does not show the Jira link in the menu' do - page.within('.nav-sidebar') do - expect(page).not_to have_link('Jira', href: url) + within_testid('super-sidebar') do + click_button 'Plan' + expect(page).not_to have_link('Jira') end end end diff --git a/spec/features/projects/issuable_templates_spec.rb b/spec/features/projects/issuable_templates_spec.rb index 9ba4b544191..bc67cdbfad1 100644 --- a/spec/features/projects/issuable_templates_spec.rb +++ b/spec/features/projects/issuable_templates_spec.rb @@ -64,6 +64,27 @@ RSpec.describe 'issuable templates', :js, feature_category: :groups_and_projects end end + context 'user creates an issue template using issuable_template query param' do + let(:template_content) { 'this is a test "bug" template' } + + before do + project.repository.create_file( + user, + '.gitlab/issue_templates/bug.md', + template_content, + message: 'added issue template', + branch_name: 'master') + end + + it 'applies correctly in the rich text editor' do + visit new_project_issue_path project + click_button "Switch to rich text editing" + visit new_project_issue_path(project, { issuable_template: 'bug' }) + + expect(page).to have_content(template_content) + end + end + context 'user creates an issue using templates, with a prior description' do let(:prior_description) { 'test issue description' } let(:template_content) { 'this is a test "bug" template' } diff --git a/spec/features/projects/issues/email_participants_spec.rb b/spec/features/projects/issues/email_participants_spec.rb index 215c45351c1..e1b8133a10f 100644 --- a/spec/features/projects/issues/email_participants_spec.rb +++ b/spec/features/projects/issues/email_participants_spec.rb @@ -68,18 +68,4 @@ RSpec.describe 'viewing an issue', :js, feature_category: :service_desk do end end end - - context 'for feature flags' do - before do - sign_in(user) - end - - it 'pushes service_desk_new_note_email_native_attachments feature flag to frontend' do - stub_feature_flags(service_desk_new_note_email_native_attachments: true) - - visit project_issue_path(project, issue) - - expect(page).to have_pushed_frontend_feature_flags(serviceDeskNewNoteEmailNativeAttachments: true) - end - end end diff --git a/spec/features/projects/jobs/user_browses_jobs_spec.rb b/spec/features/projects/jobs/user_browses_jobs_spec.rb index fc67d7dedcc..115b3dda5b2 100644 --- a/spec/features/projects/jobs/user_browses_jobs_spec.rb +++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb @@ -72,7 +72,7 @@ RSpec.describe 'User browses jobs', feature_category: :groups_and_projects do wait_for_requests - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Canceled') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Canceled') expect(page).not_to have_selector('[data-testid="jobs-table-error-alert"]') end end @@ -93,7 +93,7 @@ RSpec.describe 'User browses jobs', feature_category: :groups_and_projects do wait_for_requests - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending') end end @@ -133,7 +133,7 @@ RSpec.describe 'User browses jobs', feature_category: :groups_and_projects do wait_for_requests - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending') end it 'unschedules a job successfully' do @@ -141,7 +141,7 @@ RSpec.describe 'User browses jobs', feature_category: :groups_and_projects do wait_for_requests - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Manual') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Manual') end end diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 12ed2558712..050ed4e0e4c 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -66,7 +66,7 @@ RSpec.describe 'Jobs', :clean_gitlab_redis_shared_state, feature_category: :grou wait_for_requests - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Passed') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Passed') end it 'shows commit`s data', :js do diff --git a/spec/features/projects/members/sorting_spec.rb b/spec/features/projects/members/sorting_spec.rb index 9747d499ae9..94c42c0f098 100644 --- a/spec/features/projects/members/sorting_spec.rb +++ b/spec/features/projects/members/sorting_spec.rb @@ -149,7 +149,7 @@ RSpec.describe 'Projects > Members > Sorting', :js, feature_category: :groups_an def expect_sort_by(text, sort_direction) within('[data-testid="members-sort-dropdown"]') do expect(page).to have_css('button[aria-haspopup="menu"]', text: text) - expect(page).to have_button("Sorting Direction: #{sort_direction == :asc ? 'Ascending' : 'Descending'}") + expect(page).to have_button("Sort direction: #{sort_direction == :asc ? 'Ascending' : 'Descending'}") end end end diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb index d1e58ba91f0..e7f99a4048c 100644 --- a/spec/features/projects/members/user_requests_access_spec.rb +++ b/spec/features/projects/members/user_requests_access_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'Projects > Members > User requests access', :js, feature_category: :groups_and_projects do include Spec::Support::Helpers::ModalHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:maintainer) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } + let_it_be(:maintainer) { create(:user) } let_it_be(:project) { create(:project, :public, :repository) } let(:owner) { project.first_owner } @@ -54,10 +54,9 @@ RSpec.describe 'Projects > Members > User requests access', :js, feature_categor expect(project.requesters.exists?(user_id: user)).to be_truthy - click_link 'Project information' - - page.within('.nav-sidebar') do - click_link('Members') + within_testid('super-sidebar') do + click_button 'Manage' + click_link 'Members' end page.within('.content') do diff --git a/spec/features/projects/milestones/user_interacts_with_labels_spec.rb b/spec/features/projects/milestones/user_interacts_with_labels_spec.rb index 3742c9f19d8..9c3eaff1545 100644 --- a/spec/features/projects/milestones/user_interacts_with_labels_spec.rb +++ b/spec/features/projects/milestones/user_interacts_with_labels_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User interacts with labels', feature_category: :team_planning do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } let(:milestone) { create(:milestone, project: project, title: 'v2.2', description: '# Description header') } let(:issue1) { create(:issue, project: project, title: 'Bugfix1', milestone: milestone) } @@ -25,9 +25,7 @@ RSpec.describe 'User interacts with labels', feature_category: :team_planning do it 'shows the list of labels', :js do click_link('v2.2') - page.within('.nav-sidebar') do - page.find(:xpath, "//a[@href='#tab-labels']").click - end + page.find(:xpath, "//a[@href='#tab-labels']").click expect(page).to have_selector('ul.manage-labels-list') diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb index e967c1be3bc..348a661855c 100644 --- a/spec/features/projects/navbar_spec.rb +++ b/spec/features/projects/navbar_spec.rb @@ -2,13 +2,13 @@ require 'spec_helper' -RSpec.describe 'Project navbar', :with_license, feature_category: :groups_and_projects do +RSpec.describe 'Project navbar', :with_license, :js, feature_category: :groups_and_projects do include NavbarStructureHelper include WaitForRequests include_context 'project navbar structure' - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } before do @@ -16,7 +16,7 @@ RSpec.describe 'Project navbar', :with_license, feature_category: :groups_and_pr stub_config(registry: { enabled: false }) stub_feature_flags(ml_experiment_tracking: false) - insert_package_nav(_('Deployments')) + insert_package_nav insert_infrastructure_registry_nav insert_infrastructure_google_cloud_nav insert_infrastructure_aws_nav @@ -28,29 +28,13 @@ RSpec.describe 'Project navbar', :with_license, feature_category: :groups_and_pr end end - context 'when value stream is available' do - before do - visit project_path(project) - end - - it 'redirects to value stream when Analytics item is clicked' do - page.within('.sidebar-top-level-items') do - find('.shortcuts-analytics').click - end - - wait_for_requests - - expect(page).to have_current_path(project_cycle_analytics_path(project)) - end - end - context 'when pages are available' do before do stub_config(pages: { enabled: true }) insert_after_sub_nav_item( - _('Releases'), - within: _('Deployments'), + _('Package Registry'), + within: _('Deploy'), new_sub_nav_item_name: _('Pages') ) @@ -86,7 +70,7 @@ RSpec.describe 'Project navbar', :with_license, feature_category: :groups_and_pr let_it_be(:harbor_integration) { create(:harbor_integration, project: project) } before do - insert_harbor_registry_nav(_('Terraform modules')) + insert_harbor_registry_nav(_('AWS')) visit project_path(project) end @@ -98,7 +82,11 @@ RSpec.describe 'Project navbar', :with_license, feature_category: :groups_and_pr before do stub_feature_flags(ml_experiment_tracking: true) - insert_model_experiments_nav(_('Terraform modules')) + if Gitlab.ee? # rubocop: disable RSpec/AvoidConditionalStatements + insert_model_experiments_nav(_('Merge request analytics')) + else + insert_model_experiments_nav(_('Repository analytics')) + end visit project_path(project) end diff --git a/spec/features/projects/network_graph_spec.rb b/spec/features/projects/network_graph_spec.rb index eff0335c891..e84bbf382ad 100644 --- a/spec/features/projects/network_graph_spec.rb +++ b/spec/features/projects/network_graph_spec.rb @@ -124,12 +124,4 @@ RSpec.describe 'Project Network Graph', :js, feature_category: :groups_and_proje end it_behaves_like 'network graph' - - context 'when disable_network_graph_notes_count is disabled' do - before do - stub_feature_flags(disable_network_graph_notes_count: false) - end - - it_behaves_like 'network graph' - end end diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index 926fea24e14..a3cbb86da2c 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -9,13 +9,37 @@ RSpec.describe 'New project', :js, feature_category: :groups_and_projects do stub_application_setting(import_sources: Gitlab::ImportSources.values) end + shared_examples 'shows correct navigation' do + context 'for a new top-level project' do + it 'shows the "Your work" navigation' do + visit new_project_path + expect(page).to have_selector(".super-sidebar", text: "Your work") + end + end + + context 'for a new group project' do + let_it_be(:parent_group) { create(:group) } + + before do + parent_group.add_owner(user) + end + + it 'shows the group sidebar of the parent group' do + visit new_project_path(namespace_id: parent_group.id) + expect(page).to have_selector(".super-sidebar", text: parent_group.name) + end + end + end + context 'as a user' do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } before do sign_in(user) end + it_behaves_like 'shows correct navigation' + it 'shows the project description field when it should' do description_label = 'Project description (optional)' @@ -76,7 +100,9 @@ RSpec.describe 'New project', :js, feature_category: :groups_and_projects do end context 'as an admin' do - let(:user) { create(:admin, :no_super_sidebar) } + let(:user) { create(:admin) } + + it_behaves_like 'shows correct navigation' shared_examples '"New project" page' do before do @@ -103,14 +129,6 @@ RSpec.describe 'New project', :js, feature_category: :groups_and_projects do include_examples '"New project" page' - context 'when the new navigation is enabled' do - before do - user.update!(use_new_navigation: true) - end - - include_examples '"New project" page' - end - shared_examples 'renders importer link' do |params| context 'with user namespace' do before do @@ -566,66 +584,17 @@ RSpec.describe 'New project', :js, feature_category: :groups_and_projects do let(:provider) { :bitbucket } context 'as a user' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:oauth_config_instructions) { 'To enable importing projects from Bitbucket, ask your GitLab administrator to configure OAuth integration' } it_behaves_like 'has instructions to enable OAuth' end context 'as an admin', :do_not_mock_admin_mode_setting do - let(:user) { create(:admin, :no_super_sidebar) } + let(:user) { create(:admin) } let(:oauth_config_instructions) { 'To enable importing projects from Bitbucket, as administrator you need to configure OAuth integration' } it_behaves_like 'has instructions to enable OAuth' end end - - describe 'sidebar' do - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:parent_group) { create(:group) } - - before do - parent_group.add_owner(user) - sign_in(user) - end - - context 'in the current navigation' do - before do - user.update!(use_new_navigation: false) - end - - context 'for a new top-level project' do - it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :new_project_path, :projects - end - - context 'for a new group project' do - it 'shows the group sidebar of the parent group' do - visit new_project_path(namespace_id: parent_group.id) - expect(page).to have_selector(".nav-sidebar[aria-label=\"Group navigation\"] .context-header[title=\"#{parent_group.name}\"]") - end - end - end - - context 'in the new navigation' do - before do - parent_group.add_owner(user) - user.update!(use_new_navigation: true) - sign_in(user) - end - - context 'for a new top-level project' do - it 'shows the "Your work" navigation' do - visit new_project_path - expect(page).to have_selector(".super-sidebar", text: "Your work") - end - end - - context 'for a new group project' do - it 'shows the group sidebar of the parent group' do - visit new_project_path(namespace_id: parent_group.id) - expect(page).to have_selector(".super-sidebar", text: parent_group.name) - end - end - end - end end diff --git a/spec/features/projects/pages/user_configures_pages_pipeline_spec.rb b/spec/features/projects/pages/user_configures_pages_pipeline_spec.rb index baef75ca303..eb7bcb38d38 100644 --- a/spec/features/projects/pages/user_configures_pages_pipeline_spec.rb +++ b/spec/features/projects/pages/user_configures_pages_pipeline_spec.rb @@ -15,45 +15,23 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do sign_in(user) end - context 'when pipeline wizard feature is enabled' do - before do - Feature.enable(:use_pipeline_wizard_for_pages) - end - - context 'when onboarding is not complete' do - it 'renders onboarding instructions' do - visit project_pages_path(project) - - expect(page).to have_content('Get started with Pages') - end - end - - context 'when onboarding is complete' do - before do - project.mark_pages_onboarding_complete - end - - it 'shows waiting screen' do - visit project_pages_path(project) + context 'when onboarding is not complete' do + it 'renders onboarding instructions' do + visit project_pages_path(project) - expect(page).to have_content('Waiting for the Pages Pipeline to complete...') - end + expect(page).to have_content('Get started with GitLab Pages') end end - context 'when pipeline wizard feature is disabled' do + context 'when onboarding is complete' do before do - Feature.disable(:use_pipeline_wizard_for_pages) - end - - after do - Feature.enable(:use_pipeline_wizard_for_pages) + project.mark_pages_onboarding_complete end - it 'shows configure pages instructions' do + it 'shows waiting screen' do visit project_pages_path(project) - expect(page).to have_content('Configure pages') + expect(page).to have_content('Waiting for the Pages Pipeline to complete...') end end end diff --git a/spec/features/projects/pages/user_edits_settings_spec.rb b/spec/features/projects/pages/user_edits_settings_spec.rb index 8350214bf99..4ad729a29e1 100644 --- a/spec/features/projects/pages/user_edits_settings_spec.rb +++ b/spec/features/projects/pages/user_edits_settings_spec.rb @@ -5,7 +5,7 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do include Spec::Support::Helpers::ModalHelpers let_it_be_with_reload(:project) { create(:project, :pages_published, pages_https_only: false) } - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } before do allow(Gitlab.config.pages).to receive(:enabled).and_return(true) @@ -22,7 +22,7 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do context 'when pages deployed' do before do - project.mark_pages_as_deployed + create(:pages_deployment, project: project) end it 'renders Access pages' do @@ -85,7 +85,7 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do it 'renders "Pages" tab' do visit project_pages_path(project) - page.within '.nav-sidebar' do + within_testid 'super-sidebar' do expect(page).to have_link('Pages') end end @@ -96,7 +96,8 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do it 'renders "Pages" tab' do visit project_environments_path(project) - page.within '.nav-sidebar' do + within_testid 'super-sidebar' do + click_button 'Deploy' expect(page).to have_link('Pages') end end @@ -110,7 +111,8 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do it 'does not render "Pages" tab' do visit project_environments_path(project) - page.within '.nav-sidebar' do + within_testid 'super-sidebar' do + click_button 'Deploy' expect(page).not_to have_link('Pages') end end @@ -123,7 +125,7 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do before do project.namespace.update!(owner: user) - project.mark_pages_as_deployed + create(:pages_deployment, project: project) end it 'tries to change the setting' do @@ -185,7 +187,7 @@ RSpec.describe 'Pages edits pages settings', :js, feature_category: :pages do describe 'Remove page' do context 'when pages are deployed' do before do - project.mark_pages_as_deployed + create(:pages_deployment, project: project) end it 'removes the pages', :sidekiq_inline do diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index f042a12884c..fccfe00f593 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -165,7 +165,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows a running icon and a cancel action for the running build' do page.within('#ci-badge-deploy') do - expect(page).to have_selector('[data-testid="status_running-icon"]') + expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') expect(page).to have_selector('.js-icon-cancel') expect(page).to have_content('deploy') end @@ -187,7 +187,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows a preparing icon and a cancel action' do page.within('#ci-badge-prepare') do - expect(page).to have_selector('[data-testid="status_preparing-icon"]') + expect(page).to have_selector('[data-testid="status_preparing_borderless-icon"]') expect(page).to have_selector('.js-icon-cancel') expect(page).to have_content('prepare') end @@ -209,7 +209,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows the success icon and a retry action for the successful build' do page.within('#ci-badge-build') do - expect(page).to have_selector('[data-testid="status_success-icon"]') + expect(page).to have_selector('[data-testid="status_success_borderless-icon"]') expect(page).to have_content('build') end @@ -224,7 +224,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do expect(page).not_to have_content('Retry job') within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end end end @@ -238,7 +238,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows the scheduled icon and an unschedule action for the delayed job' do page.within('#ci-badge-delayed-job') do - expect(page).to have_selector('[data-testid="status_scheduled-icon"]') + expect(page).to have_selector('[data-testid="status_scheduled_borderless-icon"]') expect(page).to have_content('delayed-job') end @@ -263,7 +263,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows the failed icon and a retry action for the failed build' do page.within('#ci-badge-test') do - expect(page).to have_selector('[data-testid="status_failed-icon"]') + expect(page).to have_selector('[data-testid="status_failed_borderless-icon"]') expect(page).to have_content('test') end @@ -278,7 +278,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do expect(page).not_to have_content('Retry job') within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end end @@ -297,7 +297,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows the skipped icon and a play action for the manual build' do page.within('#ci-badge-manual-build') do - expect(page).to have_selector('[data-testid="status_manual-icon"]') + expect(page).to have_selector('[data-testid="status_manual_borderless-icon"]') expect(page).to have_content('manual') end @@ -312,7 +312,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do expect(page).not_to have_content('Play job') within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end end end @@ -323,7 +323,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do end it 'shows the success icon and the generic comit status build' do - expect(page).to have_selector('[data-testid="status_success-icon"]') + expect(page).to have_selector('[data-testid="status_success_borderless-icon"]') expect(page).to have_content('jenkins') expect(page).to have_link('jenkins', href: 'http://gitlab.com/status') end @@ -358,7 +358,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do let(:status) { :success } it 'does not show the cancel or retry action' do - expect(page).to have_selector('.ci-status-icon-success') + expect(page).to have_selector('[data-testid="status_success_borderless-icon"]') expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]') expect(page).not_to have_selector('button[aria-label="Cancel downstream pipeline"]') end @@ -379,7 +379,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows the pipeline as canceled with the retry action' do expect(page).to have_selector('button[aria-label="Retry downstream pipeline"]') - expect(page).to have_selector('.ci-status-icon-canceled') + expect(page).to have_selector('[data-testid="status_canceled_borderless-icon"]') end end end @@ -398,7 +398,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do end it 'shows running pipeline with the cancel action' do - expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]') end end @@ -418,7 +418,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do end it 'shows running pipeline with the cancel action' do - expect(page).to have_selector('.ci-status-icon-running') + expect(page).to have_selector('[data-testid="status_running_borderless-icon"]') expect(page).to have_selector('button[aria-label="Cancel downstream pipeline"]') end end @@ -438,7 +438,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do end it 'does not show the retry button' do - expect(page).to have_selector('.ci-status-icon-failed') + expect(page).to have_selector('[data-testid="status_failed_borderless-icon"]') expect(page).not_to have_selector('button[aria-label="Retry downstream pipeline"]') end end @@ -537,7 +537,7 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do it 'shows running status in pipeline header', :sidekiq_might_not_need_inline do within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end end end @@ -782,8 +782,8 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do expect(page).to have_content('Cancel pipeline') end - it 'does not link to job', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/408215' do - expect(page).not_to have_selector('.js-pipeline-graph-job-link') + it 'does link to job' do + expect(page).to have_selector('.js-pipeline-graph-job-link') end end end @@ -900,18 +900,18 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do subject within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Pending') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Pending') end within('.js-pipeline-graph') do within(all('[data-testid="stage-column"]')[0]) do expect(page).to have_content('test') - expect(page).to have_css('.ci-status-icon-pending') + expect(page).to have_css('[data-testid="status_pending_borderless-icon"]') end within(all('[data-testid="stage-column"]')[1]) do expect(page).to have_content('deploy') - expect(page).to have_css('.ci-status-icon-created') + expect(page).to have_css('[data-testid="status_created_borderless-icon"]') end end end @@ -925,18 +925,18 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do subject within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end within('.js-pipeline-graph') do within(all('[data-testid="stage-column"]')[0]) do expect(page).to have_content('test') - expect(page).to have_css('.ci-status-icon-success') + expect(page).to have_css('[data-testid="status_success_borderless-icon"]') end within(all('[data-testid="stage-column"]')[1]) do expect(page).to have_content('deploy') - expect(page).to have_css('.ci-status-icon-pending') + expect(page).to have_css('[data-testid="status_pending_borderless-icon"]') end end end @@ -954,13 +954,13 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do subject within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Waiting') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Waiting') end within('.js-pipeline-graph') do within(all('[data-testid="stage-column"]')[1]) do expect(page).to have_content('deploy') - expect(page).to have_css('.ci-status-icon-waiting-for-resource') + expect(page).to have_css('[data-testid="status_pending_borderless-icon"]') end end end @@ -974,13 +974,13 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do subject within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end within('.js-pipeline-graph') do within(all('[data-testid="stage-column"]')[1]) do expect(page).to have_content('deploy') - expect(page).to have_css('.ci-status-icon-pending') + expect(page).to have_css('[data-testid="status_pending_borderless-icon"]') end end end @@ -1002,13 +1002,13 @@ RSpec.describe 'Pipeline', :js, feature_category: :continuous_integration do subject within('[data-testid="pipeline-details-header"]') do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Waiting') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Waiting') end within('.js-pipeline-graph') do within(all('[data-testid="stage-column"]')[1]) do expect(page).to have_content('deploy') - expect(page).to have_css('.ci-status-icon-waiting-for-resource') + expect(page).to have_css('[data-testid="status_pending_borderless-icon"]') end end end diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index ca3b7f0ad47..30d3303dfbb 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -11,7 +11,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do let(:expected_detached_mr_tag) { 'merge request' } context 'when user is logged in' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in(user) @@ -115,7 +115,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do it 'indicates that pipeline can be canceled' do expect(page).to have_selector('.js-pipelines-cancel-button') - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end context 'when canceling' do @@ -127,7 +127,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do it 'indicated that pipelines was canceled', :sidekiq_might_not_need_inline do expect(page).not_to have_selector('.js-pipelines-cancel-button') - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Canceled') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Canceled') end end end @@ -144,7 +144,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do it 'indicates that pipeline can be retried' do expect(page).to have_selector('.js-pipelines-retry-button') - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Failed') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Failed') end context 'when retrying' do @@ -155,7 +155,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do it 'shows running pipeline that is not retryable' do expect(page).not_to have_selector('.js-pipelines-retry-button') - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end end end @@ -183,7 +183,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do within '.pipeline-tags' do expect(page).to have_content(expected_detached_mr_tag) - expect(page).to have_link(merge_request.iid, href: project_merge_request_path(project, merge_request)) + expect(page).to have_link(merge_request.iid.to_s, href: project_merge_request_path(project, merge_request)) expect(page).not_to have_link(pipeline.ref) end @@ -223,7 +223,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do within '.pipeline-tags' do expect(page).not_to have_content(expected_detached_mr_tag) - expect(page).to have_link(merge_request.iid, href: project_merge_request_path(project, merge_request)) + expect(page).to have_link(merge_request.iid.to_s, href: project_merge_request_path(project, merge_request)) expect(page).not_to have_link(pipeline.ref) end @@ -396,7 +396,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do end it 'shows the pipeline as preparing' do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Preparing') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Preparing') end end @@ -417,7 +417,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do end it 'has pipeline running' do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Running') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Running') end context 'when canceling' do @@ -428,7 +428,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do it 'indicates that pipeline was canceled', :sidekiq_might_not_need_inline do expect(page).not_to have_selector('.js-pipelines-cancel-button') - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Canceled') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Canceled') end end end @@ -450,7 +450,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do end it 'has failed pipeline', :sidekiq_might_not_need_inline do - expect(page).to have_selector('[data-testid="ci-badge-link"]', text: 'Failed') + expect(page).to have_selector('[data-testid="ci-icon"]', text: 'Failed') end end end @@ -650,7 +650,7 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do # header expect(page).to have_text("##{pipeline.id}") - expect(page).to have_link(pipeline.user.name, href: user_path(pipeline.user)) + expect(page).to have_link(pipeline.user.name, href: /#{user_path(pipeline.user)}$/) # stages expect(page).to have_text('build') @@ -805,29 +805,12 @@ RSpec.describe 'Pipelines', :js, feature_category: :continuous_integration do describe 'Empty State' do let(:project) { create(:project, :repository) } - context 'when `ios_specific_templates` is not enabled' do - before do - visit project_pipelines_path(project) - end - - it 'renders empty state' do - expect(page).to have_content 'Try test template' - end + before do + visit project_pipelines_path(project) end - describe 'when the `ios_specific_templates` experiment is enabled and the "Set up a runner" button is clicked' do - before do - stub_experiments(ios_specific_templates: :candidate) - project.project_setting.update!(target_platforms: %w[ios]) - visit project_pipelines_path(project) - click_button 'Set up a runner' - end - - it 'displays a modal with the macOS platform selected and an explanation popover' do - expect(page).to have_button 'macOS', class: 'selected' - expect(page).to have_selector('#runner-instructions-modal___BV_modal_content_') - expect(page).to have_selector('.popover') - end + it 'renders empty state' do + expect(page).to have_content 'Try test template' end end end diff --git a/spec/features/projects/releases/user_creates_release_spec.rb b/spec/features/projects/releases/user_creates_release_spec.rb index 678c8df666f..319053ddcb5 100644 --- a/spec/features/projects/releases/user_creates_release_spec.rb +++ b/spec/features/projects/releases/user_creates_release_spec.rb @@ -148,8 +148,7 @@ RSpec.describe 'User creates release', :js, feature_category: :continuous_delive fill_release_title(release_title) - select_milestone(milestone_1.title) - select_milestone(milestone_2.title) + select_milestones(milestone_1.title, milestone_2.title) fill_release_notes(release_notes) diff --git a/spec/features/projects/releases/user_views_edit_release_spec.rb b/spec/features/projects/releases/user_views_edit_release_spec.rb index b3f21a2d328..203b4ce82e3 100644 --- a/spec/features/projects/releases/user_views_edit_release_spec.rb +++ b/spec/features/projects/releases/user_views_edit_release_spec.rb @@ -20,8 +20,8 @@ RSpec.describe 'User edits Release', :js, feature_category: :continuous_delivery end def fill_out_form_and_click(button_to_click) - fill_in 'Release title', with: 'Updated Release title' - fill_in 'Release notes', with: 'Updated Release notes' + fill_in 'release-title', with: 'Updated Release title', fill_options: { clear: :backspace } + fill_in 'release-notes', with: 'Updated Release notes' click_link_or_button button_to_click @@ -44,8 +44,8 @@ RSpec.describe 'User edits Release', :js, feature_category: :continuous_delivery expect(page).to have_content('Releases are based on Git tags. We recommend tags that use semantic versioning, for example 1.0.0, 2.1.0-pre.') expect(find_field('Tag name', disabled: true).value).to eq(release.tag) - expect(find_field('Release title').value).to eq(release.name) - expect(find_field('Release notes').value).to eq(release.description) + expect(find_field('release-title').value).to eq(release.name) + expect(find_field('release-notes').value).to eq(release.description) expect(page).to have_button('Save changes') expect(page).to have_link('Cancel') diff --git a/spec/features/projects/settings/monitor_settings_spec.rb b/spec/features/projects/settings/monitor_settings_spec.rb index c2914c020e3..fca10d9c0b0 100644 --- a/spec/features/projects/settings/monitor_settings_spec.rb +++ b/spec/features/projects/settings/monitor_settings_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Projects > Settings > For a forked project', :js, feature_category: :groups_and_projects do include ListboxHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, create_templates: :issue, namespace: user.namespace) } before do @@ -15,13 +15,10 @@ RSpec.describe 'Projects > Settings > For a forked project', :js, feature_catego describe 'Sidebar > Monitor' do it 'renders the menu in the sidebar' do visit project_path(project) - wait_for_requests - expect(page).to have_selector( - '.sidebar-sub-level-items a[aria-label="Error Tracking"]', - text: 'Error Tracking', - visible: :hidden - ) + within_testid('super-sidebar') do + expect(page).to have_link('Error Tracking', visible: :hidden) + end end end diff --git a/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb b/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb index ee54065fdf8..1b53a6222e6 100644 --- a/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb +++ b/spec/features/projects/settings/registry_settings_cleanup_tags_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy', feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) } let(:container_registry_enabled) { true } @@ -24,9 +24,10 @@ RSpec.describe 'Project > Settings > Packages and registries > Container registr it 'shows active tab on sidebar' do subject - expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings') - expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)')) - .to have_content('Packages and registries') + within_testid('super-sidebar') do + expect(page).to have_selector('button[aria-expanded="true"]', text: 'Settings') + expect(page).to have_selector('[aria-current="page"]', text: 'Packages and registries') + end end it 'shows available section' do @@ -44,7 +45,7 @@ RSpec.describe 'Project > Settings > Packages and registries > Container registr wait_for_requests expect(page).to be_axe_clean.within('[data-testid="container-expiration-policy-project-settings"]') - .skipping :'link-in-text-block' + .skipping :'link-in-text-block', :'heading-order' end it 'saves cleanup policy submit the form' do diff --git a/spec/features/projects/settings/registry_settings_spec.rb b/spec/features/projects/settings/registry_settings_spec.rb index 7f0367f47f7..d6e08628721 100644 --- a/spec/features/projects/settings/registry_settings_spec.rb +++ b/spec/features/projects/settings/registry_settings_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Project > Settings > Packages and registries > Container registry tag expiration policy', feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project, reload: true) { create(:project, namespace: user.namespace) } let(:container_registry_enabled) { true } @@ -27,15 +27,16 @@ RSpec.describe 'Project > Settings > Packages and registries > Container registr wait_for_requests expect(page).to be_axe_clean.within('[data-testid="packages-and-registries-project-settings"]') - .skipping :'link-in-text-block' + .skipping :'link-in-text-block', :'heading-order' end it 'shows active tab on sidebar' do subject - expect(find('.sidebar-top-level-items > li.active')).to have_content('Settings') - expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)')) - .to have_content('Packages and registries') + within_testid('super-sidebar') do + expect(page).to have_selector('button[aria-expanded="true"]', text: 'Settings') + expect(page).to have_selector('[aria-current="page"]', text: 'Packages and registries') + end end it 'shows available section' do diff --git a/spec/features/projects/show/user_sees_collaboration_links_spec.rb b/spec/features/projects/show/user_sees_collaboration_links_spec.rb index 626d4de7baf..f231b4a591a 100644 --- a/spec/features/projects/show/user_sees_collaboration_links_spec.rb +++ b/spec/features/projects/show/user_sees_collaboration_links_spec.rb @@ -6,14 +6,14 @@ RSpec.describe 'Projects > Show > Collaboration links', :js, feature_category: : using RSpec::Parameterized::TableSyntax let_it_be(:project) { create(:project, :repository, :public) } - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } before do sign_in(user) end def find_new_menu_toggle - find('#js-onboarding-new-project-link') + find('[data-testid="base-dropdown-toggle"]', text: 'Create new...') end context 'with developer user' do @@ -25,7 +25,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js, feature_category: : visit project_path(project) # The navigation bar - page.within('.header-new') do + within_testid('super-sidebar') do find_new_menu_toggle.click aggregate_failures 'dropdown links in the navigation bar' do @@ -60,7 +60,7 @@ RSpec.describe 'Projects > Show > Collaboration links', :js, feature_category: : visit project_path(project) - page.within('.header-new') do + within_testid('super-sidebar') do find_new_menu_toggle.click aggregate_failures 'dropdown links' do diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb index 12018b4b9d7..e5836739c57 100644 --- a/spec/features/projects/snippets/show_spec.rb +++ b/spec/features/projects/snippets/show_spec.rb @@ -3,35 +3,62 @@ require 'spec_helper' RSpec.describe 'Projects > Snippets > Project snippet', :js, feature_category: :source_code_management do - let_it_be(:user) { create(:user) } + let_it_be(:author) { create(:author) } let_it_be(:project) do - create(:project, creator: user).tap do |p| - p.add_maintainer(user) + create(:project, :public, creator: author).tap do |p| + p.add_maintainer(author) end end - let_it_be(:snippet) { create(:project_snippet, :repository, project: project, author: user) } + let_it_be(:snippet) { create(:project_snippet, :public, :repository, project: project, author: author) } + let(:anchor) { nil } + let(:file_path) { 'files/ruby/popen.rb' } + + def visit_page + visit project_snippet_path(project, snippet, anchor: anchor) + end before do - sign_in(user) + # rubocop: disable RSpec/AnyInstanceOf -- TODO: The usage of let_it_be forces us + allow_any_instance_of(Snippet).to receive(:blobs) + .and_return([snippet.repository.blob_at('master', file_path)]) + # rubocop: enable RSpec/AnyInstanceOf end - it_behaves_like 'show and render proper snippet blob' do - let(:anchor) { nil } + context 'when signed in' do + before do + sign_in(user) + visit_page + end - subject do - visit project_snippet_path(project, snippet, anchor: anchor) + context 'as project member' do + let(:user) { author } - wait_for_requests + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does show New Snippet button' end - end - # it_behaves_like 'showing user status' do - # This will be handled in https://gitlab.com/gitlab-org/gitlab/-/issues/262394 + context 'as external user' do + let_it_be(:user) { create(:user, :external) } + + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does not show New Snippet button' + end - it_behaves_like 'does not show New Snippet button' do - let(:file_path) { 'files/ruby/popen.rb' } + context 'as another user' do + let_it_be(:user) { create(:user) } + + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does not show New Snippet button' + end + end + + context 'when unauthenticated' do + before do + visit_page + end - subject { visit project_snippet_path(project, snippet) } + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does not show New Snippet button' end end diff --git a/spec/features/projects/tree/tree_show_spec.rb b/spec/features/projects/tree/tree_show_spec.rb index 3becc48d450..4a913d82a78 100644 --- a/spec/features/projects/tree/tree_show_spec.rb +++ b/spec/features/projects/tree/tree_show_spec.rb @@ -21,6 +21,15 @@ RSpec.describe 'Projects tree', :js, feature_category: :web_ide do sign_in(user) end + it 'passes axe automated accessibility testing' do + visit project_tree_path(project, test_sha) + wait_for_requests + + expect(page).to be_axe_clean.within('.project-last-commit') + expect(page).to be_axe_clean.within('.nav-block') + expect(page).to be_axe_clean.within('.tree-content-holder').skipping :'link-in-text-block' + end + it 'renders tree table without errors' do visit project_tree_path(project, test_sha) wait_for_requests @@ -111,9 +120,16 @@ RSpec.describe 'Projects tree', :js, feature_category: :web_ide do end context 'LFS' do - it 'renders LFS badge on blob item' do + before do visit project_tree_path(project, File.join('master', 'files/lfs')) + wait_for_requests + end + it 'passes axe automated accessibility testing' do + expect(page).to be_axe_clean.within('.tree-content-holder').skipping :'link-in-text-block' + end + + it 'renders LFS badge on blob item' do expect(page).to have_selector('[data-testid="label-lfs"]', text: 'LFS') end end diff --git a/spec/features/projects/user_sees_sidebar_spec.rb b/spec/features/projects/user_sees_sidebar_spec.rb index 22d00e9a351..61225b45760 100644 --- a/spec/features/projects/user_sees_sidebar_spec.rb +++ b/spec/features/projects/user_sees_sidebar_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' -RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } +RSpec.describe 'Projects > User sees sidebar', :js, feature_category: :groups_and_projects do + let(:user) { create(:user) } let(:project) { create(:project, :private, public_builds: false, namespace: user.namespace) } # NOTE: See documented behaviour https://design.gitlab.com/regions/navigation#contextual-navigation @@ -14,44 +14,25 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro sign_in(user) end - shared_examples 'has a expanded nav sidebar' do - it 'has a expanded desktop nav-sidebar on load' do - expect(page).to have_content('Collapse sidebar') - expect(page).not_to have_selector('.sidebar-collapsed-desktop') - expect(page).not_to have_selector('.sidebar-expanded-mobile') + shared_examples 'has an expanded nav sidebar' do + it 'has an expanded nav sidebar on load' do + expect(page).to have_selector('[data-testid="super-sidebar-collapse-button"]', visible: :visible) end - it 'can collapse the nav-sidebar' do - page.find('.nav-sidebar .js-toggle-sidebar').click - expect(page).to have_selector('.sidebar-collapsed-desktop') - expect(page).not_to have_content('Collapse sidebar') - expect(page).not_to have_selector('.sidebar-expanded-mobile') + it 'can collapse the nav sidebar' do + find_by_testid('super-sidebar-collapse-button').click + expect(page).to have_selector('[data-testid="super-sidebar-collapse-button"]', visible: :hidden) end end shared_examples 'has a collapsed nav sidebar' do - it 'has a collapsed desktop nav-sidebar on load' do - expect(page).not_to have_content('Collapse sidebar') - expect(page).not_to have_selector('.sidebar-expanded-mobile') + it 'has a collapsed nav sidebar on load' do + expect(page).to have_selector('[data-testid="super-sidebar-collapse-button"]', visible: :hidden) end - it 'can expand the nav-sidebar' do - page.find('.nav-sidebar .js-toggle-sidebar').click - expect(page).to have_selector('.sidebar-expanded-mobile') - expect(page).to have_content('Collapse sidebar') - end - end - - shared_examples 'has a mobile nav-sidebar' do - it 'has a hidden nav-sidebar on load' do - expect(page).not_to have_content('.mobile-nav-open') - expect(page).not_to have_selector('.sidebar-expanded-mobile') - end - - it 'can expand the nav-sidebar' do - page.find('.toggle-mobile-nav').click - expect(page).to have_selector('.mobile-nav-open') - expect(page).to have_selector('.sidebar-expanded-mobile') + it 'can expand the nav sidebar' do + page.find('.js-super-sidebar-toggle-expand').click + expect(page).to have_selector('[data-testid="super-sidebar-collapse-button"]', visible: :visible) end end @@ -59,29 +40,24 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro before do resize_screen_xs visit project_path(project) - expect(page).to have_selector('.nav-sidebar') - expect(page).to have_selector('.toggle-mobile-nav') end - it_behaves_like 'has a mobile nav-sidebar' + it_behaves_like 'has a collapsed nav sidebar' end context 'with a small size viewport' do before do resize_screen_sm visit project_path(project) - expect(page).to have_selector('.nav-sidebar') - expect(page).to have_selector('.toggle-mobile-nav') end - it_behaves_like 'has a mobile nav-sidebar' + it_behaves_like 'has a collapsed nav sidebar' end context 'with medium size viewport' do before do resize_window(768, 800) visit project_path(project) - expect(page).to have_selector('.nav-sidebar') end it_behaves_like 'has a collapsed nav sidebar' @@ -91,7 +67,6 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro before do resize_window(1199, 800) visit project_path(project) - expect(page).to have_selector('.nav-sidebar') end it_behaves_like 'has a collapsed nav sidebar' @@ -101,10 +76,9 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro before do resize_window(1200, 800) visit project_path(project) - expect(page).to have_selector('.nav-sidebar') end - it_behaves_like 'has a expanded nav sidebar' + it_behaves_like 'has an expanded nav sidebar' end end @@ -121,8 +95,8 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro it 'does not display a "Snippets" link' do visit project_path(project) - within('.nav-sidebar') do - expect(page).not_to have_content 'Snippets' + within_testid('super-sidebar') do + expect(page).not_to have_button 'Code' end end end @@ -182,7 +156,7 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro end context 'as guest' do - let(:guest) { create(:user, :no_super_sidebar) } + let(:guest) { create(:user) } let!(:issue) { create(:issue, :opened, project: project, author: guest) } before do @@ -194,15 +168,19 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro it 'shows allowed tabs only' do visit project_path(project) - within('.nav-sidebar') do - expect(page).to have_content 'Project' - expect(page).to have_content 'Issues' - expect(page).to have_content 'Wiki' - expect(page).to have_content 'Monitor' + within_testid('super-sidebar') do + expect(page).to have_button 'Pinned' + expect(page).to have_button 'Manage' + expect(page).to have_button 'Plan' + expect(page).to have_button 'Code' + expect(page).to have_button 'Monitor' + expect(page).to have_button 'Analyze' + + expect(page).not_to have_button 'Build' - expect(page).not_to have_content 'Repository' - expect(page).not_to have_content 'CI/CD' - expect(page).not_to have_content 'Merge Requests' + click_button 'Code' + expect(page).not_to have_link 'Repository' + expect(page).not_to have_link 'Merge requests' end end @@ -212,8 +190,8 @@ RSpec.describe 'Projects > User sees sidebar', feature_category: :groups_and_pro visit project_path(project) - within('.nav-sidebar') do - expect(page).to have_content 'CI/CD' + within_testid('super-sidebar') do + expect(page).to have_button 'Build' end end diff --git a/spec/features/projects/user_uses_shortcuts_spec.rb b/spec/features/projects/user_uses_shortcuts_spec.rb index b7b2093d78a..a000c9e1da8 100644 --- a/spec/features/projects/user_uses_shortcuts_spec.rb +++ b/spec/features/projects/user_uses_shortcuts_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } before do @@ -21,14 +21,14 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('o') - expect(page).to have_active_navigation(project.name) + expect(page).to have_active_sub_navigation(project.name) end it 'redirects to the activity page' do find('body').native.send_key('g') find('body').native.send_key('v') - expect(page).to have_active_navigation('Project') + expect(page).to have_active_navigation('Manage') expect(page).to have_active_sub_navigation('Activity') end end @@ -38,31 +38,39 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('f') - expect(page).to have_active_navigation('Repository') - expect(page).to have_active_sub_navigation('Files') + expect(page).to have_active_navigation('Code') + expect(page).to have_active_sub_navigation('Repository') end - it 'redirects to the repository commits page' do - find('body').native.send_key('g') - find('body').native.send_key('c') + context 'when hitting the commits controller' do + # Hitting the commits controller with the super sidebar enabled seems to trigger more SQL + # queries, exceeding the 100 limit. We need to increase the limit a bit for these tests to pass. + before do + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(110) + end + + it 'redirects to the repository commits page' do + find('body').native.send_key('g') + find('body').native.send_key('c') - expect(page).to have_active_navigation('Repository') - expect(page).to have_active_sub_navigation('Commits') + expect(page).to have_active_navigation('Code') + expect(page).to have_active_sub_navigation('Commits') + end end it 'redirects to the repository graph page' do find('body').native.send_key('g') find('body').native.send_key('n') - expect(page).to have_active_navigation('Repository') - expect(page).to have_active_sub_navigation('Graph') + expect(page).to have_active_navigation('Code') + expect(page).to have_active_sub_navigation('Repository graph') end it 'redirects to the repository charts page' do find('body').native.send_key('g') find('body').native.send_key('d') - expect(page).to have_active_navigation(_('Analytics')) + expect(page).to have_active_navigation(_('Analyze')) expect(page).to have_active_sub_navigation(_('Repository')) end end @@ -72,16 +80,16 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('i') - expect(page).to have_active_navigation('Issues') - expect(page).to have_active_sub_navigation('List') + expect(page).to have_active_navigation('Pinned') + expect(page).to have_active_sub_navigation('Issues') end it 'redirects to the issue board page' do find('body').native.send_key('g') find('body').native.send_key('b') - expect(page).to have_active_navigation('Issues') - expect(page).to have_active_sub_navigation('Board') + expect(page).to have_active_navigation('Plan') + expect(page).to have_active_sub_navigation('Issue boards') end it 'redirects to the new issue page' do @@ -97,7 +105,8 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('m') - expect(page).to have_active_navigation('Merge requests') + expect(page).to have_active_navigation('Pinned') + expect(page).to have_active_sub_navigation('Merge requests') end end @@ -106,7 +115,7 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('p') - expect(page).to have_active_navigation('CI/CD') + expect(page).to have_active_navigation('Build') expect(page).to have_active_sub_navigation('Pipelines') end @@ -114,7 +123,7 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('j') - expect(page).to have_active_navigation('CI/CD') + expect(page).to have_active_navigation('Build') expect(page).to have_active_sub_navigation('Jobs') end end @@ -124,7 +133,7 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('e') - expect(page).to have_active_navigation('Deployments') + expect(page).to have_active_navigation('Operate') expect(page).to have_active_sub_navigation('Environments') end end @@ -134,7 +143,7 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('k') - expect(page).to have_active_navigation('Infrastructure') + expect(page).to have_active_navigation('Operate') expect(page).to have_active_sub_navigation('Kubernetes') end end @@ -144,7 +153,8 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('s') - expect(page).to have_active_navigation('Snippets') + expect(page).to have_active_navigation('Code') + expect(page).to have_active_sub_navigation('Snippets') end end @@ -153,7 +163,8 @@ RSpec.describe 'User uses shortcuts', :js, feature_category: :groups_and_project find('body').native.send_key('g') find('body').native.send_key('w') - expect(page).to have_active_navigation('Wiki') + expect(page).to have_active_navigation('Plan') + expect(page).to have_active_sub_navigation('Wiki') end end end diff --git a/spec/features/projects/wikis_spec.rb b/spec/features/projects/wikis_spec.rb index 63714954c0c..5d950da6674 100644 --- a/spec/features/projects/wikis_spec.rb +++ b/spec/features/projects/wikis_spec.rb @@ -3,7 +3,7 @@ require "spec_helper" RSpec.describe 'Project wikis', :js, feature_category: :wiki do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let(:wiki) { create(:project_wiki, user: user, project: project) } let(:project) { create(:project, namespace: user.namespace, creator: user) } diff --git a/spec/features/projects/work_items/linked_work_items_spec.rb b/spec/features/projects/work_items/linked_work_items_spec.rb index 66016cf8b7b..49f723c3055 100644 --- a/spec/features/projects/work_items/linked_work_items_spec.rb +++ b/spec/features/projects/work_items/linked_work_items_spec.rb @@ -102,8 +102,8 @@ RSpec.describe 'Work item linked items', :js, feature_category: :team_planning d expect(find('.work-items-list')).to have_content('Task 1') - find_by_testid('links-menu').click - click_button 'Remove' + find_by_testid('links-child').hover + find_by_testid('remove-work-item-link').click wait_for_all_requests diff --git a/spec/features/projects/work_items/work_item_children_spec.rb b/spec/features/projects/work_items/work_item_children_spec.rb index 843afb54dec..752ea282fbf 100644 --- a/spec/features/projects/work_items/work_item_children_spec.rb +++ b/spec/features/projects/work_items/work_item_children_spec.rb @@ -87,8 +87,8 @@ RSpec.describe 'Work item children', :js, feature_category: :team_planning do expect(find('[data-testid="links-child"]')).to have_content('Task 1') expect(find('[data-testid="children-count"]')).to have_content('1') - find('[data-testid="links-menu"]').click - click_button 'Remove' + find_by_testid('links-child').hover + find_by_testid('remove-work-item-link').click wait_for_all_requests diff --git a/spec/features/projects/work_items/work_item_spec.rb b/spec/features/projects/work_items/work_item_spec.rb index 5210d67b78c..33153d21575 100644 --- a/spec/features/projects/work_items/work_item_spec.rb +++ b/spec/features/projects/work_items/work_item_spec.rb @@ -3,11 +3,14 @@ require 'spec_helper' RSpec.describe 'Work item', :js, feature_category: :team_planning do - let_it_be_with_reload(:user) { create(:user, :no_super_sidebar) } - let_it_be_with_reload(:user2) { create(:user, :no_super_sidebar, name: 'John') } + include ListboxHelpers + + let_it_be_with_reload(:user) { create(:user) } + let_it_be_with_reload(:user2) { create(:user, name: 'John') } let_it_be(:project) { create(:project, :public) } let_it_be(:work_item) { create(:work_item, project: project) } + 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) } @@ -18,9 +21,7 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do context 'for signed in user' do before do project.add_developer(user) - sign_in(user) - visit work_items_path end @@ -37,7 +38,7 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do end it 'actions dropdown is displayed' do - expect(page).to have_selector('[data-testid="work-item-actions-dropdown"]') + expect(page).to have_button _('More actions') end it 'reassigns to another user', @@ -74,9 +75,7 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do context 'for signed in owner' do before do project.add_owner(user) - sign_in(user) - visit work_items_path end @@ -86,29 +85,37 @@ RSpec.describe 'Work item', :js, feature_category: :team_planning do context 'for guest users' do before do project.add_guest(user) - sign_in(user) - visit work_items_path end it_behaves_like 'work items comment actions for guest users' end + context 'when item is a task' do + before do + project.add_developer(user) + + sign_in(user) + + visit project_work_item_path(project, task.iid) + end + + it_behaves_like 'work items parent', :issue + end + context 'for user not signed in' do before do visit work_items_path end it 'todos action is not displayed' do - expect(page).not_to have_selector('[data-testid="work-item-todos-action"]') + expect(page).not_to have_button s_('WorkItem|Add a to do') end it 'award button is disabled and add reaction is not displayed' do - within('[data-testid="work-item-award-list"]') do - expect(page).not_to have_selector('[data-testid="emoji-picker"]') - expect(page).to have_selector('[data-testid="award-button"].disabled') - end + expect(page).not_to have_button _('Add reaction') + expect(page).to have_selector('[data-testid="award-button"].disabled') end it 'assignees input field is disabled' do diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 7ca9395f669..c6966e47f0a 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -7,7 +7,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do include MobileHelpers describe 'template' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in user @@ -78,7 +78,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'shows tip about push to create git command' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in user @@ -214,7 +214,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'showing information about source of a project fork', :js do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:base_project) { create(:project, :public, :repository) } let(:forked_project) { fork_project(base_project, user, repository: true) } @@ -265,7 +265,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'when the project repository is disabled', :js do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, :repository_disabled, :repository, namespace: user.namespace) } before do @@ -282,7 +282,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'removal', :js do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace) } before do @@ -307,7 +307,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'tree view (default view is set to Files)', :js do - let(:user) { create(:user, :no_super_sidebar, project_view: 'files') } + let(:user) { create(:user, project_view: 'files') } let(:project) { create(:forked_project_with_submodules) } before do @@ -379,7 +379,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'activity view' do - let(:user) { create(:user, :no_super_sidebar, project_view: 'activity') } + let(:user) { create(:user, project_view: 'activity') } let(:project) { create(:project, :repository) } before do @@ -410,7 +410,7 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do end describe 'edit' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, :public) } let(:path) { edit_project_path(project) } @@ -425,9 +425,9 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do describe 'view for a user without an access to a repo' do let(:project) { create(:project, :repository) } - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } - it 'does not contain default branch information in its content' do + it 'does not contain default branch information in its content', :js do default_branch = 'merge-commit-analyze-side-branch' project.add_guest(user) @@ -436,8 +436,10 @@ RSpec.describe 'Project', feature_category: :groups_and_projects do sign_in(user) visit project_path(project) - lines_with_default_branch = page.html.lines.select { |line| line.include?(default_branch) } - expect(lines_with_default_branch).to eq([]) + page.within('#content-body') do + lines_with_default_branch = page.html.lines.select { |line| line.include?(default_branch) } + expect(lines_with_default_branch).to eq([]) + end end end diff --git a/spec/features/search/user_searches_for_code_spec.rb b/spec/features/search/user_searches_for_code_spec.rb index d2847203669..976324a5032 100644 --- a/spec/features/search/user_searches_for_code_spec.rb +++ b/spec/features/search/user_searches_for_code_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'User searches for code', :js, :disable_rate_limiter, feature_cat using RSpec::Parameterized::TableSyntax include ListboxHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be_with_reload(:project) { create(:project, :repository, namespace: user.namespace) } context 'when signed in' do diff --git a/spec/features/search/user_searches_for_comments_spec.rb b/spec/features/search/user_searches_for_comments_spec.rb index f47e692c652..f7af1797c71 100644 --- a/spec/features/search/user_searches_for_comments_spec.rb +++ b/spec/features/search/user_searches_for_comments_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'User searches for comments', :js, :disable_rate_limiter, feature_category: :global_search do let_it_be(:project) { create(:project, :repository) } - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } before do project.add_reporter(user) diff --git a/spec/features/search/user_searches_for_commits_spec.rb b/spec/features/search/user_searches_for_commits_spec.rb index 140d8763813..724daf9277d 100644 --- a/spec/features/search/user_searches_for_commits_spec.rb +++ b/spec/features/search/user_searches_for_commits_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User searches for commits', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository) } let(:sha) { '6d394385cf567f80a8fd85055db1ab4c5295806f' } diff --git a/spec/features/search/user_searches_for_issues_spec.rb b/spec/features/search/user_searches_for_issues_spec.rb index d816b393cce..9451e337db1 100644 --- a/spec/features/search/user_searches_for_issues_spec.rb +++ b/spec/features/search/user_searches_for_issues_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User searches for issues', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: user.namespace) } let!(:issue1) { create(:issue, title: 'issue Foo', project: project, created_at: 1.hour.ago) } diff --git a/spec/features/search/user_searches_for_merge_requests_spec.rb b/spec/features/search/user_searches_for_merge_requests_spec.rb index 61af5e86eea..d7b52d9e07a 100644 --- a/spec/features/search/user_searches_for_merge_requests_spec.rb +++ b/spec/features/search/user_searches_for_merge_requests_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User searches for merge requests', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: user.namespace) } let_it_be(:merge_request1) { create(:merge_request, title: 'Merge Request Foo', source_project: project, target_project: project, created_at: 1.hour.ago) } let_it_be(:merge_request2) { create(:merge_request, :simple, title: 'Merge Request Bar', source_project: project, target_project: project) } diff --git a/spec/features/search/user_searches_for_milestones_spec.rb b/spec/features/search/user_searches_for_milestones_spec.rb index ad62c8eb3da..7ca7958f61b 100644 --- a/spec/features/search/user_searches_for_milestones_spec.rb +++ b/spec/features/search/user_searches_for_milestones_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'User searches for milestones', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, namespace: user.namespace) } let_it_be(:milestone1) { create(:milestone, title: 'Foo', project: project) } let_it_be(:milestone2) { create(:milestone, title: 'Bar', project: project) } diff --git a/spec/features/search/user_searches_for_projects_spec.rb b/spec/features/search/user_searches_for_projects_spec.rb index 51e5ad85e2b..48a94161927 100644 --- a/spec/features/search/user_searches_for_projects_spec.rb +++ b/spec/features/search/user_searches_for_projects_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'User searches for projects', :js, :disable_rate_limiter, feature context 'when signed out' do context 'when block_anonymous_global_searches is disabled' do before do - stub_feature_flags(block_anonymous_global_searches: false, super_sidebar_logged_out: false) + stub_feature_flags(block_anonymous_global_searches: false) end include_examples 'top right search form' diff --git a/spec/features/search/user_searches_for_users_spec.rb b/spec/features/search/user_searches_for_users_spec.rb index b52f6aeba68..e0a07c5103d 100644 --- a/spec/features/search/user_searches_for_users_spec.rb +++ b/spec/features/search/user_searches_for_users_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' RSpec.describe 'User searches for users', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - let_it_be(:user1) { create(:user, :no_super_sidebar, username: 'gob_bluth', name: 'Gob Bluth') } - let_it_be(:user2) { create(:user, :no_super_sidebar, username: 'michael_bluth', name: 'Michael Bluth') } - let_it_be(:user3) { create(:user, :no_super_sidebar, username: 'gob_2018', name: 'George Oscar Bluth') } + let_it_be(:user1) { create(:user, username: 'gob_bluth', name: 'Gob Bluth') } + let_it_be(:user2) { create(:user, username: 'michael_bluth', name: 'Michael Bluth') } + let_it_be(:user3) { create(:user, username: 'gob_2018', name: 'George Oscar Bluth') } before do sign_in(user1) diff --git a/spec/features/search/user_searches_for_wiki_pages_spec.rb b/spec/features/search/user_searches_for_wiki_pages_spec.rb index a5b63243d0b..65f262075f9 100644 --- a/spec/features/search/user_searches_for_wiki_pages_spec.rb +++ b/spec/features/search/user_searches_for_wiki_pages_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'User searches for wiki pages', :js, :clean_gitlab_redis_rate_limiting, feature_category: :global_search do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) } let_it_be(:wiki_page) do create(:wiki_page, wiki: project.wiki, title: 'directory/title', content: 'Some Wiki content') diff --git a/spec/features/search/user_uses_header_search_field_spec.rb b/spec/features/search/user_uses_header_search_field_spec.rb index 3f2a71b63dc..1ab47f6fd59 100644 --- a/spec/features/search/user_uses_header_search_field_spec.rb +++ b/spec/features/search/user_uses_header_search_field_spec.rb @@ -6,8 +6,8 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat include FilteredSearchHelpers let_it_be(:project) { create(:project, :repository) } - let_it_be(:reporter) { create(:user, :no_super_sidebar) } - let_it_be(:developer) { create(:user, :no_super_sidebar) } + let_it_be(:reporter) { create(:user) } + let_it_be(:developer) { create(:user) } let(:user) { reporter } @@ -31,12 +31,6 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat submit_search('gitlab') end - it 'renders page title' do - page.within('.page-title') do - expect(page).to have_content('Search') - end - end - it 'renders breadcrumbs' do page.within('.breadcrumbs') do expect(page).to have_content('Search') @@ -46,31 +40,34 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat context 'when using the keyboard shortcut' do before do - find('#search') find('body').native.send_keys('s') - wait_for_all_requests end - it 'shows the category search dropdown', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/250285' do - expect(page).to have_selector('.dropdown-header', text: /#{scope_name}/i) + it 'shows the search modal' do + expect(page).to have_selector(search_modal_results, visible: :visible) end end - context 'when clicking the search field' do + context 'when clicking the search button' do before do - page.find('#search').click + within_testid('super-sidebar') do + click_button "Search or go to…" + end wait_for_all_requests end - it 'shows category search dropdown', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/250285' do - expect(page).to have_selector('.dropdown-header', text: /#{scope_name}/i) + it 'shows search scope badge' do + fill_in 'search', with: 'text' + within('#super-sidebar-search-modal') do + expect(page).to have_selector('.search-scope-help', text: scope_name) + end end context 'when clicking issues', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/332317' do let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) } it 'shows assigned issues' do - find('[data-testid="header-search-dropdown-menu"]').click_link('Issues assigned to me') + find(search_modal_results).click_link('Issues assigned to me') expect(page).to have_selector('.issues-list .issue') expect_tokens([assignee_token(user.name)]) @@ -78,7 +75,7 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat end it 'shows created issues' do - find('[data-testid="header-search-dropdown-menu"]').click_link("Issues I've created") + find(search_modal_results).click_link("Issues I've created") expect(page).to have_selector('.issues-list .issue') expect_tokens([author_token(user.name)]) @@ -90,7 +87,7 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignees: [user]) } it 'shows assigned merge requests' do - find('[data-testid="header-search-dropdown-menu"]').click_link('Merge requests assigned to me') + find(search_modal_results).click_link('Merge requests assigned to me') expect(page).to have_selector('.mr-list .merge-request') expect_tokens([assignee_token(user.name)]) @@ -98,7 +95,7 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat end it 'shows created merge requests' do - find('[data-testid="header-search-dropdown-menu"]').click_link("Merge requests I've created") + find(search_modal_results).click_link("Merge requests I've created") expect(page).to have_selector('.mr-list .merge-request') expect_tokens([author_token(user.name)]) @@ -119,7 +116,7 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat context 'when user is in a global scope' do include_examples 'search field examples' do let(:url) { root_path } - let(:scope_name) { 'All GitLab' } + let(:scope_name) { 'in all GitLab' } end it 'displays search options', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/251076' do @@ -136,11 +133,13 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat end it 'displays result counts for all categories' do - expect(page).to have_content('Projects 1') - expect(page).to have_content('Issues 1') - expect(page).to have_content('Merge requests 0') - expect(page).to have_content('Milestones 0') - expect(page).to have_content('Users 0') + within_testid('super-sidebar') do + expect(page).to have_link('Projects 1') + expect(page).to have_link('Issues 1') + expect(page).to have_link('Merge requests 0') + expect(page).to have_link('Milestones 0') + expect(page).to have_link('Users 0') + end end end end @@ -162,9 +161,8 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat it 'displays search options' do fill_in_search('test') - expect(page).to have_selector(scoped_search_link('test', search_code: true)) expect(page).to have_selector(scoped_search_link('test', group_id: group.id, search_code: true)) - expect(page).to have_selector(scoped_search_link('test', project_id: project.id, group_id: group.id, search_code: true)) + expect(page).to have_selector(scoped_search_link('test', search_code: true)) end end @@ -176,26 +174,25 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat it 'displays search options' do fill_in_search('test') - sleep 0.5 - expect(page).to have_selector(scoped_search_link('test', search_code: true, repository_ref: 'master')) + expect(page).not_to have_selector(scoped_search_link('test', search_code: true, group_id: project.namespace_id, repository_ref: 'master')) - expect(page).to have_selector(scoped_search_link('test', search_code: true, project_id: project.id, repository_ref: 'master')) + expect(page).to have_selector(scoped_search_link('test', search_code: true, repository_ref: 'master')) end it 'displays a link to project merge requests' do fill_in_search('Merge') - within(dashboard_search_options_popup_menu) do - expect(page).to have_text('Merge requests') + within(search_modal_results) do + expect(page).to have_link('Merge requests') end end it 'does not display a link to project feature flags' do fill_in_search('Feature') - within(dashboard_search_options_popup_menu) do - expect(page).to have_text('Feature in all GitLab') - expect(page).to have_no_text('Feature Flags') + within(search_modal_results) do + expect(page).to have_link('in all GitLab Feature') + expect(page).not_to have_link('Feature Flags') end end @@ -205,8 +202,8 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat it 'displays a link to project feature flags' do fill_in_search('Feature') - within(dashboard_search_options_popup_menu) do - expect(page).to have_text('Feature Flags') + within(search_modal_results) do + expect(page).to have_link('Feature Flags') end end end @@ -228,8 +225,8 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat it 'displays search options' do fill_in_search('test') + expect(page).to have_selector(scoped_search_link('test')) - expect(page).to have_selector(scoped_search_link('test', group_id: group.id)) expect(page).not_to have_selector(scoped_search_link('test', project_id: project.id)) end end @@ -253,7 +250,6 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat fill_in_search('test') expect(page).to have_selector(scoped_search_link('test')) - expect(page).to have_selector(scoped_search_link('test', group_id: subgroup.id)) expect(page).not_to have_selector(scoped_search_link('test', project_id: project.id)) end end @@ -268,10 +264,10 @@ RSpec.describe 'User uses header search field', :js, :disable_rate_limiter, feat href.concat("&search_code=true") if search_code href.concat("&repository_ref=#{repository_ref}") if repository_ref - "[data-testid='header-search-dropdown-menu'] a[href='#{href}']" + ".global-search-results a[href='#{href}']" end - def dashboard_search_options_popup_menu - "[data-testid='header-search-dropdown-menu'] .header-search-dropdown-content" + def search_modal_results + ".global-search-results" end end diff --git a/spec/features/snippets/search_snippets_spec.rb b/spec/features/snippets/search_snippets_spec.rb index 7a07299a14f..cf6f9825932 100644 --- a/spec/features/snippets/search_snippets_spec.rb +++ b/spec/features/snippets/search_snippets_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Search Snippets', :js, feature_category: :global_search do it 'user searches for snippets by title' do - user = create(:user, :no_super_sidebar) + user = create(:user) public_snippet = create(:personal_snippet, :public, title: 'Beginning and Middle') private_snippet = create(:personal_snippet, :private, title: 'Middle and End', author: user) diff --git a/spec/features/snippets/show_spec.rb b/spec/features/snippets/show_spec.rb index bbb120edb80..03f46ea0122 100644 --- a/spec/features/snippets/show_spec.rb +++ b/spec/features/snippets/show_spec.rb @@ -3,49 +3,63 @@ require 'spec_helper' RSpec.describe 'Snippet', :js, feature_category: :source_code_management do - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:snippet) { create(:personal_snippet, :public, :repository, author: user) } + let_it_be(:owner) { create(:user) } + let_it_be(:snippet) { create(:personal_snippet, :public, :repository, author: owner) } + let(:anchor) { nil } + let(:file_path) { 'files/ruby/popen.rb' } before do - stub_feature_flags(super_sidebar_logged_out: false) + # rubocop: disable RSpec/AnyInstanceOf -- TODO: The usage of let_it_be forces us + allow_any_instance_of(Snippet).to receive(:blobs) + .and_return([snippet.repository.blob_at('master', file_path)]) + # rubocop: enable RSpec/AnyInstanceOf end - it_behaves_like 'show and render proper snippet blob' do - let(:anchor) { nil } - - subject do - visit snippet_path(snippet, anchor: anchor) + def visit_page + visit snippet_path(snippet, anchor: anchor) + end - wait_for_requests + context 'when signed in' do + before do + sign_in(user) + visit_page end - end - # it_behaves_like 'showing user status' do - # This will be handled in https://gitlab.com/gitlab-org/gitlab/-/issues/262394 + context 'as the snippet owner' do + let(:user) { owner } - it_behaves_like 'does not show New Snippet button' do - let(:file_path) { 'files/ruby/popen.rb' } + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does show New Snippet button' + it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets + end - subject { visit snippet_path(snippet) } - end + context 'as external user' do + let_it_be(:user) { create(:user, :external) } - it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does not show New Snippet button' + it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets + end - context 'when unauthenticated' do - it 'shows the "Explore" sidebar' do - visit snippet_path(snippet) + context 'as another user' do + let_it_be(:user) { create(:user) } - expect(page).to have_css('aside.nav-sidebar[aria-label="Explore"]') + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does show New Snippet button' + it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets end end - context 'when authenticated as a different user' do - let_it_be(:different_user) { create(:user, :no_super_sidebar) } - + context 'when unauthenticated' do before do - sign_in(different_user) + visit_page end - it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets + it_behaves_like 'show and render proper snippet blob' + it_behaves_like 'does not show New Snippet button' + + it 'shows the "Explore" sidebar' do + expect(page).to have_css('#super-sidebar-context-header', text: 'Explore') + end end end diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb index 341cc150a64..f1f804786a3 100644 --- a/spec/features/snippets/user_creates_snippet_spec.rb +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'User creates snippet', :js, feature_category: :source_code_manag include DropzoneHelper include Features::SnippetSpecHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let(:title) { 'My Snippet Title' } let(:file_content) { 'Hello World!' } diff --git a/spec/features/task_lists_spec.rb b/spec/features/task_lists_spec.rb index 24d63cadf00..c1be2b8e3c7 100644 --- a/spec/features/task_lists_spec.rb +++ b/spec/features/task_lists_spec.rb @@ -6,8 +6,8 @@ RSpec.describe 'Task Lists', :js, feature_category: :team_planning do include Warden::Test::Helpers let_it_be(:project) { create(:project, :public, :repository) } - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:user2) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } let(:markdown) do <<-MARKDOWN.strip_heredoc @@ -44,7 +44,7 @@ RSpec.describe 'Task Lists', :js, feature_category: :team_planning do end before do - login_as(user) + sign_in(user) end def visit_issue(project, issue) diff --git a/spec/features/unsubscribe_links_spec.rb b/spec/features/unsubscribe_links_spec.rb index b78efa65888..77ef3df97f6 100644 --- a/spec/features/unsubscribe_links_spec.rb +++ b/spec/features/unsubscribe_links_spec.rb @@ -6,8 +6,8 @@ RSpec.describe 'Unsubscribe links', :sidekiq_inline, feature_category: :shared d include Warden::Test::Helpers let_it_be(:project) { create(:project, :public) } - let_it_be(:author) { create(:user, :no_super_sidebar).tap { |u| project.add_reporter(u) } } - let_it_be(:recipient) { create(:user, :no_super_sidebar) } + let_it_be(:author) { create(:user).tap { |u| project.add_reporter(u) } } + let_it_be(:recipient) { create(:user) } let(:params) { { title: 'A bug!', description: 'Fix it!', assignee_ids: [recipient.id] } } let(:issue) { Issues::CreateService.new(container: project, current_user: author, params: params).execute[:issue] } @@ -22,10 +22,6 @@ RSpec.describe 'Unsubscribe links', :sidekiq_inline, feature_category: :shared d end context 'when logged out' do - before do - stub_feature_flags(super_sidebar_logged_out: false) - end - context 'when visiting the link from the body' do it 'shows the unsubscribe confirmation page and redirects to root path when confirming' do visit body_link diff --git a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb index 5de544e866e..83eb7cb989e 100644 --- a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb +++ b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User uploads avatar to profile', feature_category: :user_profile do - let!(:user) { create(:user, :no_super_sidebar) } + let!(:user) { create(:user) } let(:avatar_file_path) { Rails.root.join('spec', 'fixtures', 'dk.png') } shared_examples 'upload avatar' do @@ -19,8 +19,7 @@ RSpec.describe 'User uploads avatar to profile', feature_category: :user_profile wait_for_all_requests data_uri = find('.avatar-image .gl-avatar')['src'] - expect(page.find('.header-user-avatar')['src']).to eq data_uri - expect(page.find('[data-testid="sidebar-user-avatar"]')['src']).to eq data_uri + within_testid('user-dropdown') { expect(find('.gl-avatar')['src']).to eq data_uri } visit profile_path diff --git a/spec/features/usage_stats_consent_spec.rb b/spec/features/usage_stats_consent_spec.rb index 92f7a944007..ebf1cd9e143 100644 --- a/spec/features/usage_stats_consent_spec.rb +++ b/spec/features/usage_stats_consent_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe 'Usage stats consent', feature_category: :service_ping do context 'when signed in' do - let(:user) { create(:admin, :no_super_sidebar, created_at: 8.days.ago) } + let(:user) { create(:admin, created_at: 8.days.ago) } let(:message) { 'To help improve GitLab, we would like to periodically collect usage information.' } before do @@ -22,24 +22,29 @@ RSpec.describe 'Usage stats consent', feature_category: :service_ping do gitlab_enable_admin_mode_sign_in(user) end - it 'hides the banner permanently when sets usage stats' do - visit root_dashboard_path + shared_examples 'dismissible banner' do |button_text| + it 'hides the banner permanently when sets usage stats', :js do + visit root_dashboard_path - expect(page).to have_content(message) + expect(page).to have_content(message) - click_link 'Send service data' + click_link button_text - expect(page).not_to have_content(message) - expect(page).to have_content('Application settings saved successfully') + expect(page).not_to have_content(message) + expect(page).to have_content('Application settings saved successfully') - gitlab_sign_out - gitlab_sign_in(user) - visit root_dashboard_path + gitlab_sign_out + gitlab_sign_in(user) + visit root_dashboard_path - expect(page).not_to have_content(message) + expect(page).not_to have_content(message) + end end - it 'shows banner on next session if user did not set usage stats' do + it_behaves_like 'dismissible banner', _('Send service data') + it_behaves_like 'dismissible banner', _("Don't send service data") + + it 'shows banner on next session if user did not set usage stats', :js do visit root_dashboard_path expect(page).to have_content(message) diff --git a/spec/features/user_can_display_performance_bar_spec.rb b/spec/features/user_can_display_performance_bar_spec.rb index caf13c4111b..a22418760aa 100644 --- a/spec/features/user_can_display_performance_bar_spec.rb +++ b/spec/features/user_can_display_performance_bar_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'User can display performance bar', :js, feature_category: :application_performance do +RSpec.describe 'User can display performance bar', :js, feature_category: :cloud_connector do shared_examples 'performance bar cannot be displayed' do it 'does not show the performance bar by default' do expect(page).not_to have_css('#js-peek') diff --git a/spec/features/user_sees_active_nav_items_spec.rb b/spec/features/user_sees_active_nav_items_spec.rb new file mode 100644 index 00000000000..966b8491374 --- /dev/null +++ b/spec/features/user_sees_active_nav_items_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'User sees correct active nav items in the super sidebar', :js, feature_category: :value_stream_management do + let_it_be(:current_user) { create(:user) } + + before do + sign_in(current_user) + end + + describe 'profile pages' do + context 'when visiting profile page' do + before do + visit profile_path + end + + it 'renders the side navigation with the correct submenu set as active' do + expect(page).to have_active_sub_navigation('Profile') + end + end + + context 'when visiting preferences page' do + before do + visit profile_preferences_path + end + + it 'renders the side navigation with the correct submenu set as active' do + expect(page).to have_active_sub_navigation('Preferences') + end + end + + context 'when visiting authentication logs' do + before do + visit audit_log_profile_path + end + + it 'renders the side navigation with the correct submenu set as active' do + expect(page).to have_active_sub_navigation('Authentication Log') + end + end + + context 'when visiting SSH keys page' do + before do + visit profile_keys_path + end + + it 'renders the side navigation with the correct submenu set as active' do + expect(page).to have_active_sub_navigation('SSH Keys') + end + end + + context 'when visiting account page' do + before do + visit profile_account_path + end + + it 'renders the side navigation with the correct submenu set as active' do + expect(page).to have_active_sub_navigation('Account') + end + end + end +end diff --git a/spec/features/user_sees_revert_modal_spec.rb b/spec/features/user_sees_revert_modal_spec.rb index fdeee6a2808..ebb84a0d87f 100644 --- a/spec/features/user_sees_revert_modal_spec.rb +++ b/spec/features/user_sees_revert_modal_spec.rb @@ -12,6 +12,8 @@ RSpec.describe 'Merge request > User sees revert modal', :js, :sidekiq_might_not it 'shows the revert modal' do click_button('Revert') + wait_for_requests + page.within('[data-testid="modal-commit"]') do expect(page).to have_content 'Revert this merge request' end @@ -19,7 +21,6 @@ RSpec.describe 'Merge request > User sees revert modal', :js, :sidekiq_might_not end before do - stub_feature_flags(unbatch_graphql_queries: false) sign_in(user) visit(project_merge_request_path(project, merge_request)) @@ -27,6 +28,10 @@ RSpec.describe 'Merge request > User sees revert modal', :js, :sidekiq_might_not click_button 'Merge' end + wait_for_all_requests + + page.refresh + wait_for_requests end diff --git a/spec/features/users/active_sessions_spec.rb b/spec/features/users/active_sessions_spec.rb index 663d2283dbd..8509a8d7356 100644 --- a/spec/features/users/active_sessions_spec.rb +++ b/spec/features/users/active_sessions_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' RSpec.describe 'Active user sessions', :clean_gitlab_redis_sessions, feature_category: :system_access do - it 'successful login adds a new active user login' do - user = create(:user, :no_super_sidebar) + it 'successful login adds a new active user login', :js do + user = create(:user) - now = Time.zone.parse('2018-03-12 09:06') + now = Time.zone.now.change(usec: 0) travel_to(now) do gitlab_sign_in(user) expect(page).to have_current_path root_path, ignore_query: true @@ -24,14 +24,14 @@ RSpec.describe 'Active user sessions', :clean_gitlab_redis_sessions, feature_cat sessions = ActiveSession.list(user) expect(sessions.first).to have_attributes( - created_at: Time.zone.parse('2018-03-12 09:06'), - updated_at: Time.zone.parse('2018-03-12 09:07') + created_at: now, + updated_at: now + 1.minute ) end end it 'successful login cleans up obsolete entries' do - user = create(:user, :no_super_sidebar) + user = create(:user) Gitlab::Redis::Sessions.with do |redis| redis.sadd?("session:lookup:user:gitlab:#{user.id}", '59822c7d9fcdfa03725eff41782ad97d') @@ -45,7 +45,7 @@ RSpec.describe 'Active user sessions', :clean_gitlab_redis_sessions, feature_cat end it 'sessionless login does not clean up obsolete entries' do - user = create(:user, :no_super_sidebar) + user = create(:user) personal_access_token = create(:personal_access_token, user: user) Gitlab::Redis::Sessions.with do |redis| @@ -60,8 +60,8 @@ RSpec.describe 'Active user sessions', :clean_gitlab_redis_sessions, feature_cat end end - it 'logout deletes the active user login' do - user = create(:user, :no_super_sidebar) + it 'logout deletes the active user login', :js do + user = create(:user) gitlab_sign_in(user) expect(page).to have_current_path root_path, ignore_query: true diff --git a/spec/features/users/anonymous_sessions_spec.rb b/spec/features/users/anonymous_sessions_spec.rb index 368f272ba23..81b18b7ca02 100644 --- a/spec/features/users/anonymous_sessions_spec.rb +++ b/spec/features/users/anonymous_sessions_spec.rb @@ -5,6 +5,10 @@ require 'spec_helper' RSpec.describe 'Session TTLs', :clean_gitlab_redis_shared_state, feature_category: :system_access do include SessionHelpers + before do + expire_session + end + it 'creates a session with a short TTL when login fails' do visit new_user_session_path # The session key only gets created after a post @@ -18,10 +22,10 @@ RSpec.describe 'Session TTLs', :clean_gitlab_redis_shared_state, feature_categor end it 'increases the TTL when the login succeeds' do - user = create(:user, :no_super_sidebar) + user = create(:user) gitlab_sign_in(user) - expect(page).to have_content(user.name) + expect(find('.js-super-sidebar')['data-sidebar']).to include(user.name) expect_single_session_with_authenticated_ttl end diff --git a/spec/features/users/email_verification_on_login_spec.rb b/spec/features/users/email_verification_on_login_spec.rb index d83040efd72..ad62af6ec69 100644 --- a/spec/features/users/email_verification_on_login_spec.rb +++ b/spec/features/users/email_verification_on_login_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting, :js, feature_category: :system_access do include EmailHelpers - let_it_be_with_reload(:user) { create(:user, :no_super_sidebar) } - let_it_be(:another_user) { create(:user, :no_super_sidebar) } + let_it_be_with_reload(:user) { create(:user) } + let_it_be(:another_user) { create(:user) } let_it_be(:new_email) { build_stubbed(:user).email } let(:require_email_verification_enabled) { user } @@ -220,7 +220,7 @@ RSpec.describe 'Email Verification On Login', :clean_gitlab_redis_rate_limiting, shared_examples 'no email verification required when 2fa enabled or ff disabled' do context 'when 2FA is enabled' do - let_it_be(:user) { create(:user, :no_super_sidebar, :two_factor) } + let_it_be(:user) { create(:user, :two_factor) } it_behaves_like 'no email verification required', two_factor_auth: true end diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb index 87afcbd416b..0f086af227c 100644 --- a/spec/features/users/login_spec.rb +++ b/spec/features/users/login_spec.rb @@ -16,7 +16,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ expect(authentication_metrics) .to increment(:user_authenticated_counter) - user = create(:user, :no_super_sidebar) + user = create(:user) expect(user.reset_password_token).to be_nil @@ -43,7 +43,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ # This behavior is dependent on there only being one user User.delete_all - user = create(:admin, :no_super_sidebar, password_automatically_set: true) + user = create(:admin, password_automatically_set: true) visit root_path expect(page).to have_current_path edit_user_password_path, ignore_query: true @@ -77,7 +77,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ .and increment(:user_unauthenticated_counter) .and increment(:user_session_destroyed_counter).twice - user = create(:user, :no_super_sidebar, :blocked) + user = create(:user, :blocked) gitlab_sign_in(user) @@ -90,14 +90,14 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ .and increment(:user_unauthenticated_counter) .and increment(:user_session_destroyed_counter).twice - user = create(:user, :no_super_sidebar, :blocked) + user = create(:user, :blocked) expect { gitlab_sign_in(user) }.not_to change { user.reload.sign_in_count } end end describe 'with an unconfirmed email address' do - let!(:user) { create(:user, :no_super_sidebar, confirmed_at: nil) } + let!(:user) { create(:user, confirmed_at: nil) } let(:grace_period) { 2.days } let(:alert_title) { 'Please confirm your email address' } let(:alert_message) { "To continue, you need to select the link in the confirmation email we sent to verify your email address. If you didn't get our email, select Resend confirmation email" } @@ -141,7 +141,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'when resending the confirmation email' do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } it 'redirects to the "almost there" page' do visit new_user_confirmation_path @@ -154,7 +154,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end describe 'with a disallowed password' do - let(:user) { create(:user, :no_super_sidebar, :disallowed_password) } + let(:user) { create(:user, :disallowed_password) } before do expect(authentication_metrics) @@ -295,7 +295,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ # Freeze time to prevent failures when time between code being entered and # validated greater than otp_allowed_drift context 'with valid username/password', :freeze_time do - let(:user) { create(:user, :no_super_sidebar, :two_factor) } + let(:user) { create(:user, :two_factor) } before do gitlab_sign_in(user, remember: true) @@ -372,13 +372,13 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'when user with TOTP enabled' do - let(:user) { create(:user, :no_super_sidebar, :two_factor) } + let(:user) { create(:user, :two_factor) } include_examples 'can login with recovery codes' end context 'when user with only Webauthn enabled' do - let(:user) { create(:user, :no_super_sidebar, :two_factor_via_webauthn, registrations_count: 1) } + let(:user) { create(:user, :two_factor_via_webauthn, registrations_count: 1) } include_examples 'can login with recovery codes', only_two_factor_webauthn_enabled: true end @@ -494,7 +494,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'with correct username and password' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } it 'allows basic login' do expect(authentication_metrics) @@ -584,7 +584,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'with correct username and invalid password' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } it 'blocks invalid login' do expect(authentication_metrics) @@ -601,7 +601,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end describe 'with required two-factor authentication enabled' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } # TODO: otp_grace_period_started_at @@ -639,7 +639,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'after the grace period' do - let(:user) { create(:user, :no_super_sidebar, otp_grace_period_started_at: 9999.hours.ago) } + let(:user) { create(:user, otp_grace_period_started_at: 9999.hours.ago) } it 'redirects to two-factor configuration page' do expect(authentication_metrics) @@ -728,7 +728,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'after the grace period' do - let(:user) { create(:user, :no_super_sidebar, otp_grace_period_started_at: 9999.hours.ago) } + let(:user) { create(:user, otp_grace_period_started_at: 9999.hours.ago) } it 'redirects to two-factor configuration page' do expect(authentication_metrics) @@ -919,7 +919,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'when terms are enforced', :js do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do enforce_terms @@ -1090,7 +1090,7 @@ RSpec.describe 'Login', :clean_gitlab_redis_sessions, feature_category: :system_ end context 'when sending confirmation email and not yet confirmed' do - let!(:user) { create(:user, :no_super_sidebar, confirmed_at: nil) } + let!(:user) { create(:user, confirmed_at: nil) } let(:grace_period) { 2.days } let(:alert_title) { 'Please confirm your email address' } let(:alert_message) { "To continue, you need to select the link in the confirmation email we sent to verify your email address. If you didn't get our email, select Resend confirmation email" } diff --git a/spec/features/users/logout_spec.rb b/spec/features/users/logout_spec.rb index d0e5be8dca3..c9839247e7d 100644 --- a/spec/features/users/logout_spec.rb +++ b/spec/features/users/logout_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Logout/Sign out', :js, feature_category: :system_access do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in(user) diff --git a/spec/features/users/overview_spec.rb b/spec/features/users/overview_spec.rb index d1ff60b6069..1da61ecb868 100644 --- a/spec/features/users/overview_spec.rb +++ b/spec/features/users/overview_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_profile do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:contributed_project) { create(:project, :public, :repository) } def push_code_contribution @@ -27,8 +27,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr shared_context 'visit overview tab' do before do visit user.username - page.find('.js-overview-tab a').click - wait_for_requests + click_nav user.name end end @@ -61,15 +60,15 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr end end - describe 'user has 11 activities' do + describe 'user has 15 activities' do before do - 11.times { push_code_contribution } + 16.times { push_code_contribution } end include_context 'visit overview tab' - it 'displays 10 entries in the list of activities' do - expect(find('#js-overview')).to have_selector('.event-item', count: 10) + it 'displays 15 entries in the list of activities' do + expect(find('#js-overview')).to have_selector('.event-item', count: 15) end it 'shows a link to the activity list' do @@ -158,8 +157,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr describe 'user has no followers' do before do visit user.username - page.find('.js-followers-tab a').click - wait_for_requests + click_nav 'Followers' end it 'shows an empty followers list with an info message' do @@ -177,8 +175,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr before do follower.follow(user) visit user.username - page.find('.js-followers-tab a').click - wait_for_requests + click_nav 'Followers' end it 'shows followers' do @@ -199,8 +196,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr end visit user.username - page.find('.js-followers-tab a').click - wait_for_requests + click_nav 'Followers' end it 'shows paginated followers' do page.within('#followers') do @@ -221,8 +217,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr describe 'user is not following others' do before do visit user.username - page.find('.js-following-tab a').click - wait_for_requests + click_nav 'Following' end it 'shows an empty following list with an info message' do @@ -240,8 +235,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr before do user.follow(followee) visit user.username - page.find('.js-following-tab a').click - wait_for_requests + click_nav 'Following' end it 'shows following user' do @@ -262,8 +256,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr end visit user.username - page.find('.js-following-tab a').click - wait_for_requests + click_nav 'Following' end it 'shows paginated following' do page.within('#following') do @@ -286,8 +279,7 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr shared_context "visit bot's overview tab" do before do visit bot_user.username - page.find('.js-overview-tab a').click - wait_for_requests + click_nav bot_user.name end end @@ -327,4 +319,13 @@ RSpec.describe 'Overview tab on a user profile', :js, feature_category: :user_pr end end end + + private + + def click_nav(title) + within_testid('super-sidebar') do + click_link title + end + wait_for_requests + end end diff --git a/spec/features/users/rss_spec.rb b/spec/features/users/rss_spec.rb index 99451ac472d..730c31df899 100644 --- a/spec/features/users/rss_spec.rb +++ b/spec/features/users/rss_spec.rb @@ -3,58 +3,35 @@ require 'spec_helper' RSpec.describe 'User RSS', feature_category: :user_profile do - let(:user) { create(:user, :no_super_sidebar) } - let(:path) { user_path(create(:user, :no_super_sidebar)) } + let(:user) { create(:user) } + let(:path) { user_path(create(:user)) } - describe 'with "user_profile_overflow_menu_vue" feature flag off' do + context 'when signed in' do before do - stub_feature_flags(user_profile_overflow_menu_vue: false) + sign_in(user) + visit path end - context 'when signed in' do - before do - sign_in(user) - visit path + it 'shows the RSS link with overflow menu', :js do + page.within('.user-cover-block') do + find_by_testid('base-dropdown-toggle').click end - it_behaves_like "it has an RSS button with current_user's feed token" - end - - context 'when signed out' do - before do - stub_feature_flags(super_sidebar_logged_out: false) - visit path - end - - it_behaves_like "it has an RSS button without a feed token" + expect(page).to have_link 'Subscribe', href: /feed_token=glft-.*-#{user.id}/ end end - describe 'with "user_profile_overflow_menu_vue" feature flag on', :js do - context 'when signed in' do - before do - sign_in(user) - visit path - end - - it 'shows the RSS link with overflow menu' do - find('[data-testid="base-dropdown-toggle"').click - - expect(page).to have_link 'Subscribe', href: /feed_token=glft-.*-#{user.id}/ - end + context 'when signed out' do + before do + visit path end - context 'when signed out' do - before do - stub_feature_flags(super_sidebar_logged_out: false) - visit path + it 'has an RSS without a feed token', :js do + page.within('.user-cover-block') do + find_by_testid('base-dropdown-toggle').click end - it 'has an RSS without a feed token' do - find('[data-testid="base-dropdown-toggle"').click - - expect(page).not_to have_link 'Subscribe', href: /feed_token=glft-.*-#{user.id}/ - end + expect(page).not_to have_link 'Subscribe', href: /feed_token=glft-.*-#{user.id}/ end end end diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index 522eb12f507..2821e8286a4 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -7,38 +7,16 @@ RSpec.describe 'User page', feature_category: :user_profile do let_it_be(:user) { create(:user, bio: '<b>Lorem</b> <i>ipsum</i> dolor sit <a href="https://example.com">amet</a>') } - before do - stub_feature_flags(super_sidebar_logged_out: false) - end - subject(:visit_profile) { visit(user_path(user)) } - context 'with "user_profile_overflow_menu_vue" feature flag enabled', :js do - it 'does not show the user id in the profile info' do - subject - - expect(page).not_to have_content("User ID: #{user.id}") - end - - it 'shows copy user id action in the dropdown' do - subject - - find('[data-testid="base-dropdown-toggle"').click - - expect(page).to have_content("Copy user ID: #{user.id}") - end - end + it 'shows copy user id action in the dropdown', :js do + subject - context 'with "user_profile_overflow_menu_vue" feature flag disabled', :js do - before do - stub_feature_flags(user_profile_overflow_menu_vue: false) + page.within('.user-cover-block') do + find_by_testid('base-dropdown-toggle').click end - it 'shows user id' do - subject - - expect(page).to have_content("User ID: #{user.id}") - end + expect(page).to have_content("Copy user ID: #{user.id}") end it 'shows name on breadcrumbs' do @@ -193,33 +171,37 @@ RSpec.describe 'User page', feature_category: :user_profile do expect(page).not_to have_button(text: 'Follow', class: 'gl-button') end - shared_examples 'follower tabs with count badges' do - it 'shows 0 followers and 0 following' do + shared_examples 'follower links with count badges' do + it 'shows no count if no followers / following' do subject - expect(page).to have_content('Followers 0') - expect(page).to have_content('Following 0') + within_testid('super-sidebar') do + expect(page).to have_link(text: 'Followers') + expect(page).to have_link(text: 'Following') + end end - it 'shows 1 followers and 1 following' do + it 'shows count if followers / following' do follower.follow(user) user.follow(followee) subject - expect(page).to have_content('Followers 1') - expect(page).to have_content('Following 1') + within_testid('super-sidebar') do + expect(page).to have_link(text: 'Followers 1') + expect(page).to have_link(text: 'Following 1') + end end end - it_behaves_like 'follower tabs with count badges' + it_behaves_like 'follower links with count badges' context 'with profile_tabs_vue feature flag disabled' do before_all do stub_feature_flags(profile_tabs_vue: false) end - it_behaves_like 'follower tabs with count badges' + it_behaves_like 'follower links with count badges' end it 'does show button to follow' do diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb index 968308938d1..d873c4846fd 100644 --- a/spec/features/users/signup_spec.rb +++ b/spec/features/users/signup_spec.rb @@ -54,7 +54,7 @@ RSpec.shared_examples 'Signup name validation' do |field, max_length, label| end end -RSpec.describe 'Signup', :js, feature_category: :user_profile do +RSpec.describe 'Signup', :js, feature_category: :user_management do include TermsHelper let(:new_user) { build_stubbed(:user) } diff --git a/spec/features/users/snippets_spec.rb b/spec/features/users/snippets_spec.rb index 98ac9fa5f92..3a56b371a8c 100644 --- a/spec/features/users/snippets_spec.rb +++ b/spec/features/users/snippets_spec.rb @@ -4,10 +4,10 @@ require 'spec_helper' RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_code_management do context 'when the user has snippets' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do - stub_feature_flags(profile_tabs_vue: false, super_sidebar_logged_out: false) + stub_feature_flags(profile_tabs_vue: false) end context 'pagination' do @@ -16,7 +16,7 @@ RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_ before do allow(Snippet).to receive(:default_per_page).and_return(1) visit user_path(user) - page.within('.user-profile-nav') { click_link 'Snippets' } + within_testid('super-sidebar') { click_link 'Snippets' } wait_for_requests end @@ -30,9 +30,9 @@ RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_ let!(:other_snippet) { create(:snippet, :public) } it 'contains only internal and public snippets of a user when a user is logged in' do - sign_in(create(:user, :no_super_sidebar)) + sign_in(create(:user)) visit user_path(user) - page.within('.user-profile-nav') { click_link 'Snippets' } + within_testid('super-sidebar') { click_link 'Snippets' } wait_for_requests expect(page).to have_selector('.snippet-row', count: 2) @@ -43,7 +43,7 @@ RSpec.describe 'Snippets tab on a user profile', :js, feature_category: :source_ it 'contains only public snippets of a user when a user is not logged in' do visit user_path(user) - page.within('.user-profile-nav') { click_link 'Snippets' } + within_testid('super-sidebar') { click_link 'Snippets' } wait_for_requests expect(page).to have_selector('.snippet-row', count: 1) diff --git a/spec/features/users/terms_spec.rb b/spec/features/users/terms_spec.rb index e51ed3a0e80..28191587572 100644 --- a/spec/features/users/terms_spec.rb +++ b/spec/features/users/terms_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Users > Terms', :js, feature_category: :user_profile do end context 'when user is a project bot' do - let(:project_bot) { create(:user, :no_super_sidebar, :project_bot) } + let(:project_bot) { create(:user, :project_bot) } before do enforce_terms @@ -42,7 +42,7 @@ RSpec.describe 'Users > Terms', :js, feature_category: :user_profile do end context 'when user is a service account' do - let(:service_account) { create(:user, :no_super_sidebar, :service_account) } + let(:service_account) { create(:user, :service_account) } before do enforce_terms @@ -57,7 +57,7 @@ RSpec.describe 'Users > Terms', :js, feature_category: :user_profile do end context 'when signed in' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do sign_in(user) @@ -115,7 +115,7 @@ RSpec.describe 'Users > Terms', :js, feature_category: :user_profile do # Application settings are cached for a minute travel_to 2.minutes.from_now do - within('.nav-sidebar') do + within('.contextual-nav') do click_link 'Issues' end diff --git a/spec/features/users/user_browses_projects_on_user_page_spec.rb b/spec/features/users/user_browses_projects_on_user_page_spec.rb index 5e047192e7b..039b1bbe5b1 100644 --- a/spec/features/users/user_browses_projects_on_user_page_spec.rb +++ b/spec/features/users/user_browses_projects_on_user_page_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Users > User browses projects on user page', :js, feature_category: :groups_and_projects do - let!(:user) { create(:user, :no_super_sidebar) } + let!(:user) { create(:user) } let!(:private_project) do create :project, :private, name: 'private', namespace: user.namespace do |project| project.add_maintainer(user) @@ -23,13 +23,13 @@ RSpec.describe 'Users > User browses projects on user page', :js, feature_catego end def click_nav_link(name) - page.within '.nav-links' do + within_testid('super-sidebar') do click_link name end end before do - stub_feature_flags(profile_tabs_vue: false, super_sidebar_logged_out: false) + stub_feature_flags(profile_tabs_vue: false) end it 'hides loading spinner after load', :js do @@ -87,7 +87,7 @@ RSpec.describe 'Users > User browses projects on user page', :js, feature_catego end context 'when signed in as another user' do - let(:another_user) { create(:user, :no_super_sidebar) } + let(:another_user) { create(:user) } before do sign_in(another_user) diff --git a/spec/features/webauthn_spec.rb b/spec/features/webauthn_spec.rb index 52e2b375187..72463a0b9ab 100644 --- a/spec/features/webauthn_spec.rb +++ b/spec/features/webauthn_spec.rb @@ -15,7 +15,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor # TODO: it_behaves_like 'hardware device for 2fa', 'WebAuthn' describe 'registration' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do gitlab_sign_in(user) @@ -58,7 +58,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor gitlab_sign_out # Second user - user = create(:user, :no_super_sidebar) + user = create(:user) gitlab_sign_in(user) visit profile_account_path enable_two_factor_authentication @@ -126,7 +126,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor it_behaves_like 'hardware device for 2fa', 'WebAuthn' describe 'registration' do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } before do gitlab_sign_in(user) @@ -161,7 +161,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor gitlab_sign_out # Second user - user = create(:user, :no_super_sidebar) + user = create(:user) gitlab_sign_in(user) user.update_attribute(:otp_required_for_login, true) visit profile_account_path @@ -227,7 +227,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor describe 'authentication' do let(:otp_required_for_login) { true } - let(:user) { create(:user, :no_super_sidebar, webauthn_xid: WebAuthn.generate_user_id, otp_required_for_login: otp_required_for_login) } + let(:user) { create(:user, webauthn_xid: WebAuthn.generate_user_id, otp_required_for_login: otp_required_for_login) } let!(:webauthn_device) do add_webauthn_device(app_id, user) end @@ -256,7 +256,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor describe 'when a given WebAuthn device has already been registered by another user' do describe 'but not the current user' do - let(:other_user) { create(:user, :no_super_sidebar, webauthn_xid: WebAuthn.generate_user_id, otp_required_for_login: otp_required_for_login) } + let(:other_user) { create(:user, webauthn_xid: WebAuthn.generate_user_id, otp_required_for_login: otp_required_for_login) } it 'does not allow logging in with that particular device' do # Register other user with a different WebAuthn device @@ -277,7 +277,7 @@ RSpec.describe 'Using WebAuthn Devices for Authentication', :js, feature_categor it "allows logging in with that particular device" do pending("support for passing credential options in FakeClient") # Register current user with the same WebAuthn device - current_user = create(:user, :no_super_sidebar) + current_user = create(:user) gitlab_sign_in(current_user) visit profile_account_path manage_two_factor_authentication diff --git a/spec/features/whats_new_spec.rb b/spec/features/whats_new_spec.rb index c8bcf5f6ef0..887994106b6 100644 --- a/spec/features/whats_new_spec.rb +++ b/spec/features/whats_new_spec.rb @@ -2,36 +2,28 @@ require "spec_helper" -RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboarding do - let_it_be(:user) { create(:user, :no_super_sidebar) } +RSpec.describe "renders a `whats new` dropdown item", :js, feature_category: :onboarding do + let_it_be(:user) { create(:user) } context 'when not logged in' do - before do - stub_feature_flags(super_sidebar_logged_out: false) - end - it 'and on SaaS it renders', :saas do visit user_path(user) - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } - expect(page).to have_button(text: "What's new") - end + expect(page).to have_button(text: "What's new") end it "doesn't render what's new" do visit user_path(user) - page.within '.header-help' do - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } - expect(page).not_to have_button(text: "What's new") - end + expect(page).not_to have_button(text: "What's new") end end - context 'when logged in', :js do + context 'when logged in' do before do sign_in(user) end @@ -40,7 +32,7 @@ RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboard Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:all_tiers]) visit root_dashboard_path - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } expect(page).to have_button(text: "What's new") end @@ -49,7 +41,7 @@ RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboard Gitlab::CurrentSettings.update!(whats_new_variant: ApplicationSetting.whats_new_variants[:disabled]) visit root_dashboard_path - find('.header-help-dropdown-toggle').click + within_testid('super-sidebar') { click_on 'Help' } expect(page).not_to have_button(text: "What's new") end @@ -57,24 +49,24 @@ RSpec.describe "renders a `whats new` dropdown item", feature_category: :onboard it 'shows notification dot and count and removes it once viewed' do visit root_dashboard_path - page.within '.header-help' do - expect(page).to have_selector('.notification-dot', visible: true) + within_testid('super-sidebar') do + click_on 'Help' + button = find_button(text: "What's new") - find('.header-help-dropdown-toggle').click + has_testid?('notification-dot', visible: true) + expect(button).to have_selector('.badge-pill') - expect(page).to have_button(text: "What's new") - expect(page).to have_selector('.js-whats-new-notification-count') - - find('button', text: "What's new").click + button.click end find('.whats-new-drawer .gl-drawer-close-button').click - find('.header-help-dropdown-toggle').click - page.within '.header-help' do - expect(page).not_to have_selector('.notification-dot', visible: true) - expect(page).to have_button(text: "What's new") - expect(page).not_to have_selector('.js-whats-new-notification-count') + within_testid('super-sidebar') do + click_on 'Help' + button = find_button(text: "What's new") + + has_testid?('notification-dot', visible: false) + expect(button).not_to have_selector('.badge-pill') end end end |