mirror of
				https://github.com/redmine/redmine.git
				synced 2025-10-31 02:15:52 +01:00 
			
		
		
		
	Fix selenium chrome options so files are downloaded to tmp/downloads in system tests (#34119).
Patch by Jens Krämer. git-svn-id: http://svn.redmine.org/redmine/trunk@20549 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
		| @@ -30,7 +30,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase | |||||||
|   # Allow running tests using a remote Selenium hub |   # Allow running tests using a remote Selenium hub | ||||||
|   options[:url] = ENV['SELENIUM_REMOTE_URL'] if ENV['SELENIUM_REMOTE_URL'] |   options[:url] = ENV['SELENIUM_REMOTE_URL'] if ENV['SELENIUM_REMOTE_URL'] | ||||||
|   options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( |   options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome( | ||||||
|                   'chromeOptions' => { |                   'goog:chromeOptions' => { | ||||||
|                     'prefs' => { |                     'prefs' => { | ||||||
|                       'download.default_directory' => DOWNLOADS_PATH, |                       'download.default_directory' => DOWNLOADS_PATH, | ||||||
|                       'download.prompt_for_download' => false, |                       'download.prompt_for_download' => false, | ||||||
| @@ -76,14 +76,11 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase | |||||||
|   end |   end | ||||||
|  |  | ||||||
|   def clear_downloaded_files |   def clear_downloaded_files | ||||||
|     # https://github.com/SeleniumHQ/selenium/issues/5292 |     FileUtils.rm downloaded_files | ||||||
|     FileUtils.rm downloaded_files if Redmine::Platform.mswin? |  | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   def downloaded_files(filename='*') |   def downloaded_files(filename='*') | ||||||
|     # https://github.com/SeleniumHQ/selenium/issues/5292 |     Dir.glob("#{DOWNLOADS_PATH}/#{filename}"). | ||||||
|     downloaded_path = Redmine::Platform.mswin? ? DOWNLOADS_PATH : "#{ENV['HOME']}/Downloads" |  | ||||||
|     Dir.glob("#{downloaded_path}/#{filename}"). |  | ||||||
|       reject{|f| f=~/\.(tmp|crdownload)$/}.sort_by{|f| File.mtime(f)} |       reject{|f| f=~/\.(tmp|crdownload)$/}.sort_by{|f| File.mtime(f)} | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -519,9 +519,7 @@ class IssuesSystemTest < ApplicationSystemTestCase | |||||||
|     click_on 'CSV' |     click_on 'CSV' | ||||||
|     click_on 'Export' |     click_on 'Export' | ||||||
|  |  | ||||||
|     # https://github.com/SeleniumHQ/selenium/issues/5292 |     csv = CSV.read(downloaded_file("issues.csv")) | ||||||
|     # if issues.csv exists, Chrome creates issues (1).csv, issues (2).csv ... |  | ||||||
|     csv = CSV.read(downloaded_file("issues*.csv")) |  | ||||||
|     subject_index = csv.shift.index('Subject') |     subject_index = csv.shift.index('Subject') | ||||||
|     subjects = csv.map {|row| row[subject_index]} |     subjects = csv.map {|row| row[subject_index]} | ||||||
|     assert_equal subjects.sort, subjects |     assert_equal subjects.sort, subjects | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user