A platform for community discussion. Free, open, simple.
DEV: Silence expected error/debug output in system specs (#39164)
Jarek Radosze559da5bf705
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex d9900f553bf..edf2f5db65f 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -52,7 +52,7 @@ jobs:PGPASSWORD: discourseUSES_PARALLEL_DATABASES: ${{ matrix.build_type == 'backend' || matrix.build_type == 'system' }}CAPYBARA_DEFAULT_MAX_WAIT_TIME: 20- MINIO_RUNNER_LOG_LEVEL: DEBUG+ MINIO_RUNNER_LOG_LEVEL: WARNDISCOURSE_TURBO_RSPEC_RETRY_AND_LOG_FLAKY_TESTS: ${{ (matrix.build_type == 'system' || matrix.build_type == 'backend') && '1' }}CHEAP_SOURCE_MAPS: "1"MINIO_RUNNER_INSTALL_DIR: /home/discourse/.minio_runnerdiff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rbindex a4ca7f4f733..0c1a9f54dd6 100644--- a/app/controllers/uploads_controller.rb+++ b/app/controllers/uploads_controller.rb@@ -386,7 +386,7 @@ class UploadsController < ApplicationControllerresponse.headers["Content-Security-Policy"] = "sandbox;"file_path = Discourse.store.path_for(upload)- return render_404 unless file_path+ return render_404 unless file_path && File.exist?(file_path)send_file(file_path, opts)enddiff --git a/config/environments/test.rb b/config/environments/test.rbindex fa04be355d7..d0f8d59d7ef 100644--- a/config/environments/test.rb+++ b/config/environments/test.rb@@ -77,6 +77,10 @@ Discourse::Application.configure doconfig.logger = Logger.new(STDOUT)config.log_level =ENV["RAILS_TEST_LOG_LEVEL"].present? ? ENV["RAILS_TEST_LOG_LEVEL"].to_sym : :info++ # Don't log rescued exceptions (RoutingError, RecordNotFound, etc.)+ # These are expected in system specs that intentionally visit nonexistent routes+ config.action_dispatch.log_rescued_responses = falseelseconfig.logger = Logger.new(nil)config.log_level = :fataldiff --git a/lib/hijack.rb b/lib/hijack.rbindex d21e6f04465..76ed6a61425 100644--- a/lib/hijack.rb+++ b/lib/hijack.rb@@ -106,7 +106,7 @@ module Hijackio.write "\r\n"io.write body- rescue Errno::EPIPE, IOError+ rescue Errno::EPIPE, Errno::ECONNRESET, IOError# happens if client terminated before we responded, ignoreio = nilensurediff --git a/plugins/chat/spec/system/chat_composer_draft_spec.rb b/plugins/chat/spec/system/chat_composer_draft_spec.rbindex 36b033f7c17..8d7df18df8b 100644--- a/plugins/chat/spec/system/chat_composer_draft_spec.rb+++ b/plugins/chat/spec/system/chat_composer_draft_spec.rb@@ -86,16 +86,7 @@ RSpec.describe "Chat composer draft" doendcontext "with uploads" do- fab!(:upload_1) do- Fabricate(- :upload,- url: "/images/logo-dark.png",- original_filename: "logo_dark.png",- width: 400,- height: 300,- extension: "png",- )- end+ fab!(:upload_1, :image_upload)before docreate_draft(channel_1, user: current_user, data: { message: "draft", uploads: [upload_1] })@@ -215,16 +206,7 @@ RSpec.describe "Chat composer draft" doendcontext "with uploads" do- fab!(:upload_1) do- Fabricate(- :upload,- url: "/images/logo-dark.png",- original_filename: "logo_dark.png",- width: 400,- height: 300,- extension: "png",- )- end+ fab!(:upload_1, :image_upload)before docreate_draft(diff --git a/plugins/chat/spec/system/deleted_channel_spec.rb b/plugins/chat/spec/system/deleted_channel_spec.rbindex 0431f925e68..f8ea6634f12 100644--- a/plugins/chat/spec/system/deleted_channel_spec.rb+++ b/plugins/chat/spec/system/deleted_channel_spec.rb@@ -13,7 +13,7 @@ RSpec.describe "Deleted channel" docontext "when visiting deleted channel" doit "redirects to homepage" do- chat_page.visit_channel(channel_1)+ chat_page.visit_channel(channel_1, check: false)expect(page).to have_content("Not Found") # this is not a translated keyenddiff --git a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rbindex 02e8b78c1b6..fc60b925780 100644--- a/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb+++ b/plugins/chat/spec/system/sidebar_navigation_menu_spec.rb@@ -191,6 +191,9 @@ RSpec.describe "Sidebar navigation menu" dobefore doother_user.username = "<script>alert('hello')</script>"+ # Use an uploaded avatar to avoid a letter_avatar request with the+ # malicious username (which contains `/` and breaks URL routing)+ other_user.uploaded_avatar_id = Fabricate(:image_upload).idother_user.save!(validate: false)enddiff --git a/spec/system/impersonation_spec.rb b/spec/system/impersonation_spec.rbindex c0f98be5485..5ff95f36871 100644--- a/spec/system/impersonation_spec.rb+++ b/spec/system/impersonation_spec.rb@@ -58,9 +58,12 @@ describe "Impersonation" dovisit("/admin/users/#{user.id}/#{user.username}")- page.find(".btn-impersonate").click+ # Suppress the expected error from the intentionally raised StandardError+ silence_stdout do+ page.find(".btn-impersonate").click- expect(dialog).to be_open- expect(dialog).to have_content(I18n.t("admin_js.admin.impersonate.error"))+ expect(dialog).to be_open+ expect(dialog).to have_content(I18n.t("admin_js.admin.impersonate.error"))+ endendenddiff --git a/spec/system/locale_spec.rb b/spec/system/locale_spec.rbindex be2c68a7263..23bb3cd5145 100644--- a/spec/system/locale_spec.rb+++ b/spec/system/locale_spec.rb@@ -197,7 +197,10 @@ RSpec.describe "Locale choice" doit "does not throw error for malformed messages" doSiteSetting.default_locale = "zh_TW"- visit "/"++ # Suppress the expected error from the intentionally malformed zh_TW MF string+ silence_stdout { visit "/" }+expect(page).to have_css("#site-logo")expect(page.evaluate_script("Object.keys(I18n._mfMessages._data)").length).to eq(0)diff --git a/spec/system/network_disconnected_spec.rb b/spec/system/network_disconnected_spec.rbindex 841e5ef4e13..e6d9e200edb 100644--- a/spec/system/network_disconnected_spec.rb+++ b/spec/system/network_disconnected_spec.rb@@ -4,10 +4,9 @@ RSpec.describe "Network Disconnected" dolet(:cdp) { PageObjects::CDP.new }it "NetworkConnectivity service adds class to DOM and displays offline indicator" do- skip_on_ci!(<<~TEXT)- In CI this test will randomly flake - timing issue with the offline indicator- not being rendered soon enough after network conditions change- TEXT+ skip_on_ci!(+ "In CI this test will randomly flake - timing issue with the offline indicator not being rendered soon enough after network conditions change",+ )SiteSetting.enable_offline_indicator = truediff --git a/spec/system/welcome_banner_spec.rb b/spec/system/welcome_banner_spec.rbindex 4699dc0cddb..b3911bcfb71 100644--- a/spec/system/welcome_banner_spec.rb+++ b/spec/system/welcome_banner_spec.rb@@ -273,7 +273,7 @@ describe "Welcome banner" dovisit "/filter?q=tag%3Ain-progress"expect(banner).to be_visible- visit "/upcoming-events?view=month"+ visit "/about"expect(banner).to be_hiddenend@@ -288,7 +288,7 @@ describe "Welcome banner" doexpect(banner).to be_visibleend- visit "/my/posts"+ visit "/about"expect(banner).to be_hiddenend