Merge pull request #2723 from wairbut-m2c/backport_2400_combine_free_text_search_and_filters

Combine text search and filters for Investments on Admin panel
This commit is contained in:
Alberto
2018-07-25 14:42:19 +02:00
committed by GitHub
8 changed files with 247 additions and 120 deletions

View File

@@ -110,24 +110,28 @@ feature 'Admin budget investments' do
expect(page).to have_link("Plant trees")
select "Central Park", from: "heading_id"
click_button 'Filter'
expect(page).not_to have_link("Realocate visitors")
expect(page).not_to have_link("Change name")
expect(page).to have_link("Plant trees")
select "All headings", from: "heading_id"
click_button 'Filter'
expect(page).to have_link("Realocate visitors")
expect(page).to have_link("Change name")
expect(page).to have_link("Plant trees")
select "Streets: Main Avenue", from: "heading_id"
click_button 'Filter'
expect(page).to have_link("Realocate visitors")
expect(page).not_to have_link("Change name")
expect(page).not_to have_link("Plant trees")
select "Streets: Mercy Street", from: "heading_id"
click_button 'Filter'
expect(page).not_to have_link("Realocate visitors")
expect(page).to have_link("Change name")
@@ -146,18 +150,22 @@ feature 'Admin budget investments' do
expect(page).to have_link("Destroy the city")
select "Admin 1", from: "administrator_id"
click_button 'Filter'
expect(page).to have_content('There is 1 investment')
expect(page).not_to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
select "All administrators", from: "administrator_id"
click_button 'Filter'
expect(page).to have_content('There are 2 investments')
expect(page).to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
select "Admin 1", from: "administrator_id"
click_button 'Filter'
expect(page).to have_content('There is 1 investment')
expect(page).not_to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
@@ -177,18 +185,21 @@ feature 'Admin budget investments' do
expect(page).to have_link("Destroy the city")
select "Valuator 1", from: "valuator_or_group_id"
click_button 'Filter'
expect(page).to have_content('There is 1 investment')
expect(page).not_to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
select "All valuators", from: "valuator_or_group_id"
click_button 'Filter'
expect(page).to have_content('There are 2 investments')
expect(page).to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
select "Valuator 1", from: "valuator_or_group_id"
click_button 'Filter'
expect(page).to have_content('There is 1 investment')
expect(page).not_to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
@@ -210,18 +221,22 @@ feature 'Admin budget investments' do
expect(page).to have_link("Build a theatre")
select "Health", from: "valuator_or_group_id"
click_button 'Filter'
expect(page).to have_content('There is 1 investment')
expect(page).to have_link("Build a hospital")
expect(page).not_to have_link("Build a theatre")
select "All valuators", from: "valuator_or_group_id"
click_button 'Filter'
expect(page).to have_content('There are 2 investments')
expect(page).to have_link("Build a hospital")
expect(page).to have_link("Build a theatre")
select "Culture", from: "valuator_or_group_id"
click_button 'Filter'
expect(page).to have_content('There is 1 investment')
expect(page).to have_link("Build a theatre")
expect(page).not_to have_link("Build a hospital")
@@ -411,6 +426,140 @@ feature 'Admin budget investments' do
end
end
scenario "Combination of checkbox with text search", :js do
user = create(:user, username: 'Admin 1')
administrator = create(:administrator, user: user)
create(:budget_investment, budget: budget, title: 'Educate the children',
id: 20, administrator: administrator)
create(:budget_investment, budget: budget, title: 'More schools',
id: 10, administrator: administrator)
create(:budget_investment, budget: budget, title: 'More hospitals')
visit admin_budget_budget_investments_path(budget_id: budget.id)
expect(page).to have_css(".budget_investment", count: 3)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).to have_content("More hospitals")
select "Admin 1", from: "administrator_id"
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 2)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).not_to have_content("More hospitals")
fill_in 'title_or_id', with: 20
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 1)
expect(page).to have_content("Educate the children")
expect(page).not_to have_content("More schools")
expect(page).not_to have_content("More hospitals")
expect(page).to have_content('Selected')
end
scenario "Combination of select with text search", :js do
create(:budget_investment, budget: budget, title: 'Educate the children',
feasibility: 'feasible', id: 20,
valuation_finished: true)
create(:budget_investment, budget: budget, title: 'More schools',
feasibility: 'feasible', id: 10,
valuation_finished: true)
create(:budget_investment, budget: budget, title: 'More hospitals')
visit admin_budget_budget_investments_path(budget_id: budget.id)
expect(page).to have_css(".budget_investment", count: 3)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).to have_content("More hospitals")
click_link 'Advanced filters'
page.check('advanced_filters_feasible')
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 2)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).not_to have_content("More hospitals")
fill_in 'title_or_id', with: 20
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 1)
expect(page).to have_content("Educate the children")
expect(page).not_to have_content("More schools")
expect(page).not_to have_content("More hospitals")
expect(page).to have_content('Selected')
end
scenario "Combination of checkbox with text search and checkbox", :js do
user = create(:user, username: 'Admin 1')
administrator = create(:administrator, user: user)
create(:budget_investment, budget: budget, title: 'Educate the children',
feasibility: 'feasible', id: 20,
valuation_finished: true,
administrator: administrator)
create(:budget_investment, budget: budget, title: 'More schools',
feasibility: 'feasible', id: 10,
valuation_finished: true,
administrator: administrator)
create(:budget_investment, budget: budget, title: 'More hospitals',
administrator: administrator)
create(:budget_investment, budget: budget, title: 'More hostals')
visit admin_budget_budget_investments_path(budget_id: budget.id)
expect(page).to have_css(".budget_investment", count: 4)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).to have_content("More hospitals")
expect(page).to have_content("More hostals")
select "Admin 1", from: "administrator_id"
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 3)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).to have_content("More hospitals")
expect(page).not_to have_content("More hostals")
click_link 'Advanced filters'
page.check('advanced_filters_feasible')
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 2)
expect(page).to have_content("Educate the children")
expect(page).to have_content("More schools")
expect(page).not_to have_content("More hospitals")
expect(page).not_to have_content("More hostals")
fill_in 'title_or_id', with: 20
click_button "Filter"
expect(page).to have_css(".budget_investment", count: 1)
expect(page).to have_content("Educate the children")
expect(page).not_to have_content("More schools")
expect(page).not_to have_content("More hospitals")
expect(page).not_to have_content("More hostals")
expect(page).to have_content('Selected')
end
end
context 'Search' do
@@ -429,7 +578,7 @@ feature 'Admin budget investments' do
expect(page).to have_content('Some other investment')
fill_in 'title_or_id', with: 'Some investment'
click_button 'Search'
click_button 'Filter'
expect(page).to have_content('Some investment')
expect(page).not_to have_content('Some other investment')
@@ -442,7 +591,7 @@ feature 'Admin budget investments' do
expect(page).to have_content('Some other investment')
fill_in 'title_or_id', with: first_investment.id
click_button 'Search'
click_button 'Filter'
expect(page).to have_content('Some other investment')
expect(page).not_to have_content('Some investment')
@@ -823,7 +972,7 @@ feature 'Admin budget investments' do
expect(page).to have_content(winner_bi.title)
click_link 'Advanced filters'
within('#advanced_filters') { find(:css, "#advanced_filters_[value='feasible']").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_feasible").set(true) }
click_button 'Filter'
expect(page).not_to have_content(unfeasible_bi.title)
@@ -832,8 +981,8 @@ feature 'Admin budget investments' do
expect(page).to have_content(selected_bi.title)
expect(page).to have_content(winner_bi.title)
within('#advanced_filters') { find(:css, "#advanced_filters_[value='selected']").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_[value='feasible']").set(false) }
within('#advanced_filters') { find(:css, "#advanced_filters_selected").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_feasible").set(false) }
click_button 'Filter'
expect(page).not_to have_content(unfeasible_bi.title)
@@ -854,7 +1003,7 @@ feature 'Admin budget investments' do
visit admin_budget_budget_investments_path(budget)
click_link 'Advanced filters'
within('#advanced_filters') { find(:css, "#advanced_filters_[value='undecided']").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_undecided").set(true) }
click_button 'Filter'
expect(page).to have_content(undecided_bi.title)
@@ -864,7 +1013,7 @@ feature 'Admin budget investments' do
expect(page).not_to have_content(unfeasible_bi.title)
expect(page).not_to have_content(feasible_vf_bi.title)
within('#advanced_filters') { find(:css, "#advanced_filters_[value='unfeasible']").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_unfeasible").set(true) }
click_button 'Filter'
expect(page).to have_content(undecided_bi.title)
@@ -908,7 +1057,7 @@ feature 'Admin budget investments' do
end
click_link 'Advanced filters'
within('#advanced_filters') { find(:css, "#advanced_filters_[value='selected']").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_selected").set(true) }
click_button 'Filter'
within("#budget_investment_#{feasible_vf_bi.id}") do
@@ -920,7 +1069,9 @@ feature 'Admin budget investments' do
scenario "Unselecting an investment", :js do
visit admin_budget_budget_investments_path(budget)
click_link 'Advanced filters'
within('#advanced_filters') { find(:css, "#advanced_filters_[value='selected']").set(true) }
within('#advanced_filters') { find(:css, "#advanced_filters_selected").set(true) }
click_button 'Filter'
expect(page).to have_content('There are 2 investments')