diff --git a/app/assets/javascripts/boards/boards_bundle.js.es6 b/app/assets/javascripts/boards/boards_bundle.js.es6 index 560a9a079bb6c7da64542d25da1763ef843ee6d5..fbb05534ef6856ac41be7dc3bba2b1e07898f618 100644 --- a/app/assets/javascripts/boards/boards_bundle.js.es6 +++ b/app/assets/javascripts/boards/boards_bundle.js.es6 @@ -7,6 +7,7 @@ //= require_tree ./mixins //= require ./components/board //= require ./components/new_list_dropdown +//= require ./vue_resource_interceptor $(() => { const $boardApp = document.getElementById('board-app'), diff --git a/app/assets/javascripts/boards/vue_resource_interceptor.js.es6 b/app/assets/javascripts/boards/vue_resource_interceptor.js.es6 new file mode 100644 index 0000000000000000000000000000000000000000..c6db7c75ea6511e42652725e7170afc7ee3c9e9a --- /dev/null +++ b/app/assets/javascripts/boards/vue_resource_interceptor.js.es6 @@ -0,0 +1,9 @@ +Vue.activeResources = 0; + +Vue.http.interceptors.push((request, next) => { + Vue.activeResources++; + + next((response) => { + Vue.activeResources--; + }); +}); diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index 8c101a251b35d0012a097e8fd2c4e6d436fdaaad..1406c4e8b6ff99a45e5703bd7365db470dfc0405 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -72,10 +72,11 @@ describe 'Issue Boards', feature: true, js: true do before do visit namespace_project_board_path(project.namespace, project) - sleep 1 + wait_for_vue_resource end it 'shows lists' do + wait_for_vue_resource expect(page).to have_selector('.board', count: 4) end @@ -122,7 +123,7 @@ describe 'Issue Boards', feature: true, js: true do end visit namespace_project_board_path(project.namespace, project) - sleep 1 + wait_for_vue_resource page.within(first('.board')) do expect(page.find('.board-header')).to have_content('20') @@ -159,6 +160,8 @@ describe 'Issue Boards', feature: true, js: true do find('.board-search-clear-btn').click + wait_for_vue_resource + expect(page).to have_selector('.card', count: 6) end end @@ -315,6 +318,8 @@ describe 'Issue Boards', feature: true, js: true do expect(find('.js-author-search')).to have_content(user2.name) end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('1') expect(page).to have_selector('.card', count: 1) @@ -337,6 +342,8 @@ describe 'Issue Boards', feature: true, js: true do expect(find('.js-assignee-search')).to have_content(user.name) end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('1') expect(page).to have_selector('.card', count: 1) @@ -359,6 +366,8 @@ describe 'Issue Boards', feature: true, js: true do expect(find('.js-milestone-select')).to have_content(milestone.title) end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('0') expect(page).to have_selector('.card', count: 0) @@ -380,6 +389,8 @@ describe 'Issue Boards', feature: true, js: true do end end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('1') expect(page).to have_selector('.card', count: 1) @@ -405,12 +416,16 @@ describe 'Issue Boards', feature: true, js: true do end end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('20') expect(page).to have_selector('.card', count: 20) evaluate_script("document.querySelectorAll('.board .board-list')[0].scrollTop = document.querySelectorAll('.board .board-list')[0].scrollHeight") + wait_for_vue_resource + expect(page.find('.board-header')).to have_content('40') expect(page).to have_selector('.card', count: 40) end @@ -427,6 +442,8 @@ describe 'Issue Boards', feature: true, js: true do end end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('1') expect(page).to have_selector('.card', count: 1) @@ -448,6 +465,8 @@ describe 'Issue Boards', feature: true, js: true do end end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('5') expect(page).to have_selector('.card', count: 5) @@ -469,6 +488,8 @@ describe 'Issue Boards', feature: true, js: true do end end + wait_for_vue_resource + page.within(first('.board')) do expect(page.find('.board-header')).to have_content('1') expect(page).to have_selector('.card', count: 1) @@ -499,6 +520,8 @@ describe 'Issue Boards', feature: true, js: true do expect(page).to have_selector('.card', count: 1) end + wait_for_vue_resource + page.within('.labels-filter') do expect(find('.dropdown-toggle-text')).to have_content(bug.title) end @@ -513,4 +536,10 @@ describe 'Issue Boards', feature: true, js: true do loop until page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').zero? end end + + def wait_for_vue_resource + Timeout.timeout(Capybara.default_max_wait_time) do + loop until page.evaluate_script('Vue.activeResources').zero? + end + end end