workarea-commerce / workarea

Workarea is an enterprise-grade Ruby on Rails commerce platform
https://www.workarea.com
Other
326 stars 66 forks source link

Remove unnecessary Capybara blocking when testing content is not present #525

Closed jonmast closed 3 years ago

jonmast commented 3 years ago

Capybara's page.has_content? and similar methods block until a timeout is reached if they can't find the content. This is not what we want if we're checking that the content does not exist, switch to using refute_text in these scenarios.

The timeout is equal to the number of installed plugins and we have client apps with 30+, which means that the 38 instances removed in this commit could represent twenty minutes of unnecessary blocking in some scenarios.

Thanks to James Anaipakos in https://discourse.workarea.com/t/capybara-refute-assertions-waiting-full-default-wait-time/1610 for alerting me to the issue.

Note: I've selected refute_text and refute_selector somewhat arbitrarily here, they have several aliases. I'm specifically avoiding the more closely analogous page.has_no_content? because the resulting error messages aren't as nice, but I'm happy to update to whatever you all prefer.

bencrouse commented 3 years ago

Nice! Thanks for opening @jonmast .

I'd like to see a passing build on this before merging. One reason it might not have run is we have secrets set up, so allowing forks to run builds would allow listing secrets out. So, I'm going to cherry pick this into a branch on our repo. And we can move the discussion/review there.

Cheers!

bencrouse commented 3 years ago

Merged in #526