@@ -3,20 +3,13 @@ package io.sentry.react
3
3
import android.content.pm.PackageInfo
4
4
import android.content.pm.PackageManager
5
5
import com.facebook.react.bridge.Arguments
6
- import com.facebook.react.bridge.JavaOnlyMap
7
6
import com.facebook.react.bridge.Promise
8
7
import com.facebook.react.bridge.ReactApplicationContext
9
8
import com.facebook.react.bridge.WritableMap
10
- import com.facebook.react.common.JavascriptException
11
- import io.sentry.Breadcrumb
12
9
import io.sentry.ILogger
13
10
import io.sentry.SentryLevel
14
- import io.sentry.android.core.SentryAndroidOptions
15
11
import org.junit.After
16
12
import org.junit.Assert.assertEquals
17
- import org.junit.Assert.assertFalse
18
- import org.junit.Assert.assertNull
19
- import org.junit.Assert.assertTrue
20
13
import org.junit.Before
21
14
import org.junit.Test
22
15
import org.junit.runner.RunWith
@@ -103,163 +96,4 @@ class RNSentryModuleImplTest {
103
96
val capturedMap = writableMapCaptor.value
104
97
assertEquals(false , capturedMap.getBoolean(" has_fetched" ))
105
98
}
106
-
107
- @Test
108
- fun `when the spotlight option is enabled, the spotlight SentryAndroidOption is set to true and the default url is used` () {
109
- val options =
110
- JavaOnlyMap .of(
111
- " spotlight" ,
112
- true ,
113
- " defaultSidecarUrl" ,
114
- " http://localhost:8969/teststream" ,
115
- )
116
- val actualOptions = SentryAndroidOptions ()
117
- module.getSentryAndroidOptions(actualOptions, options, logger)
118
- assert (actualOptions.isEnableSpotlight)
119
- assertEquals(" http://localhost:8969/teststream" , actualOptions.spotlightConnectionUrl)
120
- }
121
-
122
- @Test
123
- fun `when the spotlight url is passed, the spotlight is enabled for the given url` () {
124
- val options = JavaOnlyMap .of(" spotlight" , " http://localhost:8969/teststream" )
125
- val actualOptions = SentryAndroidOptions ()
126
- module.getSentryAndroidOptions(actualOptions, options, logger)
127
- assert (actualOptions.isEnableSpotlight)
128
- assertEquals(" http://localhost:8969/teststream" , actualOptions.spotlightConnectionUrl)
129
- }
130
-
131
- @Test
132
- fun `when the spotlight option is disabled, the spotlight SentryAndroidOption is set to false` () {
133
- val options = JavaOnlyMap .of(" spotlight" , false )
134
- val actualOptions = SentryAndroidOptions ()
135
- module.getSentryAndroidOptions(actualOptions, options, logger)
136
- assertFalse(actualOptions.isEnableSpotlight)
137
- }
138
-
139
- @Test
140
- fun `the JavascriptException is added to the ignoredExceptionsForType list on initialisation` () {
141
- val actualOptions = SentryAndroidOptions ()
142
- module.getSentryAndroidOptions(actualOptions, JavaOnlyMap .of(), logger)
143
- assertTrue(actualOptions.ignoredExceptionsForType.contains(JavascriptException ::class .java))
144
- }
145
-
146
- @Test
147
- fun `beforeBreadcrumb callback filters out Sentry DSN requests breadcrumbs` () {
148
- val options = SentryAndroidOptions ()
149
- val rnOptions =
150
- JavaOnlyMap .of(
151
- " dsn" ,
152
- " https://abc@def.ingest.sentry.io/1234567" ,
153
- " devServerUrl" ,
154
- " http://localhost:8081" ,
155
- )
156
- module.getSentryAndroidOptions(options, rnOptions, logger)
157
-
158
- val breadcrumb =
159
- Breadcrumb ().apply {
160
- type = " http"
161
- setData(" url" , " https://def.ingest.sentry.io/1234567" )
162
- }
163
-
164
- val result = options.beforeBreadcrumb?.execute(breadcrumb, mock())
165
-
166
- assertNull(" Breadcrumb should be filtered out" , result)
167
- }
168
-
169
- @Test
170
- fun `beforeBreadcrumb callback filters out dev server breadcrumbs` () {
171
- val mockDevServerUrl = " http://localhost:8081"
172
- val options = SentryAndroidOptions ()
173
- val rnOptions =
174
- JavaOnlyMap .of(
175
- " dsn" ,
176
- " https://abc@def.ingest.sentry.io/1234567" ,
177
- " devServerUrl" ,
178
- mockDevServerUrl,
179
- )
180
- module.getSentryAndroidOptions(options, rnOptions, logger)
181
-
182
- val breadcrumb =
183
- Breadcrumb ().apply {
184
- type = " http"
185
- setData(" url" , mockDevServerUrl)
186
- }
187
-
188
- val result = options.beforeBreadcrumb?.execute(breadcrumb, mock())
189
-
190
- assertNull(" Breadcrumb should be filtered out" , result)
191
- }
192
-
193
- @Test
194
- fun `beforeBreadcrumb callback does not filter out non dev server or dsn breadcrumbs` () {
195
- val options = SentryAndroidOptions ()
196
- val rnOptions =
197
- JavaOnlyMap .of(
198
- " dsn" ,
199
- " https://abc@def.ingest.sentry.io/1234567" ,
200
- " devServerUrl" ,
201
- " http://localhost:8081" ,
202
- )
203
- module.getSentryAndroidOptions(options, rnOptions, logger)
204
-
205
- val breadcrumb =
206
- Breadcrumb ().apply {
207
- type = " http"
208
- setData(" url" , " http://testurl.com/service" )
209
- }
210
-
211
- val result = options.beforeBreadcrumb?.execute(breadcrumb, mock())
212
-
213
- assertEquals(breadcrumb, result)
214
- }
215
-
216
- @Test
217
- fun `the breadcrumb is not filtered out when the dev server url and dsn are not passed` () {
218
- val options = SentryAndroidOptions ()
219
- module.getSentryAndroidOptions(options, JavaOnlyMap (), logger)
220
-
221
- val breadcrumb =
222
- Breadcrumb ().apply {
223
- type = " http"
224
- setData(" url" , " http://testurl.com/service" )
225
- }
226
-
227
- val result = options.beforeBreadcrumb?.execute(breadcrumb, mock())
228
-
229
- assertEquals(breadcrumb, result)
230
- }
231
-
232
- @Test
233
- fun `the breadcrumb is not filtered out when the dev server url is not passed and the dsn does not match` () {
234
- val options = SentryAndroidOptions ()
235
- val rnOptions = JavaOnlyMap .of(" dsn" , " https://abc@def.ingest.sentry.io/1234567" )
236
- module.getSentryAndroidOptions(options, rnOptions, logger)
237
-
238
- val breadcrumb =
239
- Breadcrumb ().apply {
240
- type = " http"
241
- setData(" url" , " http://testurl.com/service" )
242
- }
243
-
244
- val result = options.beforeBreadcrumb?.execute(breadcrumb, mock())
245
-
246
- assertEquals(breadcrumb, result)
247
- }
248
-
249
- @Test
250
- fun `the breadcrumb is not filtered out when the dev server url does not match and the dsn is not passed` () {
251
- val options = SentryAndroidOptions ()
252
- val rnOptions = JavaOnlyMap .of(" devServerUrl" , " http://localhost:8081" )
253
- module.getSentryAndroidOptions(options, rnOptions, logger)
254
-
255
- val breadcrumb =
256
- Breadcrumb ().apply {
257
- type = " http"
258
- setData(" url" , " http://testurl.com/service" )
259
- }
260
-
261
- val result = options.beforeBreadcrumb?.execute(breadcrumb, mock())
262
-
263
- assertEquals(breadcrumb, result)
264
- }
265
99
}
0 commit comments