summaryrefslogtreecommitdiffstats
path: root/test/application_system_test_case.rb
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2020-11-19 05:11:59 +0000
committerGo MAEDA <maeda@farend.jp>2020-11-19 05:11:59 +0000
commitc85a18e9bf296cef14e36cf52599b6749f022dd8 (patch)
treeb1e9e6f8d0acaeb2c032f1a7083e332bee3f0c8f /test/application_system_test_case.rb
parent5514fe4555e62930b1f09a840a4e44e9146cad06 (diff)
downloadredmine-c85a18e9bf296cef14e36cf52599b6749f022dd8.tar.gz
redmine-c85a18e9bf296cef14e36cf52599b6749f022dd8.zip
Adds CAPYBARA_SERVER_HOST, CAPYBARA_SERVER_PORT, SELENIUM_REMOTE_URL and CAPYBARA_APP_HOST to allow running system tests on a remote Selenium hub (on CI using Docker images) (#34269).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20428 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/application_system_test_case.rb')
-rw-r--r--test/application_system_test_case.rb34
1 files changed, 23 insertions, 11 deletions
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
index 7f6097cee..d5bbe7a4f 100644
--- a/test/application_system_test_case.rb
+++ b/test/application_system_test_case.rb
@@ -22,22 +22,34 @@ require File.expand_path('../test_helper', __FILE__)
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
DOWNLOADS_PATH = File.expand_path(File.join(Rails.root, 'tmp', 'downloads'))
+ # Allow running Capybara default server on custom IP address and/or port
+ Capybara.server_host = ENV['CAPYBARA_SERVER_HOST'] if ENV['CAPYBARA_SERVER_HOST']
+ Capybara.server_port = ENV['CAPYBARA_SERVER_PORT'] if ENV['CAPYBARA_SERVER_PORT']
+
+ options = {}
+ # Allow running tests using a remote Selenium hub
+ options.merge!(url: ENV['SELENIUM_REMOTE_URL']) if ENV['SELENIUM_REMOTE_URL']
+ options.merge!(desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
+ 'chromeOptions' => {
+ 'prefs' => {
+ 'download.default_directory' => DOWNLOADS_PATH,
+ 'download.prompt_for_download' => false,
+ 'plugins.plugins_disabled' => ["Chrome PDF Viewer"]
+ }
+ }
+ ))
+
driven_by(
:selenium, using: :chrome, screen_size: [1024, 900],
- options: {
- desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
- 'chromeOptions' => {
- 'prefs' => {
- 'download.default_directory' => DOWNLOADS_PATH,
- 'download.prompt_for_download' => false,
- 'plugins.plugins_disabled' => ["Chrome PDF Viewer"]
- }
- }
- )
- }
+ options: options
)
setup do
+ # Allow defining a custom app host (useful when using a remote Selenium hub)
+ Capybara.configure do |config|
+ config.app_host = ENV['CAPYBARA_APP_HOST']
+ end if ENV['CAPYBARA_APP_HOST']
+
clear_downloaded_files
Setting.delete_all
Setting.clear_cache