2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 03:56:52 -04:00
|
|
|
require 'spec_helper'
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Issue Sidebar' do
|
2017-01-27 17:11:05 -05:00
|
|
|
include MobileHelpers
|
2016-11-17 06:13:39 -05:00
|
|
|
|
2021-05-05 08:10:33 -04:00
|
|
|
let_it_be(:group) { create(:group, :nested) }
|
|
|
|
let_it_be(:project) { create(:project, :public, namespace: group) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
2022-01-05 01:13:32 -05:00
|
|
|
let_it_be(:issue) { create(:issue, project: project) }
|
|
|
|
let_it_be(:label) { create(:label, project: project, name: 'Label') }
|
2021-05-05 08:10:33 -04:00
|
|
|
let_it_be(:mock_date) { Date.today.at_beginning_of_month + 2.days }
|
2016-04-15 15:25:36 -04:00
|
|
|
|
|
|
|
before do
|
2021-01-12 19:10:50 -05:00
|
|
|
stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2020-10-14 14:08:47 -04:00
|
|
|
end
|
2016-11-17 06:13:39 -05:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'when concerning the assignee', :js do
|
|
|
|
let(:user2) { create(:user) }
|
|
|
|
let(:issue2) { create(:issue, project: project, author: user2) }
|
2020-06-05 08:08:24 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
context 'when GraphQL assignees widget feature flag is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(issue_assignees_widget: false)
|
|
|
|
end
|
|
|
|
|
2021-05-27 08:10:56 -04:00
|
|
|
include_examples 'issuable invite members' do
|
2021-04-19 08:09:04 -04:00
|
|
|
let(:issuable_path) { project_issue_path(project, issue2) }
|
|
|
|
end
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
context 'when user is a developer' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
visit_issue(project, issue2)
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
find('.block.assignee .edit-link').click
|
|
|
|
wait_for_requests
|
2021-04-13 05:11:10 -04:00
|
|
|
end
|
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
it 'shows author in assignee dropdown' do
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
end
|
|
|
|
end
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
it 'shows author when filtering assignee dropdown' do
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
find('.dropdown-input-field').set(user2.name)
|
2016-11-17 06:13:39 -05:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
wait_for_requests
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns yourself' do
|
|
|
|
find('.block.assignee .dropdown-menu-toggle').click
|
2017-05-26 17:27:30 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
click_button 'assign yourself'
|
2017-05-26 17:27:30 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
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
|
2021-04-13 05:11:10 -04:00
|
|
|
end
|
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
it 'keeps your filtered term after filtering and dismissing the dropdown' do
|
|
|
|
find('.dropdown-input-field').set(user2.name)
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
expect(page).not_to have_content 'Unassigned'
|
|
|
|
click_link user2.name
|
|
|
|
end
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2022-08-12 14:11:09 -04:00
|
|
|
within '.js-right-sidebar' do
|
|
|
|
find('.block.assignee').click(x: 0, y: 0)
|
|
|
|
find('.block.assignee .edit-link').click
|
|
|
|
end
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
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'
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
expect(page).to have_link('Apply')
|
2021-04-13 05:11:10 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
context 'when GraphQL assignees widget feature flag is enabled' do
|
2022-03-15 08:07:44 -04:00
|
|
|
# TODO: Move to shared examples when feature flag is removed: https://gitlab.com/gitlab-org/gitlab/-/issues/328185
|
2021-04-19 08:09:04 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
expect(page).to have_link('Invite members')
|
2021-09-15 14:11:29 -04:00
|
|
|
expect(page).to have_selector('[data-track-action="click_invite_members"]')
|
2021-04-19 08:09:04 -04:00
|
|
|
expect(page).to have_selector('[data-track-label="edit_assignee"]')
|
|
|
|
end
|
2020-06-05 08:08:24 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
click_link 'Invite members'
|
2021-04-13 05:11:10 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
expect(page).to have_content("You're inviting members to the")
|
2021-01-12 19:10:50 -05:00
|
|
|
end
|
2020-06-05 08:08:24 -04:00
|
|
|
end
|
|
|
|
|
2021-04-29 05:10:11 -04:00
|
|
|
context 'when user cannot invite members in assignee dropdown' do
|
2021-04-19 08:09:04 -04:00
|
|
|
it 'shows author in assignee dropdown and no invite link' do
|
|
|
|
project.add_developer(user)
|
|
|
|
visit_issue(project, issue2)
|
|
|
|
|
|
|
|
open_assignees_dropdown
|
2020-06-05 08:08:24 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
expect(page).not_to have_link('Invite members')
|
|
|
|
end
|
2021-01-12 19:10:50 -05:00
|
|
|
end
|
2020-06-05 08:08:24 -04:00
|
|
|
end
|
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
context 'when user is a developer' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
visit_issue(project, issue2)
|
|
|
|
end
|
2020-10-14 08:08:58 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
it 'shows author in assignee dropdown' do
|
|
|
|
open_assignees_dropdown
|
2020-10-14 08:08:58 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
end
|
2021-01-12 19:10:50 -05:00
|
|
|
end
|
2020-10-14 08:08:58 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
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
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns yourself' do
|
|
|
|
click_button 'assign yourself'
|
|
|
|
wait_for_requests
|
2017-12-15 15:29:53 -05:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content(user.name)
|
|
|
|
end
|
2021-04-13 05:11:10 -04:00
|
|
|
end
|
2017-12-15 15:29:53 -05:00
|
|
|
|
2021-04-19 08:09:04 -04:00
|
|
|
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'
|
2022-07-27 14:12:02 -04:00
|
|
|
click_button user2.name
|
2021-04-19 08:09:04 -04:00
|
|
|
end
|
|
|
|
|
2021-05-03 05:10:02 -04:00
|
|
|
find('.participants').click
|
2021-04-30 11:09:50 -04:00
|
|
|
wait_for_requests
|
2021-04-19 08:09:04 -04:00
|
|
|
|
|
|
|
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
|
2021-04-13 05:11:10 -04:00
|
|
|
end
|
2017-12-15 15:29:53 -05:00
|
|
|
end
|
2016-11-14 13:56:52 -05:00
|
|
|
end
|
|
|
|
|
2021-05-05 08:10:33 -04:00
|
|
|
context 'as an allowed user' do
|
2017-02-05 22:39:20 -05:00
|
|
|
before do
|
2021-01-12 19:10:50 -05:00
|
|
|
project.add_developer(user)
|
|
|
|
visit_issue(project, issue)
|
2017-02-05 22:39:20 -05:00
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'sidebar', :js do
|
|
|
|
it 'changes size when the screen size is smaller' do
|
|
|
|
sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
|
|
|
|
# Resize the window
|
|
|
|
resize_screen_sm
|
|
|
|
# Make sure the sidebar is collapsed
|
|
|
|
find(sidebar_selector)
|
|
|
|
expect(page).to have_css(sidebar_selector)
|
|
|
|
# Once is collapsed let's open the sidebard and reload
|
|
|
|
open_issue_sidebar
|
|
|
|
refresh
|
|
|
|
find(sidebar_selector)
|
|
|
|
expect(page).to have_css(sidebar_selector)
|
|
|
|
# Restore the window size as it was including the sidebar
|
|
|
|
restore_window_size
|
|
|
|
open_issue_sidebar
|
2018-04-18 18:29:58 -04:00
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
|
|
|
|
2021-02-04 16:09:06 -05:00
|
|
|
context 'editing issue milestone', :js do
|
2021-12-14 01:13:55 -05:00
|
|
|
it_behaves_like 'milestone sidebar widget'
|
2021-02-04 16:09:06 -05:00
|
|
|
end
|
|
|
|
|
2021-12-16 01:14:40 -05:00
|
|
|
context 'editing issue due date', :js do
|
|
|
|
it_behaves_like 'date sidebar widget'
|
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'editing issue labels', :js do
|
2022-01-05 01:13:32 -05:00
|
|
|
it_behaves_like 'labels sidebar widget'
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2022-03-15 08:07:44 -04:00
|
|
|
context 'escalation status', :js do
|
|
|
|
it 'is not available for default issue type' do
|
|
|
|
expect(page).not_to have_selector('.block.escalation-status')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'interacting with collapsed sidebar', :js do
|
|
|
|
collapsed_sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
|
|
|
|
expanded_sidebar_selector = 'aside.right-sidebar.right-sidebar-expanded'
|
|
|
|
confidentiality_sidebar_block = '.block.confidentiality'
|
|
|
|
lock_sidebar_block = '.block.lock'
|
|
|
|
collapsed_sidebar_block_icon = '.sidebar-collapsed-icon'
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
before do
|
|
|
|
resize_screen_sm
|
|
|
|
end
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
it 'confidentiality block expands then collapses sidebar' do
|
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
page.within(confidentiality_sidebar_block) do
|
|
|
|
find(collapsed_sidebar_block_icon).click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_css(expanded_sidebar_selector)
|
|
|
|
|
|
|
|
page.within(confidentiality_sidebar_block) do
|
|
|
|
page.find('button', text: 'Cancel').click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
2018-04-02 14:46:50 -04:00
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
it 'lock block expands then collapses sidebar' do
|
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
|
|
|
|
|
|
|
page.within(lock_sidebar_block) do
|
|
|
|
find(collapsed_sidebar_block_icon).click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_css(expanded_sidebar_selector)
|
|
|
|
|
|
|
|
page.within(lock_sidebar_block) do
|
|
|
|
page.find('button', text: 'Cancel').click
|
|
|
|
end
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
2018-04-02 14:46:50 -04:00
|
|
|
end
|
2021-01-12 19:10:50 -05:00
|
|
|
end
|
|
|
|
end
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'as a guest' do
|
|
|
|
before do
|
|
|
|
project.add_guest(user)
|
|
|
|
visit_issue(project, issue)
|
2018-04-02 14:46:50 -04:00
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
it 'does not have a option to edit labels' do
|
|
|
|
expect(page).not_to have_selector('.block.labels .js-sidebar-dropdown-toggle')
|
|
|
|
end
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'sidebar', :js do
|
|
|
|
it 'finds issue copy forwarding email' do
|
2022-09-05 05:12:22 -04:00
|
|
|
expect(
|
|
|
|
find('[data-testid="copy-forward-email"]').text
|
|
|
|
).to eq "Issue email: #{issue.creatable_note_email_address(user)}"
|
2018-04-02 14:46:50 -04:00
|
|
|
end
|
2021-01-12 19:10:50 -05:00
|
|
|
end
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'interacting with collapsed sidebar', :js do
|
|
|
|
collapsed_sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
|
|
|
|
expanded_sidebar_selector = 'aside.right-sidebar.right-sidebar-expanded'
|
|
|
|
lock_sidebar_block = '.block.lock'
|
|
|
|
lock_button = '.block.lock .btn-close'
|
|
|
|
collapsed_sidebar_block_icon = '.sidebar-collapsed-icon'
|
2018-04-02 14:46:50 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
before do
|
|
|
|
resize_screen_sm
|
2018-04-02 14:46:50 -04:00
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
it 'expands then does not show the lock dialog form' do
|
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
page.within(lock_sidebar_block) do
|
|
|
|
find(collapsed_sidebar_block_icon).click
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
expect(page).to have_css(expanded_sidebar_selector)
|
|
|
|
expect(page).not_to have_selector(lock_button)
|
|
|
|
end
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
2021-01-12 19:10:50 -05:00
|
|
|
end
|
2020-03-05 13:08:19 -05:00
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
context 'when not signed in' do
|
|
|
|
context 'sidebar', :js do
|
2020-03-05 13:08:19 -05:00
|
|
|
before do
|
2021-01-12 19:10:50 -05:00
|
|
|
visit_issue(project, issue)
|
2020-03-05 13:08:19 -05:00
|
|
|
end
|
|
|
|
|
2021-01-12 19:10:50 -05:00
|
|
|
it 'does not find issue email' do
|
2022-09-05 05:12:22 -04:00
|
|
|
expect(page).not_to have_selector('[data-testid="copy-forward-email"]')
|
2020-03-05 13:08:19 -05:00
|
|
|
end
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_issue(project, issue)
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
2021-05-05 08:10:33 -04:00
|
|
|
|
|
|
|
wait_for_requests
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
2017-01-27 17:11:05 -05:00
|
|
|
|
|
|
|
def open_issue_sidebar
|
2017-06-17 02:08:27 -04:00
|
|
|
find('aside.right-sidebar.right-sidebar-collapsed .js-sidebar-toggle').click
|
2017-05-03 09:18:28 -04:00
|
|
|
find('aside.right-sidebar.right-sidebar-expanded')
|
2017-01-27 17:11:05 -05:00
|
|
|
end
|
2021-04-13 05:11:10 -04:00
|
|
|
|
|
|
|
def open_assignees_dropdown
|
|
|
|
page.within('.assignee') do
|
|
|
|
click_button('Edit')
|
|
|
|
wait_for_requests
|
|
|
|
end
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|