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,6 +30,87 @@ RSpec.describe 'Issue Sidebar' do
let(:user2) { create(:user) }
let(:issue2) { create(:issue, project: project, author: user2) }
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
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
it 'shows author in assignee dropdown' do
page.within '.dropdown-menu-user' do
expect(page).to have_content(user2.name)
end
end
it 'shows author when filtering assignee dropdown' do
page.within '.dropdown-menu-user' do
find('.dropdown-input-field').set(user2.name)
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').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
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
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
click_on 'Unassigned'
expect(page).to have_link('Apply')
end
end
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)
......@@ -143,6 +224,7 @@ RSpec.describe 'Issue Sidebar' do
end
end
end
end
context 'as a allowed user' do
before do
......
......@@ -167,6 +167,91 @@ RSpec.describe "Issues > User edits issue", :js do
end
describe 'update assignee' do
context 'when GraphQL assignees widget feature flag is disabled' do
before do
stub_feature_flags(issue_assignees_widget: false)
end
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
it 'allows user to select unassigned' do
visit project_issue_path(project, issue)
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'
end
end
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"
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
context 'by unauthorized user' do
let(:guest) { create(:user) }
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
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)
......@@ -243,6 +328,7 @@ RSpec.describe "Issues > User edits issue", :js do
end
end
end
end
describe 'update milestone' do
context 'by authorized user' 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