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

user_uses_header_search_field_spec.rb « search « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: af38f77c0c6000f2bc5a5ff4a64441ab8267b341 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
require 'spec_helper'

describe 'User uses header search field' do
  include FilteredSearchHelpers

  let(:project) { create(:project) }
  let(:user) { create(:user) }

  before do
    project.add_reporter(user)
    sign_in(user)
  end

  context 'when user is in a global scope', :js do
    before do
      visit(root_path)
      page.find('#search').click
    end

    context 'when clicking issues' do
      it 'shows assigned issues' do
        find('.search-input-container .dropdown-menu').click_link('Issues assigned to me')

        expect(find('.js-assignee-search')).to have_content(user.name)
      end

      it 'shows created issues' do
        find('.search-input-container .dropdown-menu').click_link("Issues I've created")

        expect(find('.js-author-search')).to have_content(user.name)
      end
    end

    context 'when clicking merge requests' do
      let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) }

      it 'shows assigned merge requests' do
        find('.search-input-container .dropdown-menu').click_link('Merge requests assigned to me')

        expect(find('.js-assignee-search')).to have_content(user.name)
      end

      it 'shows created merge requests' do
        find('.search-input-container .dropdown-menu').click_link("Merge requests I've created")

        expect(find('.js-author-search')).to have_content(user.name)
      end
    end
  end

  context 'when user is in a project scope' do
    before do
      visit(project_path(project))
    end

    it 'starts searching by pressing the enter key', :js do
      fill_in('search', with: 'gitlab')
      find('#search').native.send_keys(:enter)

      page.within('.breadcrumbs-sub-title') do
        expect(page).to have_content('Search')
      end
    end

    context 'when clicking the search field', :js do
      before do
        page.find('#search').click
      end

      it 'shows category search dropdown' do
        expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i)
      end

      context 'when clicking issues' do
        let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) }

        it 'shows assigned issues' do
          find('.dropdown-menu').click_link('Issues assigned to me')

          expect(page).to have_selector('.filtered-search')
          expect_tokens([assignee_token(user.name)])
          expect_filtered_search_input_empty
        end

        it 'shows created issues' do
          find('.dropdown-menu').click_link("Issues I've created")

          expect(page).to have_selector('.filtered-search')
          expect_tokens([author_token(user.name)])
          expect_filtered_search_input_empty
        end
      end

      context 'when clicking merge requests' do
        let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) }

        it 'shows assigned merge requests' do
          find('.dropdown-menu').click_link('Merge requests assigned to me')

          expect(page).to have_selector('.merge-requests-holder')
          expect_tokens([assignee_token(user.name)])
          expect_filtered_search_input_empty
        end

        it 'shows created merge requests' do
          find('.dropdown-menu').click_link("Merge requests I've created")

          expect(page).to have_selector('.merge-requests-holder')
          expect_tokens([author_token(user.name)])
          expect_filtered_search_input_empty
        end
      end
    end

    context 'when entering text into the search field', :js do
      before do
        page.within('.search-input-wrap') do
          fill_in('search', with: project.name[0..3])
        end
      end

      it 'does not display the category search dropdown' do
        expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i)
      end
    end
  end
end