Skip to content
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

Remove redundant configs for Capybara #3947

Merged
merged 6 commits into from
Dec 19, 2024
Merged

Remove redundant configs for Capybara #3947

merged 6 commits into from
Dec 19, 2024

Conversation

mayorova
Copy link
Contributor

What this PR does / why we need it:

There are some configs for Capybara that I believe are not needed - see comments inline.

Which issue(s) this PR fixes

Verification steps

Make sure all tests works :)

Special notes for your reviewer:

Capybara.current_driver = DEFAULT_JS_DRIVER
end

Before '@chrome' do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -16 to -22
Capybara.default_driver = :rack_test
Capybara.javascript_driver = DEFAULT_JS_DRIVER
Capybara.default_selector = :css
Capybara.disable_animation = true

# Capybara 3 changes the default server to Puma. It can be reverted to the previous default of WEBRick by specifying:
Capybara.server = :webrick
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it doesn't make sense to set the same configs both here, and then inside the Capybara.configure block. They seem to have the same effect.

Capybara.current_driver = :firefox
# Capybara 3 changes the default server to Puma. It can be reverted to the previous default of WEBRick by specifying:
config.server = :webrick
config.disable_animation = true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This disable_animation is the only one that is not documented here: https://rubydoc.info/github/jnicklas/capybara/Capybara#configure-class_method

But the tests pass, so either it works fine, or this setting is irrelevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I would remove it and see if the tests pass. The more we can cleanup the better.

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 64.28571% with 10 lines in your changes missing coverage. Please review.

Project coverage is 93.80%. Comparing base (b002a35) to head (d757111).
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
features/support/capybara.rb 54.54% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3947      +/-   ##
==========================================
- Coverage   93.85%   93.80%   -0.05%     
==========================================
  Files        3001     2999       -2     
  Lines       97351    96925     -426     
  Branches      629      629              
==========================================
- Hits        91368    90924     -444     
- Misses       5959     5977      +18     
  Partials       24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

akostadinov
akostadinov previously approved these changes Nov 26, 2024
Copy link
Contributor

@akostadinov akostadinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks nice! good to check if there are useful ideas also in #3911

@mayorova
Copy link
Contributor Author

looks nice! good to check if there are useful ideas also in #3911

Oh wow! I missed that one completely 🤦

Thanks, I'll take a look.

jlledom
jlledom previously approved these changes Nov 26, 2024
@mayorova mayorova dismissed stale reviews from jlledom and akostadinov via 4203836 December 5, 2024 14:08
@@ -237,6 +237,8 @@ def setup_provider(login)
set_current_domain(@provider.external_admin_domain)
stub_integration_errors_dashboard

@provider.users.first.user_sessions.create! # Prevents welcome flash from showing up
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the reason, but doesn't this make the login param useless? it will create a session anyway... and doesn't this break any test?

features/step_definitions/web_steps.rb Outdated Show resolved Hide resolved
@@ -22,7 +22,8 @@
click_link page
end
else
input = find('input[aria-label="Current page"]')
# Pagination controls are rendered twice: at the top and at the bottom of the data table
input = find('input[aria-label="Current page"]', match: :first)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not really needed anymore, it was needed when I tried config.match = :smart match mode for Cabybara.

But probably we can leave it here to state that we are aware of this duplication, and have it fixed, if we ever switch to :smart mode again. (currently there were too many changes to perform here)

Capybara.configure do |config|
config.default_driver = :rack_test
config.javascript_driver = DEFAULT_JS_DRIVER
config.default_selector = :css
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These first three lines are actually the defaults, so they could be removed potentially. I decided to keep them, because I think it's clearer if they are explicit and not hidden within Capybara's code (or docs).

But if anybody thinks they are redundant, we can drop them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you finally remove them?

@@ -5,8 +5,6 @@
end

When /^I switch to (builtin|3scale) content$/ do |group|
ensure_javascript
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's not strictly needed 🤔
I imagine that if this is used in a non-JS scenario, then just some following step will fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's nice to stay so that we know this is expected to fail without js. Otherwise it may require more cycles to figure out.

Comment on lines -65 to -67
Capybara.register_driver :firefox do |app|
Capybara::Selenium::Driver.new(app, browser: :firefox)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we wont be able to run with firefox?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, not 😬
Again, I just applied Josemi's suggestion.

I don't think I have run automated tests in firefox myself, but if you have and want to bring it back, I'll do it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it is nice to be able to run something with it in case we see strange results with chrome. This is the only browser we ship with RHEL. And Chrome is evil.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree Chrome is evil, in fact we should use only Firefox, but I guess clients use Chrome. IMO it's fine to keep both.

features/support/capybara.rb Show resolved Hide resolved
features/support/0001_world.rb Show resolved Hide resolved
Capybara.configure do |config|
config.default_driver = :rack_test
config.javascript_driver = DEFAULT_JS_DRIVER
config.default_selector = :css
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you finally remove them?

@mayorova mayorova merged commit 701fac1 into master Dec 19, 2024
32 of 35 checks passed
@mayorova mayorova deleted the refactor-capybara branch December 19, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants