From 0ccfa49382cab73a54b424e830e412c7d64f9b28 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 22 Jan 2025 15:05:25 +0100 Subject: [PATCH] unit tests for cuprite integration --- Appraisals | 14 ++ Rakefile | 7 +- .../jruby_9.4_cuprite_0_capybara_3.gemfile | 28 +++ ...ruby_9.4_cuprite_0_capybara_3.gemfile.lock | 157 +++++++++++++ .../ruby_3.0_cuprite_0_capybara_3.gemfile | 29 +++ ...ruby_3.0_cuprite_0_capybara_3.gemfile.lock | 178 ++++++++++++++ .../ruby_3.1_cuprite_0_capybara_3.gemfile | 29 +++ ...ruby_3.1_cuprite_0_capybara_3.gemfile.lock | 178 ++++++++++++++ .../ruby_3.2_cuprite_0_capybara_3.gemfile | 29 +++ ...ruby_3.2_cuprite_0_capybara_3.gemfile.lock | 178 ++++++++++++++ .../ruby_3.3_cuprite_0_capybara_3.gemfile | 29 +++ ...ruby_3.3_cuprite_0_capybara_3.gemfile.lock | 178 ++++++++++++++ .../ruby_3.4_cuprite_0_capybara_3.gemfile | 29 +++ ...ruby_3.4_cuprite_0_capybara_3.gemfile.lock | 217 ++++++++++++++++++ .../contrib/cuprite/features/passing.feature | 4 + .../features/step_definitions/steps.rb | 19 ++ .../contrib/cuprite/instrumentation_spec.rb | 107 +++++++++ .../features/step_definitions/steps.rb | 3 - .../contrib/selenium/instrumentation_spec.rb | 1 - 19 files changed, 1409 insertions(+), 5 deletions(-) create mode 100644 gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile create mode 100644 gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile.lock create mode 100644 gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile create mode 100644 gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile.lock create mode 100644 gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile create mode 100644 gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile.lock create mode 100644 gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile create mode 100644 gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile.lock create mode 100644 gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile create mode 100644 gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile.lock create mode 100644 gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile create mode 100644 gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile.lock create mode 100644 spec/datadog/ci/contrib/cuprite/features/passing.feature create mode 100644 spec/datadog/ci/contrib/cuprite/features/step_definitions/steps.rb create mode 100644 spec/datadog/ci/contrib/cuprite/instrumentation_spec.rb diff --git a/Appraisals b/Appraisals index e4f338f5..ac7dec51 100644 --- a/Appraisals +++ b/Appraisals @@ -167,6 +167,19 @@ def self.with_timecop_gem(timecop_versions: 0) end end +def self.with_cuprite_gem(cuprite_versions: 0, capybara_versions: 3) + Array(cuprite_versions).each do |cuprite_v| + Array(capybara_versions).each do |capybara_v| + appraise "cuprite-#{cuprite_v}-capybara-#{capybara_v}" do + gem "capybara", "~> #{capybara_v}" + gem "cuprite", "~> #{cuprite_v}" + + gem "cucumber", "~> 9" + end + end + end +end + major, minor, = RUBY_VERSION.segments with_minitest_gem @@ -179,6 +192,7 @@ with_active_support_gem(versions: 4..7) with_knapsack_pro_rspec_gem with_selenium_gem if Gem::Version.new("3.0") <= RUBY_VERSION with_timecop_gem +with_cuprite_gem if Gem::Version.new("3.0") <= RUBY_VERSION ruby_runtime = "#{RUBY_ENGINE}-#{major}.#{minor}" diff --git a/Rakefile b/Rakefile index 9eca661a..8b8b1c42 100644 --- a/Rakefile +++ b/Rakefile @@ -70,6 +70,9 @@ TEST_METADATA = { "selenium" => { "selenium-4-capybara-3" => "❌ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby" }, + "cuprite" => { + "cuprite-0-capybara-3" => "❌ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby" + }, "timecop" => { "timecop-0" => "✅ 2.7 / ✅ 3.0 / ✅ 3.1 / ✅ 3.2 / ✅ 3.3 / ✅ 3.4 / ✅ jruby" } @@ -151,7 +154,9 @@ namespace :spec do ci_queue_rspec knapsack_rspec knapsack_auto_instrument - selenium timecop + selenium + timecop + cuprite ].each do |contrib| desc "" # "Explicitly hiding from `rake -T`" RSpec::Core::RakeTask.new(contrib) do |t, args| diff --git a/gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile b/gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile new file mode 100644 index 00000000..7d2298cd --- /dev/null +++ b/gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile @@ -0,0 +1,28 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "rake-compiler" +gem "simplecov" +gem "rspec" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "climate_control" +gem "webmock" +gem "rake" +gem "yard" +gem "os" +gem "capybara", "~> 3" +gem "cuprite", "~> 0" +gem "cucumber", "~> 9" + +group :check do + +end + +group :development do + +end + +gemspec path: "../" diff --git a/gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile.lock b/gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile.lock new file mode 100644 index 00000000..4c002a29 --- /dev/null +++ b/gemfiles/jruby_9.4_cuprite_0_capybara_3.gemfile.lock @@ -0,0 +1,157 @@ +PATH + remote: .. + specs: + datadog-ci (1.11.0) + datadog (~> 2.4) + msgpack + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.9-java) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + climate_control (1.2.0) + concurrent-ruby (1.3.5) + crack (1.0.0) + bigdecimal + rexml + cucumber (9.2.1) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 13, < 14) + cucumber-cucumber-expressions (~> 17.0) + cucumber-gherkin (> 24, < 28) + cucumber-html-formatter (> 20.3, < 22) + cucumber-messages (> 19, < 25) + diff-lcs (~> 1.5) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.2) + cucumber-ci-environment (10.0.1) + cucumber-core (13.0.3) + cucumber-gherkin (>= 27, < 28) + cucumber-messages (>= 20, < 23) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (17.1.0) + bigdecimal + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-html-formatter (21.7.0) + cucumber-messages (> 19, < 27) + cucumber-messages (22.0.0) + cucumber-tag-expressions (6.1.1) + cuprite (0.15.1) + capybara (~> 3.0) + ferrum (~> 0.15.0) + datadog (2.9.0) + datadog-ruby_core_source (~> 3.3, >= 3.3.7) + libdatadog (~> 14.3.1.1.0) + libddwaf (~> 1.18.0.0.0) + msgpack + datadog-ruby_core_source (3.3.7) + diff-lcs (1.5.1) + docile (1.4.1) + ferrum (0.15) + addressable (~> 2.5) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + ffi (1.17.1-java) + hashdiff (1.1.2) + libdatadog (14.3.1.1.0) + libddwaf (1.18.0.0.0-java) + ffi (~> 1.0) + matrix (0.4.2) + mini_mime (1.1.5) + msgpack (1.7.5-java) + multi_test (1.1.0) + nokogiri (1.18.2-java) + racc (~> 1.4) + os (1.1.4) + public_suffix (6.0.1) + racc (1.8.1-java) + rack (3.1.8) + rack-test (2.2.0) + rack (>= 1.3) + rake (13.2.1) + rake-compiler (1.2.9) + rake + regexp_parser (2.10.0) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + websocket-driver (0.7.7-java) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + +PLATFORMS + universal-java-11 + +DEPENDENCIES + appraisal + capybara (~> 3) + climate_control + cucumber (~> 9) + cuprite (~> 0) + datadog-ci! + os + rake + rake-compiler + rspec + rspec-collection_matchers + rspec_junit_formatter + simplecov + webmock + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile b/gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile new file mode 100644 index 00000000..32e80f88 --- /dev/null +++ b/gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile @@ -0,0 +1,29 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "debug" +gem "rake-compiler" +gem "simplecov" +gem "rspec" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "climate_control" +gem "webmock" +gem "rake" +gem "yard" +gem "os" +gem "capybara", "~> 3" +gem "cuprite", "~> 0" +gem "cucumber", "~> 9" + +group :check do + +end + +group :development do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile.lock b/gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile.lock new file mode 100644 index 00000000..3687b4c9 --- /dev/null +++ b/gemfiles/ruby_3.0_cuprite_0_capybara_3.gemfile.lock @@ -0,0 +1,178 @@ +PATH + remote: .. + specs: + datadog-ci (1.11.0) + datadog (~> 2.4) + msgpack + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.9) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + climate_control (1.2.0) + concurrent-ruby (1.3.5) + crack (1.0.0) + bigdecimal + rexml + cucumber (9.2.1) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 13, < 14) + cucumber-cucumber-expressions (~> 17.0) + cucumber-gherkin (> 24, < 28) + cucumber-html-formatter (> 20.3, < 22) + cucumber-messages (> 19, < 25) + diff-lcs (~> 1.5) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.2) + cucumber-ci-environment (10.0.1) + cucumber-core (13.0.3) + cucumber-gherkin (>= 27, < 28) + cucumber-messages (>= 20, < 23) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (17.1.0) + bigdecimal + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-html-formatter (21.7.0) + cucumber-messages (> 19, < 27) + cucumber-messages (22.0.0) + cucumber-tag-expressions (6.1.1) + cuprite (0.15.1) + capybara (~> 3.0) + ferrum (~> 0.15.0) + datadog (2.9.0) + datadog-ruby_core_source (~> 3.3, >= 3.3.7) + libdatadog (~> 14.3.1.1.0) + libddwaf (~> 1.18.0.0.0) + msgpack + datadog-ruby_core_source (3.3.7) + date (3.4.1) + debug (1.10.0) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.1) + ferrum (0.15) + addressable (~> 2.5) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + ffi (1.17.1-aarch64-linux-gnu) + hashdiff (1.1.2) + io-console (0.8.0) + irb (1.15.1) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + libdatadog (14.3.1.1.0-aarch64-linux) + libddwaf (1.18.0.0.0-aarch64-linux) + ffi (~> 1.0) + matrix (0.4.2) + mini_mime (1.1.5) + msgpack (1.7.5) + multi_test (1.1.0) + nokogiri (1.17.2-aarch64-linux) + racc (~> 1.4) + os (1.1.4) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + psych (5.2.3) + date + stringio + public_suffix (6.0.1) + racc (1.8.1) + rack (3.1.8) + rack-test (2.2.0) + rack (>= 1.3) + rake (13.2.1) + rake-compiler (1.2.9) + rake + rdoc (6.11.0) + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + stringio (3.1.2) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + websocket-driver (0.7.7) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + capybara (~> 3) + climate_control + cucumber (~> 9) + cuprite (~> 0) + datadog-ci! + debug + os + rake + rake-compiler + rspec + rspec-collection_matchers + rspec_junit_formatter + simplecov + webmock + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile b/gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile new file mode 100644 index 00000000..32e80f88 --- /dev/null +++ b/gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile @@ -0,0 +1,29 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "debug" +gem "rake-compiler" +gem "simplecov" +gem "rspec" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "climate_control" +gem "webmock" +gem "rake" +gem "yard" +gem "os" +gem "capybara", "~> 3" +gem "cuprite", "~> 0" +gem "cucumber", "~> 9" + +group :check do + +end + +group :development do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile.lock b/gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile.lock new file mode 100644 index 00000000..79a8a378 --- /dev/null +++ b/gemfiles/ruby_3.1_cuprite_0_capybara_3.gemfile.lock @@ -0,0 +1,178 @@ +PATH + remote: .. + specs: + datadog-ci (1.11.0) + datadog (~> 2.4) + msgpack + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.9) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + climate_control (1.2.0) + concurrent-ruby (1.3.5) + crack (1.0.0) + bigdecimal + rexml + cucumber (9.2.1) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 13, < 14) + cucumber-cucumber-expressions (~> 17.0) + cucumber-gherkin (> 24, < 28) + cucumber-html-formatter (> 20.3, < 22) + cucumber-messages (> 19, < 25) + diff-lcs (~> 1.5) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.2) + cucumber-ci-environment (10.0.1) + cucumber-core (13.0.3) + cucumber-gherkin (>= 27, < 28) + cucumber-messages (>= 20, < 23) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (17.1.0) + bigdecimal + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-html-formatter (21.7.0) + cucumber-messages (> 19, < 27) + cucumber-messages (22.0.0) + cucumber-tag-expressions (6.1.1) + cuprite (0.15.1) + capybara (~> 3.0) + ferrum (~> 0.15.0) + datadog (2.9.0) + datadog-ruby_core_source (~> 3.3, >= 3.3.7) + libdatadog (~> 14.3.1.1.0) + libddwaf (~> 1.18.0.0.0) + msgpack + datadog-ruby_core_source (3.3.7) + date (3.4.1) + debug (1.10.0) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.1) + ferrum (0.15) + addressable (~> 2.5) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + ffi (1.17.1-aarch64-linux-gnu) + hashdiff (1.1.2) + io-console (0.8.0) + irb (1.15.1) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + libdatadog (14.3.1.1.0-aarch64-linux) + libddwaf (1.18.0.0.0-aarch64-linux) + ffi (~> 1.0) + matrix (0.4.2) + mini_mime (1.1.5) + msgpack (1.7.5) + multi_test (1.1.0) + nokogiri (1.18.2-aarch64-linux-gnu) + racc (~> 1.4) + os (1.1.4) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + psych (5.2.3) + date + stringio + public_suffix (6.0.1) + racc (1.8.1) + rack (3.1.8) + rack-test (2.2.0) + rack (>= 1.3) + rake (13.2.1) + rake-compiler (1.2.9) + rake + rdoc (6.11.0) + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + stringio (3.1.2) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + websocket-driver (0.7.7) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + capybara (~> 3) + climate_control + cucumber (~> 9) + cuprite (~> 0) + datadog-ci! + debug + os + rake + rake-compiler + rspec + rspec-collection_matchers + rspec_junit_formatter + simplecov + webmock + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile b/gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile new file mode 100644 index 00000000..32e80f88 --- /dev/null +++ b/gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile @@ -0,0 +1,29 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "debug" +gem "rake-compiler" +gem "simplecov" +gem "rspec" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "climate_control" +gem "webmock" +gem "rake" +gem "yard" +gem "os" +gem "capybara", "~> 3" +gem "cuprite", "~> 0" +gem "cucumber", "~> 9" + +group :check do + +end + +group :development do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile.lock b/gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile.lock new file mode 100644 index 00000000..79a8a378 --- /dev/null +++ b/gemfiles/ruby_3.2_cuprite_0_capybara_3.gemfile.lock @@ -0,0 +1,178 @@ +PATH + remote: .. + specs: + datadog-ci (1.11.0) + datadog (~> 2.4) + msgpack + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.9) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + climate_control (1.2.0) + concurrent-ruby (1.3.5) + crack (1.0.0) + bigdecimal + rexml + cucumber (9.2.1) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 13, < 14) + cucumber-cucumber-expressions (~> 17.0) + cucumber-gherkin (> 24, < 28) + cucumber-html-formatter (> 20.3, < 22) + cucumber-messages (> 19, < 25) + diff-lcs (~> 1.5) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.2) + cucumber-ci-environment (10.0.1) + cucumber-core (13.0.3) + cucumber-gherkin (>= 27, < 28) + cucumber-messages (>= 20, < 23) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (17.1.0) + bigdecimal + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-html-formatter (21.7.0) + cucumber-messages (> 19, < 27) + cucumber-messages (22.0.0) + cucumber-tag-expressions (6.1.1) + cuprite (0.15.1) + capybara (~> 3.0) + ferrum (~> 0.15.0) + datadog (2.9.0) + datadog-ruby_core_source (~> 3.3, >= 3.3.7) + libdatadog (~> 14.3.1.1.0) + libddwaf (~> 1.18.0.0.0) + msgpack + datadog-ruby_core_source (3.3.7) + date (3.4.1) + debug (1.10.0) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.1) + ferrum (0.15) + addressable (~> 2.5) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + ffi (1.17.1-aarch64-linux-gnu) + hashdiff (1.1.2) + io-console (0.8.0) + irb (1.15.1) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + libdatadog (14.3.1.1.0-aarch64-linux) + libddwaf (1.18.0.0.0-aarch64-linux) + ffi (~> 1.0) + matrix (0.4.2) + mini_mime (1.1.5) + msgpack (1.7.5) + multi_test (1.1.0) + nokogiri (1.18.2-aarch64-linux-gnu) + racc (~> 1.4) + os (1.1.4) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + psych (5.2.3) + date + stringio + public_suffix (6.0.1) + racc (1.8.1) + rack (3.1.8) + rack-test (2.2.0) + rack (>= 1.3) + rake (13.2.1) + rake-compiler (1.2.9) + rake + rdoc (6.11.0) + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + stringio (3.1.2) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + websocket-driver (0.7.7) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + capybara (~> 3) + climate_control + cucumber (~> 9) + cuprite (~> 0) + datadog-ci! + debug + os + rake + rake-compiler + rspec + rspec-collection_matchers + rspec_junit_formatter + simplecov + webmock + yard + +BUNDLED WITH + 2.3.26 diff --git a/gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile b/gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile new file mode 100644 index 00000000..32e80f88 --- /dev/null +++ b/gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile @@ -0,0 +1,29 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "debug" +gem "rake-compiler" +gem "simplecov" +gem "rspec" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "climate_control" +gem "webmock" +gem "rake" +gem "yard" +gem "os" +gem "capybara", "~> 3" +gem "cuprite", "~> 0" +gem "cucumber", "~> 9" + +group :check do + +end + +group :development do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile.lock b/gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile.lock new file mode 100644 index 00000000..e12e97b2 --- /dev/null +++ b/gemfiles/ruby_3.3_cuprite_0_capybara_3.gemfile.lock @@ -0,0 +1,178 @@ +PATH + remote: .. + specs: + datadog-ci (1.11.0) + datadog (~> 2.4) + msgpack + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.9) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + climate_control (1.2.0) + concurrent-ruby (1.3.5) + crack (1.0.0) + bigdecimal + rexml + cucumber (9.2.1) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 13, < 14) + cucumber-cucumber-expressions (~> 17.0) + cucumber-gherkin (> 24, < 28) + cucumber-html-formatter (> 20.3, < 22) + cucumber-messages (> 19, < 25) + diff-lcs (~> 1.5) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.2) + cucumber-ci-environment (10.0.1) + cucumber-core (13.0.3) + cucumber-gherkin (>= 27, < 28) + cucumber-messages (>= 20, < 23) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (17.1.0) + bigdecimal + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-html-formatter (21.7.0) + cucumber-messages (> 19, < 27) + cucumber-messages (22.0.0) + cucumber-tag-expressions (6.1.1) + cuprite (0.15.1) + capybara (~> 3.0) + ferrum (~> 0.15.0) + datadog (2.9.0) + datadog-ruby_core_source (~> 3.3, >= 3.3.7) + libdatadog (~> 14.3.1.1.0) + libddwaf (~> 1.18.0.0.0) + msgpack + datadog-ruby_core_source (3.3.7) + date (3.4.1) + debug (1.10.0) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.1) + ferrum (0.15) + addressable (~> 2.5) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + ffi (1.17.1-aarch64-linux-gnu) + hashdiff (1.1.2) + io-console (0.8.0) + irb (1.15.1) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + libdatadog (14.3.1.1.0-aarch64-linux) + libddwaf (1.18.0.0.0-aarch64-linux) + ffi (~> 1.0) + matrix (0.4.2) + mini_mime (1.1.5) + msgpack (1.7.5) + multi_test (1.1.0) + nokogiri (1.18.2-aarch64-linux-gnu) + racc (~> 1.4) + os (1.1.4) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + psych (5.2.3) + date + stringio + public_suffix (6.0.1) + racc (1.8.1) + rack (3.1.8) + rack-test (2.2.0) + rack (>= 1.3) + rake (13.2.1) + rake-compiler (1.2.9) + rake + rdoc (6.11.0) + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + stringio (3.1.2) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + websocket-driver (0.7.7) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + +PLATFORMS + aarch64-linux + +DEPENDENCIES + appraisal + capybara (~> 3) + climate_control + cucumber (~> 9) + cuprite (~> 0) + datadog-ci! + debug + os + rake + rake-compiler + rspec + rspec-collection_matchers + rspec_junit_formatter + simplecov + webmock + yard + +BUNDLED WITH + 2.4.19 diff --git a/gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile b/gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile new file mode 100644 index 00000000..32e80f88 --- /dev/null +++ b/gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile @@ -0,0 +1,29 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "debug" +gem "rake-compiler" +gem "simplecov" +gem "rspec" +gem "rspec-collection_matchers" +gem "rspec_junit_formatter" +gem "appraisal" +gem "climate_control" +gem "webmock" +gem "rake" +gem "yard" +gem "os" +gem "capybara", "~> 3" +gem "cuprite", "~> 0" +gem "cucumber", "~> 9" + +group :check do + +end + +group :development do + +end + +gemspec path: "../" diff --git a/gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile.lock b/gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile.lock new file mode 100644 index 00000000..09f6468e --- /dev/null +++ b/gemfiles/ruby_3.4_cuprite_0_capybara_3.gemfile.lock @@ -0,0 +1,217 @@ +PATH + remote: .. + specs: + datadog-ci (1.11.0) + datadog (~> 2.4) + msgpack + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + appraisal (2.5.0) + bundler + rake + thor (>= 0.14.0) + base64 (0.2.0) + bigdecimal (3.1.9) + builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + climate_control (1.2.0) + concurrent-ruby (1.3.5) + crack (1.0.0) + bigdecimal + rexml + cucumber (9.2.1) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 11) + cucumber-core (> 13, < 14) + cucumber-cucumber-expressions (~> 17.0) + cucumber-gherkin (> 24, < 28) + cucumber-html-formatter (> 20.3, < 22) + cucumber-messages (> 19, < 25) + diff-lcs (~> 1.5) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.2) + cucumber-ci-environment (10.0.1) + cucumber-core (13.0.3) + cucumber-gherkin (>= 27, < 28) + cucumber-messages (>= 20, < 23) + cucumber-tag-expressions (> 5, < 7) + cucumber-cucumber-expressions (17.1.0) + bigdecimal + cucumber-gherkin (27.0.0) + cucumber-messages (>= 19.1.4, < 23) + cucumber-html-formatter (21.7.0) + cucumber-messages (> 19, < 27) + cucumber-messages (22.0.0) + cucumber-tag-expressions (6.1.1) + cuprite (0.15.1) + capybara (~> 3.0) + ferrum (~> 0.15.0) + datadog (2.9.0) + datadog-ruby_core_source (~> 3.3, >= 3.3.7) + libdatadog (~> 14.3.1.1.0) + libddwaf (~> 1.18.0.0.0) + msgpack + datadog-ruby_core_source (3.3.7) + date (3.4.1) + debug (1.10.0) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.1) + ferrum (0.15) + addressable (~> 2.5) + concurrent-ruby (~> 1.1) + webrick (~> 1.7) + websocket-driver (~> 0.7) + ffi (1.17.1-aarch64-linux-gnu) + ffi (1.17.1-aarch64-linux-musl) + ffi (1.17.1-arm-linux-gnu) + ffi (1.17.1-arm-linux-musl) + ffi (1.17.1-arm64-darwin) + ffi (1.17.1-x86_64-darwin) + ffi (1.17.1-x86_64-linux-gnu) + ffi (1.17.1-x86_64-linux-musl) + hashdiff (1.1.2) + io-console (0.8.0) + irb (1.15.1) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + libdatadog (14.3.1.1.0) + libdatadog (14.3.1.1.0-aarch64-linux) + libdatadog (14.3.1.1.0-x86_64-linux) + libddwaf (1.18.0.0.0) + ffi (~> 1.0) + libddwaf (1.18.0.0.0-aarch64-linux) + ffi (~> 1.0) + libddwaf (1.18.0.0.0-arm64-darwin) + ffi (~> 1.0) + libddwaf (1.18.0.0.0-x86_64-darwin) + ffi (~> 1.0) + libddwaf (1.18.0.0.0-x86_64-linux) + ffi (~> 1.0) + matrix (0.4.2) + mini_mime (1.1.5) + msgpack (1.7.5) + multi_test (1.1.0) + nokogiri (1.18.2-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.2-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.2-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.2-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.2-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.2-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.2-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.2-x86_64-linux-musl) + racc (~> 1.4) + os (1.1.4) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + psych (5.2.3) + date + stringio + public_suffix (6.0.1) + racc (1.8.1) + rack (3.1.8) + rack-test (2.2.0) + rack (>= 1.3) + rake (13.2.1) + rake-compiler (1.2.9) + rake + rdoc (6.11.0) + psych (>= 4.0.0) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-collection_matchers (1.2.1) + rspec-expectations (>= 2.99.0.beta1) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.2) + rspec_junit_formatter (0.6.0) + rspec-core (>= 2, < 4, != 2.12.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + stringio (3.1.2) + sys-uname (1.3.1) + ffi (~> 1.1) + thor (1.3.2) + webmock (3.24.0) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + webrick (1.9.1) + websocket-driver (0.7.7) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + yard (0.9.37) + +PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + appraisal + capybara (~> 3) + climate_control + cucumber (~> 9) + cuprite (~> 0) + datadog-ci! + debug + os + rake + rake-compiler + rspec + rspec-collection_matchers + rspec_junit_formatter + simplecov + webmock + yard + +BUNDLED WITH + 2.5.17 diff --git a/spec/datadog/ci/contrib/cuprite/features/passing.feature b/spec/datadog/ci/contrib/cuprite/features/passing.feature new file mode 100644 index 00000000..b9b4b7aa --- /dev/null +++ b/spec/datadog/ci/contrib/cuprite/features/passing.feature @@ -0,0 +1,4 @@ +Feature: Datadog integration with browser tests via cuprite + + Scenario: Browser scenario + Given visit page diff --git a/spec/datadog/ci/contrib/cuprite/features/step_definitions/steps.rb b/spec/datadog/ci/contrib/cuprite/features/step_definitions/steps.rb new file mode 100644 index 00000000..6a0549f6 --- /dev/null +++ b/spec/datadog/ci/contrib/cuprite/features/step_definitions/steps.rb @@ -0,0 +1,19 @@ +require "capybara" +require "capybara/cucumber" +require "capybara/cuprite" + +Capybara.register_driver(:cuprite) do |app| + Capybara::Cuprite::Driver.new(app, window_size: [1200, 800]) +end + +Capybara.current_driver = :cuprite +Capybara.default_driver = :cuprite +Capybara.javascript_driver = :cuprite + +Then "visit page" do + visit "http://www.example.com" + + Capybara.reset_session! + + Capybara.current_session.quit +end diff --git a/spec/datadog/ci/contrib/cuprite/instrumentation_spec.rb b/spec/datadog/ci/contrib/cuprite/instrumentation_spec.rb new file mode 100644 index 00000000..1b89867f --- /dev/null +++ b/spec/datadog/ci/contrib/cuprite/instrumentation_spec.rb @@ -0,0 +1,107 @@ +require "cucumber" +require "capybara/cuprite" + +RSpec.describe "Browser tests with cuprite" do + let(:cucumber_features_root) { File.join(__dir__, "features") } + + before do + allow(Datadog::CI::Git::LocalRepository).to receive(:root).and_return(cucumber_features_root) + end + + include_context "CI mode activated" do + let(:integration_name) { :cucumber } + end + + let(:cookies_spy) { spy("cookies") } + let(:browser) do + instance_double( + Capybara::Cuprite::Browser, + :cookies => cookies_spy, + :current_url => "http://www.example.com", + :options => instance_double(Ferrum::Browser::Options, browser_name: "mockbrowser"), + :version => instance_double(Ferrum::Browser::VersionInfo, product: "mockversion"), + :url_blacklist= => nil, + :url_whitelist= => nil, + :reset => nil, + :quit => nil + ) + end + + let(:stdin) { StringIO.new } + # let(:stdout) { StringIO.new } + # let(:stderr) { StringIO.new } + let(:stdout) { $stdout } + let(:stderr) { $stderr } + + let(:kernel) { double(:kernel) } + + # Cucumber runtime setup + let(:existing_runtime) { Cucumber::Runtime.new(runtime_options) } + let(:runtime_options) { {} } + # CLI configuration + let(:features_path) { "spec/datadog/ci/contrib/cuprite/features" } + let(:args) do + [ + "-r", + "spec/datadog/ci/contrib/cuprite/features/step_definitions/steps.rb", + features_path + ] + end + + let(:cli) do + Cucumber::Cli::Main.new(args, stdout, stderr, kernel) + end + let(:expected_test_run_code) { 0 } + + # spies + let(:executed_scripts) { [] } + let(:visited_urls) { [] } + + before do + expect(Capybara::Cuprite::Browser).to receive(:new).and_return(browser) + allow(browser).to receive(:evaluate_func) do |script| + executed_scripts << script + "true" + end + allow(browser).to receive(:visit) do |url| + visited_urls << url + end + + expect(kernel).to receive(:exit).with(expected_test_run_code) + ClimateControl.modify("DD_CIVISIBILITY_SELENIUM_ENABLED" => "1", "DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS" => "1") do + cli.execute!(existing_runtime) + end + end + + it "recognize the test as browser test and adds additional tags" do + expect(visited_urls).to eq(["http://www.example.com"]) + expect(executed_scripts).to eq( + [ + Datadog::CI::Contrib::Cuprite::ScriptExecutor::WRAPPED_SCRIPTS[Datadog::CI::Ext::RUM::SCRIPT_IS_RUM_ACTIVE], + Datadog::CI::Contrib::Cuprite::ScriptExecutor::WRAPPED_SCRIPTS[Datadog::CI::Ext::RUM::SCRIPT_STOP_RUM_SESSION], + Datadog::CI::Contrib::Cuprite::ScriptExecutor::WRAPPED_SCRIPTS[Datadog::CI::Ext::RUM::SCRIPT_IS_RUM_ACTIVE], + Datadog::CI::Contrib::Cuprite::ScriptExecutor::WRAPPED_SCRIPTS[Datadog::CI::Ext::RUM::SCRIPT_STOP_RUM_SESSION] + ] + ) + + expect(test_spans).to have(1).item + + expect(cookies_spy).to have_received(:set).with( + {name: "datadog-ci-visibility-test-execution-id", value: first_test_span.trace_id.to_s, domain: "www.example.com"} + ) + expect(cookies_spy).to have_received(:remove).with( + {name: "datadog-ci-visibility-test-execution-id", domain: "www.example.com"} + ) + + expect(first_test_span).to have_test_tag(:type, "browser") + expect(first_test_span).to have_test_tag(:browser_driver, "cuprite") + expect(first_test_span).to have_test_tag( + :browser_driver_version, + Gem.loaded_specs["cuprite"].version.to_s + ) + expect(first_test_span).to have_test_tag(:browser_name, "mockbrowser") + expect(first_test_span).to have_test_tag(:browser_version, "mockversion") + + expect(first_test_span).to have_test_tag(:is_rum_active, "true") + end +end diff --git a/spec/datadog/ci/contrib/selenium/features/step_definitions/steps.rb b/spec/datadog/ci/contrib/selenium/features/step_definitions/steps.rb index 7b5f8e88..d77c5706 100644 --- a/spec/datadog/ci/contrib/selenium/features/step_definitions/steps.rb +++ b/spec/datadog/ci/contrib/selenium/features/step_definitions/steps.rb @@ -5,11 +5,8 @@ Then "visit page" do visit "http://www.example.com" - p "visited" Capybara.reset_session! - p "reset" Capybara.current_session.quit - p "quit" end diff --git a/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb b/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb index 8f852463..4a12b57f 100644 --- a/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/selenium/instrumentation_spec.rb @@ -58,7 +58,6 @@ let(:visited_urls) { [] } before do - # expect(kernel).to receive(:exit).with(expected_test_run_code) expect(Selenium::WebDriver::Remote::Bridge).to receive(:new).and_return(bridge) allow(bridge).to receive(:execute_script) do |script| executed_scripts << script