add builder 'replace' button specs

This commit is contained in:
Alex Turchyn
2025-05-13 21:27:40 +03:00
committed by Pete Matsyburka
parent 87265e2f22
commit 2dca7d8a8e
3 changed files with 73 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
# 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