Commit fd90a996 authored by Clement Ho's avatar Clement Ho

Define filtered_search as a variable

parent 625ecdbc
...@@ -6,6 +6,7 @@ describe 'Dropdown hint', js: true, feature: true do ...@@ -6,6 +6,7 @@ describe 'Dropdown hint', js: true, feature: true do
let!(:project) { create(:empty_project) } let!(:project) { create(:empty_project) }
let!(:user) { create(:user) } let!(:user) { create(:user) }
let(:filtered_search) { find('.filtered-search') } let(:filtered_search) { find('.filtered-search') }
before do before do
project.team << [user, :master] project.team << [user, :master]
login_as(user) login_as(user)
......
...@@ -5,6 +5,7 @@ describe 'Search bar', js: true, feature: true do ...@@ -5,6 +5,7 @@ describe 'Search bar', js: true, feature: true do
let!(:project) { create(:empty_project) } let!(:project) { create(:empty_project) }
let!(:user) { create(:user) } let!(:user) { create(:user) }
let(:filtered_search) { find('.filtered-search') }
before do before do
project.team << [user, :master] project.team << [user, :master]
...@@ -22,7 +23,6 @@ describe 'Search bar', js: true, feature: true do ...@@ -22,7 +23,6 @@ describe 'Search bar', js: true, feature: true do
describe 'clear search button' do describe 'clear search button' do
it 'clears text' do it 'clears text' do
search_text = 'search_text' search_text = 'search_text'
filtered_search = find('.filtered-search')
filtered_search.set(search_text) filtered_search.set(search_text)
expect(filtered_search.value).to eq(search_text) expect(filtered_search.value).to eq(search_text)
...@@ -35,28 +35,24 @@ describe 'Search bar', js: true, feature: true do ...@@ -35,28 +35,24 @@ describe 'Search bar', js: true, feature: true do
end end
it 'hides after clicked' do it 'hides after clicked' do
filtered_search = find('.filtered-search')
filtered_search.set('a') filtered_search.set('a')
find('.filtered-search-input-container .clear-search').click find('.filtered-search-input-container .clear-search').click
expect(page).to have_css('.clear-search', visible: false) expect(page).to have_css('.clear-search', visible: false)
end end
it 'hides when there is no text' do it 'hides when there is no text' do
filtered_search = find('.filtered-search')
filtered_search.set('a') filtered_search.set('a')
filtered_search.set('') filtered_search.set('')
expect(page).to have_css('.clear-search', visible: false) expect(page).to have_css('.clear-search', visible: false)
end end
it 'shows when there is text' do it 'shows when there is text' do
filtered_search = find('.filtered-search')
filtered_search.set('a') filtered_search.set('a')
expect(page).to have_css('.clear-search', visible: true) expect(page).to have_css('.clear-search', visible: true)
end end
it 'resets the dropdown hint filter' do it 'resets the dropdown hint filter' do
filtered_search = find('.filtered-search')
filtered_search.click(); filtered_search.click();
original_size = page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size original_size = page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size
...@@ -69,7 +65,6 @@ describe 'Search bar', js: true, feature: true do ...@@ -69,7 +65,6 @@ describe 'Search bar', js: true, feature: true do
end end
it 'resets the dropdown filters' do it 'resets the dropdown filters' do
filtered_search = find('.filtered-search')
filtered_search.set('a') filtered_search.set('a')
hintStyle = page.find('#js-dropdown-hint')['style'] hintStyle = page.find('#js-dropdown-hint')['style']
hintOffset = getLeftStyle(hintStyle) hintOffset = getLeftStyle(hintStyle)
......
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