conf(capybara): add MAKE_IT_SLOW option to reveal bugs
This commit is contained in:
parent
7c90444878
commit
091a522cbf
2 changed files with 22 additions and 8 deletions
|
@ -122,6 +122,10 @@ Pour exécuter les tests de l'application, plusieurs possibilités :
|
||||||
|
|
||||||
JS_LOG=error bin/rspec spec/system
|
JS_LOG=error bin/rspec spec/system
|
||||||
|
|
||||||
|
- Augmenter la latence lors de tests end2end pour déceler des bugs récalcitrants
|
||||||
|
|
||||||
|
MAKE_IT_SLOW=1 bin/rspec spec/system
|
||||||
|
|
||||||
### Ajout de taches à exécuter au déploiement
|
### Ajout de taches à exécuter au déploiement
|
||||||
|
|
||||||
rails generate after_party:task task_name
|
rails generate after_party:task task_name
|
||||||
|
|
|
@ -3,6 +3,22 @@ require 'capybara-screenshot/rspec'
|
||||||
require 'capybara/email/rspec'
|
require 'capybara/email/rspec'
|
||||||
require 'selenium/webdriver'
|
require 'selenium/webdriver'
|
||||||
|
|
||||||
|
def setup_driver(app, download_path, options)
|
||||||
|
Capybara::Selenium::Driver.new(app, browser: :chrome, options:).tap do |driver|
|
||||||
|
# Set download dir for Chrome < 77
|
||||||
|
driver.browser.download_path = download_path
|
||||||
|
|
||||||
|
if ENV['MAKE_IT_SLOW'].present?
|
||||||
|
driver.browser.network_conditions = {
|
||||||
|
offline: false,
|
||||||
|
latency: 800,
|
||||||
|
download_throughput: 1024000,
|
||||||
|
upload_throughput: 1024000
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Capybara.register_driver :chrome do |app|
|
Capybara.register_driver :chrome do |app|
|
||||||
options = Selenium::WebDriver::Chrome::Options.new
|
options = Selenium::WebDriver::Chrome::Options.new
|
||||||
options.add_argument('--no-sandbox') unless ENV['SANDBOX']
|
options.add_argument('--no-sandbox') unless ENV['SANDBOX']
|
||||||
|
@ -15,10 +31,7 @@ Capybara.register_driver :chrome do |app|
|
||||||
options.add_preference('download.default_directory', download_path)
|
options.add_preference('download.default_directory', download_path)
|
||||||
options.add_preference(:download, default_directory: download_path)
|
options.add_preference(:download, default_directory: download_path)
|
||||||
|
|
||||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options).tap do |driver|
|
setup_driver(app, download_path, options)
|
||||||
# Set download dir for Chrome < 77
|
|
||||||
driver.browser.download_path = download_path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.register_driver :headless_chrome do |app|
|
Capybara.register_driver :headless_chrome do |app|
|
||||||
|
@ -36,10 +49,7 @@ Capybara.register_driver :headless_chrome do |app|
|
||||||
options.add_preference('download.default_directory', download_path)
|
options.add_preference('download.default_directory', download_path)
|
||||||
options.add_preference(:download, default_directory: download_path)
|
options.add_preference(:download, default_directory: download_path)
|
||||||
|
|
||||||
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options).tap do |driver|
|
setup_driver(app, download_path, options)
|
||||||
# Set download dir for Chrome < 77
|
|
||||||
driver.browser.download_path = download_path
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.default_max_wait_time = 2
|
Capybara.default_max_wait_time = 2
|
||||||
|
|
Loading…
Reference in a new issue