diff options
author | Phil Hughes <me@iamphill.com> | 2017-01-06 19:52:18 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-02-06 14:28:16 +0300 |
commit | 653c23b9c23b6af8c57b45e7d5444e1ca6d34d9a (patch) | |
tree | 72318ea3ae9f968d0f3de2be36ea91786a984ffc /spec | |
parent | 572fb0be9b1d45437b7c0ed1000399657f471ec7 (diff) |
Removed jQuery UI sortable
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/boards/boards_spec.rb | 28 | ||||
-rw-r--r-- | spec/features/milestones/milestones_spec.rb | 5 | ||||
-rw-r--r-- | spec/features/projects/labels/update_prioritization_spec.rb | 3 | ||||
-rw-r--r-- | spec/support/drag_to_helper.rb | 13 |
4 files changed, 32 insertions, 17 deletions
diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index 34f47daf0e5..7225f38b7e5 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' describe 'Issue Boards', feature: true, js: true do include WaitForAjax include WaitForVueResource + include DragTo let(:project) { create(:empty_project, :public) } let(:board) { create(:board, project: project) } @@ -188,7 +189,7 @@ describe 'Issue Boards', feature: true, js: true do end it 'moves issue to done' do - drag_to(list_from_index: 0, list_to_index: 2) + drag(list_from_index: 0, list_to_index: 2) wait_for_board_cards(1, 7) wait_for_board_cards(2, 2) @@ -201,7 +202,7 @@ describe 'Issue Boards', feature: true, js: true do end it 'removes all of the same issue to done' do - drag_to(list_from_index: 0, list_to_index: 2) + drag(list_from_index: 0, list_to_index: 2) wait_for_board_cards(1, 7) wait_for_board_cards(2, 2) @@ -215,7 +216,7 @@ describe 'Issue Boards', feature: true, js: true do context 'lists' do it 'changes position of list' do - drag_to(list_from_index: 1, list_to_index: 0, selector: '.board-header') + drag(list_from_index: 1, list_to_index: 0, selector: '.board-header') wait_for_board_cards(1, 2) wait_for_board_cards(2, 8) @@ -226,7 +227,7 @@ describe 'Issue Boards', feature: true, js: true do end it 'issue moves between lists' do - drag_to(list_from_index: 0, card_index: 1, list_to_index: 1) + drag(list_from_index: 0, from_index: 1, list_to_index: 1) wait_for_board_cards(1, 7) wait_for_board_cards(2, 2) @@ -237,7 +238,7 @@ describe 'Issue Boards', feature: true, js: true do end it 'issue moves between lists' do - drag_to(list_from_index: 1, list_to_index: 0) + drag(list_from_index: 1, list_to_index: 0) wait_for_board_cards(1, 9) wait_for_board_cards(2, 1) @@ -248,7 +249,7 @@ describe 'Issue Boards', feature: true, js: true do end it 'issue moves from done' do - drag_to(list_from_index: 2, list_to_index: 1) + drag(list_from_index: 2, list_to_index: 1) expect(find('.board:nth-child(2)')).to have_content(issue8.title) @@ -615,14 +616,13 @@ describe 'Issue Boards', feature: true, js: true do end end - def drag_to(list_from_index: 0, card_index: 0, to_index: 0, list_to_index: 0, selector: '.board-list') - evaluate_script("simulateDrag({scrollable: document.getElementById('board-app'), from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{card_index}}, to: {el: $('.board-list').eq(#{list_to_index}).get(0), index: #{to_index}}});") - - Timeout.timeout(Capybara.default_max_wait_time) do - loop until page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').zero? - end - - wait_for_vue_resource + def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0) + 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) end def wait_for_board_cards(board_number, expected_cards) diff --git a/spec/features/milestones/milestones_spec.rb b/spec/features/milestones/milestones_spec.rb index aadd72a9f8e..8de9942c54e 100644 --- a/spec/features/milestones/milestones_spec.rb +++ b/spec/features/milestones/milestones_spec.rb @@ -2,6 +2,7 @@ require 'rails_helper' describe 'Milestone draggable', feature: true, js: true do include WaitForAjax + include DragTo let(:milestone) { create(:milestone, project: project, title: 8.14) } let(:project) { create(:empty_project, :public) } @@ -75,7 +76,7 @@ describe 'Milestone draggable', feature: true, js: true do create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone)) visit namespace_project_milestone_path(project.namespace, project, milestone) - issue.drag_to(issue_target) + drag_to(selector: '.issues-sortable-list', list_to_index: 1) wait_for_ajax end @@ -85,7 +86,7 @@ describe 'Milestone draggable', feature: true, js: true do visit namespace_project_milestone_path(project.namespace, project, milestone) page.find("a[href='#tab-merge-requests']").click - merge_request.drag_to(merge_request_target) + drag_to(selector: '.merge_requests-sortable-list', list_to_index: 1) wait_for_ajax end diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb index 97ce9cdfd87..1e900d7e660 100644 --- a/spec/features/projects/labels/update_prioritization_spec.rb +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' feature 'Prioritize labels', feature: true do include WaitForAjax + include DragTo let(:user) { create(:user) } let(:group) { create(:group) } @@ -99,7 +100,7 @@ feature 'Prioritize labels', feature: true do expect(page).to have_content 'wontfix' # Sort labels - find("#project_label_#{bug.id}").drag_to find("#group_label_#{feature.id}") + drag_to(selector: '.js-prioritized-labels', from_index: 1, to_index: 2) page.within('.prioritized-labels') do expect(first('li')).to have_content('feature') diff --git a/spec/support/drag_to_helper.rb b/spec/support/drag_to_helper.rb new file mode 100644 index 00000000000..0c0659d3ecd --- /dev/null +++ b/spec/support/drag_to_helper.rb @@ -0,0 +1,13 @@ +module DragTo + def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: '', scrollable: 'body') + evaluate_script("simulateDrag({scrollable: $('#{scrollable}').get(0), from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{from_index}}, to: {el: $('#{selector}').eq(#{list_to_index}).get(0), index: #{to_index}}});") + + Timeout.timeout(Capybara.default_max_wait_time) do + loop until drag_active? + end + end + + def drag_active? + page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').zero? + end +end |