diff --git a/spec/features/accessibility/static_pages_spec.rb b/spec/features/accessibility/static_pages_spec.rb index 1245505e5b4..173f16502ed 100644 --- a/spec/features/accessibility/static_pages_spec.rb +++ b/spec/features/accessibility/static_pages_spec.rb @@ -2,7 +2,7 @@ require 'axe-rspec' feature 'Accessibility on static pages', :js do - scenario 'not found page' do + scenario 'not found page', allow_browser_log: true do visit '/non_existent_page' expect(page).to be_axe_clean.according_to :section508, :"best-practice", :wcag21aa diff --git a/spec/features/accessibility/user_pages_spec.rb b/spec/features/accessibility/user_pages_spec.rb index 89dfe1da276..d96d5120b57 100644 --- a/spec/features/accessibility/user_pages_spec.rb +++ b/spec/features/accessibility/user_pages_spec.rb @@ -110,11 +110,11 @@ expect(page).to be_uniquely_titled end - scenario 'edit email page' do + scenario 'delete email page' do user = create(:user) sign_in_and_2fa_user(user) - visit delete_email_path(id: user.email_addresses.take.id) + visit manage_email_confirm_delete_path(id: user.email_addresses.take.id) expect(page).to be_axe_clean.according_to :section508, :"best-practice", :wcag21aa expect(page).to label_required_fields diff --git a/spec/features/idv/doc_auth/link_sent_step_spec.rb b/spec/features/idv/doc_auth/link_sent_step_spec.rb index 43d79265e2c..49ee8eaed84 100644 --- a/spec/features/idv/doc_auth/link_sent_step_spec.rb +++ b/spec/features/idv/doc_auth/link_sent_step_spec.rb @@ -80,10 +80,6 @@ metadata[:js] = true let(:doc_capture_polling_enabled) { true } - before do - visit current_path - end - it 'automatically advances when the mobile flow is complete' do expect(page).to_not have_css 'meta[http-equiv="refresh"]', visible: false expect(page).to_not have_button(t('forms.buttons.continue')) @@ -100,10 +96,6 @@ shared_examples 'with doc capture polling disabled' do let(:doc_capture_polling_enabled) { false } - before do - visit current_path - end - context 'clicks back link' do before do click_doc_auth_back_link @@ -117,7 +109,7 @@ end it 'refreshes page 4x with meta refresh extending timeout by 40 min and can start over' do - 3.times do + 4.times do expect(page).to have_css 'meta[http-equiv="refresh"]', visible: false visit idv_doc_auth_link_sent_step end diff --git a/spec/features/idv/doc_auth/test_credentials_spec.rb b/spec/features/idv/doc_auth/test_credentials_spec.rb index 0158f409df6..a7c57d8818b 100644 --- a/spec/features/idv/doc_auth/test_credentials_spec.rb +++ b/spec/features/idv/doc_auth/test_credentials_spec.rb @@ -31,7 +31,7 @@ expect(page).to have_content('Jane') end - it 'triggers an error if the test credentials have a friendly error' do + it 'triggers an error if the test credentials have a friendly error', allow_browser_log: true do complete_doc_auth_steps_before_document_capture_step attach_file( diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a7c2bd0ebfe..57158ef004e 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -105,4 +105,18 @@ class Analytics example.run Bullet.enable = false end + + config.after(:each, type: :feature, js: true) do |spec| + next unless page.driver.browser.respond_to?(:manage) + + # Always get the logs, even if logs are allowed for the spec, since otherwise unexpected + # messages bleed over between specs. + javascript_errors = page.driver.browser.manage.logs.get(:browser).map(&:message) + next if spec.metadata[:allow_browser_log] + + # Temporarily allow for document-capture bundle, since it uses React error boundaries to poll. + javascript_errors.reject! { |e| e.include? 'js/document-capture-' } + # Consider any browser console logging as a failure. + raise BrowserConsoleLogError.new(javascript_errors) if javascript_errors.present? + end end diff --git a/spec/support/browser_console_log_error.rb b/spec/support/browser_console_log_error.rb new file mode 100644 index 00000000000..66ac644cf52 --- /dev/null +++ b/spec/support/browser_console_log_error.rb @@ -0,0 +1,9 @@ +class BrowserConsoleLogError < StandardError + def initialize(messages) + @messages = messages + end + + def to_s + "Unexpected browser console logging:\n\n#{@messages.join("\n\n")}" + end +end