2017-02-02 11:16:16 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'Issue Boards add issue modal filtering', :js do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-02-02 11:16:16 +00:00
|
|
|
let(:board) { create(:board, project: project) }
|
2017-02-06 13:55:36 +00:00
|
|
|
let(:planning) { create(:label, project: project, name: 'Planning') }
|
|
|
|
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
|
2017-02-02 11:16:16 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:user2) { create(:user) }
|
|
|
|
let!(:issue1) { create(:issue, project: project) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
|
2017-02-02 14:54:45 +00:00
|
|
|
it 'shows empty state when no results found' do
|
|
|
|
visit_board
|
|
|
|
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
find('.form-control').native.send_keys('testing empty state')
|
2017-03-13 11:46:43 +00:00
|
|
|
find('.form-control').native.send_keys(:enter)
|
2017-02-02 14:54:45 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 14:54:45 +00:00
|
|
|
|
|
|
|
expect(page).to have_content('There are no issues to show.')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-02 14:34:28 +00:00
|
|
|
it 'restores filters when closing' do
|
|
|
|
visit_board
|
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('milestone')
|
|
|
|
click_filter_link('Upcoming')
|
|
|
|
submit_filter
|
2017-02-02 14:34:28 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 14:34:28 +00:00
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 0)
|
2017-02-02 14:34:28 +00:00
|
|
|
|
|
|
|
click_button 'Cancel'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button('Add issues')
|
|
|
|
|
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 14:34:28 +00:00
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 14:34:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
it 'resotres filters after clicking clear button' do
|
|
|
|
visit_board
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('milestone')
|
|
|
|
click_filter_link('Upcoming')
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 0)
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
find('.clear-search').click
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
2017-03-13 11:46:43 +00:00
|
|
|
end
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
context 'author' do
|
|
|
|
let!(:issue) { create(:issue, project: project, author: user2) }
|
|
|
|
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user2)
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
visit_board
|
|
|
|
end
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
it 'filters by selected user' do
|
|
|
|
set_filter('author')
|
|
|
|
click_filter_link(user2.name)
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-05-18 18:53:14 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: user2.name)
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'assignee' do
|
2017-05-04 12:11:15 +00:00
|
|
|
let!(:issue) { create(:issue, project: project, assignees: [user2]) }
|
2017-02-02 11:16:16 +00:00
|
|
|
|
|
|
|
before do
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user2)
|
2017-02-02 11:16:16 +00:00
|
|
|
|
|
|
|
visit_board
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by unassigned' do
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('assignee')
|
|
|
|
click_filter_link('No Assignee')
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-14 09:34:55 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: 'none')
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by selected user' do
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('assignee')
|
|
|
|
click_filter_link(user2.name)
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-05-18 18:53:14 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: user2.name)
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'milestone' do
|
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
|
|
|
let!(:issue) { create(:issue, project: project, milestone: milestone) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit_board
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by upcoming milestone' do
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('milestone')
|
|
|
|
click_filter_link('Upcoming')
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-14 09:34:55 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: 'upcoming')
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 0)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by selected milestone' do
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('milestone')
|
|
|
|
click_filter_link(milestone.name)
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-14 09:34:55 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: milestone.name)
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'label' do
|
|
|
|
let(:label) { create(:label, project: project) }
|
|
|
|
let!(:issue) { create(:labeled_issue, project: project, labels: [label]) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit_board
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by no label' do
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('label')
|
|
|
|
click_filter_link('No Label')
|
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-14 09:34:55 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: 'none')
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters by label' do
|
2017-03-13 11:46:43 +00:00
|
|
|
set_filter('label')
|
2017-03-14 09:34:55 +00:00
|
|
|
click_filter_link(label.title)
|
2017-03-13 11:46:43 +00:00
|
|
|
submit_filter
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-13 11:46:43 +00:00
|
|
|
page.within('.add-issues-modal') do
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
2017-03-14 09:34:55 +00:00
|
|
|
expect(page).to have_selector('.js-visual-token', text: label.title)
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def visit_board
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_board_path(project, board)
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-02 11:16:16 +00:00
|
|
|
|
|
|
|
click_button('Add issues')
|
|
|
|
end
|
2017-03-13 11:46:43 +00:00
|
|
|
|
|
|
|
def set_filter(type, text = '')
|
|
|
|
find('.add-issues-modal .filtered-search').native.send_keys("#{type}:#{text}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def submit_filter
|
|
|
|
find('.add-issues-modal .filtered-search').native.send_keys(:enter)
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_filter_link(link_text)
|
2017-03-30 02:04:05 +00:00
|
|
|
page.within('.add-issues-modal .filtered-search-box') do
|
2017-03-13 11:46:43 +00:00
|
|
|
expect(page).to have_button(link_text)
|
|
|
|
|
|
|
|
click_button(link_text)
|
|
|
|
end
|
|
|
|
end
|
2017-02-02 11:16:16 +00:00
|
|
|
end
|