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.
27 lines
878 B
Ruby
27 lines
878 B
Ruby
require "rails_helper"
|
|
|
|
describe "Moderate legislation proposals" do
|
|
scenario "Hide" do
|
|
citizen = create(:user)
|
|
legislation_process = create(:legislation_process)
|
|
legislation_proposal = create(:legislation_proposal, legislation_process_id: legislation_process.id)
|
|
moderator = create(:moderator)
|
|
|
|
login_as(moderator.user)
|
|
visit legislation_process_proposal_path(legislation_process, legislation_proposal)
|
|
|
|
within("#legislation_proposal_#{legislation_proposal.id}") do
|
|
accept_confirm { click_link "Hide" }
|
|
end
|
|
|
|
expect(page).to have_css("#legislation_proposal_#{legislation_proposal.id}.faded")
|
|
|
|
logout
|
|
login_as(citizen)
|
|
visit legislation_process_proposals_path(legislation_process)
|
|
|
|
expect(page).to have_css(".proposal-content", count: 0)
|
|
expect(page).not_to have_link("Hide")
|
|
end
|
|
end
|