diff options
Diffstat (limited to 'spec/support/shared_examples/features')
11 files changed, 179 insertions, 12 deletions
diff --git a/spec/support/shared_examples/features/content_editor_shared_examples.rb b/spec/support/shared_examples/features/content_editor_shared_examples.rb index 5c44cb7f04b..c93d8e3d511 100644 --- a/spec/support/shared_examples/features/content_editor_shared_examples.rb +++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb @@ -23,6 +23,8 @@ RSpec.shared_examples 'edits content using the content editor' do describe 'code block bubble menu' do it 'shows a code block bubble menu for a code block' do + find(content_editor_testid).send_keys [:enter, :enter] + find(content_editor_testid).send_keys '```js ' # trigger input rule find(content_editor_testid).send_keys 'var a = 0' find(content_editor_testid).send_keys [:shift, :left] @@ -32,6 +34,8 @@ RSpec.shared_examples 'edits content using the content editor' do end it 'sets code block type to "javascript" for `js`' do + find(content_editor_testid).send_keys [:enter, :enter] + find(content_editor_testid).send_keys '```js ' find(content_editor_testid).send_keys 'var a = 0' @@ -39,6 +43,8 @@ RSpec.shared_examples 'edits content using the content editor' do end it 'sets code block type to "Custom (nomnoml)" for `nomnoml`' do + find(content_editor_testid).send_keys [:enter, :enter] + find(content_editor_testid).send_keys '```nomnoml ' find(content_editor_testid).send_keys 'test' diff --git a/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb b/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb index 5d1488502d2..6fd844f0e5f 100644 --- a/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb +++ b/spec/support/shared_examples/features/dependency_proxy_shared_examples.rb @@ -17,7 +17,7 @@ end RSpec.shared_examples 'a successful manifest pull' do it 'sends a file' do - expect(controller).to receive(:send_file).with(manifest.file.path, type: manifest.content_type) + expect(controller).to receive(:send_file).with(manifest.file.path, { type: manifest.content_type }) subject end diff --git a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb index ccd063faac4..2fff4137934 100644 --- a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb +++ b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb @@ -48,7 +48,7 @@ RSpec.shared_examples 'an editable merge request' do end page.within '.reviewer' do - expect(page).to have_content user.username + expect(page).to have_content user.name end page.within '.milestone' do diff --git a/spec/support/shared_examples/features/inviting_groups_shared_examples.rb b/spec/support/shared_examples/features/inviting_groups_shared_examples.rb new file mode 100644 index 00000000000..4921676a065 --- /dev/null +++ b/spec/support/shared_examples/features/inviting_groups_shared_examples.rb @@ -0,0 +1,144 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'inviting groups search results' do + context 'with instance admin considerations' do + let_it_be(:group_to_invite) { create(:group) } + + context 'when user is an admin' do + let_it_be(:admin) { create(:admin) } + + before do + sign_in(admin) + gitlab_enable_admin_mode_sign_in(admin) + end + + it 'shows groups where the admin has no direct membership' do + visit members_page_path + + click_on 'Invite a group' + click_on 'Select a group' + wait_for_requests + + page.within(group_dropdown_selector) do + expect_to_have_group(group_to_invite) + expect_not_to_have_group(group) + end + end + + it 'shows groups where the admin has at least guest level membership' do + group_to_invite.add_guest(admin) + + visit members_page_path + + click_on 'Invite a group' + click_on 'Select a group' + wait_for_requests + + page.within(group_dropdown_selector) do + expect_to_have_group(group_to_invite) + expect_not_to_have_group(group) + end + end + end + + context 'when user is not an admin' do + before do + group.add_owner(user) + sign_in(user) + end + + it 'does not show groups where the user has no direct membership' do + visit members_page_path + + click_on 'Invite a group' + click_on 'Select a group' + wait_for_requests + + page.within(group_dropdown_selector) do + expect_not_to_have_group(group_to_invite) + expect_not_to_have_group(group) + end + end + + it 'shows groups where the user has at least guest level membership' do + group_to_invite.add_guest(user) + + visit members_page_path + + click_on 'Invite a group' + click_on 'Select a group' + wait_for_requests + + page.within(group_dropdown_selector) do + expect_to_have_group(group_to_invite) + expect_not_to_have_group(group) + end + end + end + end + + context 'when user is not an admin and there are hierarchy considerations' do + let_it_be(:group_outside_hierarchy) { create(:group) } + + before_all do + group.add_owner(user) + group_within_hierarchy.add_owner(user) + group_outside_hierarchy.add_owner(user) + end + + before do + sign_in(user) + end + + it 'does not show self or ancestors', :aggregate_failures do + group_sibling = create(:group, parent: group) + group_sibling.add_owner(user) + + visit members_page_path_within_hierarchy + + click_on 'Invite a group' + click_on 'Select a group' + wait_for_requests + + page.within(group_dropdown_selector) do + expect_to_have_group(group_outside_hierarchy) + expect_to_have_group(group_sibling) + expect_not_to_have_group(group) + expect_not_to_have_group(group_within_hierarchy) + end + end + + context 'when sharing with groups outside the hierarchy is enabled' do + it 'shows groups within and outside the hierarchy in search results' do + visit members_page_path + + click_on 'Invite a group' + click_on 'Select a group' + wait_for_requests + + page.within(group_dropdown_selector) do + expect_to_have_group(group_within_hierarchy) + expect_to_have_group(group_outside_hierarchy) + end + end + end + + context 'when sharing with groups outside the hierarchy is disabled' do + before do + group.update!(prevent_sharing_groups_outside_hierarchy: true) + end + + it 'shows only groups within the hierarchy in search results' do + visit members_page_path + + click_on 'Invite a group' + click_on 'Select a group' + + page.within(group_dropdown_selector) do + expect_to_have_group(group_within_hierarchy) + expect_not_to_have_group(group_outside_hierarchy) + end + end + end + end +end diff --git a/spec/support/shared_examples/features/manage_applications_shared_examples.rb b/spec/support/shared_examples/features/manage_applications_shared_examples.rb index 3a8267b21da..442264e7ae4 100644 --- a/spec/support/shared_examples/features/manage_applications_shared_examples.rb +++ b/spec/support/shared_examples/features/manage_applications_shared_examples.rb @@ -9,11 +9,9 @@ RSpec.shared_examples 'manage applications' do visit new_application_path expect(page).to have_content 'Add new application' - expect(find('#doorkeeper_application_expire_access_tokens')).to be_checked fill_in :doorkeeper_application_name, with: application_name fill_in :doorkeeper_application_redirect_uri, with: application_redirect_uri - uncheck :doorkeeper_application_expire_access_tokens check :doorkeeper_application_scopes_read_user click_on 'Save application' @@ -25,8 +23,6 @@ RSpec.shared_examples 'manage applications' do click_on 'Edit' - expect(find('#doorkeeper_application_expire_access_tokens')).not_to be_checked - application_name_changed = "#{application_name} changed" fill_in :doorkeeper_application_name, with: application_name_changed diff --git a/spec/support/shared_examples/features/multiple_assignees_mr_shared_examples.rb b/spec/support/shared_examples/features/multiple_assignees_mr_shared_examples.rb index 9d023d9514a..4565108b5e4 100644 --- a/spec/support/shared_examples/features/multiple_assignees_mr_shared_examples.rb +++ b/spec/support/shared_examples/features/multiple_assignees_mr_shared_examples.rb @@ -4,7 +4,7 @@ RSpec.shared_examples 'multiple assignees merge request' do |action, save_button it "#{action} a MR with multiple assignees", :js do find('.js-assignee-search').click page.within '.dropdown-menu-user' do - click_link user.name + click_link user.name unless action == 'creates' click_link user2.name end diff --git a/spec/support/shared_examples/features/multiple_assignees_widget_mr_shared_examples.rb b/spec/support/shared_examples/features/multiple_assignees_widget_mr_shared_examples.rb index bbde448a1a1..a44a699c878 100644 --- a/spec/support/shared_examples/features/multiple_assignees_widget_mr_shared_examples.rb +++ b/spec/support/shared_examples/features/multiple_assignees_widget_mr_shared_examples.rb @@ -4,7 +4,7 @@ RSpec.shared_examples 'multiple assignees widget merge request' do |action, save it "#{action} a MR with multiple assignees", :js do find('.js-assignee-search').click page.within '.dropdown-menu-user' do - click_link user.name + click_link user.name unless action == 'creates' click_link user2.name end diff --git a/spec/support/shared_examples/features/multiple_reviewers_mr_shared_examples.rb b/spec/support/shared_examples/features/multiple_reviewers_mr_shared_examples.rb index ad6ca3e1900..48cde90bd9b 100644 --- a/spec/support/shared_examples/features/multiple_reviewers_mr_shared_examples.rb +++ b/spec/support/shared_examples/features/multiple_reviewers_mr_shared_examples.rb @@ -40,7 +40,7 @@ RSpec.shared_examples 'multiple reviewers merge request' do |action, save_button # Closing dropdown to persist click_link 'Edit' - expect(page).to have_content user2.username + expect(page).to have_content user2.name end end end diff --git a/spec/support/shared_examples/features/packages_shared_examples.rb b/spec/support/shared_examples/features/packages_shared_examples.rb index ded30f32314..323bd4f5171 100644 --- a/spec/support/shared_examples/features/packages_shared_examples.rb +++ b/spec/support/shared_examples/features/packages_shared_examples.rb @@ -97,9 +97,9 @@ def click_sort_option(option, ascending) wait_for_requests end - find('button.gl-dropdown-toggle').click + find('[data-testid="registry-sort-dropdown"]').click - page.within('.dropdown-menu') do + page.within('[data-testid="registry-sort-dropdown"] .dropdown-menu') do click_button option end diff --git a/spec/support/shared_examples/features/sidebar_shared_examples.rb b/spec/support/shared_examples/features/sidebar_shared_examples.rb index 11d216ff4b6..af3ea0600a2 100644 --- a/spec/support/shared_examples/features/sidebar_shared_examples.rb +++ b/spec/support/shared_examples/features/sidebar_shared_examples.rb @@ -108,7 +108,11 @@ RSpec.shared_examples 'issue boards sidebar' do wait_for_requests - expect(page).to have_content('This issue is confidential') + expect(page).to have_content( + _('Only project members with at least' \ + ' Reporter role can view or be' \ + ' notified about this issue.') + ) end end end diff --git a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb index 41b1964cff0..8081c51577a 100644 --- a/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_creates_wiki_page_shared_examples.rb @@ -233,6 +233,23 @@ RSpec.shared_examples 'User creates wiki page' do .and have_content("Last edited by #{user.name}") .and have_content("My awesome wiki!") end + + context 'when a server side validation error is returned' do + it "still displays edit form", :js do + click_link("New page") + + page.within(".wiki-form") do + fill_in(:wiki_title, with: "home") + fill_in(:wiki_content, with: "My awesome home page!") + end + + # Submits page with a name already in use to trigger a validation error + click_button("Create page") + + expect(page).to have_field(:wiki_title) + expect(page).to have_field(:wiki_content) + end + end end it "shows the emoji autocompletion dropdown", :js do |