Skip to content

Optimize capybara selector to not wait

Thong Kuah requested to merge optimize_branches_spec_wait into master

What does this MR do and why?

We already wait in the previous have_content step. So it is waste of time to wait 30 seconds to confirm 0 items.

Instead we immediately find all selectors on this step.

Screenshots or screen recordings

Before:

(arm64) tkgl2:gitlab tkuah$ bundle exec rspec /Users/tkuah/code/gdk-ee/gitlab/./spec/features/projects/branches_spec.rb:162
warning: parser/current is loading parser/ruby27, which recognizes2.7.6-compliant syntax, but you are running 2.7.5.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Run options: include {:focus=>true, :locations=>{"./spec/features/projects/branches_spec.rb"=>[162]}}

Test environment set up in 7.112807 seconds
Starting the Capybara driver server...
Capybara starting Puma...
* Version 5.6.5 , codename: Birdie's Version
* Min threads: 0, max threads: 4
* Listening on unix:///var/folders/gr/1dm_jlrd4g9_724jr3dmrrtm0000gn/T/20220922-87166-zbfjnv
.

Finished in 1 minute 0.9 seconds (files took 9.65 seconds to load)
1 example, 0 failures

After:

$ bundle exec rspec /Users/tkuah/code/gdk-ee/gitlab/./spec/features/projects/branches_spec.rb:162
warning: parser/current is loading parser/ruby27, which recognizes2.7.6-compliant syntax, but you are running 2.7.5.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Run options: include {:focus=>true, :locations=>{"./spec/features/projects/branches_spec.rb"=>[162]}}

Test environment set up in 7.127124 seconds
Starting the Capybara driver server...
Capybara starting Puma...
* Version 5.6.5 , codename: Birdie's Version
* Min threads: 0, max threads: 4
* Listening on unix:///var/folders/gr/1dm_jlrd4g9_724jr3dmrrtm0000gn/T/20220922-87474-1wjioqw
.

Finished in 31.71 seconds (files took 13.54 seconds to load)
1 example, 0 failures

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Thong Kuah

Merge request reports