1- import { ExperimentalFeature , Observable , addExperimentalFeatures } from '@datadog/browser-core'
2- import { resetExperimentalFeatures } from '@datadog/browser-core/src/tools/experimentalFeatures'
1+ import { Observable } from '@datadog/browser-core'
32import type { FlushEvent } from '@datadog/browser-core/src/transport/flushController'
43import { registerCleanupTask } from '@datadog/browser-core/test'
54import type { AssembledRumEvent } from '../rawRumEvent.types'
@@ -215,11 +214,6 @@ describe('computeAssembledViewDiff', () => {
215214} )
216215
217216describe ( 'startRumBatch partial_view_updates routing' , ( ) => {
218- beforeEach ( ( ) => {
219- addExperimentalFeatures ( [ ExperimentalFeature . PARTIAL_VIEW_UPDATES ] )
220- registerCleanupTask ( resetExperimentalFeatures )
221- } )
222-
223217 it ( 'PARTIAL_VIEW_UPDATE_CHECKPOINT_INTERVAL should be 100' , ( ) => {
224218 expect ( PARTIAL_VIEW_UPDATE_CHECKPOINT_INTERVAL ) . toBe ( 100 )
225219 } )
@@ -288,13 +282,10 @@ function makeView(viewId: string, docVersion: number, overrides: Record<string,
288282// ---------------------------------------------------------------------------
289283
290284describe ( 'createBatchDispatcher' , ( ) => {
291- describe ( 'feature flag OFF ' , ( ) => {
285+ describe ( 'feature disabled ' , ( ) => {
292286 it ( 'should upsert full VIEW events (legacy behaviour)' , ( ) => {
293- resetExperimentalFeatures ( )
294- registerCleanupTask ( resetExperimentalFeatures )
295-
296287 const { batch, upsertSpy } = createMockBatch ( )
297- const { dispatch } = createBatchDispatcher ( batch )
288+ const { dispatch } = createBatchDispatcher ( batch , false )
298289
299290 const v1 = makeView ( 'view-1' , 1 )
300291 const v2 = makeView ( 'view-1' , 2 )
@@ -308,14 +299,9 @@ describe('createBatchDispatcher', () => {
308299 } )
309300
310301 describe ( 'non-view events' , ( ) => {
311- beforeEach ( ( ) => {
312- addExperimentalFeatures ( [ ExperimentalFeature . PARTIAL_VIEW_UPDATES ] )
313- registerCleanupTask ( resetExperimentalFeatures )
314- } )
315-
316302 it ( 'should always append non-view events' , ( ) => {
317303 const { batch, addSpy, upsertSpy } = createMockBatch ( )
318- const { dispatch } = createBatchDispatcher ( batch )
304+ const { dispatch } = createBatchDispatcher ( batch , true )
319305
320306 const action = { type : RumEventType . ACTION } as unknown as AssembledRumEvent
321307 dispatch ( action )
@@ -326,14 +312,9 @@ describe('createBatchDispatcher', () => {
326312 } )
327313
328314 describe ( 'optimization 1 — VIEW already in batch' , ( ) => {
329- beforeEach ( ( ) => {
330- addExperimentalFeatures ( [ ExperimentalFeature . PARTIAL_VIEW_UPDATES ] )
331- registerCleanupTask ( resetExperimentalFeatures )
332- } )
333-
334315 it ( 'should upsert the latest full VIEW for every intermediate update' , ( ) => {
335316 const { batch, upsertSpy } = createMockBatch ( )
336- const { dispatch } = createBatchDispatcher ( batch )
317+ const { dispatch } = createBatchDispatcher ( batch , true )
337318
338319 const v1 = makeView ( 'view-1' , 1 )
339320 const v2 = makeView ( 'view-1' , 2 , {
@@ -363,7 +344,7 @@ describe('createBatchDispatcher', () => {
363344
364345 it ( 'should not emit any view_update events while the VIEW is in the batch' , ( ) => {
365346 const { batch, upsertSpy } = createMockBatch ( )
366- const { dispatch } = createBatchDispatcher ( batch )
347+ const { dispatch } = createBatchDispatcher ( batch , true )
367348
368349 dispatch ( makeView ( 'view-1' , 1 ) )
369350 dispatch ( makeView ( 'view-1' , 2 ) )
@@ -375,14 +356,9 @@ describe('createBatchDispatcher', () => {
375356 } )
376357
377358 describe ( 'optimization 2 — no VIEW in batch (post-flush)' , ( ) => {
378- beforeEach ( ( ) => {
379- addExperimentalFeatures ( [ ExperimentalFeature . PARTIAL_VIEW_UPDATES ] )
380- registerCleanupTask ( resetExperimentalFeatures )
381- } )
382-
383359 it ( 'should upsert an aggregate view_update after a flush' , ( ) => {
384360 const { batch, upsertSpy, flush } = createMockBatch ( )
385- const { dispatch } = createBatchDispatcher ( batch )
361+ const { dispatch } = createBatchDispatcher ( batch , true )
386362
387363 dispatch ( makeView ( 'view-1' , 1 ) )
388364 flush ( ) // batchHasFullView resets; batchBase = v1
@@ -412,7 +388,7 @@ describe('createBatchDispatcher', () => {
412388
413389 it ( 'should aggregate multiple updates into a single view_update per batch' , ( ) => {
414390 const { batch, upsertSpy, flush } = createMockBatch ( )
415- const { dispatch } = createBatchDispatcher ( batch )
391+ const { dispatch } = createBatchDispatcher ( batch , true )
416392
417393 dispatch ( makeView ( 'view-1' , 1 ) )
418394 flush ( )
@@ -449,7 +425,7 @@ describe('createBatchDispatcher', () => {
449425
450426 it ( 'should compute the diff from batchBase, not from the previous intermediate update' , ( ) => {
451427 const { batch, upsertSpy, flush } = createMockBatch ( )
452- const { dispatch } = createBatchDispatcher ( batch )
428+ const { dispatch } = createBatchDispatcher ( batch , true )
453429
454430 // Initial view with action.count = 0
455431 dispatch ( makeView ( 'view-1' , 1 ) )
@@ -496,7 +472,7 @@ describe('createBatchDispatcher', () => {
496472
497473 it ( 'should emit nothing if nothing changed since batchBase' , ( ) => {
498474 const { batch, upsertSpy, flush } = createMockBatch ( )
499- const { dispatch } = createBatchDispatcher ( batch )
475+ const { dispatch } = createBatchDispatcher ( batch , true )
500476
501477 const v1 = makeView ( 'view-1' , 1 )
502478 dispatch ( v1 )
@@ -513,14 +489,9 @@ describe('createBatchDispatcher', () => {
513489 } )
514490
515491 describe ( 'checkpoint' , ( ) => {
516- beforeEach ( ( ) => {
517- addExperimentalFeatures ( [ ExperimentalFeature . PARTIAL_VIEW_UPDATES ] )
518- registerCleanupTask ( resetExperimentalFeatures )
519- } )
520-
521492 it ( 'should send a full VIEW after PARTIAL_VIEW_UPDATE_CHECKPOINT_INTERVAL intermediate updates' , ( ) => {
522493 const { batch, upsertSpy, flush } = createMockBatch ( )
523- const { dispatch } = createBatchDispatcher ( batch )
494+ const { dispatch } = createBatchDispatcher ( batch , true )
524495
525496 dispatch ( makeView ( 'view-1' , 1 ) )
526497 flush ( )
@@ -553,14 +524,9 @@ describe('createBatchDispatcher', () => {
553524 } )
554525
555526 describe ( 'view lifecycle' , ( ) => {
556- beforeEach ( ( ) => {
557- addExperimentalFeatures ( [ ExperimentalFeature . PARTIAL_VIEW_UPDATES ] )
558- registerCleanupTask ( resetExperimentalFeatures )
559- } )
560-
561527 it ( 'should send a full VIEW when a new view starts' , ( ) => {
562528 const { batch, upsertSpy } = createMockBatch ( )
563- const { dispatch } = createBatchDispatcher ( batch )
529+ const { dispatch } = createBatchDispatcher ( batch , true )
564530
565531 dispatch ( makeView ( 'view-1' , 1 ) )
566532 dispatch ( makeView ( 'view-2' , 1 ) ) // new view
@@ -574,7 +540,7 @@ describe('createBatchDispatcher', () => {
574540
575541 it ( 'should send a full VIEW when the view ends' , ( ) => {
576542 const { batch, upsertSpy, flush } = createMockBatch ( )
577- const { dispatch } = createBatchDispatcher ( batch )
543+ const { dispatch } = createBatchDispatcher ( batch , true )
578544
579545 dispatch ( makeView ( 'view-1' , 1 ) )
580546 flush ( )
@@ -603,7 +569,7 @@ describe('createBatchDispatcher', () => {
603569
604570 it ( 'should upsert a stale view-end without resetting state for the current view' , ( ) => {
605571 const { batch, upsertSpy, flush } = createMockBatch ( )
606- const { dispatch } = createBatchDispatcher ( batch )
572+ const { dispatch } = createBatchDispatcher ( batch , true )
607573
608574 // view-1 starts and flushes
609575 dispatch ( makeView ( 'view-1' , 1 ) )
@@ -655,7 +621,7 @@ describe('createBatchDispatcher', () => {
655621
656622 it ( 'should reset to opt-1 after a new view starts following a flush' , ( ) => {
657623 const { batch, upsertSpy, flush } = createMockBatch ( )
658- const { dispatch } = createBatchDispatcher ( batch )
624+ const { dispatch } = createBatchDispatcher ( batch , true )
659625
660626 dispatch ( makeView ( 'view-1' , 1 ) )
661627 flush ( )
0 commit comments