@@ -234,6 +234,68 @@ sentryTest('captures a "POOR" CLS vital with its source as a standalone span.',
234
234
} ) ;
235
235
} ) ;
236
236
237
+ sentryTest (
238
+ 'captures a 0 CLS vital as a standalone span if no layout shift occurred' ,
239
+ async ( { getLocalTestPath, page } ) => {
240
+ const spanEnvelopePromise = getMultipleSentryEnvelopeRequests < SpanEnvelope > (
241
+ page ,
242
+ 1 ,
243
+ { envelopeType : 'span' } ,
244
+ properFullEnvelopeRequestParser ,
245
+ ) ;
246
+
247
+ const url = await getLocalTestPath ( { testDir : __dirname } ) ;
248
+ await page . goto ( url ) ;
249
+
250
+ await page . waitForTimeout ( 1000 ) ;
251
+
252
+ await hidePage ( page ) ;
253
+
254
+ const spanEnvelope = ( await spanEnvelopePromise ) [ 0 ] ;
255
+
256
+ const spanEnvelopeHeaders = spanEnvelope [ 0 ] ;
257
+ const spanEnvelopeItem = spanEnvelope [ 1 ] [ 0 ] [ 1 ] ;
258
+
259
+ expect ( spanEnvelopeItem ) . toEqual ( {
260
+ data : {
261
+ 'sentry.exclusive_time' : 0 ,
262
+ 'sentry.op' : 'ui.webvital.cls' ,
263
+ 'sentry.origin' : 'auto.http.browser.cls' ,
264
+ transaction : expect . stringContaining ( 'index.html' ) ,
265
+ 'user_agent.original' : expect . stringContaining ( 'Chrome' ) ,
266
+ } ,
267
+ description : 'Layout shift' ,
268
+ exclusive_time : 0 ,
269
+ measurements : {
270
+ cls : {
271
+ unit : '' ,
272
+ value : 0 ,
273
+ } ,
274
+ } ,
275
+ op : 'ui.webvital.cls' ,
276
+ origin : 'auto.http.browser.cls' ,
277
+ parent_span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
278
+ span_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
279
+ segment_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 16 } / ) ,
280
+ start_timestamp : expect . any ( Number ) ,
281
+ timestamp : spanEnvelopeItem . start_timestamp ,
282
+ trace_id : expect . stringMatching ( / [ a - f 0 - 9 ] { 32 } / ) ,
283
+ } ) ;
284
+
285
+ expect ( spanEnvelopeHeaders ) . toEqual ( {
286
+ sent_at : expect . any ( String ) ,
287
+ trace : {
288
+ environment : 'production' ,
289
+ public_key : 'public' ,
290
+ sample_rate : '1' ,
291
+ sampled : 'true' ,
292
+ trace_id : spanEnvelopeItem . trace_id ,
293
+ // no transaction, because span source is URL
294
+ } ,
295
+ } ) ;
296
+ } ,
297
+ ) ;
298
+
237
299
sentryTest (
238
300
'captures CLS increases after the pageload span ended, when page is hidden' ,
239
301
async ( { getLocalTestPath, page } ) => {
0 commit comments