Skip to content

Commit

Permalink
test: ✅ add a step for optional attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerbenw committed Jun 27, 2023
1 parent 059fe5e commit 0ed3ae6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/browser/features/resource-load-spans.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ Feature: Resource Load Spans
Then the trace payload field "resourceSpans.0.scopeSpans.0.spans.2.name" equals "[Custom]/resource-load-spans"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.2.spanId" is stored as the value "parent_span_id"

# App bundle
# App bundle resource load
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$"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0.parentSpanId" equals the stored value "parent_span_id"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "bugsnag.span.category" equals "resource_load"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.0" string attribute "http.flavor" equals "1.1"

# Image
# Image resource load
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1.name" matches the regex "^\[ResourceLoad\]http:\/\/.*:[0-9]{4}\/favicon.png$"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1.parentSpanId" equals the stored value "parent_span_id"
And the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" string attribute "bugsnag.span.category" equals "resource_load"
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
11 changes: 11 additions & 0 deletions test/browser/features/steps/browser-steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +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)
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
module Driver
class Browser
Expand Down

0 comments on commit 0ed3ae6

Please sign in to comment.