-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade from 'feature' to 'system' test #3568
Conversation
frontend/spec/spec_helper.rb
Outdated
@@ -94,3 +102,5 @@ | |||
|
|||
Kernel.srand config.seed | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingBlankLines: 2 trailing blank lines detected.
frontend/spec/spec_helper.rb
Outdated
config.before(:each, type: :system) do | ||
driven_by :rack_test | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingWhitespace: Trailing whitespace detected.
backend/spec/spec_helper.rb
Outdated
ActionView::Base.raise_on_missing_translations = true | ||
|
||
Capybara.default_max_wait_time = ENV['DEFAULT_MAX_WAIT_TIME'].to_f if ENV['DEFAULT_MAX_WAIT_TIME'].present? | ||
|
||
ActiveJob::Base.queue_adapter = :test | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/EmptyLines: Extra blank line detected.
02af214
to
3368775
Compare
frontend/spec/spec_helper.rb
Outdated
@@ -93,4 +101,4 @@ | |||
config.order = :random | |||
|
|||
Kernel.srand config.seed | |||
end | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingBlankLines: Final newline missing.
3368775
to
6f31382
Compare
@@ -44,6 +44,7 @@ | |||
Capybara.exact = true | |||
|
|||
require "selenium/webdriver" | |||
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this line necessary? isn't
config.before(:each, type: :system, js: true) do
driven_by :selenium_chrome_headless
end
already taking care of defining the driver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails uses as default :selenium . If I don't define Capybara.javascript_driver
, rails will assume that we use :selenium. In my case it fails because I didn't have geckodriver( Mozilla driver used with selenium).
Then with config.before(:each, type: :system, js: true)
we redefine capybara Capybara javascript driver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's odd. I checked the branch locally and tried commenting this line and all the driven_by
below and the result is the same. I think that for some reason it's just using the default ignoring the driven_by
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to print which driver is being used. Please add this line puts Capybara.current_driver
in both config.before(:each, type: :system)
and config.before(:each, type: :system, js: true)
before and after using driven_by. You will see the difference between use and don's use driven_by
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks, I'm giving it a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if I comment out
# Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
no matter what Capybara.current_driver
prints, it is opening Firefox to run specs so it's definitely not headless.
I think there's some misconfiguration happening but I couldn't get exactly where yet.
I've also tried with this syntax, which seems to be the default to make exactly the same thing that we do with our custom driver:
driven_by :selenium, using: :headless_chrome, screen_size: [1920, 1080]
but it still opens firefox to run specs. 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gonzar11 did you get the chance to take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gonzar11, I worked on a similar PR in a Solidus extension (solidus_starter_frontend) and I would like to add my thoughts.
Capybara.javascript_driver = ...
is not necessary; Rails testing guide (but for Minitest) says that default Capybara driver settings should be changed viadriven_by
;- in my PR I choose to have 2 different variables (
CAPYBARA_DRIVER
/CAPYBARA_JS_DRIVER
), it can be useful sometimes; - I made some tests in this PR commenting out the
Capybara.javascript_driver = ...
line in spec_helper.rb; running a JS spec withCAPYBARA_DRIVER=selenium_chrome bin/rspec backend/spec/system/admin/configuration/payment_methods_spec.rb:36
first opens a Firefox empty window then a Chrome window with the specified test.
As a test, if I comment out the following lines, I see that it works as expected:
if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
end
6f31382
to
004b9c7
Compare
end | ||
|
||
config.before(:each, type: :system, js: true) do | ||
driven_by (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
end | ||
|
||
config.before(:each, type: :system, js: true) do | ||
driven_by (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint/ParenthesesAsGroupedExpression: (...) interpreted as grouped expression.
@@ -44,6 +44,7 @@ | |||
Capybara.exact = true | |||
|
|||
require "selenium/webdriver" | |||
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gonzar11, I worked on a similar PR in a Solidus extension (solidus_starter_frontend) and I would like to add my thoughts.
Capybara.javascript_driver = ...
is not necessary; Rails testing guide (but for Minitest) says that default Capybara driver settings should be changed viadriven_by
;- in my PR I choose to have 2 different variables (
CAPYBARA_DRIVER
/CAPYBARA_JS_DRIVER
), it can be useful sometimes; - I made some tests in this PR commenting out the
Capybara.javascript_driver = ...
line in spec_helper.rb; running a JS spec withCAPYBARA_DRIVER=selenium_chrome bin/rspec backend/spec/system/admin/configuration/payment_methods_spec.rb:36
first opens a Firefox empty window then a Chrome window with the specified test.
As a test, if I comment out the following lines, I see that it works as expected:
if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
end
Hey @gonzar11, it's been a while, but would you be willing to keep working on it? 🙂 |
Closing as this has no activity anymore. Thanks anyway! |
Description
I couldn't remove database cleaner because some specs on backends started to fail. Then I realized that it used just to truncate the database before starting run all specs. This is because some migrations are filling the database.
It closes #3564
Checklist: