Files
grecia/spec/system/sdg_management/targets_spec.rb
Javi Martín 92ddcb7aef Use JavaScript in system tests by default
JavaScript is used by about 98% of web users, so by testing without it
enabled, we're only testing that the application works for a very
reduced number of users.

We proceeded this way in the past because CONSUL started using Rails 4.2
and truncating the database between JavaScript tests with database
cleaner, which made these tests terribly slow.

When we upgraded to Rails 5.1 and introduced system tests, we started
using database transactions in JavaScript tests, making these tests much
faster. So now we can use JavaScript tests everywhere without critically
slowing down our test suite.
2021-04-07 14:41:06 +02:00

36 lines
1.1 KiB
Ruby

require "rails_helper"
describe "Targets" do
before do
login_as(create(:administrator).user)
Setting["feature.sdg"] = true
end
describe "Index" do
scenario "Visit the index" do
visit sdg_management_goals_path
click_link "Targets"
expect(page).to have_title "SDG content - Targets"
within("table") { expect(page).to have_content "By 2030, eradicate extreme poverty" }
end
scenario "Show targets grouped by goal and sorted asc by code" do
goal_8 = SDG::Goal[8]
goal_8_target_2 = SDG::Target["8.2"]
goal_8_target_10 = SDG::Target["8.10"]
goal_16 = SDG::Goal[16]
goal_16_target_10 = SDG::Target["16.10"]
goal_16_target_A = SDG::Target["16.A"]
visit sdg_management_targets_path
expect(goal_8.title).to appear_before(goal_8_target_2.title)
expect(goal_8_target_2.title).to appear_before(goal_8_target_10.title)
expect(goal_8_target_10.title).to appear_before(goal_16.title)
expect(goal_16.title).to appear_before(goal_16_target_10.title)
expect(goal_16_target_10.title).to appear_before(goal_16_target_A.title)
end
end
end