From 42ef5b65bdcff17dffa017dcab45a11af9f27b9f Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 9 Jul 2025 14:23:44 +0200 Subject: [PATCH] Unify similar tests in wizard budgets spec We are unifying the test "Create budget - Knapsack voting (default)" with "A new budget is always created in draft mode" because they are almost the same. On the other hand, we also merged the test "update budget" with "submit the form with errors and then without errors". Just like in the previous case, there were two ways to access the edit page, so we removed the one that is already tested in other specs. --- .../admin/budgets_wizard/budgets_spec.rb | 51 ++++--------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/spec/system/admin/budgets_wizard/budgets_spec.rb b/spec/system/admin/budgets_wizard/budgets_spec.rb index 57a0d355e..c4102b970 100644 --- a/spec/system/admin/budgets_wizard/budgets_spec.rb +++ b/spec/system/admin/budgets_wizard/budgets_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" describe "Budgets wizard, first step", :admin do describe "New" do - scenario "Create budget - Knapsack voting (default)" do + scenario "Create budget with Knapsack voting and in draft mode (default)" do visit admin_budgets_path click_button "Create new budget" click_link "Create multiple headings budget" @@ -10,7 +10,7 @@ describe "Budgets wizard, first step", :admin do fill_in "Name", with: "M30 - Summer campaign" fill_in "Text on the link", with: "Participate now!" fill_in "The link takes you to (add a link)", with: "https://consuldemocracy.org" - fill_in "Name", with: "M30 - Summer campaign" + click_button "Continue to groups" expect(page).to have_content "New participatory budget created successfully!" @@ -19,6 +19,13 @@ describe "Budgets wizard, first step", :admin do expect(page).to have_field "Name", with: "M30 - Summer campaign" expect(page).to have_select "Final voting style", selected: "Knapsack" + + within("#side_menu") { click_link "Participatory budgets" } + within("tr", text: "M30 - Summer campaign") { click_link "Edit" } + + expect(page).to have_content "This participatory budget is in draft mode" + expect(page).to have_link "Preview" + expect(page).to have_button "Publish budget" end scenario "Create budget - Approval voting" do @@ -75,52 +82,16 @@ describe "Budgets wizard, first step", :admin do end end - describe "Create" do - scenario "A new budget is always created in draft mode" do - visit admin_budgets_path - click_button "Create new budget" - click_link "Create multiple headings budget" - - fill_in "Name", with: "M30 - Summer campaign" - - click_button "Continue to groups" - - expect(page).to have_content "New participatory budget created successfully!" - - within("#side_menu") { click_link "Participatory budgets" } - within("tr", text: "M30 - Summer campaign") { click_link "Edit" } - - expect(page).to have_content "This participatory budget is in draft mode" - expect(page).to have_link "Preview" - expect(page).to have_button "Publish budget" - end - end - describe "Edit" do - scenario "update budget" do + scenario "update budget with errors and then without errors" do budget = create(:budget, name: "Budget wiht typo") - visit admin_budgets_wizard_budget_groups_path(budget) - - click_link "Go back to edit budget" + visit edit_admin_budgets_wizard_budget_path(budget) expect(page).to have_content "Edit Participatory budget" expect(page).to have_css ".creation-timeline" expect(page).to have_field "Name", with: "Budget wiht typo" - fill_in "Name", with: "Budget without typos" - click_button "Continue to groups" - - expect(page).to have_content "Participatory budget updated successfully" - expect(page).to have_content "Budget without typos" - expect(page).to have_css ".creation-timeline" - expect(page).to have_content "There are no groups" - end - - scenario "submit the form with errors and then without errors" do - budget = create(:budget, name: "Budget wiht typo") - - visit edit_admin_budgets_wizard_budget_path(budget) fill_in "Name", with: "" click_button "Continue to groups"