From 1d89fe0738db31bc2c58efeda4c4504033b73b2f Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 9 Jul 2025 14:06:55 +0200 Subject: [PATCH 1/5] Unify similar tests in proposal notifications spec The test "Link to send the message" was already included inside "Send a notification". We removed the first one to keep only one test that covers everything. --- spec/system/proposal_notifications_spec.rb | 27 ++++------------------ 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/spec/system/proposal_notifications_spec.rb b/spec/system/proposal_notifications_spec.rb index dff45c273..90257d827 100644 --- a/spec/system/proposal_notifications_spec.rb +++ b/spec/system/proposal_notifications_spec.rb @@ -2,13 +2,16 @@ require "rails_helper" describe "Proposal Notifications" do scenario "Send a notification" do - author = create(:user, :with_proposal) + author = create(:user) + proposal = create(:proposal, author: author) login_as(author) visit root_path click_link "My content" - click_link "Dashboard" + within("#proposal_#{proposal.id}") do + click_link "Dashboard" + end within("#side_menu") do click_link "Message to users" @@ -142,26 +145,6 @@ describe "Proposal Notifications" do end context "Permissions" do - scenario "Link to send the message" do - author = create(:user) - proposal = create(:proposal, author: author) - - login_as(author) - visit root_path - - click_link "My content" - - within("#proposal_#{proposal.id}") do - click_link "Dashboard" - end - - within("#side_menu") do - click_link "Message to users" - end - - expect(page).to have_link "Send notification to proposal followers" - end - scenario "Accessing form directly" do user = create(:user) author = create(:user) From 42ef5b65bdcff17dffa017dcab45a11af9f27b9f Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 9 Jul 2025 14:23:44 +0200 Subject: [PATCH 2/5] 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" From d43654be42fadcbfcbfcad9f643286b3b606dc90 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 9 Jul 2025 14:26:35 +0200 Subject: [PATCH 3/5] Unify related tests in wizard groups spec --- .../admin/budgets_wizard/groups_spec.rb | 43 ++++++------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/spec/system/admin/budgets_wizard/groups_spec.rb b/spec/system/admin/budgets_wizard/groups_spec.rb index 3927777db..959069b3a 100644 --- a/spec/system/admin/budgets_wizard/groups_spec.rb +++ b/spec/system/admin/budgets_wizard/groups_spec.rb @@ -4,7 +4,7 @@ describe "Budgets wizard, groups step", :admin do let(:budget) { create(:budget, :drafting) } describe "New" do - scenario "create group" do + scenario "create group with errors and then without errors" do visit admin_budgets_wizard_budget_groups_path(budget) within "#side_menu" do @@ -16,6 +16,17 @@ describe "Budgets wizard, groups step", :admin do click_button "Add new group" + click_button "Create new group" + + expect(page).to have_css ".is-invalid-label", text: "Group name" + expect(page).to have_css ".creation-timeline" + expect(page).to have_content "can't be blank" + expect(page).to have_button "Create new group" + expect(page).to have_button "Cancel" + expect(page).not_to have_content "Group created successfully!" + expect(page).not_to have_button "Add new group" + expect(page).not_to have_content "Continue to headings" + fill_in "Group name", with: "All City" click_button "Create new group" @@ -46,26 +57,10 @@ describe "Budgets wizard, groups step", :admin do expect(page).not_to have_button "Cancel" expect(page).to have_content "Continue to headings" end - - scenario "submit the form with errors" do - visit admin_budgets_wizard_budget_groups_path(budget) - click_button "Add new group" - - click_button "Create new group" - - expect(page).to have_css ".is-invalid-label", text: "Group name" - expect(page).to have_css ".creation-timeline" - expect(page).to have_content "can't be blank" - expect(page).to have_button "Create new group" - expect(page).to have_button "Cancel" - expect(page).not_to have_content "Group created successfully!" - expect(page).not_to have_button "Add new group" - expect(page).not_to have_content "Continue to headings" - end end describe "Edit" do - scenario "update group" do + scenario "update group with errors and then without errors" do create(:budget_group, budget: budget, name: "Group wiht a typo") visit admin_budgets_wizard_budget_groups_path(budget) @@ -73,18 +68,6 @@ describe "Budgets wizard, groups step", :admin do expect(page).to have_css ".creation-timeline" within("tr", text: "Group wiht a typo") { click_link "Edit" } - fill_in "Group name", with: "Group without typos" - click_button "Save group" - - expect(page).to have_content "Group updated successfully" - expect(page).to have_css ".creation-timeline" - expect(page).to have_css "td", exact_text: "Group without typos" - end - - scenario "submit the form with errors and then without errors" do - group = create(:budget_group, budget: budget, name: "Group wiht a typo") - - visit edit_admin_budgets_wizard_budget_group_path(budget, group) fill_in "Group name", with: "" click_button "Save group" From 3dc0de34bc2e3e1aeeb05c79d5788053fd9d48b5 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 9 Jul 2025 14:26:59 +0200 Subject: [PATCH 4/5] Unify related tests in wizard headings spec --- spec/system/admin/budgets_wizard/headings_spec.rb | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/spec/system/admin/budgets_wizard/headings_spec.rb b/spec/system/admin/budgets_wizard/headings_spec.rb index cad0180b3..15d296bed 100644 --- a/spec/system/admin/budgets_wizard/headings_spec.rb +++ b/spec/system/admin/budgets_wizard/headings_spec.rb @@ -89,7 +89,7 @@ describe "Budgets wizard, headings step", :admin do end describe "Edit" do - scenario "update heading" do + scenario "update heading with errors and then without errors" do create(:budget_heading, group: group, name: "Heading wiht a typo") visit admin_budgets_wizard_budget_group_headings_path(budget, group) @@ -97,18 +97,6 @@ describe "Budgets wizard, headings step", :admin do expect(page).to have_css ".creation-timeline" within("tr", text: "Heading wiht a typo") { click_link "Edit" } - fill_in "Heading name", with: "Heading without typos" - click_button "Save heading" - - expect(page).to have_content "Heading updated successfully" - expect(page).to have_css ".creation-timeline" - expect(page).to have_css "td", exact_text: "Heading without typos" - end - - scenario "submit the form with errors and then without errors" do - heading = create(:budget_heading, group: group, name: "Heading wiht a typo") - - visit edit_admin_budgets_wizard_budget_group_heading_path(budget, group, heading) fill_in "Heading name", with: "" click_button "Save heading" From 873968ee0aebdfd018654c82a8de7e80eaf35953 Mon Sep 17 00:00:00 2001 From: taitus Date: Wed, 9 Jul 2025 14:27:27 +0200 Subject: [PATCH 5/5] Unify related tests in wizard phases spec --- .../admin/budgets_wizard/phases_spec.rb | 22 +++++-------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/spec/system/admin/budgets_wizard/phases_spec.rb b/spec/system/admin/budgets_wizard/phases_spec.rb index 57c9e5eea..f8c408467 100644 --- a/spec/system/admin/budgets_wizard/phases_spec.rb +++ b/spec/system/admin/budgets_wizard/phases_spec.rb @@ -64,21 +64,7 @@ describe "Budgets wizard, phases step", :admin do end describe "Edit" do - scenario "update phase" do - visit admin_budgets_wizard_budget_budget_phases_path(budget) - - expect(page).to have_css ".creation-timeline" - - within("tr", text: "Selecting projects") { click_link "Edit" } - fill_in "Name", with: "Choosing projects" - click_button "Save changes" - - expect(page).to have_content "Changes saved" - expect(page).to have_css ".creation-timeline" - within_table("Phases") { expect(page).to have_content "Choosing projects" } - end - - scenario "submit the form with errors and then without errors" do + scenario "update phase with errors and then without errors" do phase = budget.phases.accepting visit edit_admin_budgets_wizard_budget_budget_phase_path(budget, phase) @@ -88,17 +74,19 @@ describe "Budgets wizard, phases step", :admin do expect(page).to have_css "#error_explanation" expect(page).to have_css ".creation-timeline" - fill_in "Name", with: "Welcoming projects" + fill_in "Name", with: "Choosing projects" click_button "Save changes" expect(page).to have_content "Changes saved" expect(page).to have_css ".creation-timeline" - within_table("Phases") { expect(page).to have_content "Welcoming projects" } + within_table("Phases") { expect(page).to have_content "Choosing projects" } end scenario "update phase in single heading budget" do visit admin_budgets_wizard_budget_budget_phases_path(budget, mode: "single") + expect(page).to have_css ".creation-timeline" + within("tr", text: "Selecting projects") { click_link "Edit" } fill_in "Name", with: "Choosing projects" click_button "Save changes"