2017-02-13 07:15:20 -05:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe 'Issue Boards', :js do
|
2017-02-13 07:15:20 -05:00
|
|
|
include DragTo
|
|
|
|
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public) }
|
2017-02-13 07:15:20 -05:00
|
|
|
let(:board) { create(:board, project: project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:label) { create(:label, project: project) }
|
|
|
|
let!(:list1) { create(:list, board: board, label: label, position: 0) }
|
2017-03-01 06:18:58 -05:00
|
|
|
let!(:issue1) { create(:labeled_issue, project: project, title: 'testing 1', labels: [label], relative_position: 3) }
|
|
|
|
let!(:issue2) { create(:labeled_issue, project: project, title: 'testing 2', labels: [label], relative_position: 2) }
|
|
|
|
let!(:issue3) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label], relative_position: 1) }
|
2017-02-13 07:15:20 -05:00
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
2017-03-02 06:42:24 -05:00
|
|
|
context 'un-ordered issues' do
|
|
|
|
let!(:issue4) { create(:labeled_issue, project: project, labels: [label]) }
|
|
|
|
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_board_path(project, board)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-03-02 06:42:24 -05:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
expect(page).to have_selector('.board', count: 3)
|
2017-03-02 06:42:24 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has un-ordered issue as last issue' do
|
2017-06-01 07:39:29 -04:00
|
|
|
page.within(find('.board:nth-child(2)')) do
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(all('.board-card').last).to have_content(issue4.title)
|
2017-03-02 06:42:24 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves un-ordered issue to top of list' do
|
2018-05-31 11:00:11 -04:00
|
|
|
drag(from_index: 3, to_index: 0, duration: 1180)
|
2017-03-02 06:42:24 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-05-09 00:15:34 -04:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
page.within(find('.board:nth-child(2)')) do
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(first('.board-card')).to have_content(issue4.title)
|
2017-03-02 06:42:24 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-13 07:15:20 -05:00
|
|
|
context 'ordering in list' do
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_board_path(project, board)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
expect(page).to have_selector('.board', count: 3)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves from middle to top' do
|
|
|
|
drag(from_index: 1, to_index: 0)
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(first('.board-card')).to have_content(issue2.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves from middle to bottom' do
|
|
|
|
drag(from_index: 1, to_index: 2)
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(all('.board-card').last).to have_content(issue2.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves from top to bottom' do
|
|
|
|
drag(from_index: 0, to_index: 2)
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(all('.board-card').last).to have_content(issue3.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves from bottom to top' do
|
2018-11-07 12:20:17 -05:00
|
|
|
drag(from_index: 2, to_index: 0, duration: 1020)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(first('.board-card')).to have_content(issue1.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves from top to middle' do
|
|
|
|
drag(from_index: 0, to_index: 1)
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(first('.board-card')).to have_content(issue2.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves from bottom to middle' do
|
|
|
|
drag(from_index: 2, to_index: 1)
|
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(all('.board-card').last).to have_content(issue2.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'ordering when changing list' do
|
|
|
|
let(:label2) { create(:label, project: project) }
|
|
|
|
let!(:list2) { create(:list, board: board, label: label2, position: 1) }
|
2017-02-17 09:44:39 -05:00
|
|
|
let!(:issue4) { create(:labeled_issue, project: project, title: 'testing 1', labels: [label2], relative_position: 3.0) }
|
|
|
|
let!(:issue5) { create(:labeled_issue, project: project, title: 'testing 2', labels: [label2], relative_position: 2.0) }
|
|
|
|
let!(:issue6) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label2], relative_position: 1.0) }
|
2017-02-13 07:15:20 -05:00
|
|
|
|
|
|
|
before do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_board_path(project, board)
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
expect(page).to have_selector('.board', count: 4)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves to top of another list' do
|
2017-06-01 07:39:29 -04:00
|
|
|
drag(list_from_index: 1, list_to_index: 2)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
|
|
|
|
expect(all('.board')[2]).to have_selector('.board-card', count: 4)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
page.within(all('.board')[2]) do
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(first('.board-card')).to have_content(issue3.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves to bottom of another list' do
|
2018-11-07 12:20:17 -05:00
|
|
|
drag(list_from_index: 1, list_to_index: 2, to_index: 2, duration: 1020)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
|
|
|
|
expect(all('.board')[2]).to have_selector('.board-card', count: 4)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
page.within(all('.board')[2]) do
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(all('.board-card').last).to have_content(issue3.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'moves to index of another list' do
|
2017-06-01 07:39:29 -04:00
|
|
|
drag(list_from_index: 1, list_to_index: 2, to_index: 1)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
|
|
|
|
expect(all('.board')[2]).to have_selector('.board-card', count: 4)
|
2017-02-13 07:15:20 -05:00
|
|
|
|
2017-06-01 07:39:29 -04:00
|
|
|
page.within(all('.board')[2]) do
|
2018-04-13 16:27:10 -04:00
|
|
|
expect(all('.board-card')[1]).to have_content(issue3.title)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-31 11:00:11 -04:00
|
|
|
def drag(selector: '.board-list', list_from_index: 1, from_index: 0, to_index: 0, list_to_index: 1, duration: 1000)
|
2017-02-13 07:15:20 -05:00
|
|
|
drag_to(selector: selector,
|
|
|
|
scrollable: '#board-app',
|
|
|
|
list_from_index: list_from_index,
|
|
|
|
from_index: from_index,
|
|
|
|
to_index: to_index,
|
2018-05-31 11:00:11 -04:00
|
|
|
list_to_index: list_to_index,
|
|
|
|
duration: duration)
|
2017-02-13 07:15:20 -05:00
|
|
|
end
|
|
|
|
end
|