mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 15:43:14 +01:00
Expand search filter spec to test type filter for aggregation counts
This commit is contained in:
parent
871c05dc11
commit
bc9b1c733b
1 changed files with 23 additions and 7 deletions
|
@ -2,17 +2,33 @@ require 'rails_helper'
|
|||
|
||||
RSpec.feature "Search filters", type: :feature, elasticsearch: true do
|
||||
|
||||
scenario "Filtering by paper type", js: true do
|
||||
paper_types = %w(Antrag Anfrage Beschlussvorlage)
|
||||
papers = paper_types.map do |t|
|
||||
FactoryGirl.create(:paper, paper_type: t)
|
||||
end
|
||||
before(:each) do
|
||||
@antrag = FactoryGirl.create(:paper, paper_type: "Antrag", name: "Mehr Spielplätze in Leipzig")
|
||||
@anfrage = FactoryGirl.create(:paper, paper_type: "Anfrage")
|
||||
@vorlage_1 = FactoryGirl.create(:paper, paper_type: "Vorlage", name: "Zustand der Spielplätze")
|
||||
@vorlage_2 = FactoryGirl.create(:paper, paper_type: "Vorlage", name: "Mehr Ampeln in der Innenstadt")
|
||||
Paper.__elasticsearch__.refresh_index!
|
||||
end
|
||||
|
||||
scenario "Displays paper types and their respective count witin the search results" do
|
||||
visit search_path body: "leipzig"
|
||||
expect(page).to have_css("li.search-result", count: 3)
|
||||
paper_type_filter = page.find("select#paper_search_paper_type")
|
||||
expect(paper_type_filter).to have_css("option", text: "Antrag (1)")
|
||||
expect(paper_type_filter).to have_css("option", text: "Anfrage (1)")
|
||||
expect(paper_type_filter).to have_css("option", text: "Vorlage (2)")
|
||||
|
||||
visit search_path body: "leipzig", paper_search: {query: "Spielplätze"}
|
||||
paper_type_filter = page.find("select#paper_search_paper_type")
|
||||
expect(paper_type_filter).to have_css("option", text: "Antrag (1)")
|
||||
expect(paper_type_filter).not_to have_css("option", text: "Anfrage")
|
||||
expect(paper_type_filter).to have_css("option", text: "Vorlage (1)")
|
||||
end
|
||||
|
||||
scenario "Filtering by paper type", js: true do
|
||||
visit search_path body: "leipzig"
|
||||
expect(page).to have_css("li.search-result", count: 4)
|
||||
select "Antrag (1)", from: "Typ"
|
||||
expect(page).to have_css("li.search-result", count: 1)
|
||||
expect(page).to have_css("li.search-result", count: 1, text: "Spielplätze")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue