A platform for community discussion. Free, open, simple.
DEV: Support running system tests using chromium and custom chromedriver (#26234)
Alan Guo Xiang Tan4f24e3b3b24c
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex 1070c35362f..08624a61d98 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -607,15 +607,8 @@ RSpec.configure do |config|driver = [:selenium]driver << :mobile if example.metadata[:mobile]- driver << (aarch64? ? :firefox : :chrome)+ driver << :chromedriver << :headless unless ENV["SELENIUM_HEADLESS"] == "0"-- if driver.include?(:firefox)- STDERR.puts(- "WARNING: Running system specs using the Firefox driver is not officially supported. Some tests will fail.",- )- end-driven_by driver.join("_").to_symsetup_system_test@@ -635,8 +628,7 @@ RSpec.configure do |config|lines << "~~~~~ END DRIVER LOGS ~~~~~"end- # The logs API isn’t available (yet?) with the Firefox driver- js_logs = aarch64? ? [] : page.driver.browser.logs.get(:browser)+ js_logs = page.driver.browser.logs.get(:browser)# Recommended that this is not disabled, since it makes debugging# failed system tests a lot trickier.@@ -954,10 +946,22 @@ def apply_base_chrome_options(options)if ENV["CHROME_DISABLE_FORCE_DEVICE_SCALE_FACTOR"].blank?options.add_argument("--force-device-scale-factor=1")end-end-def aarch64?- RUBY_PLATFORM == "aarch64-linux"+ if ENV["DISCOURSE_SYSTEM_TEST_CHROMIUM"] == "1"+ options.binary =+ case RUBY_PLATFORM+ when /linux/+ "/usr/bin/chromium"+ when /darwin/+ "/Applications/Chromium.app/Contents/MacOS/Chromium"+ else+ "Running Discourse system test with Chromium on #{RUBY_PLATFORM} is not supported"+ end+ end++ if (chromedriver_path = ENV["DISCOURSE_SYSTEM_TEST_CHROMEDRIVER_PATH"]).present?+ Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path+ endendclass SpecSecureRandom