Project

General

Profile

Defect #40683 » 0001-Upgrade-webdrivers.patch

Ko Nagase, 2024-05-12 16:18

View differences:

Gemfile
# For running system tests
gem 'puma'
gem 'capybara', '~> 3.36.0'
gem "selenium-webdriver", "~> 3.142.7"
gem 'webdrivers', '4.6.1', require: false
gem "selenium-webdriver", Gem.ruby_version < Gem::Version.new('2.7') ? "4.1.0" : "~> 4.3.0"
gem 'webdrivers', '~> 5.0.0', require: false
# RuboCop
gem 'rubocop', '~> 1.33.0'
gem 'rubocop-performance', '~> 1.14.2'
test/application_system_test_case.rb
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require File.expand_path('../test_helper', __FILE__)
require 'webdrivers/chromedriver'
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
DOWNLOADS_PATH = File.expand_path(File.join(Rails.root, 'tmp', 'downloads'))
......
GOOGLE_CHROME_OPTS_ARGS = ENV['GOOGLE_CHROME_OPTS_ARGS'].split(",") if ENV['GOOGLE_CHROME_OPTS_ARGS']
options = {}
if ENV['SELENIUM_REMOTE_URL']
options[:url] = ENV['SELENIUM_REMOTE_URL']
options[:browser] = :remote
else
require 'webdrivers/chromedriver'
end
# Allow running tests using a remote Selenium hub
options[:url] = ENV['SELENIUM_REMOTE_URL'] if ENV['SELENIUM_REMOTE_URL']
options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome(
options[:capabilities] = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions' => {
'args' => GOOGLE_CHROME_OPTS_ARGS,
'prefs' => {
......
)
setup do
Capybara.app_host = "http://#{Capybara.server_host}:#{Capybara.server_port}"
# Allow defining a custom app host (useful when using a remote Selenium hub)
if ENV['CAPYBARA_APP_HOST']
Capybara.configure do |config|
......
end
end
def finally(timeout = Capybara.default_max_wait_time, start = Time.now)
yield
return
rescue Minitest::Assertion, Capybara::ElementNotFound
raise if Time.now > start + timeout
sleep 0.1
retry
end
def clear_downloaded_files
FileUtils.rm downloaded_files
end
test/system/issues_test.rb
# wait for ajax response
assert page.has_select?('issue_project_id', selected: 'OnlineStore')
submit_buttons = page.all('input[type=submit]')
assert_equal 2, submit_buttons.size
submit_buttons = []
finally do
submit_buttons = page.all('input[type=submit]')
assert_equal 2, submit_buttons.size
end
assert_equal 'Move', submit_buttons[0].value
assert_equal 'Move and follow', submit_buttons[1].value
......
# wait for ajax response
assert page.has_select?('issue_project_id', selected: 'OnlineStore')
submit_buttons = page.all('input[type=submit]')
assert_equal 2, submit_buttons.size
submit_buttons = []
finally do
submit_buttons = page.all('input[type=submit]')
assert_equal 2, submit_buttons.size
end
assert_equal 'Copy', submit_buttons[0].value
assert_equal 'Copy and follow', submit_buttons[1].value
page.find('#issue_priority_id').select('High')
test/system/timelog_test.rb
within 'form#new_time_entry' do
select 'eCookbook', :from => 'Project'
end
within 'select#time_entry_activity_id' do
assert has_content?('Development')
assert !has_content?('Design')
finally do
within 'select#time_entry_activity_id' do
assert has_content?('Development')
assert !has_content?('Design')
end
end
end
(2-2/3)