Skip to content

Commit c049296

Browse files
authored
DEV: attempts to have a more resilient fake_scroll_down_long (#33025)
This was sometimes causing flakys and also it's better to not have to rely on sleep.
1 parent cd4b6b8 commit c049296

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

spec/support/system_helpers.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,24 @@ def current_active_element
176176
end
177177

178178
def fake_scroll_down_long(selector_to_make_tall = "#main-outlet")
179-
# Trick to give a huge vertical space to scroll
180-
page.execute_script(
181-
"document.querySelector('#{selector_to_make_tall}').style.height = '10000px'",
182-
)
183-
184-
sleep 0.1 # most resilient solution for now
185-
186-
page.scroll_to(0, 1000)
179+
find(selector_to_make_tall)
180+
execute_script(<<~JS)
181+
(function() {
182+
const el = document.querySelector("#{selector_to_make_tall}");
183+
if (!el) {
184+
throw new Error("Element '#{selector_to_make_tall}' not found");
185+
}
186+
el.style.minHeight = "10000px";
187+
188+
const sentinel = document.createElement("div");
189+
sentinel.id = "scroll-sentinel";
190+
sentinel.style.width = "1px";
191+
sentinel.style.height = "1px";
192+
document.body.appendChild(sentinel);
193+
})();
194+
JS
195+
find("#scroll-sentinel")
196+
execute_script('document.getElementById("scroll-sentinel").scrollIntoView()')
187197
end
188198

189199
def setup_or_skip_s3_system_test(enable_secure_uploads: false, enable_direct_s3_uploads: true)

0 commit comments

Comments
 (0)