mirror of https://github.com/docusealco/docuseal
parent
2dca7d8a8e
commit
0122a237e3
@ -1,37 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module RequestHelper
|
|
||||||
module_function
|
|
||||||
|
|
||||||
def wait_for_fetch
|
|
||||||
page.execute_script(
|
|
||||||
<<~JS
|
|
||||||
if (!window.fetchInitialized) {
|
|
||||||
window.pendingFetchCount = 0;
|
|
||||||
|
|
||||||
const originalFetch = window.fetch;
|
|
||||||
|
|
||||||
window.fetch = function(...args) {
|
|
||||||
window.pendingFetchCount++;
|
|
||||||
|
|
||||||
return originalFetch.apply(this, args).finally(() => {
|
|
||||||
window.pendingFetchCount--;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
window.fetchInitialized = true;
|
|
||||||
}
|
|
||||||
JS
|
|
||||||
)
|
|
||||||
|
|
||||||
yield
|
|
||||||
|
|
||||||
Timeout.timeout(Capybara.default_max_wait_time) do
|
|
||||||
loop do
|
|
||||||
break if page.evaluate_script('window.pendingFetchCount') == 0
|
|
||||||
|
|
||||||
sleep 0.1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
Reference in new issue