@@ -120,6 +120,7 @@ describe('Angular Tracing', () => {
120
120
121
121
expect ( transaction . setName ) . toHaveBeenCalledTimes ( 0 ) ;
122
122
expect ( transaction . name ) . toEqual ( url ) ;
123
+ expect ( transaction . metadata . source ) . toBe ( 'custom' ) ;
123
124
124
125
env . destroy ( ) ;
125
126
} ) ;
@@ -167,9 +168,6 @@ describe('Angular Tracing', () => {
167
168
[
168
169
'handles the root URL correctly' ,
169
170
'/' ,
170
- {
171
- root : { firstChild : { routeConfig : null } } ,
172
- } ,
173
171
'/' ,
174
172
[
175
173
{
@@ -181,9 +179,6 @@ describe('Angular Tracing', () => {
181
179
[
182
180
'does not alter static routes' ,
183
181
'/books' ,
184
- {
185
- root : { firstChild : { routeConfig : { path : 'books' } } } ,
186
- } ,
187
182
'/books/' ,
188
183
[
189
184
{
@@ -195,9 +190,6 @@ describe('Angular Tracing', () => {
195
190
[
196
191
'parameterizes IDs in the URL' ,
197
192
'/books/1/details' ,
198
- {
199
- root : { firstChild : { routeConfig : { path : 'books/:bookId/details' } } } ,
200
- } ,
201
193
'/books/:bookId/details/' ,
202
194
[
203
195
{
@@ -209,9 +201,6 @@ describe('Angular Tracing', () => {
209
201
[
210
202
'parameterizes multiple IDs in the URL' ,
211
203
'/org/sentry/projects/1234/events/04bc6846-4a1e-4af5-984a-003258f33e31' ,
212
- {
213
- root : { firstChild : { routeConfig : { path : 'org/:orgId/projects/:projId/events/:eventId' } } } ,
214
- } ,
215
204
'/org/:orgId/projects/:projId/events/:eventId/' ,
216
205
[
217
206
{
@@ -223,17 +212,6 @@ describe('Angular Tracing', () => {
223
212
[
224
213
'parameterizes URLs from route with child routes' ,
225
214
'/org/sentry/projects/1234/events/04bc6846-4a1e-4af5-984a-003258f33e31' ,
226
- {
227
- root : {
228
- firstChild : {
229
- routeConfig : { path : 'org/:orgId' } ,
230
- firstChild : {
231
- routeConfig : { path : 'projects/:projId' } ,
232
- firstChild : { routeConfig : { path : 'events/:eventId' } } ,
233
- } ,
234
- } ,
235
- } ,
236
- } ,
237
215
'/org/:orgId/projects/:projId/events/:eventId/' ,
238
216
[
239
217
{
@@ -254,15 +232,15 @@ describe('Angular Tracing', () => {
254
232
} ,
255
233
] ,
256
234
] ,
257
- ] ) ( '%s and sets the source to `route`' , async ( _ , url , routerState , result , routes ) => {
235
+ ] ) ( '%s and sets the source to `route`' , async ( _ , url , result , routes ) => {
258
236
const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
259
237
const env = await TestEnv . setup ( {
260
238
customStartTransaction,
261
239
routes,
262
240
startTransactionOnPageLoad : false ,
263
241
} ) ;
264
242
265
- await env . navigateInAngular ( url , routerState ) ;
243
+ await env . navigateInAngular ( url ) ;
266
244
267
245
expect ( customStartTransaction ) . toHaveBeenCalledWith ( {
268
246
name : url ,
@@ -304,6 +282,32 @@ describe('Angular Tracing', () => {
304
282
env . destroy ( ) ;
305
283
} ) ;
306
284
285
+ it ( 'should use component name as span description' , async ( ) => {
286
+ const directive = new TraceDirective ( ) ;
287
+ const finishMock = jest . fn ( ) ;
288
+ const customStartTransaction = jest . fn ( defaultStartTransaction ) ;
289
+
290
+ const env = await TestEnv . setup ( {
291
+ components : [ TraceDirective ] ,
292
+ customStartTransaction,
293
+ useTraceService : false ,
294
+ } ) ;
295
+
296
+ transaction . startChild = jest . fn ( ( ) => ( {
297
+ finish : finishMock ,
298
+ } ) ) ;
299
+
300
+ directive . componentName = 'test-component' ;
301
+ directive . ngOnInit ( ) ;
302
+
303
+ expect ( transaction . startChild ) . toHaveBeenCalledWith ( {
304
+ op : 'ui.angular.init' ,
305
+ description : '<test-component>' ,
306
+ } ) ;
307
+
308
+ env . destroy ( ) ;
309
+ } ) ;
310
+
307
311
it ( 'should finish tracingSpan after view init' , async ( ) => {
308
312
const directive = new TraceDirective ( ) ;
309
313
const finishMock = jest . fn ( ) ;
0 commit comments