diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/support/shared_examples/features | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features')
7 files changed, 107 insertions, 16 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 591f7973454..0ea82f37db0 100644 --- a/spec/support/shared_examples/features/content_editor_shared_examples.rb +++ b/spec/support/shared_examples/features/content_editor_shared_examples.rb @@ -31,8 +31,6 @@ RSpec.shared_examples 'edits content using the content editor' do page.go_back refresh - - click_button 'Edit rich text' end it 'applies theme classes to code blocks' do diff --git a/spec/support/shared_examples/features/discussion_comments_shared_example.rb b/spec/support/shared_examples/features/discussion_comments_shared_example.rb index 6c06cbf9082..24dc4bcfc59 100644 --- a/spec/support/shared_examples/features/discussion_comments_shared_example.rb +++ b/spec/support/shared_examples/features/discussion_comments_shared_example.rb @@ -293,7 +293,7 @@ RSpec.shared_examples 'thread comments for issue, epic and merge request' do |re it 'can be collapsed' do submit_reply('another text') - find('.js-collapse-replies').click + click_button s_('Notes|Collapse replies'), match: :first expect(page).to have_css('.discussion-notes .note', count: 1) expect(page).to have_content '1 reply' end diff --git a/spec/support/shared_examples/features/inviting_members_shared_examples.rb b/spec/support/shared_examples/features/inviting_members_shared_examples.rb index 58357b262f5..bca0e02fcdd 100644 --- a/spec/support/shared_examples/features/inviting_members_shared_examples.rb +++ b/spec/support/shared_examples/features/inviting_members_shared_examples.rb @@ -23,6 +23,22 @@ RSpec.shared_examples 'inviting members' do |snowplow_invite_label| ) end + it 'displays the user\'s avatar in the member input token', :js do + visit members_page_path + + input_invites(user2.name) + + expect(page).to have_selector(member_token_avatar_selector) + end + + it 'does not display an avatar in the member input token for an email address', :js do + visit members_page_path + + input_invites('test@example.com') + + expect(page).not_to have_selector(member_token_avatar_selector) + end + it 'invites user by email', :js, :snowplow, :aggregate_failures do visit members_page_path @@ -78,22 +94,23 @@ RSpec.shared_examples 'inviting members' do |snowplow_invite_label| end context 'when member is already a member by email' do - it 'fails with an error', :js do + it 'updates the member for that email', :js do + email = 'test@example.com' + visit members_page_path - invite_member('test@example.com', role: 'Developer') + invite_member(email, role: 'Developer') - invite_member('test@example.com', role: 'Reporter', refresh: false) + invite_member(email, role: 'Reporter', refresh: false) - expect(page).to have_selector(invite_modal_selector) - expect(page).to have_content("The member's email address has already been taken") + expect(page).not_to have_selector(invite_modal_selector) page.refresh click_link 'Invited' - page.within find_invited_member_row('test@example.com') do - expect(page).to have_button('Developer') + page.within find_invited_member_row(email) do + expect(page).to have_button('Reporter') end end end @@ -131,8 +148,8 @@ RSpec.shared_examples 'inviting members' do |snowplow_invite_label| invite_member(user2.name, role: role, refresh: false) expect(page).to have_selector(invite_modal_selector) - expect(page).to have_content "Access level should be greater than or equal to Developer inherited membership " \ - "from group #{group.name}" + expect(page).to have_content "#{user2.name}: Access level should be greater than or equal to Developer " \ + "inherited membership from group #{group.name}" page.refresh @@ -149,13 +166,31 @@ RSpec.shared_examples 'inviting members' do |snowplow_invite_label| group.add_maintainer(user3) end - it 'only shows the first user error', :js do + it 'shows the user errors and then removes them from the form', :js do visit subentity_members_page_path invite_member([user2.name, user3.name], role: role, refresh: false) expect(page).to have_selector(invite_modal_selector) - expect(page).to have_text("Access level should be greater than or equal to", count: 1) + expect(page).to have_selector(member_token_error_selector(user2.id)) + expect(page).to have_selector(member_token_error_selector(user3.id)) + expect(page).to have_text("The following 2 members couldn't be invited") + expect(page).to have_text("#{user2.name}: Access level should be greater than or equal to") + expect(page).to have_text("#{user3.name}: Access level should be greater than or equal to") + + remove_token(user2.id) + + expect(page).not_to have_selector(member_token_error_selector(user2.id)) + expect(page).to have_selector(member_token_error_selector(user3.id)) + expect(page).to have_text("The following member couldn't be invited") + expect(page).not_to have_text("#{user2.name}: Access level should be greater than or equal to") + + remove_token(user3.id) + + expect(page).not_to have_selector(member_token_error_selector(user3.id)) + expect(page).not_to have_text("The following member couldn't be invited") + expect(page).not_to have_text("Review the invite errors and try again") + expect(page).not_to have_text("#{user3.name}: Access level should be greater than or equal to") page.refresh @@ -169,6 +204,19 @@ RSpec.shared_examples 'inviting members' do |snowplow_invite_label| expect(page).not_to have_button('Maintainer') end end + + it 'only shows the error for an invalid formatted email and does not display other member errors', :js do + visit subentity_members_page_path + + invite_member([user2.name, user3.name, 'bad@email'], role: role, refresh: false) + + expect(page).to have_selector(invite_modal_selector) + expect(page).to have_text('email contains an invalid email address') + expect(page).not_to have_text("The following 2 members couldn't be invited") + expect(page).not_to have_text("Review the invite errors and try again") + expect(page).not_to have_text("#{user2.name}: Access level should be greater than or equal to") + expect(page).not_to have_text("#{user3.name}: Access level should be greater than or equal to") + end end end end 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 4565108b5e4..9d023d9514a 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 unless action == 'creates' + click_link user.name 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 a44a699c878..bbde448a1a1 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 unless action == 'creates' + click_link user.name click_link user2.name end diff --git a/spec/support/shared_examples/features/wiki/autocomplete_shared_examples.rb b/spec/support/shared_examples/features/wiki/autocomplete_shared_examples.rb new file mode 100644 index 00000000000..79de2aedf3b --- /dev/null +++ b/spec/support/shared_examples/features/wiki/autocomplete_shared_examples.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'autocompletes items' do + before do + if defined?(project) + create(:issue, project: project, title: 'My Cool Linked Issue') + create(:merge_request, source_project: project, title: 'My Cool Merge Request') + create(:label, project: project, title: 'My Cool Label') + create(:milestone, project: project, title: 'My Cool Milestone') + + project.add_maintainer(create(:user, name: 'JohnDoe123')) + else # group wikis + project = create(:project, group: group) + + create(:issue, project: project, title: 'My Cool Linked Issue') + create(:merge_request, source_project: project, title: 'My Cool Merge Request') + create(:group_label, group: group, title: 'My Cool Label') + create(:milestone, group: group, title: 'My Cool Milestone') + + project.add_maintainer(create(:user, name: 'JohnDoe123')) + end + end + + it 'works well for issues, labels, MRs, members, etc' do + fill_in :wiki_content, with: "#" + expect(page).to have_text 'My Cool Linked Issue' + + fill_in :wiki_content, with: "~" + expect(page).to have_text 'My Cool Label' + + fill_in :wiki_content, with: "!" + expect(page).to have_text 'My Cool Merge Request' + + fill_in :wiki_content, with: "%" + expect(page).to have_text 'My Cool Milestone' + + fill_in :wiki_content, with: "@" + expect(page).to have_text 'JohnDoe123' + + fill_in :wiki_content, with: ':smil' + expect(page).to have_text 'smile_cat' + end +end diff --git a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb index 12a4c6d7583..79c7c1891ac 100644 --- a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb @@ -146,6 +146,8 @@ RSpec.shared_examples 'User updates wiki page' do it_behaves_like 'edits content using the content editor' end end + + it_behaves_like 'autocompletes items' end context 'when the page is in a subdir', :js do |