Commit 82481a6a authored by Phil Hughes's avatar Phil Hughes

Added vue resource interceptor

parent 01335d7c
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
//= require_tree ./mixins //= require_tree ./mixins
//= require ./components/board //= require ./components/board
//= require ./components/new_list_dropdown //= require ./components/new_list_dropdown
//= require ./vue_resource_interceptor
$(() => { $(() => {
const $boardApp = document.getElementById('board-app'), const $boardApp = document.getElementById('board-app'),
......
Vue.activeResources = 0;
Vue.http.interceptors.push((request, next) => {
Vue.activeResources++;
next((response) => {
Vue.activeResources--;
});
});
...@@ -72,10 +72,11 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -72,10 +72,11 @@ describe 'Issue Boards', feature: true, js: true do
before do before do
visit namespace_project_board_path(project.namespace, project) visit namespace_project_board_path(project.namespace, project)
sleep 1 wait_for_vue_resource
end end
it 'shows lists' do it 'shows lists' do
wait_for_vue_resource
expect(page).to have_selector('.board', count: 4) expect(page).to have_selector('.board', count: 4)
end end
...@@ -122,7 +123,7 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -122,7 +123,7 @@ describe 'Issue Boards', feature: true, js: true do
end end
visit namespace_project_board_path(project.namespace, project) visit namespace_project_board_path(project.namespace, project)
sleep 1 wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('20') expect(page.find('.board-header')).to have_content('20')
...@@ -159,6 +160,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -159,6 +160,8 @@ describe 'Issue Boards', feature: true, js: true do
find('.board-search-clear-btn').click find('.board-search-clear-btn').click
wait_for_vue_resource
expect(page).to have_selector('.card', count: 6) expect(page).to have_selector('.card', count: 6)
end end
end end
...@@ -315,6 +318,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -315,6 +318,8 @@ describe 'Issue Boards', feature: true, js: true do
expect(find('.js-author-search')).to have_content(user2.name) expect(find('.js-author-search')).to have_content(user2.name)
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('1') expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
...@@ -337,6 +342,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -337,6 +342,8 @@ describe 'Issue Boards', feature: true, js: true do
expect(find('.js-assignee-search')).to have_content(user.name) expect(find('.js-assignee-search')).to have_content(user.name)
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('1') expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
...@@ -359,6 +366,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -359,6 +366,8 @@ describe 'Issue Boards', feature: true, js: true do
expect(find('.js-milestone-select')).to have_content(milestone.title) expect(find('.js-milestone-select')).to have_content(milestone.title)
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('0') expect(page.find('.board-header')).to have_content('0')
expect(page).to have_selector('.card', count: 0) expect(page).to have_selector('.card', count: 0)
...@@ -380,6 +389,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -380,6 +389,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('1') expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
...@@ -405,12 +416,16 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -405,12 +416,16 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('20') expect(page.find('.board-header')).to have_content('20')
expect(page).to have_selector('.card', count: 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") 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.find('.board-header')).to have_content('40')
expect(page).to have_selector('.card', count: 40) expect(page).to have_selector('.card', count: 40)
end end
...@@ -427,6 +442,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -427,6 +442,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('1') expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
...@@ -448,6 +465,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -448,6 +465,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) 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)
...@@ -469,6 +488,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -469,6 +488,8 @@ describe 'Issue Boards', feature: true, js: true do
end end
end end
wait_for_vue_resource
page.within(first('.board')) do page.within(first('.board')) do
expect(page.find('.board-header')).to have_content('1') expect(page.find('.board-header')).to have_content('1')
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
...@@ -499,6 +520,8 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -499,6 +520,8 @@ describe 'Issue Boards', feature: true, js: true do
expect(page).to have_selector('.card', count: 1) expect(page).to have_selector('.card', count: 1)
end end
wait_for_vue_resource
page.within('.labels-filter') do page.within('.labels-filter') do
expect(find('.dropdown-toggle-text')).to have_content(bug.title) expect(find('.dropdown-toggle-text')).to have_content(bug.title)
end end
...@@ -513,4 +536,10 @@ describe 'Issue Boards', feature: true, js: true do ...@@ -513,4 +536,10 @@ describe 'Issue Boards', feature: true, js: true do
loop until page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').zero? loop until page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').zero?
end end
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 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