Skip to content

A platform for community discussion. Free, open, simple.

DEV: attempts to have a more resilient fake_scroll_down_long (#33025)

Joffrey JAFFEUXc0492965366e
diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb
index 07c1c99754d..e5085e31577 100644
--- a/spec/support/system_helpers.rb
+++ b/spec/support/system_helpers.rb
@@ -176,14 +176,24 @@ module SystemHelpers
end
def fake_scroll_down_long(selector_to_make_tall = "#main-outlet")
- # Trick to give a huge vertical space to scroll
- page.execute_script(
- "document.querySelector('#{selector_to_make_tall}').style.height = '10000px'",
- )
-
- sleep 0.1 # most resilient solution for now
-
- page.scroll_to(0, 1000)
+ find(selector_to_make_tall)
+ execute_script(<<~JS)
+ (function() {
+ const el = document.querySelector("#{selector_to_make_tall}");
+ if (!el) {
+ throw new Error("Element '#{selector_to_make_tall}' not found");
+ }
+ el.style.minHeight = "10000px";
+
+ const sentinel = document.createElement("div");
+ sentinel.id = "scroll-sentinel";
+ sentinel.style.width = "1px";
+ sentinel.style.height = "1px";
+ document.body.appendChild(sentinel);
+ })();
+ JS
+ find("#scroll-sentinel")
+ execute_script('document.getElementById("scroll-sentinel").scrollIntoView()')
end
def setup_or_skip_s3_system_test(enable_secure_uploads: false, enable_direct_s3_uploads: true)