Commit 3644162b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by Phil Hughes

Fix feature spec for issues board

parent 506ab9bd
...@@ -3,17 +3,18 @@ require 'rails_helper' ...@@ -3,17 +3,18 @@ require 'rails_helper'
describe 'Issue Boards', feature: true, js: true do describe 'Issue Boards', feature: true, js: true do
include WaitForAjax include WaitForAjax
let(:project) { create(:empty_project) } let(:project) { create(:empty_project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let!(:user2) { create(:user) }
before do before do
project.create_board! project.create_board
create(:backlog_list, board: project.board) project.board.lists.create(list_type: :backlog)
create(:done_list, board: project.board) project.board.lists.create(list_type: :done)
project.team << [user, :master] project.team << [user, :master]
project.team << [user2, :master] project.team << [user2, :master]
login_as(user) login_as(user)
end end
...@@ -52,7 +53,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -52,7 +53,7 @@ describe 'Issue Boards', feature: true, js: true do
end end
context 'with lists' do context 'with lists' do
let(:milestone) { create(:milestone, project: project) } let(:milestone) { create(:milestone, project: project) }
let(:planning) { create(:label, project: project, name: 'Planning') } let(:planning) { create(:label, project: project, name: 'Planning') }
let(:development) { create(:label, project: project, name: 'Development') } let(:development) { create(:label, project: project, name: 'Development') }
...@@ -81,7 +82,10 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -81,7 +82,10 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_vue_resource wait_for_vue_resource
expect(page).to have_selector('.board', count: 4) expect(page).to have_selector('.board', count: 4)
has_issues expect(find('.board:nth-child(1)')).to have_selector('.card')
expect(find('.board:nth-child(2)')).to have_selector('.card')
expect(find('.board:nth-child(3)')).to have_selector('.card')
expect(find('.board:nth-child(4)')).to have_selector('.card')
end end
it 'shows lists' do it 'shows lists' do
...@@ -123,9 +127,10 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -123,9 +127,10 @@ describe 'Issue Boards', feature: true, js: true do
page.within(find('.board:nth-child(2)')) do page.within(find('.board:nth-child(2)')) do
find('.board-delete').click find('.board-delete').click
end end
wait_for_vue_resource wait_for_vue_resource
expect(page).to have_selector('.board', count: 3)
expect(page).to have_selector('.board', count: 3)
expect(find(".js-board-list-#{planning.id}", visible: false)).not_to have_css('.is-active') expect(find(".js-board-list-#{planning.id}", visible: false)).not_to have_css('.is-active')
end end
...@@ -273,6 +278,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -273,6 +278,8 @@ describe 'Issue Boards', feature: true, js: true do
click_link testing.title click_link testing.title
end end
wait_for_vue_resource
expect(page).to have_selector('.board', count: 5) expect(page).to have_selector('.board', count: 5)
end end
...@@ -283,6 +290,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -283,6 +290,8 @@ describe 'Issue Boards', feature: true, js: true do
click_link backlog.title click_link backlog.title
end end
wait_for_vue_resource
expect(page).to have_selector('.board', count: 5) expect(page).to have_selector('.board', count: 5)
end end
...@@ -293,6 +302,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -293,6 +302,8 @@ describe 'Issue Boards', feature: true, js: true do
click_link done.title click_link done.title
end end
wait_for_vue_resource
expect(page).to have_selector('.board', count: 5) expect(page).to have_selector('.board', count: 5)
end end
...@@ -308,6 +319,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -308,6 +319,8 @@ describe 'Issue Boards', feature: true, js: true do
click_link testing.title click_link testing.title
end end
wait_for_vue_resource
page.within(find('.board', match: :first)) do page.within(find('.board', match: :first)) do
expect(page.find('.board-header')).to have_content('5') expect(page.find('.board-header')).to have_content('5')
expect(page).to have_selector('.card', count: 5) expect(page).to have_selector('.card', count: 5)
...@@ -537,18 +550,21 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -537,18 +550,21 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
def has_issues
expect(find('.board:nth-child(1)')).to have_selector('.card')
expect(find('.board:nth-child(2)')).to have_selector('.card')
expect(find('.board:nth-child(3)')).to have_selector('.card')
expect(find('.board:nth-child(4)')).to have_selector('.card')
end
def drag_to(list_from_index: 0, card_index: 0, to_index: 0, list_to_index: 0, selector: '.board-list') 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}}});") 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
end end
def wait_for_vue_resource def wait_for_vue_resource
Timeout.timeout(Capybara.default_max_wait_time) do
loop until page.evaluate_script('Vue.activeResources').zero?
end
expect(find('.boards-list')).not_to have_selector('.fa-spinner') expect(find('.boards-list')).not_to have_selector('.fa-spinner')
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment