Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_searches_for_wiki_pages_spec.rb « search « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f20ad0aa07a2e8a7a603b5a0d98aa5d0f75681a (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'User searches for wiki pages', :js, :clean_gitlab_redis_rate_limiting do
  using RSpec::Parameterized::TableSyntax

  let_it_be(:user) { create(:user) }

  let(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
  let!(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'directory/title', content: 'Some Wiki content') }

  where(search_page_vertical_nav_enabled: [true, false])
  with_them do
    before do
      stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
      project.add_maintainer(user)
      sign_in(user)

      visit(search_path)
    end

    include_examples 'top right search form'
    include_examples 'search timeouts', 'wiki_blobs' do
      let(:additional_params) { { project_id: project.id } }
    end

    shared_examples 'search wiki blobs' do
      it 'finds a page' do
        find('[data-testid="project-filter"]').click

        wait_for_requests

        page.within('[data-testid="project-filter"]') do
          click_on(project.name)
        end

        fill_in('dashboard_search', with: search_term)
        find('.gl-search-box-by-click-search-button').click
        select_search_scope('Wiki')

        page.within('.results') do
          expect(page).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug))
        end
      end
    end

    context 'when searching by content' do
      it_behaves_like 'search wiki blobs' do
        let(:search_term) { 'content' }
      end
    end

    context 'when searching by title' do
      it_behaves_like 'search wiki blobs' do
        let(:search_term) { 'title' }
      end
    end
  end
end