diff --git a/test/browser/features/lib/browser.rb b/test/browser/features/lib/browser.rb index 929d871c3..aa71d1031 100644 --- a/test/browser/features/lib/browser.rb +++ b/test/browser/features/lib/browser.rb @@ -15,6 +15,8 @@ def initialize(browser_spec) end end + attr_reader :name, :version + # is this a mobile device? # we assume that android devices are always using the latest version of chrome def mobile? diff --git a/test/browser/features/resource-load-spans.feature b/test/browser/features/resource-load-spans.feature index 05be4a909..247376d65 100644 --- a/test/browser/features/resource-load-spans.feature +++ b/test/browser/features/resource-load-spans.feature @@ -12,19 +12,32 @@ 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 patchy browser coverage + And on Chrome versions >= 109: + """ + the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.status_code" equals 200 + """ + + # Actually Safari 16.4 but our test devices currently use 16.3, this can be dropped to 16 when the devices update + And on Chrome versions >= 54, Android versions >= 54, Safari versions >= 17, iOS versions >= 17, Firefox versions >= 45, Edge versions >= 17: + """ + the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length" equals 2202 + the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length_uncompressed" equals 2202 + """ + @skip_on_npm_build @requires_resource_load_spans Scenario: Resource load spans are automatically instrumented (CDN build) @@ -55,3 +68,16 @@ Feature: Resource Load Spans And the trace payload field "resourceSpans.0.scopeSpans.0.spans.2" string attribute "bugsnag.span.category" equals "resource_load" And the trace payload field "resourceSpans.0.scopeSpans.0.spans.2" 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.2" string attribute "http.flavor" equals "1.1" + + # Image status code and body size have patchy browser coverage + And on Chrome versions >= 109: + """ + the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.status_code" equals 200 + """ + + # Actually Safari 16.4 but our test devices currently use 16.3, this can be dropped to 16 when the devices update + And on Chrome versions >= 54, Android versions >= 54, Safari versions >= 17, iOS versions >= 17, Firefox versions >= 45, Edge versions >= 17: + """ + the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length" equals 2202 + the trace payload field "resourceSpans.0.scopeSpans.0.spans.1" integer attribute "http.response_content_length_uncompressed" equals 2202 + """ diff --git a/test/browser/features/steps/browser-steps.rb b/test/browser/features/steps/browser-steps.rb index ae8a254be..a5a192fc7 100644 --- a/test/browser/features/steps/browser-steps.rb +++ b/test/browser/features/steps/browser-steps.rb @@ -207,6 +207,43 @@ 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(/^on ((?:[A-Za-z]+ versions (?:>=?|<=?|==) [0-9.]+(?:, )?)+):$/) do |browser_specs, steps_to_run| + spec_matcher = /^([A-Za-z]+) versions (>=?|<=?|==) ([0-9.]+)$/ + run_steps = false + + browser_specs.split(", ").each do |browser_spec| + browser_spec.scan(spec_matcher) do |name, operator, version| + should_run_steps = $browser.name.casecmp?(name) && $browser.version.send(operator, version.to_i) + + # make sure this step is debuggable! + $logger.debug("#{$browser.name} == #{name} && v#{$browser.version} #{operator} #{version}? #{should_run_steps}") + + if should_run_steps + run_steps = true + end + end + end + + if run_steps + steps_to_run.each_line(chomp: true) do |step_to_run| + step(step_to_run) + end + else + indent = " " * 4 + # e.g. "a step\nanother step\n" -> " 1) a step\n 2) another step" + steps_indented = steps_to_run.each_line.map.with_index(1) { |step, i| "#{indent}#{i}) #{step.chomp}" }.join("\n") + + $logger.info("Skipping steps on #{$browser.name} v#{$browser.version}:\n#{steps_indented}") + end +end + module Maze module Driver class Browser diff --git a/test/browser/features/support/requires-performance-body-size.rb b/test/browser/features/support/requires-performance-body-size.rb deleted file mode 100644 index 92b44ed7d..000000000 --- a/test/browser/features/support/requires-performance-body-size.rb +++ /dev/null @@ -1,4 +0,0 @@ -Before("@requires_performance_body_size") do - skip_this_scenario unless $browser.supports_performance_body_size? -end - \ No newline at end of file diff --git a/test/browser/features/support/requires-performance-response-status.rb b/test/browser/features/support/requires-performance-response-status.rb deleted file mode 100644 index ea9787365..000000000 --- a/test/browser/features/support/requires-performance-response-status.rb +++ /dev/null @@ -1,4 +0,0 @@ -Before("@requires_performance_response_status") do - skip_this_scenario unless $browser.supports_performance_response_status? -end - \ No newline at end of file