Commit 3e1bf200 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'ntepluhina-assignees-feature-flag' into 'master'

Added feature flag to show/hide assignees GraphQL widget [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!59620
parents 413a6a8e 3eacfdee
......@@ -5,10 +5,13 @@ import InviteMemberModal from './components/invite_member_modal.vue';
Vue.use(GlToast);
const isAssigneesWidgetShown =
(isInIssuePage() || isInDesignPage()) && gon.features.issueAssigneesWidget;
export default function initInviteMembersModal() {
const el = document.querySelector('.js-invite-member-modal');
if (!el || isInDesignPage() || isInIssuePage()) {
if (!el || isAssigneesWidgetShown) {
return false;
}
......
......@@ -410,8 +410,11 @@ function mountCopyEmailComponent() {
});
}
const isAssigneesWidgetShown =
(isInIssuePage() || isInDesignPage()) && gon.features.issueAssigneesWidget;
export function mountSidebar(mediator) {
if (isInIssuePage() || isInDesignPage()) {
if (isAssigneesWidgetShown) {
mountAssigneesComponent();
} else {
mountAssigneesComponentDeprecated(mediator);
......
......@@ -54,6 +54,7 @@ class Projects::IssuesController < Projects::ApplicationController
push_to_gon_attributes(:features, real_time_feature_flag, real_time_enabled)
push_frontend_feature_flag(:confidential_notes, @project, default_enabled: :yaml)
push_frontend_feature_flag(:issue_assignees_widget, @project, default_enabled: :yaml)
record_experiment_user(:invite_members_version_b)
......
---
title: Added feature flag to show/hide assignees GraphQL widget
merge_request: 59620
author:
type: fixed
---
name: issue_assignees_widget
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59620/
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/328185
milestone: '13.11'
type: development
group: group::project management
default_enabled: false
......@@ -30,116 +30,198 @@ RSpec.describe 'Issue Sidebar' do
let(:user2) { create(:user) }
let(:issue2) { create(:issue, project: project, author: user2) }
context 'when a privileged user can invite' do
it 'shows a link for inviting members and launches invite modal' do
project.add_maintainer(user)
visit_issue(project, issue2)
context 'when GraphQL assignees widget feature flag is disabled' do
before do
stub_feature_flags(issue_assignees_widget: false)
end
include_examples 'issuable invite members experiments' do
let(:issuable_path) { project_issue_path(project, issue2) }
end
open_assignees_dropdown
context 'when user is a developer' do
before do
project.add_developer(user)
visit_issue(project, issue2)
find('.block.assignee .edit-link').click
wait_for_requests
end
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite members')
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]')
it 'shows author in assignee dropdown' do
page.within '.dropdown-menu-user' do
expect(page).to have_content(user2.name)
end
end
click_link 'Invite members'
it 'shows author when filtering assignee dropdown' do
page.within '.dropdown-menu-user' do
find('.dropdown-input-field').set(user2.name)
expect(page).to have_content("You're inviting members to the")
end
end
wait_for_requests
context 'when invite_members_version_b experiment is enabled' do
before do
stub_experiment_for_subject(invite_members_version_b: true)
end
expect(page).to have_content(user2.name)
end
end
it 'assigns yourself' do
find('.block.assignee .dropdown-menu-toggle').click
it 'shows a link for inviting members and follows through to modal' do
project.add_developer(user)
visit_issue(project, issue2)
click_button 'assign yourself'
open_assignees_dropdown
wait_for_requests
find('.block.assignee .edit-link').click
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite members', href: '#')
expect(page).to have_selector('[data-track-event="click_invite_members_version_b"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]')
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
click_link 'Invite members'
it 'keeps your filtered term after filtering and dismissing the dropdown' do
find('.dropdown-input-field').set(user2.name)
expect(page).to have_content("Oops, this feature isn't ready yet")
end
end
wait_for_requests
page.within '.dropdown-menu-user' do
expect(page).not_to have_content 'Unassigned'
click_link user2.name
end
context 'when invite_members_version_b experiment is disabled' do
it 'shows author in assignee dropdown and no invite link' do
project.add_developer(user)
visit_issue(project, issue2)
find('.js-right-sidebar').click
find('.block.assignee .edit-link').click
open_assignees_dropdown
expect(page.all('.dropdown-menu-user li').length).to eq(1)
expect(find('.dropdown-input-field').value).to eq(user2.name)
end
it 'shows label text as "Apply" when assignees are changed' do
project.add_developer(user)
visit_issue(project, issue2)
find('.block.assignee .edit-link').click
wait_for_requests
page.within '.dropdown-menu-user' do
expect(page).not_to have_link('Invite members')
click_on 'Unassigned'
expect(page).to have_link('Apply')
end
end
end
context 'when user is a developer' do
before do
project.add_developer(user)
visit_issue(project, issue2)
end
context 'when GraphQL assignees widget feature flag is enabled' do
context 'when a privileged user can invite' do
it 'shows a link for inviting members and launches invite modal' do
project.add_maintainer(user)
visit_issue(project, issue2)
open_assignees_dropdown
it 'shows author in assignee dropdown' do
open_assignees_dropdown
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite members')
expect(page).to have_selector('[data-track-event="click_invite_members"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]')
end
click_link 'Invite members'
page.within '.dropdown-menu-user' do
expect(page).to have_content(user2.name)
expect(page).to have_content("You're inviting members to the")
end
end
it 'shows author when filtering assignee dropdown' do
open_assignees_dropdown
context 'when invite_members_version_b experiment is enabled' do
before do
stub_experiment_for_subject(invite_members_version_b: true)
end
it 'shows a link for inviting members and follows through to modal' do
project.add_developer(user)
visit_issue(project, issue2)
page.within '.dropdown-menu-user' do
find('.js-dropdown-input-field').find('input').set(user2.name)
open_assignees_dropdown
wait_for_requests
page.within '.dropdown-menu-user' do
expect(page).to have_link('Invite members', href: '#')
expect(page).to have_selector('[data-track-event="click_invite_members_version_b"]')
expect(page).to have_selector('[data-track-label="edit_assignee"]')
end
expect(page).to have_content(user2.name)
click_link 'Invite members'
expect(page).to have_content("Oops, this feature isn't ready yet")
end
end
it 'assigns yourself' do
click_button 'assign yourself'
wait_for_requests
context 'when invite_members_version_b experiment is disabled' do
it 'shows author in assignee dropdown and no invite link' do
project.add_developer(user)
visit_issue(project, issue2)
open_assignees_dropdown
page.within '.assignee' do
expect(page).to have_content(user.name)
page.within '.dropdown-menu-user' do
expect(page).not_to have_link('Invite members')
end
end
end
it 'keeps your filtered term after filtering and dismissing the dropdown' do
open_assignees_dropdown
context 'when user is a developer' do
before do
project.add_developer(user)
visit_issue(project, issue2)
end
find('.js-dropdown-input-field').find('input').set(user2.name)
wait_for_requests
it 'shows author in assignee dropdown' do
open_assignees_dropdown
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).to have_content(user2.name)
end
end
find('.js-right-sidebar').click
it 'shows author when filtering assignee dropdown' do
open_assignees_dropdown
page.within '.dropdown-menu-user' do
find('.js-dropdown-input-field').find('input').set(user2.name)
wait_for_requests
open_assignees_dropdown
expect(page).to have_content(user2.name)
end
end
it 'assigns yourself' do
click_button 'assign yourself'
wait_for_requests
page.within('.assignee') do
expect(page.all('[data-testid="selected-participant"]').length).to eq(1)
page.within '.assignee' do
expect(page).to have_content(user.name)
end
end
expect(find('.js-dropdown-input-field').find('input').value).to eq(user2.name)
it 'keeps your filtered term after filtering and dismissing the dropdown' do
open_assignees_dropdown
find('.js-dropdown-input-field').find('input').set(user2.name)
wait_for_requests
page.within '.dropdown-menu-user' do
expect(page).not_to have_content 'Unassigned'
click_link user2.name
end
find('.js-right-sidebar').click
open_assignees_dropdown
page.within('.assignee') do
expect(page.all('[data-testid="selected-participant"]').length).to eq(1)
end
expect(find('.js-dropdown-input-field').find('input').value).to eq(user2.name)
end
end
end
end
......
......@@ -167,79 +167,165 @@ RSpec.describe "Issues > User edits issue", :js do
end
describe 'update assignee' do
context 'by authorized user' do
it 'allows user to select unassigned' do
visit project_issue_path(project, issue)
context 'when GraphQL assignees widget feature flag is disabled' do
before do
stub_feature_flags(issue_assignees_widget: false)
end
page.within('.assignee') do
expect(page).to have_content "#{user.name}"
context 'by authorized user' do
def close_dropdown_menu_if_visible
find('.dropdown-menu-toggle', visible: :all).tap do |toggle|
toggle.click if toggle.visible?
end
end
click_button('Edit')
wait_for_requests
it 'allows user to select unassigned' do
visit project_issue_path(project, issue)
find('[data-testid="unassign"]').click
find('[data-testid="title"]').click
wait_for_requests
page.within('.assignee') do
expect(page).to have_content "#{user.name}"
click_link 'Edit'
click_link 'Unassigned'
first('.title').click
expect(page).to have_content 'None - assign yourself'
expect(page).to have_content 'None - assign yourself'
end
end
end
it 'allows user to select an assignee' do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
it 'allows user to select an assignee' do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
page.within('.assignee') do
expect(page).to have_content "None"
click_button('Edit')
wait_for_requests
page.within('.assignee') do
expect(page).to have_content "None"
end
page.within '.assignee' do
click_link 'Edit'
end
page.within '.dropdown-menu-user' do
click_link user.name
end
page.within('.assignee') do
expect(page).to have_content user.name
end
end
it 'allows user to unselect themselves' do
issue2 = create(:issue, project: project, author: user, assignees: [user])
visit project_issue_path(project, issue2)
page.within '.assignee' do
expect(page).to have_content user.name
click_link 'Edit'
click_link user.name
close_dropdown_menu_if_visible
page.within '.value .assign-yourself' do
expect(page).to have_content "None"
end
end
end
end
page.within '.dropdown-menu-user' do
click_link user.name
context 'by unauthorized user' do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
end
page.within('.assignee') do
find('[data-testid="title"]').click
wait_for_requests
it 'shows assignee text' do
sign_out(:user)
sign_in(guest)
expect(page).to have_content user.name
visit project_issue_path(project, issue)
expect(page).to have_content issue.assignees.first.name
end
end
end
it 'allows user to unselect themselves' do
issue2 = create(:issue, project: project, author: user, assignees: [user])
context 'when GraphQL assignees widget feature flag is enabled' do
context 'by authorized user' do
it 'allows user to select unassigned' do
visit project_issue_path(project, issue)
visit project_issue_path(project, issue2)
page.within('.assignee') do
expect(page).to have_content "#{user.name}"
page.within '.assignee' do
expect(page).to have_content user.name
click_button('Edit')
wait_for_requests
click_button('Edit')
wait_for_requests
click_link user.name
find('[data-testid="unassign"]').click
find('[data-testid="title"]').click
wait_for_requests
find('[data-testid="title"]').click
wait_for_requests
expect(page).to have_content 'None - assign yourself'
end
end
expect(page).to have_content "None"
it 'allows user to select an assignee' do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
page.within('.assignee') do
expect(page).to have_content "None"
click_button('Edit')
wait_for_requests
end
page.within '.dropdown-menu-user' do
click_link user.name
end
page.within('.assignee') do
find('[data-testid="title"]').click
wait_for_requests
expect(page).to have_content user.name
end
end
end
end
context 'by unauthorized user' do
let(:guest) { create(:user) }
it 'allows user to unselect themselves' do
issue2 = create(:issue, project: project, author: user, assignees: [user])
before do
project.add_guest(guest)
visit project_issue_path(project, issue2)
page.within '.assignee' do
expect(page).to have_content user.name
click_button('Edit')
wait_for_requests
click_link user.name
find('[data-testid="title"]').click
wait_for_requests
expect(page).to have_content "None"
end
end
end
it 'shows assignee text' do
sign_out(:user)
sign_in(guest)
context 'by unauthorized user' do
let(:guest) { create(:user) }
visit project_issue_path(project, issue)
expect(page).to have_content issue.assignees.first.name
before do
project.add_guest(guest)
end
it 'shows assignee text' do
sign_out(:user)
sign_in(guest)
visit project_issue_path(project, issue)
expect(page).to have_content issue.assignees.first.name
end
end
end
end
......
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