Skip to content

Configure the browser before running any QA scenario

Rémy Coutable requested to merge fix-qa-template into master

What does this MR do?

An unintended side-effect of !23059 (merged) was that when the first action of a scenario is an API request (e.g. when enabling a feature flag), Capybara isn't configured and we get a failure similar to the following:

› QA_DEBUG=1 CHROME_HEADLESS=false bundle exec bin/qa Test::Instance::All http://127.0.0.1:3001 --enable-feature gitaly_enforce_requests_limits -- 'qa/specs/features/ee/browser_ui/3_create/repository/restrict_push_protected_branch_spec.rb:65'

I, [2020-01-21T12:53:41.436125 #49212]  INFO -- : Enabling feature: gitaly_enforce_requests_limits
I, [2020-01-21T12:53:42.436694 #49212]  INFO -- : Disabling feature: gitaly_enforce_requests_limits
bundler: failed to load command: bin/qa (bin/qa)
ArgumentError: rack-test requires a rack application, but none was given
  /Users/remy/.gem/ruby/2.6.5/gems/capybara-3.29.0/lib/capybara/rack_test/driver.rb:18:in `initialize'
  /Users/remy/.gem/ruby/2.6.5/gems/capybara-3.29.0/lib/capybara/registrations/drivers.rb:4:in `new'
  /Users/remy/.gem/ruby/2.6.5/gems/capybara-3.29.0/lib/capybara/registrations/drivers.rb:4:in `block in <top (required)>'
  /Users/remy/.gem/ruby/2.6.5/gems/capybara-3.29.0/lib/capybara/session.rb:102:in `driver'
  /Users/remy/.gem/ruby/2.6.5/gems/capybara-3.29.0/lib/capybara/session.rb:227:in `current_url'
  /Users/remy/.gem/ruby/2.6.5/gems/capybara-3.29.0/lib/capybara/dsl.rb:51:in `block (2 levels) in <module:DSL>'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/resource/api_fabricator.rb:112:in `api_client'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/resource/api_fabricator.rb:39:in `eager_load_api_client!'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/resource/base.rb:43:in `fabricate_via_api!'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/runtime/feature.rb:56:in `api_client'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/runtime/feature.rb:71:in `set_feature'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/runtime/feature.rb:19:in `disable'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/scenario/template.rb:34:in `ensure in perform'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/scenario/template.rb:34:in `perform'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/scenario/template.rb:10:in `block in perform'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/scenario/template.rb:8:in `tap'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/scenario/template.rb:8:in `perform'
  /Users/remy/Code/GitLab/gdk-ee/gitlab/qa/qa/scenario/bootable.rb:28:in `launch!'
  bin/qa:7:in `<top (required)>'

By calling QA::Runtime::Browser.configure! before any action, we make sure Capybara is configured. Previously, Runtime::Release.perform_before_hooks would be the first action and since the before hooks call QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login), QA::Runtime::Browser.configure! would have been called automatically via QA::Runtime::Browser.initialize:

      def initialize
        self.class.configure!
      end

Does this MR meet the acceptance criteria?

Conformity

Edited by Rémy Coutable

Merge request reports