Commit cd453d98 authored by Walmyr Lima's avatar Walmyr Lima

Refactor rspec test suite to remove duplications

Also, one of the tests was dependent of the privous, but even with-
out running the previous it would pass, but it wouldn't be testing
what it should. Now this test is not dependent on the previous one,
and its assertion will always happen after filtering by milestone:
The test in question is 'closes when the search bar is unfocused'
parent 924d80f2
...@@ -39,16 +39,28 @@ describe 'Dropdown milestone', :js do ...@@ -39,16 +39,28 @@ describe 'Dropdown milestone', :js do
end end
describe 'behavior' do describe 'behavior' do
it 'opens when the search bar has milestone:' do context 'filters by "milestone:"' do
filtered_search.set('milestone:') before do
filtered_search.set('milestone:')
end
expect(page).to have_css(js_dropdown_milestone, visible: true) it 'opens when the search bar has milestone:' do
end expect(page).to have_css(js_dropdown_milestone, visible: true)
end
it 'closes when the search bar is unfocused' do it 'closes when the search bar is unfocused' do
find('body').click find('body').click
expect(page).to have_css(js_dropdown_milestone, visible: false) expect(page).to have_css(js_dropdown_milestone, visible: false)
end
it 'hides loading indicator when loaded' do
expect(find(js_dropdown_milestone)).not_to have_css('.filter-dropdown-loading')
end
it 'loads all the milestones when opened' do
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
end
end end
it 'shows loading indicator when opened' do it 'shows loading indicator when opened' do
...@@ -58,18 +70,6 @@ describe 'Dropdown milestone', :js do ...@@ -58,18 +70,6 @@ describe 'Dropdown milestone', :js do
expect(page).to have_css('#js-dropdown-milestone .filter-dropdown-loading', visible: true) expect(page).to have_css('#js-dropdown-milestone .filter-dropdown-loading', visible: true)
end end
end end
it 'hides loading indicator when loaded' do
filtered_search.set('milestone:')
expect(find(js_dropdown_milestone)).not_to have_css('.filter-dropdown-loading')
end
it 'loads all the milestones when opened' do
filtered_search.set('milestone:')
expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
end
end end
describe 'filtering' do describe 'filtering' do
......
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