Skip to content

Commit

Permalink
test(feedback): validate envelope contents for a feedback envelope in…
Browse files Browse the repository at this point in the history
… ui test
  • Loading branch information
armcknight committed Dec 20, 2024
1 parent 4b88e4b commit 3170b09
Show file tree
Hide file tree
Showing 9 changed files with 430 additions and 252 deletions.
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 @@ -113,10 +113,10 @@ extension AppDelegate {
options.enableCrashHandler = enableCrashHandling
options.enableTracing = enableTracing
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 @@ extension AppDelegate {
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 @@ extension AppDelegate {

/// - 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 @@ extension AppDelegate {

// 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

0 comments on commit 3170b09

Please sign in to comment.