From 95db5e8959defa514d5dab975ea17da0d3484837 Mon Sep 17 00:00:00 2001 From: Matt Moretti Date: Wed, 28 Aug 2024 15:26:51 -0400 Subject: [PATCH] Don't make expectations on the downloads folder All of these system tests are a nightmare. But, at some point these ones made the transition from frequently failing to always failing. I believe it has something to de with a change Chrome made to its headless mode. And of course, these aren't even "downloads" in real life. They're `Content-Disposition: inline`. So it's only the tests that ever saw them as "downloads". --- spec/spec_helper.rb | 9 +------- spec/support/downloads.rb | 23 ------------------- spec/system/drivers/editing_incidents_spec.rb | 2 -- 3 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 spec/support/downloads.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4f67d9dc..d2445f0e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,15 +51,8 @@ config.before :each, type: :system do driven_by :rack_test end - config.before :each, type: :system, js: true do - driven_by :selenium, using: :headless_chrome do |driver_options| - driver_options.add_preference :download, default_directory: Downloads::PATH - end - end - - config.before :suite do - Downloads.clear_downloads + driven_by :selenium, using: :headless_chrome end end diff --git a/spec/support/downloads.rb b/spec/support/downloads.rb deleted file mode 100644 index b2bde870..00000000 --- a/spec/support/downloads.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -module Downloads - module_function - - PATH = Rails.root.join('spec', 'downloads') - - def downloads - PATH.glob('*') - end - - def clear_downloads - FileUtils.rm_f(downloads) - end - - def wait_for(filename) - Timeout.timeout Capybara.default_max_wait_time do - loop do - break if PATH.join(filename).exist? - end - end - end -end diff --git a/spec/system/drivers/editing_incidents_spec.rb b/spec/system/drivers/editing_incidents_spec.rb index 48384e38..2552cd0b 100644 --- a/spec/system/drivers/editing_incidents_spec.rb +++ b/spec/system/drivers/editing_incidents_spec.rb @@ -46,7 +46,6 @@ end save_and_preview - Downloads.wait_for("#{incident.id}.pdf") visit incident_path(incident) expect(page).to have_selector 'h2', text: 'Driver Incident Report' @@ -70,7 +69,6 @@ click_button 'Delete injured passenger info' save_and_preview - Downloads.wait_for("#{incident.id}.pdf") visit incident_path(incident) expect(page).to have_selector 'h2', text: 'Driver Incident Report'