Skip to content

Commit 1ea142e

Browse files
committed
test: ♻️ add ability to check any step for browser version before asserting on it
1 parent 86fe974 commit 1ea142e

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
@@ -194,15 +194,17 @@
194194
end
195195
end
196196

197-
def check_attribute_equal_if_present(field, attribute, attr_type, expected)
198-
actual = get_attribute_value field, attribute, attr_type
199-
if actual != nil
200-
Maze.check.equal(expected, actual)
197+
Then(/^on the (?:browser|browsers) (.*): (.+)/) do |spec, step_text|
198+
current_platform = $browser.name
199+
current_version = $browser.version
200+
201+
browsers = spec.split(",")
202+
203+
for browser in browsers do
204+
name, version = browser.split(" ")
205+
step(step_text) if current_platform.casecmp(name).zero? && current_version >= version.to_i
201206
end
202-
end
203207

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

208210
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)