From 7a27e78452c2ff43a9573bb0b0f8b6b8110f6f35 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 30 Mar 2020 14:20:23 +0000 Subject: [PATCH] specs: remove unused wait-for-ajax helper This helper is: - no longer used; - buggy (not all requests increment it); - discouraged (we should instead match an UI change that signals the end of an ajax request). Good riddance. --- app/javascript/shared/utils.js | 15 +-------------- spec/support/wait_for_ajax.rb | 9 --------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 spec/support/wait_for_ajax.rb diff --git a/app/javascript/shared/utils.js b/app/javascript/shared/utils.js index e74ddd78e..26603d954 100644 --- a/app/javascript/shared/utils.js +++ b/app/javascript/shared/utils.js @@ -62,7 +62,6 @@ export function ajax(options) { } export function getJSON(url, data, method = 'get') { - incrementActiveRequestsCount(); data = method !== 'get' ? JSON.stringify(data) : data; return Promise.resolve( $.ajax({ @@ -72,7 +71,7 @@ export function getJSON(url, data, method = 'get') { contentType: 'application/json', dataType: 'json' }) - ).finally(decrementActiveRequestsCount); + ); } export function scrollTo(container, scrollTo) { @@ -115,15 +114,3 @@ export function timeoutable(promise, timeoutDelay) { }); return Promise.race([promise, timeoutPromise]); } - -const DATA_ACTIVE_REQUESTS_COUNT = 'data-active-requests-count'; - -function incrementActiveRequestsCount() { - const count = document.body.getAttribute(DATA_ACTIVE_REQUESTS_COUNT) || '0'; - document.body.setAttribute(DATA_ACTIVE_REQUESTS_COUNT, parseInt(count) + 1); -} - -function decrementActiveRequestsCount() { - const count = document.body.getAttribute(DATA_ACTIVE_REQUESTS_COUNT) || '0'; - document.body.setAttribute(DATA_ACTIVE_REQUESTS_COUNT, parseInt(count) - 1); -} diff --git a/spec/support/wait_for_ajax.rb b/spec/support/wait_for_ajax.rb deleted file mode 100644 index e57061cdb..000000000 --- a/spec/support/wait_for_ajax.rb +++ /dev/null @@ -1,9 +0,0 @@ -module WaitForAjax - def wait_for_ajax - expect(page).to have_selector('body[data-active-requests-count="0"]') - end -end - -RSpec.configure do |config| - config.include WaitForAjax, type: :feature -end