Commit 64a113e8 authored by Doug Stull's avatar Doug Stull Committed by Phil Hughes

Add invite members link on issues

- to entice more user expansion into
  collaboration
parent dac3aa82
......@@ -40,4 +40,13 @@
- data['max-select'] = dropdown_options[:data][:'max-select'] if dropdown_options[:data][:'max-select']
- options[:data].merge!(data)
= dropdown_tag(title, options: options)
- if experiment_enabled?(:invite_members_version_a) && can_import_members?
- options[:dropdown_class] += ' dropdown-extended-height'
- options[:footer_content] = true
= dropdown_tag(title, options: options) do
%ul.dropdown-footer-list
%li
= link_to _('Invite Members'), project_project_members_path(@project), title: _('Invite Members'), :"data-is-link" => true
- else
= dropdown_tag(title, options: options)
......@@ -3,6 +3,10 @@
require 'spec_helper'
RSpec.describe 'projects/merge_requests/show.html.haml' do
before do
allow(view).to receive(:experiment_enabled?).and_return(false)
end
include_context 'merge request show action'
context 'when merge request is created by a GitLab team member' do
......
......@@ -47,6 +47,9 @@ module Gitlab
},
upgrade_link_in_user_menu_a: {
tracking_category: 'Growth::Expansion::Experiment::UpgradeLinkInUserMenuA'
},
invite_members_version_a: {
tracking_category: 'Growth::Expansion::Experiment::InviteMembersVersionA'
}
}.freeze
......
......@@ -12100,6 +12100,9 @@ msgstr ""
msgid "Invite \"%{trimmed}\" by email"
msgstr ""
msgid "Invite Members"
msgstr ""
msgid "Invite group"
msgstr ""
......
......@@ -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
......
......@@ -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
......@@ -3,6 +3,10 @@
require 'spec_helper'
describe 'projects/merge_requests/show.html.haml' do
before do
allow(view).to receive(:experiment_enabled?).and_return(false)
end
include_context 'merge request show action'
describe 'merge request assignee sidebar' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment