Skip to content

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

FIX: Flakey nested scroll restoration spec attempt #2 (#42216)

Mark VanLandinghamede8fb64a194
diff --git a/spec/system/nested_scroll_restoration_spec.rb b/spec/system/nested_scroll_restoration_spec.rb
index fcf3d46b223..813d55b8304 100644
--- a/spec/system/nested_scroll_restoration_spec.rb
+++ b/spec/system/nested_scroll_restoration_spec.rb
@@ -79,9 +79,9 @@ RSpec.describe "Nested view scroll restoration" do
saved_position = nested_view.current_scroll_position
nested_view.with_root_pagination_paused(topic) do |pagination|
- nested_view.visit_nested(topic)
- expect(nested_view).to have_root_post_count(20)
+ nested_view.reload_with_pending_pagination
pagination.wait
+ expect(nested_view).to have_root_post_count(20)
restored_position = nested_view.current_scroll_position
after_user_scroll_position = nested_view.user_scroll_by(distance: -1000)
diff --git a/spec/system/page_objects/pages/nested_view.rb b/spec/system/page_objects/pages/nested_view.rb
index 36e9d54981f..1d5d92ff9a1 100644
--- a/spec/system/page_objects/pages/nested_view.rb
+++ b/spec/system/page_objects/pages/nested_view.rb
@@ -17,6 +17,12 @@ module PageObjects
self
end
+ def reload_with_pending_pagination
+ # Capybara's refresh waits for AJAX to settle, but pagination is intentionally held open.
+ page.driver.with_playwright_page(&:reload)
+ self
+ end
+
# In-app navigation via DiscourseURL.routeTo — exercises the same
# routing code path a notification or in-page link click would,
# rather than doing a full page reload like visit_nested_context.