From b48e7f0c19f1a7256222c220e938832789492aa3 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Sun, 8 Feb 2015 03:46:34 -0500 Subject: [PATCH] 4958: Add tests. --- .../test/integration/browser_unsupported.rb | 17 +++++++++++++++++ apps/workbench/test/integration_helper.rb | 17 ++++++++++++----- apps/workbench/test/support/remove_file_api.js | 1 + 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 apps/workbench/test/integration/browser_unsupported.rb create mode 100644 apps/workbench/test/support/remove_file_api.js diff --git a/apps/workbench/test/integration/browser_unsupported.rb b/apps/workbench/test/integration/browser_unsupported.rb new file mode 100644 index 0000000000..788907d730 --- /dev/null +++ b/apps/workbench/test/integration/browser_unsupported.rb @@ -0,0 +1,17 @@ +require 'integration_helper' + +class BrowserUnsupported < ActionDispatch::IntegrationTest + WARNING_FRAGMENT = 'Your web browser is missing some of the features' + + test 'warning if no File API' do + Capybara.current_driver = :poltergeist_without_file_api + visit '/' + assert_text :visible, WARNING_FRAGMENT + end + + test 'no warning if File API' do + need_javascript + visit '/' + assert_no_text :visible, WARNING_FRAGMENT + end +end diff --git a/apps/workbench/test/integration_helper.rb b/apps/workbench/test/integration_helper.rb index cb07725350..39fdf4b260 100644 --- a/apps/workbench/test/integration_helper.rb +++ b/apps/workbench/test/integration_helper.rb @@ -4,12 +4,19 @@ require 'capybara/poltergeist' require 'uri' require 'yaml' +POLTERGEIST_OPTS = { + window_size: [1200, 800], + phantomjs_options: ['--ignore-ssl-errors=true'], + inspector: true, +} + Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new app, { - window_size: [1200, 800], - phantomjs_options: ['--ignore-ssl-errors=true'], - inspector: true, - } + Capybara::Poltergeist::Driver.new app, POLTERGEIST_OPTS +end + +Capybara.register_driver :poltergeist_without_file_api do |app| + js = File.expand_path '../support/remove_file_api.js', __FILE__ + Capybara::Poltergeist::Driver.new app, POLTERGEIST_OPTS.merge(extensions: [js]) end module WaitForAjax diff --git a/apps/workbench/test/support/remove_file_api.js b/apps/workbench/test/support/remove_file_api.js new file mode 100644 index 0000000000..0c64df2f07 --- /dev/null +++ b/apps/workbench/test/support/remove_file_api.js @@ -0,0 +1 @@ +window.FileReader = null; -- 2.30.2