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.
This commit is contained in:
@@ -18,7 +18,7 @@ describe "Admin legislation draft versions", :admin do
|
||||
end
|
||||
|
||||
context "Create" do
|
||||
scenario "Valid legislation draft version", :js do
|
||||
scenario "Valid legislation draft version" do
|
||||
create(:legislation_process, title: "An example legislation process")
|
||||
|
||||
visit admin_root_path
|
||||
@@ -47,7 +47,7 @@ describe "Admin legislation draft versions", :admin do
|
||||
end
|
||||
|
||||
context "Update" do
|
||||
scenario "Valid legislation draft version", :js do
|
||||
scenario "Valid legislation draft version" do
|
||||
process = create(:legislation_process, title: "An example legislation process")
|
||||
create(:legislation_draft_version, title: "Version 1", process: process)
|
||||
|
||||
@@ -75,7 +75,7 @@ describe "Admin legislation draft versions", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
context "Changing content with the markdown editor", :js do
|
||||
context "Changing content with the markdown editor" do
|
||||
let(:prompt) { "You've edited the text without saving it. Do you confirm to leave the page?" }
|
||||
let(:version) { create(:legislation_draft_version, body: "Version 1") }
|
||||
let(:path) do
|
||||
|
||||
@@ -163,7 +163,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
expect(page).not_to have_content "Describing the process"
|
||||
end
|
||||
|
||||
scenario "Create a legislation process with an image", :js do
|
||||
scenario "Create a legislation process with an image" do
|
||||
visit new_admin_legislation_process_path
|
||||
fill_in "Process Title", with: "An example legislation process"
|
||||
fill_in "Summary", with: "Summary of the process"
|
||||
@@ -251,7 +251,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
expect(page).not_to have_content "Draft publication"
|
||||
end
|
||||
|
||||
scenario "Enabling/disabling a phase enables/disables its date fields", :js do
|
||||
scenario "Enabling/disabling a phase enables/disables its date fields" do
|
||||
process.update!(published: false)
|
||||
|
||||
visit edit_admin_legislation_process_path(process)
|
||||
@@ -273,7 +273,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
expect(page).to have_field "end_date", disabled: false, with: "2008-08-08"
|
||||
end
|
||||
|
||||
scenario "Enabling/disabling a phase does not enable/disable another phase date fields", :js do
|
||||
scenario "Enabling/disabling a phase does not enable/disable another phase date fields" do
|
||||
process.update!(draft_phase_enabled: false, draft_publication_enabled: false)
|
||||
|
||||
visit edit_admin_legislation_process_path(process)
|
||||
@@ -309,7 +309,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
expect(page).to have_field("Categories", with: "bicycles, pollution, recycling")
|
||||
end
|
||||
|
||||
scenario "Edit milestones summary", :js do
|
||||
scenario "Edit milestones summary" do
|
||||
visit admin_legislation_process_milestones_path(process)
|
||||
|
||||
expect(page).not_to have_link "Remove language"
|
||||
@@ -353,7 +353,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
Setting["sdg.process.legislation"] = true
|
||||
end
|
||||
|
||||
scenario "create Collaborative Legislation with sdg related list", :js do
|
||||
scenario "create Collaborative Legislation with sdg related list" do
|
||||
visit new_admin_legislation_process_path
|
||||
fill_in "Process Title", with: "Legislation process with SDG related content"
|
||||
within_fieldset "Process" do
|
||||
@@ -370,7 +370,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "edit Collaborative Legislation with sdg related list", :js do
|
||||
scenario "edit Collaborative Legislation with sdg related list" do
|
||||
process = create(:legislation_process, title: "Legislation process with SDG related content")
|
||||
process.sdg_goals = [SDG::Goal[1], SDG::Goal[17]]
|
||||
visit edit_admin_legislation_process_path(process)
|
||||
|
||||
@@ -15,7 +15,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Selecting legislation proposals", :js do
|
||||
scenario "Selecting legislation proposals" do
|
||||
proposal = create(:legislation_proposal, cached_votes_score: 10)
|
||||
|
||||
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
|
||||
@@ -26,7 +26,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Sorting legislation proposals by title", js: true do
|
||||
scenario "Sorting legislation proposals by title" do
|
||||
process = create(:legislation_process)
|
||||
create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
|
||||
create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
|
||||
@@ -42,7 +42,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Sorting legislation proposals by supports", js: true do
|
||||
scenario "Sorting legislation proposals by supports" do
|
||||
process = create(:legislation_process)
|
||||
create(:legislation_proposal, cached_votes_score: 10, legislation_process_id: process.id)
|
||||
create(:legislation_proposal, cached_votes_score: 30, legislation_process_id: process.id)
|
||||
@@ -58,7 +58,7 @@ describe "Admin collaborative legislation", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Sorting legislation proposals by Id", js: true do
|
||||
scenario "Sorting legislation proposals by Id" do
|
||||
process = create(:legislation_process)
|
||||
proposal1 = create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
|
||||
proposal2 = create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
|
||||
|
||||
@@ -41,7 +41,7 @@ describe "Admin legislation questions", :admin do
|
||||
end
|
||||
|
||||
context "Update" do
|
||||
scenario "Valid legislation question", :js do
|
||||
scenario "Valid legislation question" do
|
||||
create(:legislation_question, title: "Question 2", process: process)
|
||||
|
||||
visit admin_root_path
|
||||
@@ -66,7 +66,7 @@ describe "Admin legislation questions", :admin do
|
||||
end
|
||||
|
||||
context "Delete" do
|
||||
scenario "Legislation question", :js do
|
||||
scenario "Legislation question" do
|
||||
create(:legislation_question, title: "Question 1", process: process)
|
||||
question = create(:legislation_question, title: "Question 2", process: process)
|
||||
question_option = create(:legislation_question_option, question: question, value: "Yes")
|
||||
@@ -100,7 +100,7 @@ describe "Admin legislation questions", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Edit an existing option", :js do
|
||||
scenario "Edit an existing option" do
|
||||
create(:legislation_question_option, question: question, value: "Original")
|
||||
|
||||
visit edit_question_url
|
||||
@@ -113,7 +113,7 @@ describe "Admin legislation questions", :admin do
|
||||
expect(page).to have_field(field_en[:id], with: "Changed")
|
||||
end
|
||||
|
||||
scenario "Remove an option", :js do
|
||||
scenario "Remove an option" do
|
||||
create(:legislation_question_option, question: question, value: "Yes")
|
||||
create(:legislation_question_option, question: question, value: "No")
|
||||
|
||||
@@ -139,7 +139,7 @@ describe "Admin legislation questions", :admin do
|
||||
question.update!(title_en: "Title in English", title_es: "Título en Español")
|
||||
end
|
||||
|
||||
scenario "Add translation for question option", :js do
|
||||
scenario "Add translation for question option" do
|
||||
visit edit_question_url
|
||||
|
||||
click_on "Add option"
|
||||
@@ -160,7 +160,7 @@ describe "Admin legislation questions", :admin do
|
||||
expect(page).to have_field(field_es[:id], with: "Opción 1")
|
||||
end
|
||||
|
||||
scenario "Add new question option after changing active locale", :js do
|
||||
scenario "Add new question option after changing active locale" do
|
||||
visit edit_question_url
|
||||
|
||||
select "Español", from: :select_language
|
||||
|
||||
Reference in New Issue
Block a user