diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/features/projects | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/features/projects')
22 files changed, 249 insertions, 350 deletions
diff --git a/spec/features/projects/ci/lint_spec.rb b/spec/features/projects/ci/lint_spec.rb index 466c7ba215e..ccffe25f45e 100644 --- a/spec/features/projects/ci/lint_spec.rb +++ b/spec/features/projects/ci/lint_spec.rb @@ -34,7 +34,7 @@ RSpec.describe 'CI Lint', :js do end it 'parses Yaml and displays the jobs' do - expect(page).to have_content('Status: syntax is correct') + expect(page).to have_content('Status: Syntax is correct') within "table" do aggregate_failures do @@ -51,7 +51,7 @@ RSpec.describe 'CI Lint', :js do let(:yaml_content) { 'value: cannot have :' } it 'displays information about an error' do - expect(page).to have_content('Status: syntax is incorrect') + expect(page).to have_content('Status: Syntax is incorrect') expect(page).to have_selector(content_selector, text: yaml_content) end end diff --git a/spec/features/projects/commit/user_reverts_commit_spec.rb b/spec/features/projects/commit/user_reverts_commit_spec.rb index ca4e070703b..f3c364dab97 100644 --- a/spec/features/projects/commit/user_reverts_commit_spec.rb +++ b/spec/features/projects/commit/user_reverts_commit_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'User reverts a commit', :js do include RepoHelpers + let_it_be(:user) { create(:user) } let(:project) { create(:project, :repository, namespace: user.namespace) } - let(:user) { create(:user) } before do sign_in(user) @@ -14,49 +14,37 @@ RSpec.describe 'User reverts a commit', :js do visit(project_commit_path(project, sample_commit.id)) end - def click_revert + def revert_commit(create_merge_request: false) find('.header-action-buttons .dropdown').click - find('a[href="#modal-revert-commit"]').click - end + find('[data-testid="revert-commit-link"]').click - context 'without creating a new merge request' do - before do - click_revert - page.within('#modal-revert-commit') do - uncheck('create_merge_request') - click_button('Revert') - end + page.within('[data-testid="modal-commit"]') do + uncheck('create_merge_request') unless create_merge_request + click_button('Revert') end + end + context 'without creating a new merge request' do it 'reverts a commit' do + revert_commit + expect(page).to have_content('The commit has been successfully reverted.') end it 'does not revert a previously reverted commit' do + revert_commit # Visit the comment again once it was reverted. visit project_commit_path(project, sample_commit.id) - find('.header-action-buttons .dropdown').click - find('a[href="#modal-revert-commit"]').click - - page.within('#modal-revert-commit') do - uncheck('create_merge_request') - click_button('Revert') - end + revert_commit expect(page).to have_content('Sorry, we cannot revert this commit automatically.') end end context 'with creating a new merge request' do - before do - click_revert - end - it 'reverts a commit' do - page.within('#modal-revert-commit') do - click_button('Revert') - end + revert_commit(create_merge_request: true) expect(page).to have_content('The commit has been successfully reverted. You can now submit a merge request to get this change into the original branch.') expect(page).to have_content("From revert-#{Commit.truncate_sha(sample_commit.id)} into master") diff --git a/spec/features/projects/environments_pod_logs_spec.rb b/spec/features/projects/environments_pod_logs_spec.rb index c491cd62d85..eaef3e6ca28 100644 --- a/spec/features/projects/environments_pod_logs_spec.rb +++ b/spec/features/projects/environments_pod_logs_spec.rb @@ -17,6 +17,8 @@ RSpec.describe 'Environment > Pod Logs', :js, :kubeclient do stub_kubeclient_pods(environment.deployment_namespace) stub_kubeclient_logs(pod_name, environment.deployment_namespace, container: 'container-0') + stub_kubeclient_deployments(environment.deployment_namespace) + stub_kubeclient_ingresses(environment.deployment_namespace) stub_kubeclient_nodes_and_nodes_metrics(cluster.platform.api_url) sign_in(project.owner) diff --git a/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb b/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb index 750f4dc5ef4..f5941d0ff15 100644 --- a/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb +++ b/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb @@ -25,7 +25,6 @@ RSpec.describe 'User sees feature flag list', :js do create_flag(project, 'mr_train', true).tap do |feature_flag| create_scope(feature_flag, 'production', false) end - stub_feature_flags(feature_flags_legacy_read_only_override: false) end it 'user sees the first flag' do @@ -79,41 +78,6 @@ RSpec.describe 'User sees feature flag list', :js do expect_status_toggle_button_to_be_disabled end end - - context 'when legacy feature flags are not read-only' do - before do - stub_feature_flags(feature_flags_legacy_read_only: false) - end - - it 'user updates the status toggle' do - visit(project_feature_flags_path(project)) - - within_feature_flag_row(1) do - status_toggle_button.click - - expect_status_toggle_button_to_be_checked - end - end - end - - context 'when legacy feature flags are read-only but the override is active for a project' do - before do - stub_feature_flags( - feature_flags_legacy_read_only: true, - feature_flags_legacy_read_only_override: project - ) - end - - it 'user updates the status toggle' do - visit(project_feature_flags_path(project)) - - within_feature_flag_row(1) do - status_toggle_button.click - - expect_status_toggle_button_to_be_checked - end - end - end end context 'with new version flags' do diff --git a/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb b/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb index bc2d63e1953..a435e565ff1 100644 --- a/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb +++ b/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb @@ -14,8 +14,7 @@ RSpec.describe 'User updates feature flag', :js do before do stub_feature_flags( - feature_flag_permissions: false, - feature_flags_legacy_read_only_override: false + feature_flag_permissions: false ) sign_in(user) end @@ -79,117 +78,11 @@ RSpec.describe 'User updates feature flag', :js do let!(:scope) { create_scope(feature_flag, 'review/*', true) } - context 'when legacy flags are editable' do - before do - stub_feature_flags(feature_flags_legacy_read_only: false) - - visit(edit_project_feature_flag_path(project, feature_flag)) - end - - it 'user sees persisted default scope' do - within_scope_row(1) do - within_environment_spec do - expect(page).to have_content('* (All Environments)') - end - - within_status do - expect(find('.project-feature-toggle')['aria-label']) - .to eq('Toggle Status: ON') - end - end - end - - context 'when user updates the status of a scope' do - before do - within_scope_row(2) do - within_status { find('.project-feature-toggle').click } - end - - click_button 'Save changes' - expect(page).to have_current_path(project_feature_flags_path(project)) - end - - it 'shows the updated feature flag' do - within_feature_flag_row(1) do - expect(page.find('.feature-flag-name')).to have_content('ci_live_trace') - expect_status_toggle_button_to_be_checked - - within_feature_flag_scopes do - expect(page.find('.badge:nth-child(1)')).to have_content('*') - expect(page.find('.badge:nth-child(1)')['class']).to include('badge-info') - expect(page.find('.badge:nth-child(2)')).to have_content('review/*') - expect(page.find('.badge:nth-child(2)')['class']).to include('badge-muted') - end - end - end - end - - context 'when user adds a new scope' do - before do - within_scope_row(3) do - within_environment_spec do - find('.js-env-search > input').set('production') - find('.js-create-button').click - end - end - - click_button 'Save changes' - expect(page).to have_current_path(project_feature_flags_path(project)) - end - - it 'shows the newly created scope' do - within_feature_flag_row(1) do - within_feature_flag_scopes do - expect(page.find('.badge:nth-child(3)')).to have_content('production') - expect(page.find('.badge:nth-child(3)')['class']).to include('badge-muted') - end - end - end - end - - context 'when user deletes a scope' do - before do - within_scope_row(2) do - within_delete { find('.js-delete-scope').click } - end - - click_button 'Save changes' - expect(page).to have_current_path(project_feature_flags_path(project)) - end - - it 'shows the updated feature flag' do - within_feature_flag_row(1) do - within_feature_flag_scopes do - expect(page).to have_css('.badge:nth-child(1)') - expect(page).not_to have_css('.badge:nth-child(2)') - end - end - end - end - end - - context 'when legacy flags are read-only' do - it 'the user cannot edit the flag' do - visit(edit_project_feature_flag_path(project, feature_flag)) - - expect(page).to have_text 'This feature flag is read-only, and it will be removed in 14.0.' - expect(page).to have_css('button.js-ff-submit.disabled') - end - end - - context 'when legacy flags are read-only, but the override is active for one project' do - it 'the user can edit the flag' do - stub_feature_flags(feature_flags_legacy_read_only_override: project) - - visit(edit_project_feature_flag_path(project, feature_flag)) - status_toggle_button.click - click_button 'Save changes' + it 'the user cannot edit the flag' do + visit(edit_project_feature_flag_path(project, feature_flag)) - expect(page).to have_current_path(project_feature_flags_path(project)) - within_feature_flag_row(1) do - expect_status_toggle_button_not_to_be_checked - end - end + expect(page).to have_text 'This feature flag is read-only, and it will be removed in 14.0.' + expect(page).to have_css('button.js-ff-submit.disabled') end end end diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb index a99df8a79d8..17258f7042f 100644 --- a/spec/features/projects/files/dockerfile_dropdown_spec.rb +++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Projects > Files > User wants to add a Dockerfile file' do +RSpec.describe 'Projects > Files > User wants to add a Dockerfile file', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/297400' do before do project = create(:project, :repository) sign_in project.owner diff --git a/spec/features/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb new file mode 100644 index 00000000000..6308acb41f5 --- /dev/null +++ b/spec/features/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do + before do + project = create(:project, :repository) + sign_in project.owner + stub_experiment(ci_syntax_templates: experiment_active) + stub_experiment_for_subject(ci_syntax_templates: in_experiment_group) + + visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') + end + + context 'when experiment is not active' do + let(:experiment_active) { false } + let(:in_experiment_group) { false } + + it 'does not show the "Learn CI/CD syntax" template dropdown' do + expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector') + end + end + + context 'when experiment is active and the user is in the control group' do + let(:experiment_active) { true } + let(:in_experiment_group) { false } + + it 'does not show the "Learn CI/CD syntax" template dropdown' do + expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector') + end + end + + context 'when experiment is active and the user is in the experimental group' do + let(:experiment_active) { true } + let(:in_experiment_group) { true } + + it 'allows the user to pick a "Learn CI/CD syntax" template from the dropdown', :js, + { quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/297347' } } do + expect(page).to have_css('.gitlab-ci-syntax-yml-selector') + + find('.js-gitlab-ci-syntax-yml-selector').click + + wait_for_requests + + within '.gitlab-ci-syntax-yml-selector' do + find('.dropdown-input-field').set('Artifacts example') + find('.dropdown-content .is-focused', text: 'Artifacts example').click + end + + wait_for_requests + + expect(page).to have_css('.gitlab-ci-syntax-yml-selector .dropdown-toggle-text', text: 'Learn CI/CD syntax') + expect(page).to have_content('You can use artifacts to pass data to jobs in later stages.') + end + end +end diff --git a/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb b/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb index b5d5527bbfe..bfa7be5bb5c 100644 --- a/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb +++ b/spec/features/projects/issues/design_management/user_uploads_designs_spec.rb @@ -38,7 +38,7 @@ RSpec.describe 'User uploads new design', :js do let(:feature_enabled) { false } it 'shows the message about requirements' do - expect(page).to have_content("To upload designs, you'll need to enable LFS and have admin enable hashed storage.") + expect(page).to have_content("To upload designs, you'll need to enable LFS and have an admin enable hashed storage.") end end diff --git a/spec/features/projects/issues/email_participants_spec.rb b/spec/features/projects/issues/email_participants_spec.rb new file mode 100644 index 00000000000..3ffe0a5ced8 --- /dev/null +++ b/spec/features/projects/issues/email_participants_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'viewing an issue', :js do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :public) } + let_it_be(:issue) { create(:issue, project: project) } + let_it_be(:note) { create(:note_on_issue, project: project, noteable: issue) } + let_it_be(:participants) { create_list(:issue_email_participant, 4, issue: issue) } + + before do + sign_in(user) + visit project_issue_path(project, issue) + end + + shared_examples 'email participants warning' do |selector| + it 'shows the correct message' do + expect(find(selector)).to have_content(", and 1 more will be notified of your comment") + end + end + + context 'for a new note' do + it_behaves_like 'email participants warning', '.new-note' + end + + context 'for a reply form' do + before do + find('.js-reply-button').click + end + + it_behaves_like 'email participants warning', '.note-edit-form' + end +end diff --git a/spec/features/projects/jobs/permissions_spec.rb b/spec/features/projects/jobs/permissions_spec.rb index b1e8127c54c..e87880d74b1 100644 --- a/spec/features/projects/jobs/permissions_spec.rb +++ b/spec/features/projects/jobs/permissions_spec.rb @@ -179,34 +179,6 @@ RSpec.describe 'Project Jobs Permissions' do expect(status_code).to eq(expected_status_code) end end - - context 'when restrict_access_to_build_debug_mode feature not enabled' do - where(:public_builds, :user_project_role, :ci_debug_trace, :expected_status_code) do - true | 'developer' | true | 200 - true | 'guest' | true | 200 - true | 'developer' | false | 200 - true | 'guest' | false | 200 - false | 'developer' | true | 200 - false | 'guest' | true | 403 - false | 'developer' | false | 200 - false | 'guest' | false | 403 - end - - with_them do - before do - stub_feature_flags(restrict_access_to_build_debug_mode: false) - ci_instance_variable.update!(value: ci_debug_trace) - project.update!(public_builds: public_builds) - project.add_role(user, user_project_role) - end - - it 'renders trace to authorized users' do - visit trace_project_job_path(project, job) - - expect(status_code).to eq(expected_status_code) - end - end - end end describe 'raw page' do @@ -237,35 +209,6 @@ RSpec.describe 'Project Jobs Permissions' do expect(page).to have_content(expected_msg) end end - - context 'when restrict_access_to_build_debug_mode feature not enabled' do - where(:public_builds, :user_project_role, :ci_debug_trace, :expected_status_code, :expected_msg) do - true | 'developer' | true | 200 | nil - true | 'guest' | true | 200 | nil - true | 'developer' | false | 200 | nil - true | 'guest' | false | 200 | nil - false | 'developer' | true | 200 | nil - false | 'guest' | true | 403 | 'The current user is not authorized to access the job log' - false | 'developer' | false | 200 | nil - false | 'guest' | false | 403 | 'The current user is not authorized to access the job log' - end - - with_them do - before do - stub_feature_flags(restrict_access_to_build_debug_mode: false) - ci_instance_variable.update!(value: ci_debug_trace) - project.update!(public_builds: public_builds) - project.add_role(user, user_project_role) - end - - it 'renders raw trace to authorized users' do - visit raw_project_job_path(project, job) - - expect(status_code).to eq(expected_status_code) - expect(page).to have_content(expected_msg) - end - end - end 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 c768b0e281c..5abebf2320e 100644 --- a/spec/features/projects/jobs/user_browses_jobs_spec.rb +++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb @@ -26,7 +26,7 @@ RSpec.describe 'User browses jobs' do it 'shows the "CI Lint" button' do page.within('.nav-controls') do - ci_lint_tool_link = page.find_link('CI lint') + ci_lint_tool_link = page.find_link('CI Lint') expect(ci_lint_tool_link[:href]).to end_with(project_ci_lint_path(project)) end diff --git a/spec/features/projects/members/group_members_spec.rb b/spec/features/projects/members/group_members_spec.rb index 3060d2c6a43..aa15f04bf24 100644 --- a/spec/features/projects/members/group_members_spec.rb +++ b/spec/features/projects/members/group_members_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'Projects members' do +RSpec.describe 'Projects members', :js do let(:user) { create(:user) } let(:developer) { create(:user) } let(:group) { create(:group, :public) } @@ -66,62 +66,61 @@ RSpec.describe 'Projects members' do end end - context 'with a group and a project invitee' do + context 'with a group, a project invitee, and a project requester' do before do + group.request_access(group_requester) + project.request_access(project_requester) group_invitee project_invitee visit project_project_members_path(project) end - it 'shows the project invitee, the project developer, and the group owner' do + it 'shows the group owner' do page.within first('.content-list') do - expect(page).to have_content('test1@abc.com') - expect(page).not_to have_content('test2@abc.com') - - # Project developer - expect(page).to have_content(developer.name) - # Group owner expect(page).to have_content(user.name) expect(page).to have_content(group.name) end end - end - context 'with a group requester' do - before do - group.request_access(group_requester) - visit project_project_members_path(project) + it 'shows the project developer' do + page.within first('.content-list') do + # Project developer + expect(page).to have_content(developer.name) + end end - it 'does not appear in the project members page' do + it 'shows the project invitee' do + click_link 'Invited' + page.within first('.content-list') do + expect(page).to have_content('test1@abc.com') + expect(page).not_to have_content('test2@abc.com') + end + end + + it 'shows the project requester' do + click_link 'Access requests' + + page.within first('.content-list') do + expect(page).to have_content(project_requester.name) expect(page).not_to have_content(group_requester.name) end end end - context 'with a group and a project requesters' do + context 'with a group requester' do before do + stub_feature_flags(invite_members_group_modal: false) group.request_access(group_requester) - project.request_access(project_requester) visit project_project_members_path(project) end - it 'shows the project requester, the project developer, and the group owner' do + it 'does not appear in the project members page' do + expect(page).not_to have_link('Access requests') page.within first('.content-list') do - expect(page).to have_content(project_requester.name) expect(page).not_to have_content(group_requester.name) end - - page.within all('.content-list').last do - # Project developer - expect(page).to have_content(developer.name) - - # Group owner - expect(page).to have_content(user.name) - expect(page).to have_content(group.name) - end end end diff --git a/spec/features/projects/members/groups_with_access_list_spec.rb b/spec/features/projects/members/groups_with_access_list_spec.rb index d59f8eb4b1d..686d86b1783 100644 --- a/spec/features/projects/members/groups_with_access_list_spec.rb +++ b/spec/features/projects/members/groups_with_access_list_spec.rb @@ -16,6 +16,7 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do project.add_maintainer(user) sign_in(user) visit project_project_members_path(project) + click_groups_tab end it 'updates group access level' do @@ -29,6 +30,8 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do visit project_project_members_path(project) + click_groups_tab + expect(first('.group_member')).to have_content('Guest') end @@ -71,23 +74,31 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do expect(page).not_to have_selector('.group_member') end - context 'search in existing members (yes, this filters the groups list as well)' do + context 'search in existing members' do it 'finds no results' do page.within '.user-search-form' do - fill_in 'search', with: 'testing 123' + fill_in 'search_groups', with: 'testing 123' find('.user-search-btn').click end + click_groups_tab + expect(page).not_to have_selector('.group_member') end it 'finds results' do page.within '.user-search-form' do - fill_in 'search', with: group.name + fill_in 'search_groups', with: group.name find('.user-search-btn').click end + click_groups_tab + expect(page).to have_selector('.group_member', count: 1) end end + + def click_groups_tab + click_link 'Groups' + end end diff --git a/spec/features/projects/members/invite_group_spec.rb b/spec/features/projects/members/invite_group_spec.rb index 30e32ad1366..bb56ae348fb 100644 --- a/spec/features/projects/members/invite_group_spec.rb +++ b/spec/features/projects/members/invite_group_spec.rb @@ -39,7 +39,7 @@ RSpec.describe 'Project > Members > Invite group', :js do it 'the project can be shared with another group' do visit project_project_members_path(project) - expect(page).not_to have_css('.project-members-groups') + expect(page).not_to have_link 'Groups' click_on 'invite-group-tab' @@ -47,7 +47,9 @@ RSpec.describe 'Project > Members > Invite group', :js do page.find('body').click find('.btn-success').click - page.within('.project-members-groups') do + click_link 'Groups' + + page.within('[data-testid="project-member-groups"]') do expect(page).to have_content(group_to_share_with.name) end end @@ -132,7 +134,9 @@ RSpec.describe 'Project > Members > Invite group', :js do end it 'the group link shows the expiration time with a warning class' do - page.within('.project-members-groups') do + click_link 'Groups' + + page.within('[data-testid="project-member-groups"]') do # Using distance_of_time_in_words_to_now because it is not the same as # subtraction, and this way avoids time zone issues as well expires_in_text = distance_of_time_in_words_to_now(project.project_group_links.first.expires_at) diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb index 36ff461aac2..62115f2dce6 100644 --- a/spec/features/projects/members/list_spec.rb +++ b/spec/features/projects/members/list_spec.rb @@ -12,6 +12,7 @@ RSpec.describe 'Project members list' do let(:project) { create(:project, namespace: group) } before do + stub_feature_flags(invite_members_group_modal: false) sign_in(user1) group.add_owner(user1) end @@ -82,7 +83,9 @@ RSpec.describe 'Project members list' do add_user('test@example.com', 'Reporter') - page.within(second_row) do + click_link 'Invited' + + page.within(first_row) do expect(page).to have_content('test@example.com') expect(page).to have_content('Invited') expect(page).to have_button('Reporter') diff --git a/spec/features/projects/members/master_manages_access_requests_spec.rb b/spec/features/projects/members/master_manages_access_requests_spec.rb index 2fdc75dca91..4c3eaa93352 100644 --- a/spec/features/projects/members/master_manages_access_requests_spec.rb +++ b/spec/features/projects/members/master_manages_access_requests_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' RSpec.describe 'Projects > Members > Maintainer manages access requests' do it_behaves_like 'Maintainer manages access requests' do - let(:has_tabs) { false } let(:entity) { create(:project, :public) } let(:members_page_path) { project_project_members_path(entity) } end diff --git a/spec/features/projects/members/tabs_spec.rb b/spec/features/projects/members/tabs_spec.rb new file mode 100644 index 00000000000..bdcf02c82a4 --- /dev/null +++ b/spec/features/projects/members/tabs_spec.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Projects > Members > Tabs' do + using RSpec::Parameterized::TableSyntax + + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, creator: user, namespace: user.namespace) } + let_it_be(:group) { create(:group) } + let_it_be(:project_members) { create_list(:project_member, 2, project: project) } + let_it_be(:access_requests) { create_list(:project_member, 2, :access_request, project: project) } + let_it_be(:invites) { create_list(:project_member, 2, :invited, project: project) } + let_it_be(:project_group_links) { create_list(:project_group_link, 2, project: project) } + + shared_examples 'active "Members" tab' do + it 'displays "Members" tab' do + expect(page).to have_selector('.nav-link.active', text: 'Members') + end + end + + before do + allow(Kaminari.config).to receive(:default_per_page).and_return(1) + + sign_in(user) + visit project_project_members_path(project) + end + + where(:tab, :count) do + 'Members' | 3 + 'Invited' | 2 + 'Groups' | 2 + 'Access requests' | 2 + end + + with_them do + it "renders #{params[:tab]} tab" do + expect(page).to have_selector('.nav-link', text: "#{tab} #{count}") + end + end + + context 'displays "Members" tab by default' do + it_behaves_like 'active "Members" tab' + end + + context 'when searching "Groups"', :js do + before do + click_link 'Groups' + + page.within '[data-testid="group-link-search-form"]' do + fill_in 'search_groups', with: 'group' + find('button[type="submit"]').click + end + end + + it 'displays "Groups" tab' do + expect(page).to have_selector('.nav-link.active', text: 'Groups') + end + + context 'and then searching "Members"' do + before do + click_link 'Members 3' + + page.within '[data-testid="user-search-form"]' do + fill_in 'search', with: 'user' + find('button[type="submit"]').click + end + end + + it_behaves_like 'active "Members" tab' + 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 0a5f7cc7edd..2acdf983cf2 100644 --- a/spec/features/projects/releases/user_creates_release_spec.rb +++ b/spec/features/projects/releases/user_creates_release_spec.rb @@ -36,7 +36,7 @@ RSpec.describe 'User creates release', :js do expect(page.find('.ref-selector button')).to have_content(project.default_branch) end - context 'when the "Save release" button is clicked' do + context 'when the "Save release" button is clicked', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/297507' do let(:tag_name) { 'v1.0' } let(:release_title) { 'A most magnificent release' } let(:release_notes) { 'Best. Release. **Ever.** :rocket:' } diff --git a/spec/features/projects/services/user_activates_alerts_spec.rb b/spec/features/projects/services/user_activates_alerts_spec.rb deleted file mode 100644 index 8b0acdf3618..00000000000 --- a/spec/features/projects/services/user_activates_alerts_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'User activates Alerts', :js do - let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user) } - - let(:service_name) { 'alerts' } - let(:service_title) { 'Alerts endpoint' } - - before do - sign_in(user) - project.add_maintainer(user) - end - - context 'when service is deactivated' do - it 'user cannot activate service' do - visit_project_services - - expect(page).to have_link(service_title) - click_link(service_title) - - expect(page).to have_callout_message - expect(page).not_to have_active_service - expect(page).to have_toggle_active_disabled - end - end - - context 'when service is activated' do - let_it_be(:activated_alerts_service) do - create(:alerts_service, :active, project: project) - end - - before do - visit_alerts_service - end - - it 'user cannot change settings' do - expect(page).to have_callout_message - expect(page).to have_active_service - expect(page).to have_toggle_active_disabled - expect(page).to have_button_reset_key_disabled - end - end - - private - - def visit_project_services - visit(project_settings_integrations_path(project)) - end - - def visit_alerts_service - visit(edit_project_service_path(project, service_name)) - end - - def have_callout_message - within('.gl-alert') do - have_content('You can now manage alert endpoint configuration in the Alerts section on the Operations settings page.') - end - end - - def have_active_service - have_selector('.js-service-active-status[data-value="true"]') - end - - def have_toggle_active_disabled - have_selector('#activated .project-feature-toggle.is-disabled') - end - - def have_button_reset_key_disabled - have_button('Reset key', disabled: true) - end -end diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index ffc0ecc4966..c087237fd7c 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -183,7 +183,7 @@ RSpec.describe "Projects > Settings > Pipelines settings" do let(:page_token) { find('#registration_token').text } before do - click_button 'Reset runners registration token' + click_button 'Reset registration token' end it 'changes registration token' do diff --git a/spec/features/projects/settings/user_manages_project_members_spec.rb b/spec/features/projects/settings/user_manages_project_members_spec.rb index 3836b95a28a..726b8fb6840 100644 --- a/spec/features/projects/settings/user_manages_project_members_spec.rb +++ b/spec/features/projects/settings/user_manages_project_members_spec.rb @@ -57,7 +57,7 @@ RSpec.describe 'Projects > Settings > User manages project members' do end end - it 'shows all members of project shared group' do + it 'shows all members of project shared group', :js do group.add_owner(user) group.add_developer(user_dmitriy) @@ -67,7 +67,9 @@ RSpec.describe 'Projects > Settings > User manages project members' do visit(project_project_members_path(project)) - page.within('.project-members-groups') do + click_link 'Groups' + + page.within('[data-testid="project-member-groups"]') do expect(page).to have_content('OpenSource') expect(first('.group_member')).to have_content('Maintainer') end diff --git a/spec/features/projects/snippets/user_deletes_snippet_spec.rb b/spec/features/projects/snippets/user_deletes_snippet_spec.rb index 6d526e60512..ca49e6a36b7 100644 --- a/spec/features/projects/snippets/user_deletes_snippet_spec.rb +++ b/spec/features/projects/snippets/user_deletes_snippet_spec.rb @@ -21,6 +21,8 @@ RSpec.describe 'Projects > Snippets > User deletes a snippet', :js do click_button('Delete snippet') wait_for_requests - expect(page).not_to have_content(snippet.title) + # This assertion also confirms we did not end up on an error page + expect(page).to have_selector('#new_snippet_link') + expect(project.snippets.length).to eq(0) end end |