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

search_bar_spec.rb « filtered_search « issues « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8639ec2a227198c9ec019f12ffab4b5a45f297a6 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Search bar', :js do
  include FilteredSearchHelpers

  let_it_be(:project) { create(:project) }
  let_it_be(:user) { create(:user) }
  let_it_be(:issue) { create(:issue, project: project) }

  before do
    stub_feature_flags(vue_issues_list: true)
    project.add_maintainer(user)
    sign_in(user)

    visit project_issues_path(project)
  end

  describe 'keyboard navigation' do
    it 'selects item' do
      click_filtered_search_bar
      send_keys :down, :enter

      expect_token_segment 'Assignee'
    end
  end

  describe 'clear search button' do
    it 'clears text' do
      search_text = 'search_text'
      click_filtered_search_bar
      send_keys search_text

      expect(page).to have_field 'Search', with: search_text

      click_button 'Clear'

      expect(page).to have_field 'Search', with: ''
    end

    it 'hides by default' do
      expect(page).not_to have_button 'Clear'
    end

    it 'hides after clicked' do
      click_filtered_search_bar
      send_keys 'a'

      click_button 'Clear'

      expect(page).not_to have_button 'Clear'
    end

    it 'hides when there is no text' do
      click_filtered_search_bar
      send_keys 'a', :backspace, :backspace

      expect(page).not_to have_button 'Clear'
    end

    it 'shows when there is text' do
      click_filtered_search_bar
      send_keys 'a'

      expect(page).to have_button 'Clear'
    end

    it 'resets the dropdown hint filter' do
      click_filtered_search_bar
      original_size = get_suggestion_count
      send_keys 'autho'

      expect_suggestion_count 1

      click_button 'Clear'
      click_filtered_search_bar

      expect_suggestion_count(original_size)
    end
  end
end