Currently it is not necessary to include the link_url field. When we display these cards without link_url, they create an empty link that redirects to the same page. I understand that this is not a desired behavior, so I think it is better to add a validation in this case and force administrators to add a link_url when creating a card.
92 lines
2.6 KiB
Ruby
92 lines
2.6 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "SDG homepage configuration" do
|
|
before do
|
|
Setting["feature.sdg"] = true
|
|
login_as(create(:sdg_manager).user)
|
|
end
|
|
|
|
describe "Show" do
|
|
scenario "Visit the index" do
|
|
visit sdg_management_root_path
|
|
|
|
within("#side_menu") do
|
|
click_link "SDG homepage"
|
|
end
|
|
|
|
expect(page).to have_title "SDG content - Homepage configuration"
|
|
end
|
|
|
|
scenario "Create card" do
|
|
visit sdg_management_homepage_path
|
|
click_link "Create planning card"
|
|
|
|
within(".translatable-fields") { fill_in "Title", with: "My planning card" }
|
|
fill_in "Link URL", with: "/any_path"
|
|
click_button "Create card"
|
|
|
|
within(".planning-cards") do
|
|
expect(page).to have_content "My planning card"
|
|
end
|
|
|
|
within(".sensitization-cards") do
|
|
expect(page).to have_content "There are no cards for this phase"
|
|
end
|
|
end
|
|
|
|
scenario "Update card" do
|
|
create(:widget_card, cardable: SDG::Phase["monitoring"], title: "My monitoring card")
|
|
|
|
visit sdg_management_homepage_path
|
|
within(".monitoring-cards") { click_link "Edit" }
|
|
|
|
within(".translatable-fields") { fill_in "Title", with: "Updated monitoring card" }
|
|
click_button "Save card"
|
|
|
|
within(".monitoring-cards") do
|
|
expect(page).to have_css "tbody tr", count: 1
|
|
expect(page).to have_content "Updated monitoring card"
|
|
expect(page).not_to have_content "My monitoring card"
|
|
end
|
|
end
|
|
|
|
scenario "Create header card" do
|
|
visit sdg_management_homepage_path
|
|
click_link "Create header"
|
|
|
|
within(".translatable-fields") { fill_in "Title", with: "My header" }
|
|
fill_in "Link URL", with: "/any_path"
|
|
click_button "Create card"
|
|
|
|
within(".sdg-header") do
|
|
expect(page).to have_content "My header"
|
|
expect(page).not_to have_content "Create header"
|
|
end
|
|
end
|
|
|
|
scenario "Update header card" do
|
|
create(:widget_card, cardable: WebSection.find_by!(name: "sdg"))
|
|
visit sdg_management_homepage_path
|
|
within ".sdg-header" do
|
|
click_link "Edit"
|
|
end
|
|
|
|
within(".translatable-fields") { fill_in "Title", with: "My header update" }
|
|
click_button "Save card"
|
|
|
|
expect(page).to have_content "My header update"
|
|
end
|
|
|
|
scenario "Remove header card" do
|
|
create(:widget_card, title: "SDG Header", cardable: WebSection.find_by!(name: "sdg"))
|
|
visit sdg_management_homepage_path
|
|
|
|
within ".sdg-header" do
|
|
accept_confirm { click_link "Delete" }
|
|
end
|
|
|
|
expect(page).not_to have_content "SDG Header"
|
|
end
|
|
end
|
|
end
|