diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-05 15:08:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-05 15:08:24 +0300 |
commit | 38b39c50473ba58a80ddad5c22c96ccd5128ddfb (patch) | |
tree | 21a3dc9f9ab12f079f4f791f40ba175b872394ef /spec/features | |
parent | 963838b90c1c121d16ec43353a4e0d44450664cf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/issues/issue_sidebar_spec.rb | 136 | ||||
-rw-r--r-- | spec/features/merge_request/user_edits_assignees_sidebar_spec.rb | 99 |
2 files changed, 174 insertions, 61 deletions
diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index e7c675bf6bf..8f52a7541f4 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -7,12 +7,13 @@ describe 'Issue Sidebar' do let(:group) { create(:group, :nested) } let(:project) { create(:project, :public, namespace: group) } - let!(:user) { create(:user)} + let!(:user) { create(:user) } let!(:label) { create(:label, project: project, title: 'bug') } let(:issue) { create(:labeled_issue, project: project, labels: [label]) } let!(:xss_label) { create(:label, project: project, title: '<script>alert("xss");</script>') } before do + stub_feature_flags(save_issuable_health_status: false) sign_in(user) end @@ -20,62 +21,123 @@ describe 'Issue Sidebar' do let(:user2) { create(:user) } let(:issue2) { create(:issue, project: project, author: user2) } - before do - project.add_developer(user) - visit_issue(project, issue2) + context 'when invite_members_version_a experiment is enabled' do + before do + stub_experiment_for_user(invite_members_version_a: true) + end - find('.block.assignee .edit-link').click + context 'when user can not see invite members' do + before do + project.add_developer(user) + visit_issue(project, issue2) - wait_for_requests - end + find('.block.assignee .edit-link').click - it 'shows author in assignee dropdown' do - page.within '.dropdown-menu-user' do - expect(page).to have_content(user2.name) + wait_for_requests + end + + it 'does not see link to invite members' do + page.within '.dropdown-menu-user' do + expect(page).not_to have_link('Invite Members') + end + end end - end - it 'shows author when filtering assignee dropdown' do - page.within '.dropdown-menu-user' do - find('.dropdown-input-field').native.send_keys user2.name - sleep 1 # Required to wait for end of input delay + context 'when user can see invite members' do + before do + project.add_maintainer(user) + visit_issue(project, issue2) + + find('.block.assignee .edit-link').click - wait_for_requests + wait_for_requests + end - expect(page).to have_content(user2.name) + it 'sees link to invite members' do + page.within '.dropdown-menu-user' do + expect(page).to have_link('Invite Members', href: project_project_members_path(project)) + end + end end end - it 'assigns yourself' do - find('.block.assignee .dropdown-menu-toggle').click + context 'when invite_members_version_a experiment is not enabled' do + context 'when user is a developer' do + before do + project.add_developer(user) + visit_issue(project, issue2) - click_button 'assign yourself' + find('.block.assignee .edit-link').click - wait_for_requests + wait_for_requests + end - find('.block.assignee .edit-link').click + it 'shows author in assignee dropdown' do + page.within '.dropdown-menu-user' do + expect(page).to have_content(user2.name) + end + end - 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 'shows author when filtering assignee dropdown' do + page.within '.dropdown-menu-user' do + find('.dropdown-input-field').native.send_keys user2.name + sleep 1 # Required to wait for end of input delay - it 'keeps your filtered term after filtering and dismissing the dropdown' do - find('.dropdown-input-field').native.send_keys user2.name + wait_for_requests - 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').native.send_keys user2.name + + wait_for_requests - page.within '.dropdown-menu-user' do - expect(page).not_to have_content 'Unassigned' - click_link user2.name + page.within '.dropdown-menu-user' do + expect(page).not_to have_content 'Unassigned' + click_link user2.name + end + + find('.js-right-sidebar').click + find('.block.assignee .edit-link').click + + expect(page.all('.dropdown-menu-user li').length).to eq(1) + expect(find('.dropdown-input-field').value).to eq(user2.name) + end end - find('.js-right-sidebar').click - find('.block.assignee .edit-link').click + context 'when user is a maintainer' do + before do + project.add_maintainer(user) + visit_issue(project, issue2) + + find('.block.assignee .edit-link').click - expect(page.all('.dropdown-menu-user li').length).to eq(1) - expect(find('.dropdown-input-field').value).to eq(user2.name) + wait_for_requests + end + + it 'shows author in assignee dropdown and no invite link' do + page.within '.dropdown-menu-user' do + expect(page).not_to have_link('Invite Members') + end + end + end end end 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 e6b77e28281..27b3ff3e085 100644 --- a/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb +++ b/spec/features/merge_request/user_edits_assignees_sidebar_spec.rb @@ -20,49 +20,100 @@ describe 'Merge request > User edits assignees sidebar', :js do let(:sidebar_assignee_dropdown_item) { sidebar_assignee_block.find(".dropdown-menu li[data-user-id=\"#{assignee.id}\"]") } let(:sidebar_assignee_dropdown_tooltip) { sidebar_assignee_dropdown_item.find('a')['data-title'] || '' } - before do - stub_const('Autocomplete::UsersFinder::LIMIT', users_find_limit) + context 'when invite_members_version_a experiment is not enabled' do + before do + stub_const('Autocomplete::UsersFinder::LIMIT', users_find_limit) - sign_in(project.owner) + sign_in(project.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 + end + + shared_examples 'when assigned' do |expected_tooltip: ''| + it 'shows assignee name' do + expect(sidebar_assignee_block).to have_text(assignee.name) + end + + it "shows assignee tooltip '#{expected_tooltip}'" do + expect(sidebar_assignee_tooltip).to eql(expected_tooltip) + 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 'does not show invite link' do + page.within '.dropdown-menu-user' do + expect(page).not_to have_link('Invite Members') + end + end + end + end + + context 'when assigned to maintainer' do + let(:assignee) { project_maintainers.last } - shared_examples 'when assigned' do |expected_tooltip: ''| - it 'shows assignee name' do - expect(sidebar_assignee_block).to have_text(assignee.name) + it_behaves_like 'when assigned', expected_tooltip: '' end - it "shows assignee tooltip '#{expected_tooltip}'" do - expect(sidebar_assignee_tooltip).to eql(expected_tooltip) + context 'when assigned to developer' do + let(:assignee) { project_developers.last } + + it_behaves_like 'when assigned', expected_tooltip: 'Cannot merge' end + end - context 'when edit is clicked' do + context 'when invite_members_version_a experiment is enabled' do + let_it_be(:user) { create(:user) } + + before do + stub_experiment_for_user(invite_members_version_a: true) + sign_in(user) + end + + context 'when user can not see invite members' do before do - sidebar_assignee_block.click_link('Edit') + project.add_developer(user) + visit project_merge_request_path(project, merge_request) + + find('.block.assignee .edit-link').click wait_for_requests end - it "shows assignee tooltip '#{expected_tooltip}" do - expect(sidebar_assignee_dropdown_tooltip).to eql(expected_tooltip) + it 'does not see link to invite members' do + page.within '.dropdown-menu-user' do + expect(page).not_to have_link('Invite Members') + end end end - end - context 'when assigned to maintainer' do - let(:assignee) { project_maintainers.last } + context 'when user can see invite members' do + before do + project.add_maintainer(user) + visit project_merge_request_path(project, merge_request) - it_behaves_like 'when assigned', expected_tooltip: '' - end + find('.block.assignee .edit-link').click - context 'when assigned to developer' do - let(:assignee) { project_developers.last } + wait_for_requests + end - it_behaves_like 'when assigned', expected_tooltip: 'Cannot merge' + it 'sees link to invite members' do + page.within '.dropdown-menu-user' do + expect(page).to have_link('Invite Members', href: project_project_members_path(project)) + end + end + end end end |