diff options
Diffstat (limited to 'spec/features/groups')
-rw-r--r-- | spec/features/groups/labels/search_labels_spec.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/features/groups/labels/search_labels_spec.rb b/spec/features/groups/labels/search_labels_spec.rb new file mode 100644 index 00000000000..14b88a561b1 --- /dev/null +++ b/spec/features/groups/labels/search_labels_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Search for labels', :js do + let(:user) { create(:user) } + let(:group) { create(:group) } + let!(:label1) { create(:group_label, title: 'Foo', description: 'Lorem ipsum', group: group) } + let!(:label2) { create(:group_label, title: 'Bar', description: 'Fusce consequat', group: group) } + + before do + group.add_maintainer(user) + sign_in(user) + + visit group_labels_path(group) + 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 description' 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 +end |