spec/features/advanced_search_spec.rb in blacklight-8.0.1 vs spec/features/advanced_search_spec.rb in blacklight-8.1.0

- old
+ new

@@ -3,13 +3,31 @@ require 'spec_helper' RSpec.describe "Blacklight Advanced Search Form" do describe "advanced search form" do before do + CatalogController.blacklight_config.search_fields['all_fields']['clause_params'] = { + edismax: {} + } + CatalogController.blacklight_config.search_fields['author']['clause_params'] = { + edismax: { qf: '${author_qf}' } + } + CatalogController.blacklight_config.search_fields['title']['clause_params'] = { + edismax: { qf: '${title_qf}' } + } + CatalogController.blacklight_config.search_fields['subject']['clause_params'] = { + edismax: { qf: '${subject_qf}' } + } visit '/catalog/advanced?hypothetical_existing_param=true&q=ignore+this+existing+query' end + after do + %w[all_fields author title subject].each do |field| + CatalogController.blacklight_config.search_fields[field].delete(:clause_params) + end + end + it "has field and facet blocks" do expect(page).to have_selector('.query-criteria') expect(page).to have_selector('.limit-criteria') end @@ -43,9 +61,46 @@ it 'scopes searches to fields' do fill_in 'Title', with: 'Medicine' click_on 'advanced-search-submit' expect(page).to have_content 'Remove constraint Title: Medicine' expect(page).to have_content 'Strong Medicine speaks' + expect(page).to have_selector('article.document', count: 1) + end + + it 'can limit to facets' do + fill_in 'Subject', with: 'Women' + click_on 'Language' + check 'Urdu 3' + click_on 'advanced-search-submit' + expect(page).to have_content 'Pākistānī ʻaurat dorāhe par' + expect(page).not_to have_content 'Ajikto kŭrŏk chŏrŏk sasimnikka : and 아직도 그럭 저럭 사십니까' + expect(page).to have_selector('article.document', count: 1) + end + + it 'handles boolean queries' do + fill_in 'All Fields', with: 'history NOT strong' + click_on 'advanced-search-submit' + expect(page).to have_content('Ci an zhou bian') + expect(page).not_to have_content('Strong Medicine speaks') + expect(page).to have_selector('article.document', count: 10) + end + + it 'handles queries in multiple fields with the ALL operator' do + fill_in 'All Fields', with: 'history' + fill_in 'Author', with: 'hearth' + click_on 'advanced-search-submit' + expect(page).to have_content('Strong Medicine speaks') + expect(page).to have_selector('article.document', count: 1) + end + + it 'handles queries in multiple fields with the ANY operator' do + select 'any', from: 'op' + fill_in 'All Fields', with: 'history' + fill_in 'Subject', with: 'women' + click_on 'advanced-search-submit' + expect(page).to have_content('Ci an zhou bian') + expect(page).to have_content('Pākistānī ʻaurat dorāhe par') + expect(page).to have_selector('article.document', count: 10) end end describe "prepopulated advanced search form" do before do