diff options
Diffstat (limited to 'spec/features/search')
-rw-r--r-- | spec/features/search/user_searches_for_code_spec.rb | 1 | ||||
-rw-r--r-- | spec/features/search/user_uses_header_search_field_spec.rb | 26 | ||||
-rw-r--r-- | spec/features/search/user_uses_search_filters_spec.rb | 38 |
3 files changed, 45 insertions, 20 deletions
diff --git a/spec/features/search/user_searches_for_code_spec.rb b/spec/features/search/user_searches_for_code_spec.rb index 227e75088d2..a88043c98ac 100644 --- a/spec/features/search/user_searches_for_code_spec.rb +++ b/spec/features/search/user_searches_for_code_spec.rb @@ -21,6 +21,7 @@ RSpec.describe 'User searches for code' do expect(page).to have_selector('.results', text: 'application.js') expect(page).to have_selector('.file-content .code') expect(page).to have_selector("span.line[lang='javascript']") + expect(page).to have_link('application.js', href: /master\/files\/js\/application.js/) end context 'when on a project page', :js do diff --git a/spec/features/search/user_uses_header_search_field_spec.rb b/spec/features/search/user_uses_header_search_field_spec.rb index cfda25b9ab4..5cbfacf4e48 100644 --- a/spec/features/search/user_uses_header_search_field_spec.rb +++ b/spec/features/search/user_uses_header_search_field_spec.rb @@ -30,6 +30,8 @@ RSpec.describe 'User uses header search field', :js do before do find('#search') find('body').native.send_keys('s') + + wait_for_all_requests end it 'shows the category search dropdown' do @@ -89,9 +91,7 @@ RSpec.describe 'User uses header search field', :js do context 'when entering text into the search field' do it 'does not display the category search dropdown' do - page.within('.search-input-wrap') do - fill_in('search', with: scope_name.first(4)) - end + fill_in_search(scope_name.first(4)) expect(page).not_to have_selector('.dropdown-header', text: /#{scope_name}/i) end @@ -105,9 +105,7 @@ RSpec.describe 'User uses header search field', :js do end it 'displays search options' do - page.within('.search-input-wrap') do - fill_in('search', with: 'test') - end + fill_in_search('test') expect(page).to have_selector(scoped_search_link('test')) end @@ -140,9 +138,7 @@ RSpec.describe 'User uses header search field', :js do end it 'displays search options' do - page.within('.search-input-wrap') do - fill_in('search', with: 'test') - end + fill_in_search('test') expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test', group_id: group.id)) @@ -157,9 +153,7 @@ RSpec.describe 'User uses header search field', :js do end it 'displays search options' do - page.within('.search-input-wrap') do - fill_in('search', with: 'test') - end + fill_in_search('test') expect(page).to have_selector(scoped_search_link('test')) expect(page).not_to have_selector(scoped_search_link('test', group_id: project.namespace_id)) @@ -182,9 +176,7 @@ RSpec.describe 'User uses header search field', :js do end it 'displays search options' do - page.within('.search-input-wrap') do - fill_in('search', with: 'test') - end + fill_in_search('test') expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test', group_id: group.id)) @@ -208,9 +200,7 @@ RSpec.describe 'User uses header search field', :js do end it 'displays search options' do - page.within('.search-input-wrap') do - fill_in('search', with: 'test') - end + fill_in_search('test') expect(page).to have_selector(scoped_search_link('test')) expect(page).to have_selector(scoped_search_link('test', group_id: subgroup.id)) diff --git a/spec/features/search/user_uses_search_filters_spec.rb b/spec/features/search/user_uses_search_filters_spec.rb index f39a1f8fe37..080cced21c3 100644 --- a/spec/features/search/user_uses_search_filters_spec.rb +++ b/spec/features/search/user_uses_search_filters_spec.rb @@ -12,12 +12,12 @@ RSpec.describe 'User uses search filters', :js do project.add_reporter(user) group.add_owner(user) sign_in(user) - - visit(search_path) end context 'when filtering by group' do it 'shows group projects' do + visit search_path + find('.js-search-group-dropdown').click wait_for_requests @@ -36,10 +36,27 @@ RSpec.describe 'User uses search filters', :js do expect(page).to have_link(group_project.full_name) end end + + context 'when the group filter is set' do + before do + visit search_path(search: "test", group_id: group.id, project_id: project.id) + end + + describe 'clear filter button' do + it 'removes Group and Project filters' do + link = find('[data-testid="group-filter"] .js-search-clear') + params = CGI.parse(URI.parse(link[:href]).query) + + expect(params).not_to include(:group_id, :project_id) + end + end + end end context 'when filtering by project' do it 'shows a project' do + visit search_path + page.within('.project-filter') do find('.js-search-project-dropdown').click @@ -50,5 +67,22 @@ RSpec.describe 'User uses search filters', :js do expect(find('.js-search-project-dropdown')).to have_content(project.full_name) end + + context 'when the project filter is set' do + before do + visit search_path(search: "test", project_id: project.id) + end + + let(:query) { { project_id: project.id } } + + describe 'clear filter button' do + it 'removes Project filters' do + link = find('.project-filter .js-search-clear') + params = CGI.parse(URI.parse(link[:href]).query) + + expect(params).not_to include(:project_id) + end + end + end end end |