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

search_labels_spec.rb « labels « projects « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 04dfd4ca5f129bd48bc877c81e4d7a94baa54181 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Search for labels', :js do
  let(:user) { create(:user) }
  let(:project) { create(:project) }
  let!(:label1) { create(:label, title: 'Foo', description: 'Lorem ipsum', project: project) }
  let!(:label2) { create(:label, title: 'Bar', description: 'Fusce consequat', project: project) }

  before do
    project.add_maintainer(user)
    sign_in(user)

    visit project_labels_path(project)
  end

  it 'searches for label by title' do
    fill_in 'label-search', with: 'Bar'
    find('#label-search').native.send_keys(:enter)

    expect(page).to have_content(label2.title)
    expect(page).to have_content(label2.description)
    expect(page).not_to have_content(label1.title)
    expect(page).not_to have_content(label1.description)
  end

  it 'searches for label by title' do
    fill_in 'label-search', with: 'Lorem'
    find('#label-search').native.send_keys(:enter)

    expect(page).to have_content(label1.title)
    expect(page).to have_content(label1.description)
    expect(page).not_to have_content(label2.title)
    expect(page).not_to have_content(label2.description)
  end

  it 'shows nothing found message' do
    fill_in 'label-search', with: 'nonexistent'
    find('#label-search').native.send_keys(:enter)

    expect(page).to have_content('No labels with such name or description')
    expect(page).not_to have_content(label1.title)
    expect(page).not_to have_content(label1.description)
    expect(page).not_to have_content(label2.title)
    expect(page).not_to have_content(label2.description)
  end

  context 'priority labels' do
    let!(:label_priority) { create(:label_priority, label: label1, project: project) }

    it 'searches for priority label' do
      fill_in 'label-search', with: 'Foo'
      find('#label-search').native.send_keys(:enter)

      page.within('.prioritized-labels') do
        expect(page).to have_content(label1.title)
        expect(page).to have_content(label1.description)
      end

      page.within('.other-labels') do
        expect(page).to have_content('No other labels with such name or description')
      end
    end

    it 'searches for other label' do
      fill_in 'label-search', with: 'Bar'
      find('#label-search').native.send_keys(:enter)

      page.within('.prioritized-labels') do
        expect(page).to have_content('No prioritized labels with such name or description')
      end

      page.within('.other-labels') do
        expect(page).to have_content(label2.title)
        expect(page).to have_content(label2.description)
      end
    end
  end
end