diff --git a/features/step_definitions/cms/page_template_steps.rb b/features/step_definitions/cms/page_template_steps.rb index c361db56ad..a79efea268 100644 --- a/features/step_definitions/cms/page_template_steps.rb +++ b/features/step_definitions/cms/page_template_steps.rb @@ -9,7 +9,7 @@ end def fill_draft(text) - raise 'Please mark this scenario with @javascript if you want to work with codemirror.' unless @javascript + raise 'Please mark this scenario with @javascript if you want to work with codemirror.' unless javascript_test? find('#cms_template_draft', visible: :all) execute_script("$('#cms_template_draft').data('codemirror').setValue(#{text.inspect});") diff --git a/features/step_definitions/cms/sidebar_steps.rb b/features/step_definitions/cms/sidebar_steps.rb index e88743b287..61771375be 100644 --- a/features/step_definitions/cms/sidebar_steps.rb +++ b/features/step_definitions/cms/sidebar_steps.rb @@ -5,8 +5,6 @@ end When /^I switch to (builtin|3scale) content$/ do |group| - ensure_javascript - within "#cms-sidebar-filter-origin" do li = page.find("li[data-filter-origin='builtin']") li.click diff --git a/features/step_definitions/provider_steps.rb b/features/step_definitions/provider_steps.rb index 212b29fae3..907bf9ad21 100644 --- a/features/step_definitions/provider_steps.rb +++ b/features/step_definitions/provider_steps.rb @@ -3,7 +3,7 @@ def import_simple_layout(provider) simple_layout = SimpleLayout.new(provider) simple_layout.import_pages! - simple_layout.import_js_and_css! if @javascript + simple_layout.import_js_and_css! if javascript_test? end Given "a provider signed up to {plan}" do |plan| @@ -237,6 +237,8 @@ def setup_provider(login) set_current_domain(@provider.external_admin_domain) stub_integration_errors_dashboard + @provider.users.first.user_sessions.create! # Prevents welcome flash from showing up + return unless login try_provider_login('foo.3scale.localhost', 'supersecret') diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 5aa38cc956..2f4082ca04 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -143,14 +143,10 @@ def with_scope(locator) Then /^(.+) and confirm the dialog(?: "(.*)")?$/ do |original, text| ActiveSupport::Deprecation.warn "🥒 Replace with step 'And confirm the dialog'" - if rack_test? + accept_confirm(text) do step original - else - accept_confirm(text) do - step original - end - wait_for_requests end + wait_for_requests end Then "(they )should see the following details(:)" do |table| diff --git a/features/support/capybara.rb b/features/support/capybara.rb index c0b9665b47..db1203df00 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -1,13 +1,6 @@ # frozen_string_literal: true require 'selenium/webdriver' -require 'capybara/minitest' -include Capybara::Minitest::Assertions - -# in case firefox is needed! -#Capybara.register_driver :selenium do |app| -# Capybara::Selenium::Driver.new(app, :browser => :firefox) -#end DEFAULT_JS_DRIVER = :headless_chrome # in case firefox is needed! @@ -15,21 +8,17 @@ Capybara.configure do |config| config.default_driver = :rack_test - config.javascript_driver = DEFAULT_JS_DRIVER config.default_selector = :css config.raise_server_errors = true - config.match = :prefer_exact + config.match = :smart + + config.javascript_driver = DEFAULT_JS_DRIVER config.always_include_port = true config.default_max_wait_time = 10 - # Capybara 3 changes the default server to Puma. It can be reverted to the previous default of WEBRick by specifying: - config.server = :webrick + config.server = :webrick # default is `:default` (which uses puma) config.disable_animation = true end -Around '@security' do |scenario, block| - with_forgery_protection(&block) -end - # monkeypatch to fix # not opened for reading (IOError) # /cucumber-1.3.20/lib/cucumber/formatter/interceptor.rb:33:in `each' diff --git a/features/support/helpers/capybara_helpers.rb b/features/support/helpers/capybara_helpers.rb index 97a299d543..ab82f7b7c0 100644 --- a/features/support/helpers/capybara_helpers.rb +++ b/features/support/helpers/capybara_helpers.rb @@ -1,14 +1,18 @@ # frozen_string_literal: true +require 'capybara/minitest' + module CapybaraHelpers + include Capybara::Minitest::Assertions + FLASH_SELECTOR = [ '#flash-messages', '#flashWrapper span', '#flashWrapper p' ].join(', ').freeze - def rack_test? - %I[webkit selenium webkit_debug headless_chrome chrome headless_firefox firefox].exclude? Capybara.current_driver + def javascript_test? + Capybara.current_driver == Capybara.javascript_driver end def assert_flash(message) diff --git a/features/support/helpers/js_helpers.rb b/features/support/helpers/js_helpers.rb index 9a588f8b98..8e4993432f 100644 --- a/features/support/helpers/js_helpers.rb +++ b/features/support/helpers/js_helpers.rb @@ -6,10 +6,6 @@ def bypass_confirm_dialog page.evaluate_script('window.confirm = function() { return true; }') end - def ensure_javascript - raise 'This step requires JS enabled' unless @javascript - end - def local_storage(key) Capybara.current_session.driver.browser.local_storage.[](key) end diff --git a/features/support/helpers/requests_helper.rb b/features/support/helpers/requests_helper.rb index 740bb45725..a83d03a208 100644 --- a/features/support/helpers/requests_helper.rb +++ b/features/support/helpers/requests_helper.rb @@ -103,10 +103,6 @@ def finished_all_ajax_requests? Capybara.page.evaluate_script('jQuery.active').zero? end - - def javascript_test? - Capybara.current_driver == Capybara.javascript_driver - end end diff --git a/features/support/hooks.rb b/features/support/hooks.rb index c7a352b72d..f613a1a893 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -1,5 +1,9 @@ # frozen_string_literal: true +Around '@security' do |scenario, block| + with_forgery_protection(&block) +end + Before '@onpremises' do ThreeScale.config.stubs(onpremises: true) ThreeScale.config.stubs(saas?: false) @@ -28,7 +32,6 @@ Before '@javascript' do stub_core_reset! - @javascript = true end AfterStep('@javascript') do