mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: allows to open chrome tools by default (#21778)
Usage: ``` CHROME_DEV_TOOLS=bottom bundle exec rspec /path/to/system/spec ``` This commit also regroups common chrome options under `apply_base_chrome_options`, and removes the size of the mobile window which was incorrect. browser_log param is also passed to mobile chrome options.
This commit is contained in:
parent
71330961dc
commit
885ab7c7bb
@ -272,24 +272,15 @@ RSpec.configure do |config|
|
|||||||
|
|
||||||
Capybara::Session.class_eval { prepend IgnoreUnicornCapturedErrors }
|
Capybara::Session.class_eval { prepend IgnoreUnicornCapturedErrors }
|
||||||
|
|
||||||
# The valid values for SELENIUM_BROWSER_LOG_LEVEL are:
|
# possible values: OFF, SEVERE, WARNING, INFO, DEBUG, ALL
|
||||||
#
|
|
||||||
# OFF
|
|
||||||
# SEVERE
|
|
||||||
# WARNING
|
|
||||||
# INFO
|
|
||||||
# DEBUG
|
|
||||||
# ALL
|
|
||||||
browser_log_level = ENV["SELENIUM_BROWSER_LOG_LEVEL"] || "SEVERE"
|
browser_log_level = ENV["SELENIUM_BROWSER_LOG_LEVEL"] || "SEVERE"
|
||||||
|
|
||||||
chrome_browser_options =
|
chrome_browser_options =
|
||||||
Selenium::WebDriver::Chrome::Options
|
Selenium::WebDriver::Chrome::Options
|
||||||
.new(logging_prefs: { "browser" => browser_log_level, "driver" => "ALL" })
|
.new(logging_prefs: { "browser" => browser_log_level, "driver" => "ALL" })
|
||||||
.tap do |options|
|
.tap do |options|
|
||||||
|
apply_base_chrome_options(options)
|
||||||
options.add_argument("--window-size=1400,1400")
|
options.add_argument("--window-size=1400,1400")
|
||||||
options.add_argument("--no-sandbox")
|
|
||||||
options.add_argument("--disable-dev-shm-usage")
|
|
||||||
options.add_argument("--mute-audio")
|
|
||||||
options.add_argument("--force-device-scale-factor=1")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.register_driver :selenium_chrome do |app|
|
Capybara.register_driver :selenium_chrome do |app|
|
||||||
@ -304,14 +295,10 @@ RSpec.configure do |config|
|
|||||||
|
|
||||||
mobile_chrome_browser_options =
|
mobile_chrome_browser_options =
|
||||||
Selenium::WebDriver::Chrome::Options
|
Selenium::WebDriver::Chrome::Options
|
||||||
.new(logging_prefs: { "browser" => "INFO", "driver" => "ALL" })
|
.new(logging_prefs: { "browser" => browser_log_level, "driver" => "ALL" })
|
||||||
.tap do |options|
|
.tap do |options|
|
||||||
options.add_argument("--window-size=390,960")
|
|
||||||
options.add_argument("--no-sandbox")
|
|
||||||
options.add_argument("--disable-dev-shm-usage")
|
|
||||||
options.add_emulation(device_name: "iPhone 12 Pro")
|
options.add_emulation(device_name: "iPhone 12 Pro")
|
||||||
options.add_argument("--mute-audio")
|
apply_base_chrome_options(options)
|
||||||
options.add_argument("--force-device-scale-factor=1")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Capybara.register_driver :selenium_mobile_chrome do |app|
|
Capybara.register_driver :selenium_mobile_chrome do |app|
|
||||||
@ -630,6 +617,27 @@ def decrypt_auth_cookie(cookie)
|
|||||||
].with_indifferent_access
|
].with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apply_base_chrome_options(options)
|
||||||
|
# possible values: undocked, bottom, right, left
|
||||||
|
chrome_dev_tools = ENV["CHROME_DEV_TOOLS"]
|
||||||
|
|
||||||
|
if chrome_dev_tools
|
||||||
|
options.add_argument("--auto-open-devtools-for-tabs")
|
||||||
|
options.add_preference(
|
||||||
|
"devtools",
|
||||||
|
"preferences" => {
|
||||||
|
"currentDockState" => "\"#{chrome_dev_tools}\"",
|
||||||
|
"panel-selectedTab" => '"console"',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
options.add_argument("--no-sandbox")
|
||||||
|
options.add_argument("--disable-dev-shm-usage")
|
||||||
|
options.add_argument("--mute-audio")
|
||||||
|
options.add_argument("--force-device-scale-factor=1")
|
||||||
|
end
|
||||||
|
|
||||||
class SpecSecureRandom
|
class SpecSecureRandom
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :value
|
attr_accessor :value
|
||||||
|
Loading…
Reference in New Issue
Block a user