Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-15 12:06:09 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-15 12:06:09 +0300
commit3d13802bc2c9400ea33defdd43bff6d904ee9c4d (patch)
tree44f66ca61ea85130cf210d013b737642ce9c7794 /spec/features/boards/multi_select_spec.rb
parent00050519d16f7c0296fa0113de7065a607862501 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/boards/multi_select_spec.rb')
-rw-r--r--spec/features/boards/multi_select_spec.rb110
1 files changed, 110 insertions, 0 deletions
diff --git a/spec/features/boards/multi_select_spec.rb b/spec/features/boards/multi_select_spec.rb
new file mode 100644
index 00000000000..885dc08e38d
--- /dev/null
+++ b/spec/features/boards/multi_select_spec.rb
@@ -0,0 +1,110 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Multi Select Issue', :js do
+ include DragTo
+
+ let(:group) { create(:group, :nested) }
+ let(:project) { create(:project, :public, namespace: group) }
+ let(:board) { create(:board, project: project) }
+ let(:user) { create(:user) }
+
+ def drag(selector: '.board-list', list_from_index: 1, from_index: 0, to_index: 0, list_to_index: 1, duration: 1000)
+ drag_to(selector: selector,
+ scrollable: '#board-app',
+ list_from_index: list_from_index,
+ from_index: from_index,
+ to_index: to_index,
+ list_to_index: list_to_index,
+ duration: duration)
+ end
+
+ def wait_for_board_cards(board_number, expected_cards)
+ page.within(find(".board:nth-child(#{board_number})")) do
+ expect(page.find('.board-header')).to have_content(expected_cards.to_s)
+ expect(page).to have_selector('.board-card', count: expected_cards)
+ end
+ end
+
+ def multi_select(selector, action = 'select')
+ element = page.find(selector)
+ script = "var el = document.querySelector('#{selector}');"
+ script += "var mousedown = new MouseEvent('mousedown', { button: 0, bubbles: true });"
+ script += "var mouseup = new MouseEvent('mouseup', { ctrlKey: true, button: 0, bubbles:true });"
+ script += "el.dispatchEvent(mousedown); el.dispatchEvent(mouseup);"
+ script += "Sortable.utils.#{action}(el);"
+
+ page.execute_script(script, element)
+ end
+
+ before do
+ project.add_maintainer(user)
+
+ sign_in(user)
+ end
+
+ context 'with lists' do
+ let(:label1) { create(:label, project: project, name: 'Label 1', description: 'Test') }
+ let(:label2) { create(:label, project: project, name: 'Label 2', description: 'Test') }
+ let!(:list1) { create(:list, board: board, label: label1, position: 0) }
+ let!(:list2) { create(:list, board: board, label: label2, position: 1) }
+ let!(:issue1) { create(:labeled_issue, project: project, title: 'Issue 1', description: '', assignees: [user], labels: [label1], relative_position: 1) }
+ let!(:issue2) { create(:labeled_issue, project: project, title: 'Issue 2', description: '', author: user, labels: [label1], relative_position: 2) }
+ let!(:issue3) { create(:labeled_issue, project: project, title: 'Issue 3', description: '', labels: [label1], relative_position: 3) }
+ let!(:issue4) { create(:labeled_issue, project: project, title: 'Issue 4', description: '', labels: [label1], relative_position: 4) }
+ let!(:issue5) { create(:labeled_issue, project: project, title: 'Issue 5', description: '', labels: [label1], relative_position: 5) }
+
+ before do
+ visit project_board_path(project, board)
+
+ wait_for_requests
+ end
+
+ it 'moves multiple issues to another list', :js do
+ multi_select('.board-card:nth-child(1)')
+ multi_select('.board-card:nth-child(2)')
+ drag(list_from_index: 1, list_to_index: 2)
+
+ wait_for_requests
+
+ page.within(all('.js-board-list')[2]) do
+ expect(find('.board-card:nth-child(1)')).to have_content(issue1.title)
+ expect(find('.board-card:nth-child(2)')).to have_content(issue2.title)
+ end
+ end
+
+ it 'maintains order when moved', :js do
+ multi_select('.board-card:nth-child(3)')
+ multi_select('.board-card:nth-child(2)')
+ multi_select('.board-card:nth-child(1)')
+
+ drag(list_from_index: 1, list_to_index: 2)
+
+ wait_for_requests
+
+ page.within(all('.js-board-list')[2]) do
+ expect(find('.board-card:nth-child(1)')).to have_content(issue1.title)
+ expect(find('.board-card:nth-child(2)')).to have_content(issue2.title)
+ expect(find('.board-card:nth-child(3)')).to have_content(issue3.title)
+ end
+ end
+
+ it 'move issues in the same list', :js do
+ multi_select('.board-card:nth-child(3)')
+ multi_select('.board-card:nth-child(4)')
+
+ drag(list_from_index: 1, list_to_index: 1, from_index: 2, to_index: 4)
+
+ wait_for_requests
+
+ page.within(all('.js-board-list')[1]) do
+ expect(find('.board-card:nth-child(1)')).to have_content(issue1.title)
+ expect(find('.board-card:nth-child(2)')).to have_content(issue2.title)
+ expect(find('.board-card:nth-child(3)')).to have_content(issue5.title)
+ expect(find('.board-card:nth-child(4)')).to have_content(issue3.title)
+ expect(find('.board-card:nth-child(5)')).to have_content(issue4.title)
+ end
+ end
+ end
+end