Skip to content

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

DEV: Make `page.visit` wait for ember boot too (#39764)

Jarek Radosz3c35398a111e
diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb
index f9dac7df393..db4efc7cd04 100644
--- a/spec/support/system_helpers.rb
+++ b/spec/support/system_helpers.rb
@@ -54,14 +54,6 @@ module SystemHelpers
self
end
- # Waits for the Ember app to boot before continuing.
- def visit(...)
- super
- return if page.has_no_css?("discourse-assets", wait: 0, visible: :all)
-
- page.assert_selector("#main.ember-application", visible: :all)
- end
-
def sign_in(user)
visit File.join(
GlobalSetting.relative_url_root || "",
@@ -444,12 +436,24 @@ module SystemHelpers
end
module CapybaraSessionEmberWaiter
- # Waits for the Ember app to boot before continuing.
+ def visit(...)
+ super
+ wait_for_ember_boot
+ end
+
def refresh
super
+ wait_for_ember_boot
+ end
+
+ private
+
+ def wait_for_ember_boot
return unless RSpec.current_example&.metadata&.[](:type) == :system
- return if has_no_css?("discourse-assets", wait: 0, visible: :all)
+ # `<discourse-assets>` is only present on Ember pages;
+ return if has_no_css?("discourse-assets", wait: 0, visible: :all)
+ # `ember-application` is added to `#main` when the app boots.
assert_selector("#main.ember-application", visible: :all)
end
end