-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract RUM logic out of Selenium contrib, reenable testing selenium/…
…capybara integration for Ruby 3.4
- Loading branch information
1 parent
ff0a815
commit aac60e3
Showing
14 changed files
with
114 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module CI | ||
module Ext | ||
# Defines constants for Git tags | ||
module RUM | ||
ENV_RUM_FLUSH_WAIT_MILLIS = "DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS" | ||
|
||
COOKIE_TEST_EXECUTION_ID = "datadog-ci-visibility-test-execution-id" | ||
|
||
SCRIPT_IS_RUM_ACTIVE = <<~JS | ||
return !!window.DD_RUM | ||
JS | ||
SCRIPT_STOP_RUM_SESSION = <<~JS | ||
if (window.DD_RUM && window.DD_RUM.stopSession) { | ||
window.DD_RUM.stopSession(); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
JS | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../ext/rum" | ||
require_relative "../ext/test" | ||
require_relative "parsing" | ||
|
||
module Datadog | ||
module CI | ||
module Utils | ||
# Provides functionality to interact with Datadog Real User Monitoring product | ||
# via executing JavaScript code in the browser. | ||
# | ||
# Relevant docs: https://docs.datadoghq.com/real_user_monitoring/browser/ | ||
module RUM | ||
def self.is_rum_active?(script_executor) | ||
is_rum_active_script_result = script_executor.execute_script(Ext::RUM::SCRIPT_IS_RUM_ACTIVE) | ||
|
||
Datadog.logger.debug { "[Selenium] SCRIPT_IS_RUM_ACTIVE result is #{is_rum_active_script_result.inspect}" } | ||
|
||
Utils::Parsing.convert_to_bool(is_rum_active_script_result) | ||
end | ||
|
||
def self.stop_rum_session(script_executor) | ||
config = Datadog.configuration.ci[:selenium] | ||
if is_rum_active?(script_executor) | ||
Datadog::CI.active_test&.set_tag( | ||
CI::Ext::Test::TAG_IS_RUM_ACTIVE, | ||
"true" | ||
) | ||
|
||
result = script_executor.execute_script(Ext::RUM::SCRIPT_STOP_RUM_SESSION) | ||
Datadog.logger.debug { "[RUM] SCRIPT_STOP_RUM_SESSION result is #{result.inspect}" } | ||
|
||
# introduce a delay to allow the RUM session to be stopped | ||
delay = config[:rum_flush_wait_millis] / 1000.0 | ||
Datadog.logger.debug { "[RUM] Waiting for #{delay} seconds" } | ||
sleep(delay) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Datadog | ||
module CI | ||
module Ext | ||
module RUM | ||
ENV_RUM_FLUSH_WAIT_MILLIS: "DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS" | ||
|
||
COOKIE_TEST_EXECUTION_ID: "datadog-ci-visibility-test-execution-id" | ||
|
||
SCRIPT_IS_RUM_ACTIVE: String | ||
SCRIPT_STOP_RUM_SESSION: String | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Datadog | ||
module CI | ||
module Utils | ||
module RUM | ||
def self.is_rum_active?: (untyped script_executor) -> bool | ||
|
||
def self.stop_rum_session: (untyped script_executor) -> void | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters