From 60ccabd640ee6c4bfee16715897032f95f82127e Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Tue, 15 Oct 2024 10:14:24 +0200 Subject: [PATCH] Fix system tests --- spec/system/admin_explores_processes_spec.rb | 4 +-- ...partment_admin_manages_newsletters_spec.rb | 34 +++++-------------- ..._be_able_to_access_admin_dashboard_spec.rb | 10 +++--- ...hould_be_able_to_manage_assemblies_spec.rb | 6 ++-- ...ould_be_able_to_manage_conferences_spec.rb | 2 +- ...should_be_able_to_manage_processes_spec.rb | 13 ++++--- ..._see_only_assemblies_from_her_area_spec.rb | 7 ++-- ...o_see_only_processes_from_her_area_spec.rb | 7 ++-- 8 files changed, 37 insertions(+), 46 deletions(-) diff --git a/spec/system/admin_explores_processes_spec.rb b/spec/system/admin_explores_processes_spec.rb index 9a63ad4..26b0e84 100644 --- a/spec/system/admin_explores_processes_spec.rb +++ b/spec/system/admin_explores_processes_spec.rb @@ -40,13 +40,13 @@ end def check_column_header_exists(position: 1, content: "") - within "#processes .table-scroll table thead th:nth-child(#{position})" do + within ".table-scroll table thead th:nth-child(#{position})" do expect(page).to have_content(content) end end def check_column_data_exists(position: 1, content: "") - within "#processes .table-scroll table tbody td:nth-child(#{position})" do + within ".table-scroll table tbody td:nth-child(#{position})" do expect(page).to have_content(content) end end diff --git a/spec/system/department_admin_manages_newsletters_spec.rb b/spec/system/department_admin_manages_newsletters_spec.rb index 3ca7373..1393ae5 100644 --- a/spec/system/department_admin_manages_newsletters_spec.rb +++ b/spec/system/department_admin_manages_newsletters_spec.rb @@ -5,7 +5,7 @@ describe "Admin manages newsletters" do let(:organization) { create(:organization) } let(:area) { create(:area, organization:) } - let(:department_admin) { create(:department_admin, :confirmed, name: "Sarah Kerrigan", organization:, area:) } + let!(:department_admin) { create(:department_admin, :confirmed, name: "Sarah Kerrigan", organization:, area:) } let!(:deliverable_users) { create_list(:user, 5, :confirmed, newsletter_notifications_at: Time.current, organization:) } before do @@ -21,27 +21,9 @@ def fill_newsletter_form fill_in_i18n( :newsletter_subject, "#newsletter-subject-tabs", - **attributes[:subject].except("machine_translations") - ) - - fill_in_i18n_editor( - :newsletter_settings_introduction, - "#newsletter-settings--introduction-tabs", - en: "Hello %{name}! Relevant content.", - es: "Hola, %{name}! Contenido relevante.", - ca: "Hola, %{name}! Contingut rellevant." - ) - - fill_in_i18n( - :newsletter_settings_cta_text, - "#newsletter-settings--cta_text-tabs", - en: "Hello %{name}! Relevant content." - ) - - fill_in_i18n( - :newsletter_settings_cta_url, - "#newsletter-settings--cta_url-tabs", - en: "Hello %{name}! Relevant content." + en: "A fancy newsletter for %{name}", + es: "Un correo electrónico muy chulo para %{name}", + ca: "Un correu electrònic flipant per a %{name}" ) fill_in_i18n_editor( @@ -60,7 +42,7 @@ def fill_newsletter_form find(".button.new").click within "#image_text_cta" do - click_link_or_button "Use this template" + click_on "Use this template" end within ".new_newsletter" do @@ -110,14 +92,14 @@ def fill_newsletter_form it "allows a newsletter to be updated" do visit decidim_admin.newsletters_path within("tr[data-newsletter-id=\"#{newsletter.id}\"]") do - click_link_or_button "Edit" + click_on "Edit" end within ".edit_newsletter" do fill_newsletter_form end - expect(page).to have_content("Preview") + expect(page).to have_content("Save and preview") expect(page).to have_content("A fancy newsletter") end end @@ -245,7 +227,7 @@ def fill_newsletter_form visit decidim_admin.newsletters_path within("tr[data-newsletter-id=\"#{newsletter.id}\"]") do - accept_confirm { click_link_or_button "Delete" } + accept_confirm { click_on "Delete" } end expect(page).to have_content("successfully") diff --git a/spec/system/department_admin_should_be_able_to_access_admin_dashboard_spec.rb b/spec/system/department_admin_should_be_able_to_access_admin_dashboard_spec.rb index 79e6726..b192c4e 100644 --- a/spec/system/department_admin_should_be_able_to_access_admin_dashboard_spec.rb +++ b/spec/system/department_admin_should_be_able_to_access_admin_dashboard_spec.rb @@ -21,35 +21,35 @@ context "when accessing the dashboard some left menu elements should be accessible" do it "is able to access 'Processes'" do expect(page).to have_content("Processes") - click_link_or_button "Processes" + click_on "Processes" expect(page).to have_current_path "/admin/participatory_processes" expect(page).to have_content("New process") end it "is able to access 'Assemblies'" do expect(page).to have_content("Assemblies") - click_link_or_button "Assemblies" + click_on "Assemblies" expect(page).to have_current_path "/admin/assemblies" expect(page).to have_content("New assembly") end it "is able to access 'Participants'" do expect(page).to have_content("Participants") - click_link_or_button "Participants" + click_on "Participants" expect(page).to have_current_path "/admin/users" expect(page).to have_content("New admin") end it "is able to access 'Newsletter'" do expect(page).to have_content("Newsletter") - click_link_or_button "Newsletter" + click_on "Newsletter" expect(page).to have_current_path "/admin/newsletters" expect(page).to have_content("New newsletter") end it "is able to access 'Conferences'" do expect(page).to have_content("Conferences") - click_link_or_button "Conferences" + click_on "Conferences" expect(page).to have_current_path "/admin/conferences" expect(page).to have_content("New conference") end diff --git a/spec/system/department_admin_should_be_able_to_manage_assemblies_spec.rb b/spec/system/department_admin_should_be_able_to_manage_assemblies_spec.rb index e74339f..d2567ec 100644 --- a/spec/system/department_admin_should_be_able_to_manage_assemblies_spec.rb +++ b/spec/system/department_admin_should_be_able_to_manage_assemblies_spec.rb @@ -22,7 +22,7 @@ before do visit decidim_admin_assemblies.assemblies_path - click_link_or_button "New assembly" + click_on "New assembly" end it "creates a new assembly" do @@ -58,7 +58,7 @@ expect(page).to have_admin_callout("successfully") expect(Decidim::Assembly.last.area).to eq(area) - within ".container" do + within ".card#assemblies" do # expect(page).to have_current_path decidim_admin_assemblies.assemblies_path(q: { parent_id_eq: parent_assembly&.id }) expect(page).to have_content(translated(attributes[:title])) end @@ -89,7 +89,7 @@ login_as department_admin, scope: :user visit decidim_admin_assemblies.assemblies_path within "tr", text: translated(parent_assembly.title) do - click_link_or_button "Assemblies" + click_on "Assemblies" end end diff --git a/spec/system/department_admin_should_be_able_to_manage_conferences_spec.rb b/spec/system/department_admin_should_be_able_to_manage_conferences_spec.rb index 8d21eb8..613062e 100644 --- a/spec/system/department_admin_should_be_able_to_manage_conferences_spec.rb +++ b/spec/system/department_admin_should_be_able_to_manage_conferences_spec.rb @@ -21,7 +21,7 @@ before do visit decidim_admin_conferences.assemblies_path - click_link_or_button "New conference" + click_on "New conference" end it "creates a new conference" do diff --git a/spec/system/department_admin_should_be_able_to_manage_processes_spec.rb b/spec/system/department_admin_should_be_able_to_manage_processes_spec.rb index 8c823c4..108469e 100644 --- a/spec/system/department_admin_should_be_able_to_manage_processes_spec.rb +++ b/spec/system/department_admin_should_be_able_to_manage_processes_spec.rb @@ -37,7 +37,7 @@ let(:image2_path) { Decidim::Dev.asset(image2_filename) } before do - click_link_or_button "New process" + click_on "New process" end it "creates a new participatory process with department admin's area" do @@ -88,7 +88,7 @@ expect(page).to have_admin_callout("successfully") expect(Decidim::ParticipatoryProcess.last.area).to eq(area) - within ".container" do + within ".card#steps" do expect(page).to have_current_path decidim_admin_participatory_processes.participatory_process_steps_path(Decidim::ParticipatoryProcess.last) expect(page).to have_content("Phases") expect(page).to have_content("Introduction") @@ -104,9 +104,12 @@ end it "update a participatory process without images does not delete them" do - click_link_or_button translated(participatory_process_3.title) - click_submenu_link "Info" - click_link_or_button "Update" + click_on translated(participatory_process_3.title) + within_admin_sidebar_menu do + click_on "About this process" + end + + click_on "Update" expect(participatory_process_3.reload.area).to eq(area) expect(page).to have_admin_callout("successfully") diff --git a/spec/system/department_admin_should_be_able_to_see_only_assemblies_from_her_area_spec.rb b/spec/system/department_admin_should_be_able_to_see_only_assemblies_from_her_area_spec.rb index ae4fab7..d8a7665 100644 --- a/spec/system/department_admin_should_be_able_to_see_only_assemblies_from_her_area_spec.rb +++ b/spec/system/department_admin_should_be_able_to_see_only_assemblies_from_her_area_spec.rb @@ -18,12 +18,15 @@ def visit_admin_assemblies_list it "sees the import button" do visit_admin_assemblies_list - expect(page).to have_content("Import") + + within_admin_menu do + expect(page).to have_content("Import") + end end it "sees the export button" do visit_admin_assemblies_list - expect(page).to have_css(".icon--data-transfer-download") + expect(page).to have_css(".action-icon--export") end it "sees only processes in the same area" do diff --git a/spec/system/department_admin_should_be_able_to_see_only_processes_from_her_area_spec.rb b/spec/system/department_admin_should_be_able_to_see_only_processes_from_her_area_spec.rb index 312812d..ccdcc9c 100644 --- a/spec/system/department_admin_should_be_able_to_see_only_processes_from_her_area_spec.rb +++ b/spec/system/department_admin_should_be_able_to_see_only_processes_from_her_area_spec.rb @@ -22,12 +22,15 @@ def visit_admin_processes_list it "sees the import button" do visit_admin_processes_list - expect(page).to have_content("Import") + + within_admin_menu do + expect(page).to have_content("Import") + end end it "sees the export button" do visit_admin_processes_list - expect(page).to have_css(".icon--data-transfer-download") + expect(page).to have_css(".action-icon--export") end it "sees only processes in the same area" do