summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/shared_contexts/advanced_search_shared_context.rb
blob: c6836d11803f26cfc108e5f9a2bd92872cbc9c28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

module QA
  RSpec.shared_context 'advanced search active' do
    let!(:advanced_search_on) { check_advanced_search_status }

    before do
      QA::EE::Resource::Settings::Elasticsearch.fabricate_via_api! unless advanced_search_on
    end

    after do
      Runtime::Search.disable_elasticsearch(api_client) if !advanced_search_on && !api_client.nil?
    end

    # TODO: convert this method to use the API instead of the UI once the functionality exists
    # https://gitlab.com/gitlab-org/gitlab/-/issues/382849
    def check_advanced_search_status
      Flow::Login.sign_in
      QA::Page::Main::Menu.perform do |menu|
        menu.search_for('lorem ipsum')
      end
      page.has_text?('Advanced search is enabled')
    end
  end
end