Don't loop over budget phases in system tests
We've already got model tests for that, and we were modifying the
database after a `visit`, since we were doing a loop consisting of
"update!" -> "visit" -> "update!" -> "visit!" -> (...).
Besides, note that the `.kind_or_later("publishing_prices").each` block
wasn't modifying the budget, so it always visited the page under the
same conditions.
So we're simply randomly checking one phase to test that the user
interface works as expected.
This commit is contained in:
@@ -529,26 +529,21 @@ describe "Budget Investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Order always is random for unfeasible and unselected investments" do
|
scenario "Order always is random for unfeasible and unselected investments" do
|
||||||
Budget::Phase::kind_or_later("valuating").each do |phase|
|
phase = Budget::Phase::kind_or_later("valuating").sample
|
||||||
budget.update!(phase: phase)
|
budget.update!(phase: phase)
|
||||||
|
|
||||||
visit budget_investments_path(budget, heading_id: heading.id, filter: "unfeasible")
|
filter = if Budget::Phase.kind_or_later("publishing_prices").include?(phase)
|
||||||
|
"unselected"
|
||||||
|
else
|
||||||
|
"unfeasible"
|
||||||
|
end
|
||||||
|
|
||||||
within(".submenu") do
|
visit budget_investments_path(budget, heading_id: heading.id, filter: filter)
|
||||||
expect(page).to have_content "random"
|
|
||||||
expect(page).not_to have_content "by price"
|
|
||||||
expect(page).not_to have_content "highest rated"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Budget::Phase.kind_or_later("publishing_prices").each do |phase|
|
within(".submenu") do
|
||||||
visit budget_investments_path(budget, heading_id: heading.id, filter: "unselected")
|
expect(page).to have_content "random"
|
||||||
|
expect(page).not_to have_content "by price"
|
||||||
within(".submenu") do
|
expect(page).not_to have_content "highest rated"
|
||||||
expect(page).to have_content "random"
|
|
||||||
expect(page).not_to have_content "price"
|
|
||||||
expect(page).not_to have_content "highest rated"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -872,38 +867,36 @@ describe "Budget Investments" do
|
|||||||
|
|
||||||
context "When investment with price is selected" do
|
context "When investment with price is selected" do
|
||||||
scenario "Price & explanation is shown when Budget is on published prices phase" do
|
scenario "Price & explanation is shown when Budget is on published prices phase" do
|
||||||
Budget::Phase::PUBLISHED_PRICES_PHASES.each do |phase|
|
phase = Budget::Phase::PUBLISHED_PRICES_PHASES.sample
|
||||||
budget.update!(phase: phase)
|
budget.update!(phase: phase)
|
||||||
|
|
||||||
if budget.finished?
|
if budget.finished?
|
||||||
investment.update!(winner: true)
|
investment.update!(winner: true)
|
||||||
end
|
|
||||||
|
|
||||||
visit budget_investment_path(budget, id: investment.id)
|
|
||||||
|
|
||||||
expect(page).to have_content(investment.formatted_price)
|
|
||||||
expect(page).to have_content(investment.price_explanation)
|
|
||||||
expect(page).to have_link("See price explanation")
|
|
||||||
|
|
||||||
visit budget_investments_path(budget)
|
|
||||||
|
|
||||||
expect(page).to have_content(investment.formatted_price)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
visit budget_investment_path(budget, id: investment.id)
|
||||||
|
|
||||||
|
expect(page).to have_content(investment.formatted_price)
|
||||||
|
expect(page).to have_content(investment.price_explanation)
|
||||||
|
expect(page).to have_link("See price explanation")
|
||||||
|
|
||||||
|
visit budget_investments_path(budget)
|
||||||
|
|
||||||
|
expect(page).to have_content(investment.formatted_price)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Price & explanation isn't shown when Budget is not on published prices phase" do
|
scenario "Price & explanation isn't shown when Budget is not on published prices phase" do
|
||||||
(Budget::Phase::PHASE_KINDS - Budget::Phase::PUBLISHED_PRICES_PHASES).each do |phase|
|
phase = (Budget::Phase::PHASE_KINDS - Budget::Phase::PUBLISHED_PRICES_PHASES).sample
|
||||||
budget.update!(phase: phase)
|
budget.update!(phase: phase)
|
||||||
visit budget_investment_path(budget, id: investment.id)
|
visit budget_investment_path(budget, id: investment.id)
|
||||||
|
|
||||||
expect(page).not_to have_content(investment.formatted_price)
|
expect(page).not_to have_content(investment.formatted_price)
|
||||||
expect(page).not_to have_content(investment.price_explanation)
|
expect(page).not_to have_content(investment.price_explanation)
|
||||||
expect(page).not_to have_link("See price explanation")
|
expect(page).not_to have_link("See price explanation")
|
||||||
|
|
||||||
visit budget_investments_path(budget)
|
visit budget_investments_path(budget)
|
||||||
|
|
||||||
expect(page).not_to have_content(investment.formatted_price)
|
expect(page).not_to have_content(investment.formatted_price)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -913,18 +906,17 @@ describe "Budget Investments" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Price & explanation isn't shown for any Budget's phase" do
|
scenario "Price & explanation isn't shown for any Budget's phase" do
|
||||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
phase = Budget::Phase::PHASE_KINDS.sample
|
||||||
budget.update!(phase: phase)
|
budget.update!(phase: phase)
|
||||||
visit budget_investment_path(budget, id: investment.id)
|
visit budget_investment_path(budget, id: investment.id)
|
||||||
|
|
||||||
expect(page).not_to have_content(investment.formatted_price)
|
expect(page).not_to have_content(investment.formatted_price)
|
||||||
expect(page).not_to have_content(investment.price_explanation)
|
expect(page).not_to have_content(investment.price_explanation)
|
||||||
expect(page).not_to have_link("See price explanation")
|
expect(page).not_to have_link("See price explanation")
|
||||||
|
|
||||||
visit budget_investments_path(budget)
|
visit budget_investments_path(budget)
|
||||||
|
|
||||||
expect(page).not_to have_content(investment.formatted_price)
|
expect(page).not_to have_content(investment.formatted_price)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user