@@ -36,7 +36,7 @@ describe('Performance Monitoring > perf_logger', () => {
36
36
const IID = 'idasdfsffe' ;
37
37
const PAGE_URL = 'http://mock-page.com' ;
38
38
const APP_ID = '1:123:web:2er' ;
39
- const VISIBILITY_STATE = 3 ;
39
+ const VISIBILITY_STATE = attributeUtils . VisibilityState . UNKNOWN ;
40
40
const EFFECTIVE_CONNECTION_TYPE = 2 ;
41
41
const SERVICE_WORKER_STATUS = 3 ;
42
42
const TIME_ORIGIN = 1556512199893.9033 ;
@@ -54,6 +54,7 @@ describe('Performance Monitoring > perf_logger', () => {
54
54
Array < { message : string ; eventTime : number } > ,
55
55
void
56
56
> ;
57
+ const flushQueuedEventsStub = stub ( transportService , 'flushQueuedEvents' ) ;
57
58
let getIidStub : SinonStub < [ ] , string | undefined > ;
58
59
let clock : SinonFakeTimers ;
59
60
@@ -141,6 +142,8 @@ describe('Performance Monitoring > perf_logger', () => {
141
142
expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
142
143
EXPECTED_TRACE_MESSAGE
143
144
) ;
145
+ // Only page load traces should be immediately flushed
146
+ expect ( flushQueuedEventsStub ) . not . to . be . called ;
144
147
} ) ;
145
148
146
149
it ( 'does not log an event if cookies are disabled in the browser' , ( ) => {
@@ -182,6 +185,8 @@ describe('Performance Monitoring > perf_logger', () => {
182
185
expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
183
186
EXPECTED_TRACE_MESSAGE
184
187
) ;
188
+ // Only page load traces should be immediately flushed
189
+ expect ( flushQueuedEventsStub ) . not . to . be . called ;
185
190
} ) ;
186
191
187
192
it ( 'ascertains that the max number of custom attributes allowed is 5' , ( ) => {
@@ -207,6 +212,8 @@ describe('Performance Monitoring > perf_logger', () => {
207
212
expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
208
213
EXPECTED_TRACE_MESSAGE
209
214
) ;
215
+ // Only page load traces should be immediately flushed
216
+ expect ( flushQueuedEventsStub ) . not . to . be . called ;
210
217
} ) ;
211
218
} ) ;
212
219
@@ -222,7 +229,9 @@ describe('Performance Monitoring > perf_logger', () => {
222
229
"application_process_state":0},"trace_metric":{"name":"_wt_${ PAGE_URL } ","is_auto":true,\
223
230
"client_start_time_us":${ flooredStartTime } ,"duration_us":${ DURATION * 1000 } ,\
224
231
"counters":{"domInteractive":10000,"domContentLoadedEventEnd":20000,"loadEventEnd":10000,\
225
- "_fp":40000,"_fcp":50000,"_fid":90000}}}` ;
232
+ "_fp":40000,"_fcp":50000,"_fid":90000,"_lcp":3999,"_cls":250,"_inp":100},\
233
+ "custom_attributes":{"lcp_element":"lcp-element","cls_largestShiftTarget":"cls-element",\
234
+ "inp_interactionTarget":"inp-element"}}}` ;
226
235
stub ( initializationService , 'isPerfInitialized' ) . returns ( true ) ;
227
236
getIidStub . returns ( IID ) ;
228
237
SettingsService . getInstance ( ) . loggingEnabled = true ;
@@ -275,6 +284,11 @@ describe('Performance Monitoring > perf_logger', () => {
275
284
performanceController ,
276
285
navigationTimings ,
277
286
paintTimings ,
287
+ {
288
+ lcp : { value : 3.999 , elementAttribution : 'lcp-element' } ,
289
+ inp : { value : 0.1 , elementAttribution : 'inp-element' } ,
290
+ cls : { value : 0.250 , elementAttribution : 'cls-element' } ,
291
+ } ,
278
292
90
279
293
) ;
280
294
clock . tick ( 1 ) ;
@@ -283,6 +297,7 @@ describe('Performance Monitoring > perf_logger', () => {
283
297
expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
284
298
EXPECTED_TRACE_MESSAGE
285
299
) ;
300
+ expect ( flushQueuedEventsStub ) . to . be . called ;
286
301
} ) ;
287
302
} ) ;
288
303
0 commit comments