Commit e3395e3a authored by Clement Ho's avatar Clement Ho

Add specs for clear search button

parent c07a5227
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment