Skip to content

Commit 9e1aebc

Browse files
committed
test: ♻️ add ability to check any step for browser version before asserting on it
1 parent 0ed3ae6 commit 9e1aebc

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

test/browser/features/lib/browser.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ def initialize(browser_spec)
1515
end
1616
end
1717

18+
def name
19+
@name
20+
end
21+
22+
def version
23+
@version
24+
end
25+
1826
# is this a mobile device?
1927
# we assume that android devices are always using the latest version of chrome
2028
def mobile?
@@ -63,6 +71,20 @@ def supported_web_vitals
6371
end
6472
end
6573

74+
# | browser | version |
75+
# | chrome | 54 |
76+
# | firefox | 45 |
77+
# | edge | 17 |
78+
# | safari | 16.4 |
79+
def supports_performance_encoded_body_size?
80+
case @name
81+
when "safari"
82+
@version >= 17 # we test on 16.3 - not sure what to do here?
83+
else
84+
true
85+
end
86+
end
87+
6688
def supports_performance_response_status?
6789
case @name
6890
when "chrome", "edge"

test/browser/features/resource-load-spans.feature

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Feature: Resource Load Spans
2525
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$"
2626
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" string attribute "http.flavor" equals "1.1"
2727

28-
# Image status code and body size have very patchy browser coverage
29-
And if present, the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.status_code" equals 200
30-
And if present, the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length" equals 2202
31-
And if present, the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length_uncompressed" equals 2202
28+
# Image status code and body size have patchy browser coverage
29+
And on the browser Chrome 109: the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.status_code" equals 200
30+
31+
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
32+
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

test/browser/features/steps/browser-steps.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,17 @@
182182
end
183183
end
184184

185-
def check_attribute_equal_if_present(field, attribute, attr_type, expected)
186-
actual = get_attribute_value field, attribute, attr_type
187-
if actual != nil
188-
Maze.check.equal(expected, actual)
185+
Then(/^on the (?:browser|browsers) (.*): (.+)/) do |spec, step_text|
186+
current_platform = $browser.name
187+
current_version = $browser.version
188+
189+
browsers = spec.split(",")
190+
191+
for browser in browsers do
192+
name, version = browser.split(" ")
193+
step(step_text) if current_platform.casecmp(name).zero? && current_version >= version.to_i
189194
end
190-
end
191195

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

196198
module Maze

test/browser/features/support/requires-performance-body-size.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/browser/features/support/requires-performance-response-status.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)