Add specs for clear search button

This commit is contained in:
Clement Ho 2016-11-14 16:55:38 -06:00
parent c07a522743
commit e3395e3a9d

View file

@ -0,0 +1,55 @@
require 'rails_helper'
describe 'Search bar', feature: true do
include WaitForAjax
let!(:project) { create(:project) }
let!(:group) { create(:group) }
let!(:user) { create(:user) }
before do
project.team << [user, :master]
group.add_developer(user)
login_as(user)
create(:issue, project: project)
visit namespace_project_issues_path(project.namespace, project)
end
describe 'clear search button', js: true do
it 'clears text' do
search_text = 'search_text'
filtered_search = find('.filtered-search')
filtered_search.set(search_text)
expect(filtered_search.value).to eq(search_text)
find('.filtered-search-input-container .clear-search').click
expect(filtered_search.value).to eq('')
end
it 'hides by default' do
expect(page).to have_css('.clear-search', visible: false)
end
it 'hides after clicked' do
filtered_search = find('.filtered-search')
filtered_search.set('a')
find('.filtered-search-input-container .clear-search').click
expect(page).to have_css('.clear-search', visible: false)
end
it 'hides when there is no text' do
filtered_search = find('.filtered-search')
filtered_search.set('a')
filtered_search.set('')
expect(page).to have_css('.clear-search', visible: false)
end
it 'shows when there is text' do
filtered_search = find('.filtered-search')
filtered_search.set('a')
expect(page).to have_css('.clear-search', visible: true)
end
end
end