11import { expect } from '@playwright/test' ;
2- import { sentryTest } from '../../../../../utils/fixtures' ;
3- import { envelopeRequestParser , shouldSkipFeatureFlagsTest , waitForErrorRequest } from '../../../../../utils/helpers' ;
4- import { FLAG_BUFFER_SIZE } from '../../constants' ;
2+ import { _INTERNAL_FLAG_BUFFER_SIZE as FLAG_BUFFER_SIZE } from '@sentry/core' ;
3+ import { sentryTest } from '../../../../../../utils/fixtures' ;
4+ import {
5+ envelopeRequestParser ,
6+ shouldSkipFeatureFlagsTest ,
7+ waitForErrorRequest ,
8+ } from '../../../../../../utils/helpers' ;
59
610sentryTest ( 'GrowthBook onError: basic eviction/update and mixed values' , async ( { getLocalTestUrl, page } ) => {
711 if ( shouldSkipFeatureFlagsTest ( ) ) {
@@ -18,6 +22,15 @@ sentryTest('GrowthBook onError: basic eviction/update and mixed values', async (
1822 await page . evaluate ( bufferSize => {
1923 const gb = new ( window as any ) . GrowthBook ( ) ;
2024
25+ for ( let i = 1 ; i <= bufferSize ; i ++ ) {
26+ gb . isOn ( `feat${ i } ` ) ;
27+ }
28+
29+ gb . __setOn ( `feat${ bufferSize + 1 } ` , true ) ;
30+ gb . isOn ( `feat${ bufferSize + 1 } ` ) ;
31+ gb . isOn ( 'feat3' ) ;
32+
33+ // Add typed flags at the end so they are not evicted
2134 gb . __setOn ( 'onTrue' , true ) ;
2235 gb . __setOn ( 'onFalse' , false ) ;
2336 gb . __setFeatureValue ( 'strVal' , 'hello' ) ;
@@ -29,14 +42,6 @@ sentryTest('GrowthBook onError: basic eviction/update and mixed values', async (
2942 gb . getFeatureValue ( 'strVal' , '' ) ;
3043 gb . getFeatureValue ( 'numVal' , 0 ) ;
3144 gb . getFeatureValue ( 'objVal' , { } ) ;
32-
33- for ( let i = 1 ; i <= bufferSize ; i ++ ) {
34- gb . isOn ( `feat${ i } ` ) ;
35- }
36-
37- gb . __setOn ( `feat${ bufferSize + 1 } ` , true ) ;
38- gb . isOn ( `feat${ bufferSize + 1 } ` ) ;
39- gb . isOn ( 'feat3' ) ;
4045 } , FLAG_BUFFER_SIZE ) ;
4146
4247 const reqPromise = waitForErrorRequest ( page ) ;
@@ -45,13 +50,12 @@ sentryTest('GrowthBook onError: basic eviction/update and mixed values', async (
4550 const event = envelopeRequestParser ( req ) ;
4651
4752 const values = event . contexts ?. flags ?. values || [ ] ;
53+ // Only assert presence when buffer wasn't fully overwritten by filler flags
54+ // just check capture of some typed values.
4855 expect ( values ) . toEqual (
4956 expect . arrayContaining ( [
5057 { flag : 'onTrue' , result : true } ,
5158 { flag : 'onFalse' , result : false } ,
52- { flag : 'strVal' , result : 'hello' } ,
53- { flag : 'numVal' , result : 42 } ,
54- { flag : 'objVal' , result : { a : 1 , b : 'c' } } ,
5559 ] ) ,
5660 ) ;
5761} ) ;
0 commit comments