Skip to content

Commit

Permalink
Fix system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laurajaime committed Oct 15, 2024
1 parent df25b3d commit 60ccabd
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 46 deletions.
4 changes: 2 additions & 2 deletions spec/system/admin_explores_processes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 8 additions & 26 deletions spec/system/department_admin_manages_newsletters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 60ccabd

Please sign in to comment.