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:
Javi Martín
2021-04-01 17:55:31 +02:00
parent 424fe7f5d2
commit 92ddcb7aef
153 changed files with 859 additions and 862 deletions

View File

@@ -62,7 +62,7 @@ describe "Legislation Draft Versions" do
expect(page).to have_content("Current version")
end
it "switches to another version with js", :js do
it "switches to another version with js" do
visit legislation_process_draft_version_path(process, original)
expect(page).to have_content("Original version")
@@ -72,7 +72,7 @@ describe "Legislation Draft Versions" do
expect(page).to have_content("Current version")
end
scenario "show more info button", :js do
scenario "show more info button" do
process.update!(additional_info: "Text for additional info of the process")
visit legislation_process_draft_version_path(process, original)
@@ -83,7 +83,7 @@ describe "Legislation Draft Versions" do
expect(page).to have_content "Text for additional info of the process"
end
scenario "show help gif", :js do
scenario "show help gif" do
visit legislation_process_draft_version_path(process, original)
click_button text: "How can I comment this document?"
@@ -162,7 +162,7 @@ describe "Legislation Draft Versions" do
expect(page).to have_content("Changes for second version")
end
it "switches to another version with js", :js do
it "switches to another version with js" do
visit legislation_process_draft_version_changes_path(process, original)
expect(page).to have_content("Changes for first version")
@@ -173,7 +173,7 @@ describe "Legislation Draft Versions" do
end
end
context "Annotations", :js do
context "Annotations" do
let(:user) { create(:user) }
let(:draft_version) { create(:legislation_draft_version, :published) }
@@ -299,7 +299,7 @@ describe "Legislation Draft Versions" do
end
end
context "Merged annotations", :js do
context "Merged annotations" do
let(:user) { create(:user) }
let(:draft_version) { create(:legislation_draft_version, :published) }
@@ -364,7 +364,7 @@ describe "Legislation Draft Versions" do
expect(page).to have_content("quote for version 2")
end
scenario "with js", :js do
scenario "with js" do
visit legislation_process_draft_version_annotations_path(process, original)
expect(page).to have_content("quote for version 1")

View File

@@ -41,7 +41,7 @@ describe "Legislation" do
end
end
scenario "Processes are sorted by descending start date", :js do
scenario "Processes are sorted by descending start date" do
create(:legislation_process, title: "Process 1", start_date: 3.days.ago)
create(:legislation_process, title: "Process 2", start_date: 2.days.ago)
create(:legislation_process, title: "Process 3", start_date: Date.yesterday)
@@ -128,7 +128,7 @@ describe "Legislation" do
end
end
scenario "Show SDG tags when feature is enabled", :js do
scenario "Show SDG tags when feature is enabled" do
Setting["feature.sdg"] = true
Setting["sdg.process.legislation"] = true
@@ -162,7 +162,7 @@ describe "Legislation" do
end
end
scenario "show draft publication and final result publication dates", :js do
scenario "show draft publication and final result publication dates" do
process = create(:legislation_process, draft_publication_date: Date.new(2019, 01, 10),
result_publication_date: Date.new(2019, 01, 20))
@@ -187,7 +187,7 @@ describe "Legislation" do
end
end
scenario "show additional info button", :js do
scenario "show additional info button" do
process = create(:legislation_process, additional_info: "Text for additional info of the process")
visit legislation_process_path(process)
@@ -227,7 +227,7 @@ describe "Legislation" do
expect(page).to have_current_path new_legislation_process_proposal_path(process)
end
scenario "Show SDG tags when feature is enabled", :js do
scenario "Show SDG tags when feature is enabled" do
Setting["feature.sdg"] = true
Setting["sdg.process.legislation"] = true

View File

@@ -36,7 +36,7 @@ describe "Legislation Proposals" do
let(:user2) { create(:user) }
let(:per_page) { 12 }
scenario "Each user has a different and consistent random proposals order", :js do
scenario "Each user has a different and consistent random proposals order" do
first_user_proposals_order = nil
second_user_proposals_order = nil
@@ -66,7 +66,7 @@ describe "Legislation Proposals" do
end
end
scenario "Random order maintained with pagination", :js do
scenario "Random order maintained with pagination" do
login_as user
visit legislation_process_proposals_path(process)
first_page_proposals_order = legislation_proposals_order
@@ -82,7 +82,7 @@ describe "Legislation Proposals" do
expect(legislation_proposals_order).to eq(first_page_proposals_order)
end
scenario "Does not crash when the seed is not a number", :js do
scenario "Does not crash when the seed is not a number" do
login_as user
visit legislation_process_proposals_path(process, random_seed: "Spoof")
@@ -137,7 +137,7 @@ describe "Legislation Proposals" do
all("[id^='legislation_proposal_']").map { |e| e[:id] }
end
scenario "Create a legislation proposal with an image", :js do
scenario "Create a legislation proposal with an image" do
create(:legislation_proposal, process: process)
login_as user
@@ -200,7 +200,7 @@ describe "Legislation Proposals" do
expect(page).to have_content("-6 votes")
end
scenario "Show link to process on show", :js do
scenario "Show link to process on show" do
create(:legislation_proposal, legislation_process_id: process.id)
visit legislation_process_proposal_path(proposal.process, proposal)
@@ -211,7 +211,7 @@ describe "Legislation Proposals" do
end
end
scenario "Shows proposal tags as proposals filter", :js do
scenario "Shows proposal tags as proposals filter" do
create(:legislation_proposal, process: process, tag_list: "Culture", title: "Open concert")
create(:legislation_proposal, process: process, tag_list: "Sports", title: "Baseball field")
@@ -226,7 +226,7 @@ describe "Legislation Proposals" do
expect(page).to have_content "Open concert"
end
scenario "Show proposal tags on show when SDG is enabled", :js do
scenario "Show proposal tags on show when SDG is enabled" do
Setting["feature.sdg"] = true
Setting["sdg.process.legislation"] = true

View File

@@ -14,7 +14,7 @@ describe "Legislation" do
create(:legislation_question, process: process, title: "Question 3")
end
scenario "shows question list", :js do
scenario "shows question list" do
visit legislation_process_path(process)
expect(page).to have_content("Participate in the debate")
@@ -46,7 +46,7 @@ describe "Legislation" do
expect(page).to have_content("Open answers (0)")
end
scenario "shows next question link in question page", :js do
scenario "shows next question link in question page" do
visit legislation_process_question_path(process, process.questions.first)
expect(page).to have_content("Question 1")