Skip to content

Commit

Permalink
test: ♻️ add ability to check any step for browser version before ass…
Browse files Browse the repository at this point in the history
…erting on it
  • Loading branch information
gingerbenw committed Jun 27, 2023
1 parent 0ed3ae6 commit a96a7e7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
22 changes: 22 additions & 0 deletions test/browser/features/lib/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def initialize(browser_spec)
end
end

def name
@name
end

def version
@version
end

# is this a mobile device?
# we assume that android devices are always using the latest version of chrome
def mobile?
Expand Down Expand Up @@ -63,6 +71,20 @@ def supported_web_vitals
end
end

# | browser | version |
# | chrome | 54 |
# | firefox | 45 |
# | edge | 17 |
# | safari | 16.4 |
def supports_performance_encoded_body_size?
case @name
when "safari"
@version >= 17 # we test on 16.3 - not sure what to do here?
else
true
end
end

def supports_performance_response_status?
case @name
when "chrome", "edge"
Expand Down
9 changes: 5 additions & 4 deletions test/browser/features/resource-load-spans.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ Feature: Resource Load Spans
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" string attribute "http.url" matches the regex "^http:\/\/.*:[0-9]{4}\/favicon\.png\?height=100&width=100$"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" string attribute "http.flavor" equals "1.1"

# Image status code and body size have very patchy browser coverage
And if present, the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.status_code" equals 200
And if present, the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length" equals 2202
And if present, the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length_uncompressed" equals 2202
# Image status code and body size have patchy browser coverage
And on the browsers Chrome 109: the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.status_code" equals 200

And on the browsers Chrome 73, Safari 13, Firefox 67: the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length" equals 2202
And on the browsers Chrome 73, Safari 13, Firefox 67: the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length_uncompressed" equals 2202
16 changes: 9 additions & 7 deletions test/browser/features/steps/browser-steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,17 @@
end
end

def check_attribute_equal_if_present(field, attribute, attr_type, expected)
actual = get_attribute_value field, attribute, attr_type
if actual != nil
Maze.check.equal(expected, actual)
Then(/^on the browsers (.*): (.+)/) do |spec, step_text|
current_platform = $browser.name
current_version = $browser.version

browsers = spec.split(",")

for browser in browsers do
name, version = browser.split(" ")
step(step_text) if current_platform.casecmp(name).zero? && !version || current_version >= version.to_i
end
end

Then('if present, the trace payload field {string} integer attribute {string} equals {int}') do |field, attribute, expected|
check_attribute_equal_if_present field, attribute, 'intValue', expected
end

module Maze
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit a96a7e7

Please sign in to comment.