2018-07-31 06:56:58 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-20 12:05:36 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
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)
|
2018-07-30 13:36:37 -04:00
|
|
|
end
|
2018-07-20 12:05:36 -04:00
|
|
|
|
2018-07-30 13:36:37 -04:00
|
|
|
it 'searches for label by title' do
|
2018-07-20 12:05:36 -04:00
|
|
|
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
|
2018-07-30 13:36:37 -04:00
|
|
|
|
|
|
|
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
|
2018-07-31 06:07:44 -04:00
|
|
|
expect(page).to have_content('No other labels with such name or description')
|
2018-07-30 13:36:37 -04:00
|
|
|
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
|
2019-11-08 07:06:32 -05:00
|
|
|
expect(page).to have_content('No prioritized labels with such name or description')
|
2018-07-30 13:36:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.other-labels') do
|
|
|
|
expect(page).to have_content(label2.title)
|
|
|
|
expect(page).to have_content(label2.description)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-07-20 12:05:36 -04:00
|
|
|
end
|