2016-06-02 11:05:42 +05:30
|
|
|
require 'rails_helper'
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
describe 'Issue Sidebar' do
|
2017-08-17 22:00:37 +05:30
|
|
|
include MobileHelpers
|
|
|
|
|
|
|
|
let(:group) { create(:group, :nested) }
|
|
|
|
let(:project) { create(:project, :public, namespace: group) }
|
2016-06-02 11:05:42 +05:30
|
|
|
let!(:user) { create(:user)}
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:label) { create(:label, project: project, title: 'bug') }
|
2018-10-15 14:42:47 +05:30
|
|
|
let(:issue) { create(:labeled_issue, project: project, labels: [label]) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let!(:xss_label) { create(:label, project: project, title: '<script>alert("xss");</script>') }
|
2016-06-02 11:05:42 +05:30
|
|
|
|
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'assignee', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:user2) { create(:user) }
|
|
|
|
let(:issue2) { create(:issue, project: project, author: user2) }
|
|
|
|
|
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_developer(user)
|
2017-08-17 22:00:37 +05:30
|
|
|
visit_issue(project, issue2)
|
|
|
|
|
|
|
|
find('.block.assignee .edit-link').click
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
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').native.send_keys user2.name
|
|
|
|
sleep 1 # Required to wait for end of input delay
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'assigns yourself' do
|
|
|
|
find('.block.assignee .dropdown-menu-toggle').click
|
|
|
|
|
|
|
|
click_button 'assign yourself'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
wait_for_requests
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
context 'as a allowed user' do
|
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_developer(user)
|
2016-06-02 11:05:42 +05:30
|
|
|
visit_issue(project, issue)
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'sidebar', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
it 'escapes XSS when viewing issue labels' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
find('.edit-link').click
|
|
|
|
|
|
|
|
expect(page).to have_content '<script>alert("xss");</script>'
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'editing issue labels', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
issue.update(labels: [label])
|
2016-06-02 11:05:42 +05:30
|
|
|
page.within('.block.labels') do
|
|
|
|
find('.edit-link').click
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
it 'shows the current set of labels' do
|
|
|
|
page.within('.issuable-show-labels') do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
it 'shows option to create a project label' do
|
2017-08-17 22:00:37 +05:30
|
|
|
page.within('.block.labels') do
|
2018-05-09 12:01:36 +05:30
|
|
|
expect(page).to have_content 'Create project'
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
context 'creating a project label', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
|
|
|
page.within('.block.labels') do
|
2018-05-09 12:01:36 +05:30
|
|
|
click_link 'Create project'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows dropdown switches to "create label" section' do
|
|
|
|
page.within('.block.labels') do
|
2018-05-09 12:01:36 +05:30
|
|
|
expect(page).to have_content 'Create project label'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'adds new label' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
fill_in 'new_label_name', with: 'wontfix'
|
2018-03-17 18:26:18 +05:30
|
|
|
page.find('.suggest-colors a', match: :first).click
|
|
|
|
page.find('button', text: 'Create').click
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
page.within('.dropdown-page-one') do
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
it 'shows error message if label title is taken' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
fill_in 'new_label_name', with: label.title
|
2018-03-17 18:26:18 +05:30
|
|
|
page.find('.suggest-colors a', match: :first).click
|
|
|
|
page.find('button', text: 'Create').click
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
page.within('.dropdown-page-two') do
|
|
|
|
expect(page).to have_content 'Title has already been taken'
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
before do
|
|
|
|
resize_screen_sm
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'confidentiality block expands then collapses sidebar' do
|
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
|
|
|
|
|
|
|
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)
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
expect(page).to have_css(collapsed_sidebar_selector)
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context 'as a guest' do
|
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_guest(user)
|
2016-06-02 11:05:42 +05:30
|
|
|
visit_issue(project, issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not have a option to edit labels' do
|
|
|
|
expect(page).not_to have_selector('.block.labels .edit-link')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_issue(project, issue)
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_issue_path(project, issue)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
def open_issue_sidebar
|
2018-03-17 18:26:18 +05:30
|
|
|
find('aside.right-sidebar.right-sidebar-collapsed .js-sidebar-toggle').click
|
2017-08-17 22:00:37 +05:30
|
|
|
find('aside.right-sidebar.right-sidebar-expanded')
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|