Skip to content

Commit

Permalink
Some improvements from #3911
Browse files Browse the repository at this point in the history
Remove session creation

Revert to :prefer_exact capybara matching

Remove default capybara values
  • Loading branch information
mayorova committed Dec 10, 2024
1 parent 0af3143 commit 226b48c
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion features/step_definitions/cms/page_template_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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});")
Expand Down
2 changes: 0 additions & 2 deletions features/step_definitions/cms/sidebar_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/provider_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
8 changes: 2 additions & 6 deletions features/step_definitions/web_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
13 changes: 3 additions & 10 deletions features/support/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@
DEFAULT_JS_DRIVER = :headless_chrome

Capybara.configure do |config|
config.default_driver = :rack_test
config.default_selector = :css
config.raise_server_errors = true

config.match = :prefer_exact
config.javascript_driver = DEFAULT_JS_DRIVER
config.always_include_port = true
config.default_max_wait_time = 10
config.server = :webrick # default is `:default` (which uses puma)
end

# --window-size=1200,2048: When width < 1200px, vertical navigation overlaps the page's main content,
# and that will make some cucumbers fail
BASE_DRIVER_OPTIONS = {
args: [
# When width < 1200px, vertical navigation overlaps the page's main content and that will make
# some cucumbers fail
'--window-size=1200,2048',
'--disable-search-engine-choice-screen'
]
args: %w[--window-size=1200,2048 --disable-search-engine-choice-screen]
}.freeze

Capybara.register_driver :chrome do |app|
Expand Down
8 changes: 6 additions & 2 deletions features/support/helpers/capybara_helpers.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 0 additions & 4 deletions features/support/helpers/js_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions features/support/helpers/requests_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
5 changes: 4 additions & 1 deletion features/support/hooks.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -28,7 +32,6 @@

Before '@javascript' do
stub_core_reset!
@javascript = true
end

AfterStep('@javascript') do
Expand Down

0 comments on commit 226b48c

Please sign in to comment.