Skip to content

Commit 609706a

Browse files
authored
Fix some of the drag_to specs (#310)
* feat: pending_connection_errors are false now in ferrum by default * fix: some of the drag_to specs are passing now after adding scroll_into_view * fix: linter * ci: update Ruby versions and enable Chrome dockerization in test workflow * chore: update Gemfile platforms for byebug and add ostruct dependency * fix: linter matrix * fix: skip response_headers as it's also skipped in capybara test, and only passing for rack-test * chore: add logger for ruby 4.0 * chore: bump ruby * fix: lint
1 parent bc06cc0 commit 609706a

11 files changed

Lines changed: 37 additions & 36 deletions

File tree

.github/workflows/linter.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: Linter
2-
on: [push]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
37

48
jobs:
59
linters:
610
name: Linters
711
strategy:
812
fail-fast: false
913
matrix:
10-
ruby: [ 2.7, "3.0" ]
14+
ruby: ["3.1", "4.0"]
1115
runs-on: ubuntu-latest
1216
steps:
1317
- name: Checkout code

.github/workflows/tests.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
14+
ruby: ["3.1", "3.2", "3.3", "3.4", "4.0"]
1515
runs-on: ubuntu-latest
1616
env:
1717
FERRUM_PROCESS_TIMEOUT: 25
1818
FERRUM_DEFAULT_TIMEOUT: 15
19+
FERRUM_CHROME_DOCKERIZE: true
1920
steps:
2021
- name: Checkout code
2122
uses: actions/checkout@v4
@@ -31,11 +32,6 @@ jobs:
3132
with:
3233
chrome-version: stable
3334

34-
- name: Fix GA Chrome Permissions
35-
run: |
36-
sudo chown root:root /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox
37-
sudo chmod 4755 /opt/hostedtoolcache/setup-chrome/chromium/stable/x64/chrome-sandbox
38-
3935
- name: Run tests
4036
run: |
4137
mkdir -p /tmp/cuprite

.rubocop.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AllCops:
2-
TargetRubyVersion: 2.7
2+
TargetRubyVersion: 3.1
33
NewCops: enable
44
SuggestExtensions: false
55

@@ -57,5 +57,5 @@ Metrics/ModuleLength:
5757
Metrics/PerceivedComplexity:
5858
Max: 14
5959

60-
require:
60+
plugins:
6161
- rubocop-rake

Gemfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
source "https://rubygems.org"
44

5-
gem "byebug", "~> 11.1", platforms: %i[mri mingw x64_mingw]
5+
gem "byebug", "~> 11.1", platforms: %i[mri windows]
66
gem "chunky_png", "~> 1.4"
77
gem "image_size", "~> 3.0"
88
gem "launchy", "~> 2.5"
9+
gem "logger"
10+
gem "ostruct"
911
gem "pdf-reader", "~> 2.12"
1012
gem "puma", ">= 5.6.7"
1113
gem "rake", "~> 13.0"

cuprite.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
2222
"rubygems_mfa_required" => "true"
2323
}
2424

25-
s.required_ruby_version = ">= 2.7.0"
25+
s.required_ruby_version = ">= 3.1"
2626

2727
s.add_dependency "capybara", "~> 3.0"
2828
s.add_dependency "ferrum", "~> 0.17.0"

lib/capybara/cuprite/browser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def source
140140
end
141141

142142
def drag(node, other, steps, delay = nil, scroll = true)
143+
node.scroll_into_view if scroll
143144
x1, y1 = node.find_position
144145

145146
mouse.move(x: x1, y: y1)

lib/capybara/cuprite/driver.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def initialize(app, options = {})
3535
@screen_size ||= DEFAULT_MAXIMIZE_SCREEN_SIZE
3636
@options[:save_path] ||= File.expand_path(Capybara.save_path) if Capybara.save_path
3737

38+
@options[:pending_connection_errors] = true unless @options.key?(:pending_connection_errors)
39+
3840
# It's set for debug() to make devtools tab open correctly.
3941
@options[:browser_options] ||= {}
4042
unless @options[:browser_options][:"remote-allow-origins"]

lib/capybara/cuprite/page.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Page < Ferrum::Page
1515
TRIGGER_CLICK_WAIT = ENV.fetch("CUPRITE_TRIGGER_CLICK_WAIT", 0.1).to_f
1616

1717
extend Forwardable
18+
1819
delegate %i[at_css at_xpath css xpath
1920
current_url current_title body execution_id execution_id!
2021
evaluate evaluate_on evaluate_async execute] => :active_frame

spec/features/session_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
Capybara::SpecHelper.run_specs TestSessions::Cuprite, "Cuprite"
3+
Capybara::SpecHelper.run_specs TestSessions::Cuprite, "Cuprite", capybara_skip: %i[response_headers]
44

55
describe Capybara::Session do
66
context "with cuprite driver" do

spec/spec_helper.rb

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,21 @@ module TestSessions
3636
RSpec.configure do |config|
3737
config.define_derived_metadata do |metadata|
3838
regexes = <<~REGEXP.split("\n").map { |s| Regexp.quote(s.strip) }.join("|")
39-
node #drag_to should work with jsTree
40-
node #drag_to should drag and drop an object
41-
node #drag_to should drag and drop if scrolling is needed
42-
node #drag_to should drag a link
43-
node #drag_to should work with Dragula
44-
node #drag_to HTML5 should work with SortableJS
45-
node #drag_to HTML5 should HTML5 drag and drop an object
46-
node #drag_to HTML5 should set clientX/Y in dragover events
47-
node #drag_to HTML5 should not HTML5 drag and drop on a non HTML5 drop element
48-
node #drag_to HTML5 should HTML5 drag and drop when scrolling needed
49-
node #drag_to HTML5 should drag HTML5 default draggable elements
50-
node #drag_to HTML5 should drag HTML5 default draggable element child
51-
node #drag_to should simulate a single held down modifier key
52-
node #drag_to should simulate multiple held down modifier keys
53-
node #drag_to should support key aliases
54-
node #drag_to HTML5 should preserve clientX/Y from last dragover event
55-
node #drag_to HTML5 should simulate a single held down modifier key
56-
node #drag_to HTML5 should simulate multiple held down modifier keys
57-
node #drag_to HTML5 should support key aliases
58-
node #drag_to HTML5 should trigger a dragenter event, before the first dragover event
39+
#drag_to should simulate a single held down modifier key
40+
#drag_to should simulate multiple held down modifier keys
41+
#drag_to should support key aliases
42+
#drag_to HTML5 should HTML5 drag and drop an object
43+
#drag_to HTML5 should HTML5 drag and drop an object child
44+
#drag_to HTML5 should set clientX/Y in dragover events
45+
#drag_to HTML5 should preserve clientX/Y from last dragover event
46+
#drag_to HTML5 should HTML5 drag and drop when scrolling needed
47+
#drag_to HTML5 should drag HTML5 default draggable elements
48+
#drag_to HTML5 should work with SortableJS
49+
#drag_to HTML5 should drag HTML5 default draggable element child
50+
#drag_to HTML5 should simulate a single held down modifier key
51+
#drag_to HTML5 should simulate multiple held down modifier keys
52+
#drag_to HTML5 should support key aliases
53+
#drag_to HTML5 should trigger a dragenter event, before the first dragover event
5954
node Element#drop can drop a file
6055
node Element#drop can drop multiple files
6156
node Element#drop can drop strings
@@ -68,6 +63,7 @@ module TestSessions
6863
node #set should submit single text input forms if ended with
6964
#fill_in should fill in a color field
7065
#fill_in should handle carriage returns with line feeds in a textarea correctly
66+
#fill_in should fill in a textarea in a reasonable time by default
7167
#has_field with valid should be false if field is invalid
7268
#find with spatial filters should find an element above another element
7369
#find with spatial filters should find an element below another element
@@ -77,7 +73,6 @@ module TestSessions
7773
#find with spatial filters should find an element "near" another element
7874
#has_css? with spatial requirements accepts spatial options
7975
#has_css? with spatial requirements supports spatial sugar
80-
#fill_in should fill in a textarea in a reasonable time by default
8176
#has_element? should be true if the given element is on the page
8277
#assert_matches_style should raise error if the elements style doesn't contain the given properties
8378
#has_css? :style option should support Hash

0 commit comments

Comments
 (0)