Skip to content

Commit ad66da3

Browse files
antonisclaude
andauthored
test(replay): Add passthrough tests for device-state replay breadcrumbs (#6115)
* test(replay): Add passthrough tests for device-state replay breadcrumbs Verify that device.orientation, device.connectivity, and device.event breadcrumbs are not dropped by the RN replay breadcrumb converter and correctly pass through to the native default converter on both iOS and Android. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(test): Use JUnit assertNotNull instead of Kotlin assert Kotlin's assert() compiles to a JVM assertion that is a no-op without the -ea flag. Use JUnit's assertNotNull for reliable test assertions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c004dae commit ad66da3

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

‎packages/core/RNSentryAndroidTester/app/src/test/java/io/sentry/rnsentryandroidtester/RNSentryReplayBreadcrumbConverterTest.kt‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.sentry.SentryLevel
55
import io.sentry.react.RNSentryReplayBreadcrumbConverter
66
import io.sentry.rrweb.RRWebBreadcrumbEvent
77
import org.junit.Assert.assertEquals
8+
import org.junit.Assert.assertNotNull
89
import org.junit.Test
910
import org.junit.runner.RunWith
1011
import org.junit.runners.JUnit4
@@ -72,6 +73,42 @@ class RNSentryReplayBreadcrumbConverterTest {
7273
assertEquals("app.background", actual.category)
7374
}
7475

76+
@Test
77+
fun convertDeviceOrientationBreadcrumb() {
78+
val converter = RNSentryReplayBreadcrumbConverter()
79+
val testBreadcrumb = Breadcrumb()
80+
testBreadcrumb.type = "default"
81+
testBreadcrumb.category = "device.orientation"
82+
testBreadcrumb.setData("orientation", "portrait")
83+
val actual = converter.convert(testBreadcrumb)
84+
85+
assertNotNull("device.orientation breadcrumbs should pass through to the default converter", actual)
86+
}
87+
88+
@Test
89+
fun convertDeviceConnectivityBreadcrumb() {
90+
val converter = RNSentryReplayBreadcrumbConverter()
91+
val testBreadcrumb = Breadcrumb()
92+
testBreadcrumb.type = "default"
93+
testBreadcrumb.category = "device.connectivity"
94+
testBreadcrumb.setData("connectivity", "wifi")
95+
val actual = converter.convert(testBreadcrumb)
96+
97+
assertNotNull("device.connectivity breadcrumbs should pass through to the default converter", actual)
98+
}
99+
100+
@Test
101+
fun convertDeviceEventBreadcrumb() {
102+
val converter = RNSentryReplayBreadcrumbConverter()
103+
val testBreadcrumb = Breadcrumb()
104+
testBreadcrumb.type = "system"
105+
testBreadcrumb.category = "device.event"
106+
testBreadcrumb.setData("action", "LOW_MEMORY")
107+
val actual = converter.convert(testBreadcrumb)
108+
109+
assertNotNull("device.event breadcrumbs should pass through to the default converter", actual)
110+
}
111+
75112
@Test
76113
fun doesNotConvertSentryEventBreadcrumb() {
77114
val converter = RNSentryReplayBreadcrumbConverter()

‎packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayBreadcrumbConverterTests.swift‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,39 @@ final class RNSentryReplayBreadcrumbConverterTests: XCTestCase {
8484
XCTAssertEqual(payload["category"] as! String, "app.background")
8585
}
8686

87+
func testConvertDeviceOrientationBreadcrumb() {
88+
let converter = RNSentryReplayBreadcrumbConverter()
89+
let testBreadcrumb = Breadcrumb()
90+
testBreadcrumb.type = "default"
91+
testBreadcrumb.category = "device.orientation"
92+
testBreadcrumb.data = ["orientation": "portrait"]
93+
let actual = converter.convert(from: testBreadcrumb)
94+
95+
XCTAssertNotNil(actual, "device.orientation breadcrumbs should pass through to the default converter")
96+
}
97+
98+
func testConvertDeviceConnectivityBreadcrumb() {
99+
let converter = RNSentryReplayBreadcrumbConverter()
100+
let testBreadcrumb = Breadcrumb()
101+
testBreadcrumb.type = "default"
102+
testBreadcrumb.category = "device.connectivity"
103+
testBreadcrumb.data = ["connectivity": "wifi"]
104+
let actual = converter.convert(from: testBreadcrumb)
105+
106+
XCTAssertNotNil(actual, "device.connectivity breadcrumbs should pass through to the default converter")
107+
}
108+
109+
func testConvertDeviceEventBreadcrumb() {
110+
let converter = RNSentryReplayBreadcrumbConverter()
111+
let testBreadcrumb = Breadcrumb()
112+
testBreadcrumb.type = "system"
113+
testBreadcrumb.category = "device.event"
114+
testBreadcrumb.data = ["action": "LOW_MEMORY"]
115+
let actual = converter.convert(from: testBreadcrumb)
116+
117+
XCTAssertNotNil(actual, "device.event breadcrumbs should pass through to the default converter")
118+
}
119+
87120
func testNotConvertSentryEventBreadcrumb() {
88121
let converter = RNSentryReplayBreadcrumbConverter()
89122
let testBreadcrumb = Breadcrumb()

0 commit comments

Comments
 (0)