Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add firefox headless to test the broken chrome float input

Oliver Günther4a8eb0225f40
diff --git a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
index 27a34f572fb..4548a8e7026 100644
--- a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
+++ b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
@@ -210,7 +210,7 @@ describe 'custom field inplace editor', js: true do
end
context 'with german locale',
- driver: :chrome_headless_de do
+ driver: :firefox_headless_de do
let(:user) { FactoryBot.create :admin, language: 'de' }
it 'displays the float with german locale and allows editing' do
diff --git a/spec/support/browsers/firefox.rb b/spec/support/browsers/firefox.rb
index 4b7076dd193..5102e685a6e 100644
--- a/spec/support/browsers/firefox.rb
+++ b/spec/support/browsers/firefox.rb
@@ -1,47 +1,72 @@
-Capybara.register_driver :firefox_headless do |app|
+# Force the latest version of geckodriver using the webdriver gem
+require 'webdrivers/geckodriver'
+
+if ENV['CI']
+ ::Webdrivers.logger.level = :DEBUG
+ ::Webdrivers::Geckodriver.update
+end
+
+
+def register_firefox_headless(language)
+ name = :"firefox_headless_#{language}"
+
require 'selenium/webdriver'
- Selenium::WebDriver::Firefox::Binary.path = ENV['FIREFOX_BINARY_PATH'] ||
- Selenium::WebDriver::Firefox::Binary.path
+ Capybara.register_driver name do |app|
+ Selenium::WebDriver::Firefox::Binary.path = ENV['FIREFOX_BINARY_PATH'] ||
+ Selenium::WebDriver::Firefox::Binary.path
- capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: true)
- capabilities["elementScrollBehavior"] = 1
+ client = Selenium::WebDriver::Remote::Http::Default.new
+ client.timeout = 180
- client = Selenium::WebDriver::Remote::Http::Default.new
- client.timeout = 180
+ profile = Selenium::WebDriver::Firefox::Profile.new
+ profile['intl.accept_languages'] = language
+ profile['browser.download.dir'] = DownloadedFile::PATH.to_s
+ profile['browser.download.folderList'] = 2
+ profile['browser.helperApps.neverAsk.saveToDisk'] = 'text/csv'
- profile = Selenium::WebDriver::Firefox::Profile.new
- profile['intl.accept_languages'] = 'en'
- profile['browser.download.dir'] = DownloadedFile::PATH.to_s
- profile['browser.download.folderList'] = 2
- profile['browser.helperApps.neverAsk.saveToDisk'] = 'text/csv'
+ # prevent stale firefoxCP processes
+ profile['browser.tabs.remote.autostart'] = false
+ profile['browser.tabs.remote.autostart.2'] = false
- # prevent stale firefoxCP processes
- profile['browser.tabs.remote.autostart'] = false
- profile['browser.tabs.remote.autostart.2'] = false
+ # only one FF process
+ profile['dom.ipc.processCount'] = 1
- # only one FF process
- profile['dom.ipc.processCount'] = 1
+ # use native instead of synthetic events
+ # https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
+ profile.native_events = true
- # use native instead of synthetic events
- # https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
- profile.native_events = true
+ options = Selenium::WebDriver::Firefox::Options.new(profile: profile)
- options = Selenium::WebDriver::Firefox::Options.new
- options.profile = profile
+ unless ActiveRecord::Type::Boolean.new.cast(ENV['OPENPROJECT_TESTING_NO_HEADLESS'])
+ options.args << "--headless"
+ end
- unless ActiveRecord::Type::Boolean.new.cast(ENV['OPENPROJECT_TESTING_NO_HEADLESS'])
- options.args << "--headless"
- end
+ # If you need to trace the webdriver commands, un-comment this line
+ # Selenium::WebDriver.logger.level = :info
- # If you need to trace the webdriver commands, un-comment this line
- # Selenium::WebDriver.logger.level = :info
+ driver = Capybara::Selenium::Driver.new(
+ app,
+ browser: :firefox,
+ options: options,
+ http_client: client,
+ )
- Capybara::Selenium::Driver.new(
- app,
- browser: :firefox,
- options: options,
- http_client: client,
- desired_capabilities: capabilities
- )
+ Capybara::Screenshot.register_driver(name) do |driver, path|
+ driver.browser.save_screenshot(path)
+ end
+
+ driver
+ end
end
+
+register_firefox_headless 'en'
+# Register german locale for custom field decimal test
+register_firefox_headless 'de'
+
+# Resize window if firefox
+RSpec.configure do |config|
+ config.before(:each, driver: Proc.new { |val| val.to_s.start_with? 'firefox_headless_' }) do
+ Capybara.page.driver.browser.manage.window.maximize
+ end
+end
\ No newline at end of file