2017-01-25 16:53:09 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 04:13:10 +00:00
|
|
|
describe 'Issue Boards add issue modal', :js do
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-01-25 16:53:09 +00:00
|
|
|
let(:board) { create(:board, project: project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let!(:planning) { create(:label, project: project, name: 'Planning') }
|
|
|
|
let!(:label) { create(:label, project: project) }
|
|
|
|
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
|
2017-01-27 16:49:56 +00:00
|
|
|
let!(:list2) { create(:list, board: board, label: label, position: 1) }
|
2017-08-30 14:37:23 +00:00
|
|
|
let!(:issue) { create(:issue, project: project, title: 'abc', description: 'def') }
|
|
|
|
let!(:issue2) { create(:issue, project: project, title: 'hij', description: 'klm') }
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-01-25 16:53:09 +00:00
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2017-01-25 16:53:09 +00:00
|
|
|
|
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-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
|
2017-03-21 14:57:21 +00:00
|
|
|
it 'resets filtered search state' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_board_path(project, board, search: 'testing')
|
2017-03-21 14:57:21 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-21 14:57:21 +00:00
|
|
|
|
|
|
|
click_button('Add issues')
|
|
|
|
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
expect(find('.form-control').value).to eq('')
|
|
|
|
expect(page).to have_selector('.clear-search', visible: false)
|
|
|
|
expect(find('.form-control')[:placeholder]).to eq('Search or filter results...')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-25 16:53:09 +00:00
|
|
|
context 'modal interaction' do
|
|
|
|
it 'opens modal' do
|
|
|
|
click_button('Add issues')
|
|
|
|
|
|
|
|
expect(page).to have_selector('.add-issues-modal')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'closes modal' do
|
|
|
|
click_button('Add issues')
|
|
|
|
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
find('.close').click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.add-issues-modal')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'closes modal if cancel button clicked' do
|
|
|
|
click_button('Add issues')
|
|
|
|
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
click_button 'Cancel'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.add-issues-modal')
|
|
|
|
end
|
2017-02-10 16:38:11 +00:00
|
|
|
|
|
|
|
it 'does not show tooltip on add issues button' do
|
2017-03-08 12:17:01 +00:00
|
|
|
button = page.find('.filter-dropdown-container button', text: 'Add issues')
|
2017-02-10 16:38:11 +00:00
|
|
|
|
|
|
|
expect(button[:title]).not_to eq("Please add a list to your board first")
|
|
|
|
end
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'issues list' do
|
|
|
|
before do
|
|
|
|
click_button('Add issues')
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'loads issues' do
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
page.within('.nav-links') do
|
|
|
|
expect(page).to have_content('2')
|
|
|
|
end
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 2)
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows selected issues' do
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
click_link 'Selected issues'
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).not_to have_selector('.board-card')
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-03 14:48:31 +00:00
|
|
|
context 'list dropdown' do
|
|
|
|
it 'resets after deleting list' do
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
expect(find('.add-issues-footer')).to have_button(planning.title)
|
|
|
|
|
|
|
|
click_button 'Cancel'
|
|
|
|
end
|
|
|
|
|
2017-10-04 21:52:22 +00:00
|
|
|
accept_confirm { first('.board-delete').click }
|
2017-10-10 20:56:43 +00:00
|
|
|
|
2017-02-03 14:48:31 +00:00
|
|
|
click_button('Add issues')
|
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-03 14:48:31 +00:00
|
|
|
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
expect(find('.add-issues-footer')).not_to have_button(planning.title)
|
|
|
|
expect(find('.add-issues-footer')).to have_button(label.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-25 16:53:09 +00:00
|
|
|
context 'search' do
|
|
|
|
it 'returns issues' do
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
find('.form-control').native.send_keys(issue.title)
|
2017-03-13 13:05:32 +00:00
|
|
|
find('.form-control').native.send_keys(:enter)
|
2017-01-25 16:53:09 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-16 15:01:14 +00:00
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns no issues' do
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
find('.form-control').native.send_keys('testing search')
|
2017-03-13 13:05:32 +00:00
|
|
|
find('.form-control').native.send_keys(:enter)
|
2017-01-25 16:53:09 +00:00
|
|
|
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-03-16 15:01:14 +00:00
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).not_to have_selector('.board-card')
|
2017-01-31 10:39:44 +00:00
|
|
|
expect(page).not_to have_content("You haven't added any issues to your project yet")
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'selecing issues' do
|
|
|
|
it 'selects single issue' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
page.within('.nav-links') do
|
|
|
|
expect(page).to have_content('Selected issues 1')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes button text' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
expect(first('.add-issues-footer .btn')).to have_content('Add 1 issue')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'changes button text with plural' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
all('.board-card .board-card-number').each do |el|
|
2017-01-25 16:53:09 +00:00
|
|
|
el.click
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(first('.add-issues-footer .btn')).to have_content('Add 2 issues')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows only selected issues on selected tab' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
click_link 'Selected issues'
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card', count: 1)
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'selects all issues' do
|
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
click_button 'Select all'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.is-active', count: 2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-31 16:35:04 +00:00
|
|
|
it 'deselects all issues' do
|
2017-01-25 16:53:09 +00:00
|
|
|
page.within('.add-issues-modal') do
|
|
|
|
click_button 'Select all'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.is-active', count: 2)
|
|
|
|
|
2017-01-31 16:35:04 +00:00
|
|
|
click_button 'Deselect all'
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
expect(page).not_to have_selector('.is-active')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'selects all that arent already selected' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector('.is-active', count: 1)
|
|
|
|
|
|
|
|
click_button 'Select all'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.is-active', count: 2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'unselects from selected tab' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
click_link 'Selected issues'
|
|
|
|
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
2017-01-27 16:49:56 +00:00
|
|
|
expect(page).not_to have_selector('.is-active')
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'adding issues' do
|
|
|
|
it 'adds to board' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
click_button 'Add 1 issue'
|
|
|
|
end
|
|
|
|
|
2017-06-01 13:54:10 +00:00
|
|
|
page.within(find('.board:nth-child(2)')) do
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card')
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds to second list' do
|
|
|
|
page.within('.add-issues-modal') do
|
2018-04-13 20:27:10 +00:00
|
|
|
first('.board-card .board-card-number').click
|
2017-01-25 16:53:09 +00:00
|
|
|
|
|
|
|
click_button planning.title
|
|
|
|
|
|
|
|
click_link label.title
|
|
|
|
|
|
|
|
click_button 'Add 1 issue'
|
|
|
|
end
|
|
|
|
|
2017-06-01 13:54:10 +00:00
|
|
|
page.within(find('.board:nth-child(3)')) do
|
2018-04-13 20:27:10 +00:00
|
|
|
expect(page).to have_selector('.board-card')
|
2017-01-25 16:53:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|