@@ -36,7 +36,7 @@ describe('Performance Monitoring > perf_logger', () => {
3636 const IID = 'idasdfsffe' ;
3737 const PAGE_URL = 'http://mock-page.com' ;
3838 const APP_ID = '1:123:web:2er' ;
39- const VISIBILITY_STATE = 3 ;
39+ const VISIBILITY_STATE = attributeUtils . VisibilityState . UNKNOWN ;
4040 const EFFECTIVE_CONNECTION_TYPE = 2 ;
4141 const SERVICE_WORKER_STATUS = 3 ;
4242 const TIME_ORIGIN = 1556512199893.9033 ;
@@ -54,6 +54,7 @@ describe('Performance Monitoring > perf_logger', () => {
5454 Array < { message : string ; eventTime : number } > ,
5555 void
5656 > ;
57+ const flushQueuedEventsStub = stub ( transportService , 'flushQueuedEvents' ) ;
5758 let getIidStub : SinonStub < [ ] , string | undefined > ;
5859 let clock : SinonFakeTimers ;
5960
@@ -141,6 +142,8 @@ describe('Performance Monitoring > perf_logger', () => {
141142 expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
142143 EXPECTED_TRACE_MESSAGE
143144 ) ;
145+ // Only page load traces should be immediately flushed
146+ expect ( flushQueuedEventsStub ) . not . to . be . called ;
144147 } ) ;
145148
146149 it ( 'does not log an event if cookies are disabled in the browser' , ( ) => {
@@ -182,6 +185,8 @@ describe('Performance Monitoring > perf_logger', () => {
182185 expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
183186 EXPECTED_TRACE_MESSAGE
184187 ) ;
188+ // Only page load traces should be immediately flushed
189+ expect ( flushQueuedEventsStub ) . not . to . be . called ;
185190 } ) ;
186191
187192 it ( 'ascertains that the max number of custom attributes allowed is 5' , ( ) => {
@@ -207,6 +212,8 @@ describe('Performance Monitoring > perf_logger', () => {
207212 expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
208213 EXPECTED_TRACE_MESSAGE
209214 ) ;
215+ // Only page load traces should be immediately flushed
216+ expect ( flushQueuedEventsStub ) . not . to . be . called ;
210217 } ) ;
211218 } ) ;
212219
@@ -222,7 +229,9 @@ describe('Performance Monitoring > perf_logger', () => {
222229"application_process_state":0},"trace_metric":{"name":"_wt_${ PAGE_URL } ","is_auto":true,\
223230"client_start_time_us":${ flooredStartTime } ,"duration_us":${ DURATION * 1000 } ,\
224231"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"}}}` ;
226235 stub ( initializationService , 'isPerfInitialized' ) . returns ( true ) ;
227236 getIidStub . returns ( IID ) ;
228237 SettingsService . getInstance ( ) . loggingEnabled = true ;
@@ -275,6 +284,11 @@ describe('Performance Monitoring > perf_logger', () => {
275284 performanceController ,
276285 navigationTimings ,
277286 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+ } ,
278292 90
279293 ) ;
280294 clock . tick ( 1 ) ;
@@ -283,6 +297,7 @@ describe('Performance Monitoring > perf_logger', () => {
283297 expect ( addToQueueStub . getCall ( 0 ) . args [ 0 ] . message ) . to . be . equal (
284298 EXPECTED_TRACE_MESSAGE
285299 ) ;
300+ expect ( flushQueuedEventsStub ) . to . be . called ;
286301 } ) ;
287302 } ) ;
288303
0 commit comments