Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(feedback): validate envelopes #4652

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions Samples/iOS-Swift/iOS-Swift-UITests/UserFeedbackUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,21 @@ class UserFeedbackUITests: BaseUITest {
// MARK: Tests validating happy path / successful submission

func testSubmitFullyFilledForm() throws {
launchApp(args: ["--io.sentry.feedback.all-defaults"])
launchApp(args: ["--io.sentry.feedback.all-defaults", "--io.sentry.disable-everything", "--io.sentry.wipe-data", "--io.sentry.base64-attachment-data"])

widgetButton.tap()

nameField.tap()
nameField.typeText("Andrew")
let testName = "Andrew"
nameField.typeText(testName)

emailField.tap()
emailField.typeText("[email protected]")
let testContactEmail = "[email protected]"
emailField.typeText(testContactEmail)

messageTextView.tap()
messageTextView.typeText("UITest user feedback")
let testMessage = "UITest user feedback"
messageTextView.typeText(testMessage)

sendButton.tap()

Expand All @@ -135,10 +138,20 @@ class UserFeedbackUITests: BaseUITest {

XCTAssertEqual(try XCTUnwrap(messageTextView.value as? String), "", "The UITextView shouldn't have any initial text functioning as a placeholder; as UITextView has no placeholder property, the \"placeholder\" is a label on top of it.")

// TODO: go to Extras view
app.buttons["io.sentry.ui-test.button.get-feedback-envelope"].tap()
// TODO: pull contents out of text field
// TODO: validate contents
cancelButton.tap()

app.buttons["Extra"].tap()
app.buttons["io.sentry.ui-test.button.get-latest-envelope"].tap()
let marshaledDataBase64 = try XCTUnwrap(app.textFields["io.sentry.ui-test.text-field.data-marshaling.latest-envelope"].value as? String)
let data = try XCTUnwrap(Data(base64Encoded: marshaledDataBase64))
let dict = try XCTUnwrap(JSONSerialization.jsonObject(with: data) as? [String: Any])
XCTAssertEqual(try XCTUnwrap(dict["event_type"] as? String), "feedback")
XCTAssertEqual(try XCTUnwrap(dict["message"] as? String), testMessage)
XCTAssertEqual(try XCTUnwrap(dict["contact_email"] as? String), testContactEmail)
XCTAssertEqual(try XCTUnwrap(dict["source"] as? String), "widget")
XCTAssertEqual(try XCTUnwrap(dict["name"] as? String), testName)
XCTAssertNotNil(dict["event_id"])
XCTAssertEqual(try XCTUnwrap(dict["item_header_type"] as? String), "feedback")
}

func testSubmitWithOnlyRequiredFieldsFilled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@
argument = "--io.sentry.disable-everything"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-time-to-full-display-tracing"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-performance-v2"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-attach-view-hierarchy"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-attach-screenshot"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--io.sentry.base64-attachment-data"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--io.sentry.disable-http-transport"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--disable-file-io-tracing"
isEnabled = "NO">
Expand Down Expand Up @@ -240,11 +264,6 @@
value = ""
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "--io.sentry.user.name"
value = ""
isEnabled = "NO">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
Expand Down
16 changes: 10 additions & 6 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@
options.enableNetworkBreadcrumbs = enableNetworkBreadcrumbs
options.enableSwizzling = enableSwizzling
options.enableCrashHandler = enableCrashHandling
options.enableTracing = enableTracing

Check warning on line 114 in Samples/iOS-Swift/iOS-Swift/AppDelegate.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 14 (16.4) Simulator

'enableTracing' is deprecated: Use tracesSampleRate or tracesSampler instead
options.enablePersistingTracesWhenCrashing = true
options.attachScreenshot = true
options.attachViewHierarchy = true
options.enableTimeToFullDisplayTracing = true
options.enablePerformanceV2 = true
options.attachScreenshot = enableAttachScreenshot
options.attachViewHierarchy = enableAttachViewHierarchy
options.enableTimeToFullDisplayTracing = enableTimeToFullDisplayTracing
options.enablePerformanceV2 = enablePerformanceV2
options.failedRequestStatusCodes = [ HttpStatusCodeRange(min: 400, max: 599) ]

options.beforeBreadcrumb = { breadcrumb in
Expand Down Expand Up @@ -298,7 +298,7 @@
var isUITest: Bool { env["--io.sentry.sdk-environment"] == "ui-tests" }

func checkDisabled(with arg: String) -> Bool {
args.contains("--disable-everything") || args.contains(arg)
args.contains("--io.sentry.disable-everything") || args.contains(arg)
}

// MARK: features that care about simulator vs device, ui tests and profiling benchmarks
Expand All @@ -312,7 +312,7 @@

/// - note: the benchmark test starts and stops a custom transaction using a UIButton, and automatic user interaction tracing stops the transaction that begins with that button press after the idle timeout elapses, stopping the profiler (only one profiler runs regardless of the number of concurrent transactions)
var enableUITracing: Bool { !isBenchmarking && !checkDisabled(with: "--disable-ui-tracing") }
var enablePrewarmedAppStartTracing: Bool { !isBenchmarking }
var enablePrewarmedAppStartTracing: Bool { !isBenchmarking && !checkDisabled(with: "--disable-prewarmed-app-start-tracing") }
var enablePerformanceTracing: Bool { !isBenchmarking && !checkDisabled(with: "--disable-auto-performance-tracing") }
var enableTracing: Bool { !isBenchmarking && !checkDisabled(with: "--disable-tracing") }
/// - note: UI tests generate false OOMs
Expand All @@ -322,6 +322,10 @@

// MARK: Other features

var enableTimeToFullDisplayTracing: Bool { !checkDisabled(with: "--disable-time-to-full-display-tracing")}
var enableAttachScreenshot: Bool { !checkDisabled(with: "--disable-attach-screenshot")}
var enableAttachViewHierarchy: Bool { !checkDisabled(with: "--disable-attach-view-hierarchy")}
var enablePerformanceV2: Bool { !checkDisabled(with: "--disable-performance-v2")}
var enableSessionReplay: Bool { !checkDisabled(with: "--disable-session-replay") }
var enableMetricKit: Bool { !checkDisabled(with: "--disable-metrickit-integration") }
var enableSessionTracking: Bool { !checkDisabled(with: "--disable-automatic-session-tracking") }
Expand Down
Loading
Loading