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.
46 lines
1.2 KiB
Ruby
46 lines
1.2 KiB
Ruby
shared_examples "progressable" do |factory_name|
|
|
describe "Progress bars" do
|
|
let!(:progressable) { create(factory_name) }
|
|
let(:path) { polymorphic_path(progressable) }
|
|
|
|
scenario "With main progress bar" do
|
|
create(:progress_bar, progressable: progressable)
|
|
|
|
visit path
|
|
|
|
find("#tab-milestones-label").click
|
|
|
|
within("#tab-milestones") do
|
|
expect(page).to have_content "Progress"
|
|
end
|
|
end
|
|
|
|
scenario "With main and secondary progress bar" do
|
|
create(:progress_bar, progressable: progressable)
|
|
create(:progress_bar, :secondary, progressable: progressable, title: "Build laboratory")
|
|
|
|
visit path
|
|
|
|
find("#tab-milestones-label").click
|
|
|
|
within("#tab-milestones") do
|
|
expect(page).to have_content "Progress"
|
|
expect(page).to have_content "Build laboratory"
|
|
end
|
|
end
|
|
|
|
scenario "No main progress bar" do
|
|
create(:progress_bar, :secondary, progressable: progressable, title: "Defeat Evil Lords")
|
|
|
|
visit path
|
|
|
|
find("#tab-milestones-label").click
|
|
|
|
within("#tab-milestones") do
|
|
expect(page).not_to have_content "Progress"
|
|
expect(page).not_to have_content "Defeat Evil Lords"
|
|
end
|
|
end
|
|
end
|
|
end
|