Skip to content

Commit

Permalink
Fix network breadcrumb test (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesLindsay0 authored Jul 17, 2024
1 parent 51851fb commit c667ade
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
26 changes: 13 additions & 13 deletions features/csharp/csharp_breadcrumbs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,24 @@ Feature: Csharp Breadcrumbs
Then the error is valid for the error reporting API sent by the Unity notifier
And the exception "message" equals "NetworkBreadcrumbsSuccess"

And the event "breadcrumbs.0.name" equals "UnityWebRequest succeeded"
And the event "breadcrumbs.0.type" equals "request"
And the event "breadcrumbs.0.metaData.method" equals "GET"
And the error payload field "events.0.breadcrumbs.0.metaData.url" matches the regex "^http:\/\/\S*:\d{4}(\/.*)?"
And the event "breadcrumbs.0.metaData.status" equals 200
And the event "breadcrumbs.0.metaData.urlParams.success" equals "true"
And the event "breadcrumbs.0.metaData.urlParams.redactthis" equals "[REDACTED]"
And the event "breadcrumbs.0.metaData.duration" is greater than 0
And the event "breadcrumbs.0.metaData.responseContentLength" is greater than 0

And the event "breadcrumbs.1.name" equals "UnityWebRequest succeeded"
And the event "breadcrumbs.1.type" equals "request"
And the event "breadcrumbs.1.metaData.method" equals "GET"
And the event "breadcrumbs.1.metaData.method" equals "POST"
And the error payload field "events.0.breadcrumbs.1.metaData.url" matches the regex "^http:\/\/\S*:\d{4}(\/.*)?"
And the event "breadcrumbs.1.metaData.status" equals 200
And the event "breadcrumbs.1.metaData.urlParams.success" equals "true"
And the event "breadcrumbs.1.metaData.urlParams.redactthis" equals "[REDACTED]"
And the event "breadcrumbs.1.metaData.duration" is greater than 0
And the event "breadcrumbs.1.metaData.responseContentLength" is greater than 0

And the event "breadcrumbs.2.name" equals "UnityWebRequest succeeded"
And the event "breadcrumbs.2.type" equals "request"
And the event "breadcrumbs.2.metaData.method" equals "POST"
And the error payload field "events.0.breadcrumbs.2.metaData.url" matches the regex "^http:\/\/\S*:\d{4}(\/.*)?"
And the event "breadcrumbs.2.metaData.status" equals 200
And the event "breadcrumbs.2.metaData.duration" is greater than 0
And the event "breadcrumbs.2.metaData.responseContentLength" is greater than 0
And the event "breadcrumbs.2.metaData.requestContentLength" is greater than 0
And the event "breadcrumbs.1.metaData.requestContentLength" is greater than 0


Scenario: Network breadcrumb fails
Expand All @@ -113,7 +113,7 @@ Feature: Csharp Breadcrumbs
And the event "breadcrumbs.1.type" equals "request"
And the event "breadcrumbs.1.metaData.method" equals "GET"
And the error payload field "events.0.breadcrumbs.1.metaData.url" equals "https://localhost:994/?success=false"
And the event "breadcrumbs.1.metaData.status" equals 0
And the event "breadcrumbs.1.metaData.status" has failed
And the event "breadcrumbs.1.metaData.urlParams.success" equals "false"
And the event "breadcrumbs.1.metaData.duration" is greater than 0

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using BugsnagNetworking;
using BugsnagUnity;
using UnityEngine;

public class NetworkBreadcrumbsSuccess : Scenario
Expand All @@ -11,6 +12,7 @@ public override void PrepareConfig(string apiKey, string host)
{
base.PrepareConfig(apiKey, host);
Configuration.RedactedKeys = new List<Regex> { new Regex("redactthis") };
Configuration.EnabledBreadcrumbTypes = new BugsnagUnity.Payload.BreadcrumbType[] { BugsnagUnity.Payload.BreadcrumbType.Request };
}
public override void Run()
{
Expand Down
6 changes: 6 additions & 0 deletions features/steps/unity_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ def check_error_reporting_api(notifier_name)
check_error_reporting_api notifier_name
end

Then('the event "breadcrumbs.1.metaData.status" has failed') do
status = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], 'events.0.breadcrumbs.1.metaData.status')
# 500 may be returned due to browser CORs
Maze.check.true(status == 0 || status == 500, "Expected an error status of 0 or 500 but got #{status}")
end

Then('the stack frame methods should match:') do |expected_values|
stacktrace = Maze::Helper.read_key_path(Maze::Server.errors.current[:body], 'events.0.exceptions.0.stacktrace')
expected_frame_values = expected_values.raw
Expand Down

0 comments on commit c667ade

Please sign in to comment.