Skip to content

Commit 0ed3ae6

Browse files
committed
test: ✅ add a step for optional attribute values
1 parent 059fe5e commit 0ed3ae6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ Feature: Resource Load Spans
1212
Then the trace payload field "resourceSpans.0.scopeSpans.0.spans.2.name" equals "[Custom]/resource-load-spans"
1313
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.2.spanId" is stored as the value "parent_span_id"
1414

15-
# App bundle
15+
# App bundle resource load
1616
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.name" matches the regex "^\[ResourceLoad\]http:\/\/.*:[0-9]{4}\/resource-load-spans\/dist\/bundle\.js$"
1717
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.parentSpanId" equals the stored value "parent_span_id"
1818
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "bugsnag.span.category" equals "resource_load"
1919
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "http.flavor" equals "1.1"
2020

21-
# Image
21+
# Image resource load
2222
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1.name" matches the regex "^\[ResourceLoad\]http:\/\/.*:[0-9]{4}\/favicon.png$"
2323
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1.parentSpanId" equals the stored value "parent_span_id"
2424
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" string attribute "bugsnag.span.category" equals "resource_load"
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"
27-
27+
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

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +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)
189+
end
190+
end
191+
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
194+
end
195+
185196
module Maze
186197
module Driver
187198
class Browser

0 commit comments

Comments
 (0)