Skip to content

Commit 86fe974

Browse files
committed
test: ✅ add a step for optional attribute values
1 parent 813dfda commit 86fe974

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
@@ -194,6 +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)
201+
end
202+
end
203+
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
206+
end
207+
197208
module Maze
198209
module Driver
199210
class Browser

0 commit comments

Comments
 (0)