summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-08-16 11:34:32 +0100
committerPhil Hughes <me@iamphill.com>2016-08-17 17:17:39 +0100
commit82481a6a9d0674b4edce38b11d79d2e3676672f1 (patch)
tree674fb0e84691f3c67cef76a56efa478658b25833
parent01335d7cd555a92d0e9ac2db6f6a356a496218cd (diff)
downloadgitlab-ce-82481a6a9d0674b4edce38b11d79d2e3676672f1.tar.gz
Added vue resource interceptor
-rw-r--r--app/assets/javascripts/boards/boards_bundle.js.es61
-rw-r--r--app/assets/javascripts/boards/vue_resource_interceptor.js.es69
-rw-r--r--spec/features/boards/boards_spec.rb33
3 files changed, 41 insertions, 2 deletions
diff --git a/app/assets/javascripts/boards/boards_bundle.js.es6 b/app/assets/javascripts/boards/boards_bundle.js.es6
index 560a9a079bb..fbb05534ef6 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 00000000000..c6db7c75ea6
--- /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 8c101a251b3..1406c4e8b6f 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