2016-04-15 15:25:36 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Issue Sidebar' do
|
2017-01-27 17:11:05 -05:00
|
|
|
include MobileHelpers
|
2016-11-17 06:13:39 -05:00
|
|
|
|
2017-05-01 01:57:58 -04:00
|
|
|
let(:group) { create(:group, :nested) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public, namespace: group) }
|
2016-04-15 15:25:36 -04:00
|
|
|
let(:issue) { create(:issue, project: project) }
|
|
|
|
let!(:user) { create(:user)}
|
2017-02-05 22:39:20 -05:00
|
|
|
let!(:label) { create(:label, project: project, title: 'bug') }
|
2017-12-15 15:29:53 -05:00
|
|
|
let!(:xss_label) { create(:label, project: project, title: '<script>alert("xss");</script>') }
|
2016-04-15 15:25:36 -04:00
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
context 'assignee', :js do
|
2016-11-17 06:13:39 -05:00
|
|
|
let(:user2) { create(:user) }
|
|
|
|
let(:issue2) { create(:issue, project: project, author: user2) }
|
|
|
|
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2016-11-17 06:13:39 -05:00
|
|
|
visit_issue(project, issue2)
|
|
|
|
|
|
|
|
find('.block.assignee .edit-link').click
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-17 06:13:39 -05:00
|
|
|
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-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-17 06:13:39 -05:00
|
|
|
|
|
|
|
expect(page).to have_content(user2.name)
|
|
|
|
end
|
|
|
|
end
|
2017-05-04 08:11:15 -04:00
|
|
|
|
|
|
|
it 'assigns yourself' do
|
|
|
|
find('.block.assignee .dropdown-menu-toggle').click
|
|
|
|
|
|
|
|
click_button 'assign yourself'
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-04 08:11:15 -04:00
|
|
|
|
|
|
|
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
|
2017-05-26 17:27:30 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
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
|
2016-11-17 06:13:39 -05:00
|
|
|
end
|
|
|
|
|
2016-04-15 15:25:36 -04:00
|
|
|
context 'as a allowed user' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2016-04-15 15:25:36 -04:00
|
|
|
visit_issue(project, issue)
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
context 'sidebar', :js do
|
2016-11-14 13:56:52 -05:00
|
|
|
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
|
2017-05-02 21:37:01 -04:00
|
|
|
find(sidebar_selector)
|
2016-11-14 13:56:52 -05:00
|
|
|
expect(page).to have_css(sidebar_selector)
|
|
|
|
# Once is collapsed let's open the sidebard and reload
|
2017-01-27 17:11:05 -05:00
|
|
|
open_issue_sidebar
|
2016-11-14 13:56:52 -05:00
|
|
|
refresh
|
2017-05-02 21:37:01 -04:00
|
|
|
find(sidebar_selector)
|
2016-11-14 13:56:52 -05:00
|
|
|
expect(page).to have_css(sidebar_selector)
|
|
|
|
# Restore the window size as it was including the sidebar
|
|
|
|
restore_window_size
|
2017-01-27 17:11:05 -05:00
|
|
|
open_issue_sidebar
|
2016-11-14 13:56:52 -05:00
|
|
|
end
|
2017-12-15 15:29:53 -05:00
|
|
|
|
|
|
|
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-11-14 13:56:52 -05:00
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
context 'editing issue labels', :js do
|
2017-02-05 22:39:20 -05:00
|
|
|
before do
|
2016-04-15 15:25:36 -04:00
|
|
|
page.within('.block.labels') do
|
|
|
|
find('.edit-link').click
|
2017-02-05 22:39:20 -05:00
|
|
|
end
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2017-02-05 22:39:20 -05:00
|
|
|
it 'shows option to create a new label' do
|
|
|
|
page.within('.block.labels') do
|
2016-04-15 15:25:36 -04:00
|
|
|
expect(page).to have_content 'Create new'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
context 'creating a new label', :js do
|
2017-02-05 22:39:20 -05:00
|
|
|
before do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
click_link 'Create new'
|
|
|
|
end
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2017-02-05 22:39:20 -05:00
|
|
|
it 'shows dropdown switches to "create label" section' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
expect(page).to have_content 'Create new label'
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
|
|
|
|
2017-02-05 22:39:20 -05:00
|
|
|
it 'adds new label' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
fill_in 'new_label_name', with: 'wontfix'
|
2017-08-13 01:51:35 -04:00
|
|
|
page.find('.suggest-colors a', match: :first).click
|
|
|
|
page.find('button', text: 'Create').click
|
2017-02-05 22:39:20 -05:00
|
|
|
|
|
|
|
page.within('.dropdown-page-one') do
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2017-02-05 22:39:20 -05:00
|
|
|
it 'shows error message if label title is taken' do
|
|
|
|
page.within('.block.labels') do
|
|
|
|
fill_in 'new_label_name', with: label.title
|
2017-08-13 01:51:35 -04:00
|
|
|
page.find('.suggest-colors a', match: :first).click
|
|
|
|
page.find('button', text: 'Create').click
|
2016-04-15 15:25:36 -04:00
|
|
|
|
2017-02-05 22:39:20 -05:00
|
|
|
page.within('.dropdown-page-two') do
|
|
|
|
expect(page).to have_content 'Title has already been taken'
|
|
|
|
end
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'as a guest' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_guest(user)
|
2016-04-15 15:25:36 -04:00
|
|
|
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-07-06 12:20:50 -04:00
|
|
|
visit project_issue_path(project, issue)
|
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
|
2016-04-15 15:25:36 -04:00
|
|
|
end
|