@@ -94,6 +94,83 @@ describe('convertTraceToRUM', () => {
94
94
expect ( embeddedSpan . spans [ 0 ] ! . duration ) . toBe ( 50 ) // 50.499 rounded
95
95
expect ( embeddedSpan . spans [ 1 ] ! . startOffset ) . toBe ( 200 ) // 200.001 rounded
96
96
expect ( embeddedSpan . spans [ 1 ] ! . duration ) . toBe ( 51 ) // 50.999 rounded
97
+
98
+ expect ( result . nonEmbeddedSpans ) . toEqual ( [ ] )
99
+ }
100
+ } )
101
+
102
+ it ( 'should return correct non embedded spans' , ( ) => {
103
+ const definition : CompleteTraceDefinition <
104
+ 'ticket' ,
105
+ TicketIdRelationSchemasFixture ,
106
+ 'origin'
107
+ > = {
108
+ name : 'test-trace' ,
109
+ relationSchemaName : 'ticket' ,
110
+ relationSchema : { ticketId : String } ,
111
+ requiredSpans : [ ( ) => true ] ,
112
+ computedSpanDefinitions : { } ,
113
+ computedValueDefinitions : { } ,
114
+ variants : {
115
+ origin : { timeout : 45_000 } ,
116
+ } ,
117
+ }
118
+
119
+ const input : ActiveTraceInput <
120
+ MapTypesToSchema < TicketIdRelationSchemasFixture [ 'ticket' ] > ,
121
+ 'origin'
122
+ > = {
123
+ id : 'test' ,
124
+ startTime : createTimestamp ( 0 ) ,
125
+ relatedTo : { ticketId : '74' } ,
126
+ variant : 'origin' ,
127
+ }
128
+
129
+ const recordedItems = new Set ( [
130
+ createMockSpanAndAnnotation ( 100.501 , {
131
+ name : 'test-component' ,
132
+ type : 'component-render' ,
133
+ relatedTo : { } ,
134
+ duration : 50.499 ,
135
+ isIdle : false ,
136
+ renderCount : 1 ,
137
+ renderedOutput : 'loading' ,
138
+ } ) ,
139
+ createMockSpanAndAnnotation (
140
+ 200.001 ,
141
+ {
142
+ name : 'test-component' ,
143
+ type : 'component-render' ,
144
+ relatedTo : { } ,
145
+ duration : 50.999 ,
146
+ isIdle : true ,
147
+ renderCount : 2 ,
148
+ renderedOutput : 'content' ,
149
+ } ,
150
+ { occurrence : 2 } ,
151
+ ) ,
152
+ ] )
153
+ const traceRecording = createTraceRecording (
154
+ {
155
+ definition,
156
+ input,
157
+ recordedItemsByLabel : { } ,
158
+ recordedItems,
159
+ } ,
160
+ { transitionFromState : 'active' } ,
161
+ )
162
+
163
+ const context = {
164
+ definition,
165
+ input,
166
+ recordedItemsByLabel : { } ,
167
+ recordedItems,
97
168
}
169
+
170
+ // we dont want to return any embedded spans
171
+ const result = convertTraceToRUM ( traceRecording , context , ( ) => false )
172
+ expect ( Object . keys ( result . embeddedSpans ) ) . toHaveLength ( 0 )
173
+ expect ( result . nonEmbeddedSpans ) . toEqual ( [ 'component-render|test-component' ] )
174
+ expect ( result . nonEmbeddedSpans ) . toHaveLength ( 1 )
98
175
} )
99
176
} )
0 commit comments