@@ -1960,63 +1960,15 @@ describe('DecisionService', () => {
19601960 } ) ;
19611961 } ) ;
19621962
1963- it ( "should consider global holdout even if local holdout is present" , async ( ) => {
1964- const { decisionService } = getDecisionService ( ) ;
1965- const datafile = getHoldoutTestDatafile ( ) ;
1966- const newEntry = {
1967- id : 'holdout_included_id' ,
1968- key : 'holdout_included' ,
1969- status : 'Running' ,
1970- includedFlags : [ '1001' ] ,
1971- excludedFlags : [ ] ,
1972- audienceIds : [ '4002' ] , // age_40 audience
1973- audienceConditions : [ 'or' , '4002' ] ,
1974- variations : [
1975- {
1976- id : 'holdout_variation_included_id' ,
1977- key : 'holdout_variation_included' ,
1978- variables : [ ] ,
1979- } ,
1980- ] ,
1981- trafficAllocation : [
1982- {
1983- entityId : 'holdout_variation_included_id' ,
1984- endOfRange : 5000 ,
1985- } ,
1986- ] ,
1987- } ;
1988- datafile . holdouts = [ newEntry , ...datafile . holdouts ] ;
1989- const config = createProjectConfig ( datafile ) ;
1990- const user = new OptimizelyUserContext ( {
1991- optimizely : { } as any ,
1992- userId : 'tester' ,
1993- attributes : {
1994- age : 20 , // satisfies both global holdout (age_22) and included holdout (age_40) audiences
1995- } ,
1996- } ) ;
1997- const feature = config . featureKeyMap [ 'flag_1' ] ;
1998- const value = decisionService . resolveVariationsForFeatureList ( 'async' , config , [ feature ] , user , { } ) . get ( ) ;
1999-
2000- expect ( value ) . toBeInstanceOf ( Promise ) ;
2001-
2002- const variation = ( await value ) [ 0 ] ;
2003-
2004- expect ( variation . result ) . toEqual ( {
2005- experiment : config . holdoutIdMap && config . holdoutIdMap [ 'holdout_running_id' ] ,
2006- variation : config . variationIdMap [ 'holdout_variation_running_id' ] ,
2007- decisionSource : DECISION_SOURCES . HOLDOUT ,
2008- } ) ;
2009- } ) ;
2010-
2011- it ( "should consider local holdout if misses global holdout" , async ( ) => {
1963+ it ( "should consider next global holdout if misses previous holdouts" , async ( ) => {
20121964 const { decisionService } = getDecisionService ( ) ;
20131965 const datafile = getHoldoutTestDatafile ( ) ;
20141966
20151967 datafile . holdouts . push ( {
20161968 id : 'holdout_included_specific_id' ,
20171969 key : 'holdout_included_specific' ,
20181970 status : 'Running' ,
2019- includedFlags : [ '1001' ] ,
1971+ includedFlags : [ ] ,
20201972 excludedFlags : [ ] ,
20211973 audienceIds : [ '4002' ] , // age_60 audience (age <= 60)
20221974 audienceConditions : [ 'or' , '4002' ] ,
@@ -2039,7 +1991,7 @@ describe('DecisionService', () => {
20391991 optimizely : { } as any ,
20401992 userId : 'test_holdout_user' ,
20411993 attributes : {
2042- age : 50 , // Does not satisfy global holdout (age_22, age <= 22) but satisfies included holdout (age_60, age <= 60)
1994+ age : 50 , // Does not satisfy first global holdout (age_22, age <= 22) but satisfies newly added holdout (age_60, age <= 60)
20431995 } ,
20441996 } ) ;
20451997 const feature = config . featureKeyMap [ 'flag_1' ] ;
@@ -2195,42 +2147,6 @@ describe('DecisionService', () => {
21952147 } ) ;
21962148 } ) ;
21972149
2198- it ( 'should skip holdouts excluded for specific flags' , async ( ) => {
2199- const { decisionService } = getDecisionService ( ) ;
2200- const datafile = getHoldoutTestDatafile ( ) ;
2201-
2202- datafile . holdouts = datafile . holdouts . map ( ( holdout : any ) => {
2203- if ( holdout . id === 'holdout_running_id' ) {
2204- return {
2205- ...holdout ,
2206- excludedFlags : [ '1001' ]
2207- }
2208- }
2209- return holdout ;
2210- } ) ;
2211-
2212- const config = createProjectConfig ( datafile ) ;
2213- const user = new OptimizelyUserContext ( {
2214- optimizely : { } as any ,
2215- userId : 'tester' ,
2216- attributes : {
2217- age : 15 , // satisfies age_22 audience condition (age <= 22) for global holdout, but holdout excludes flag_1
2218- } ,
2219- } ) ;
2220- const feature = config . featureKeyMap [ 'flag_1' ] ;
2221- const value = decisionService . resolveVariationsForFeatureList ( 'async' , config , [ feature ] , user , { } ) . get ( ) ;
2222-
2223- expect ( value ) . toBeInstanceOf ( Promise ) ;
2224-
2225- const variation = ( await value ) [ 0 ] ;
2226-
2227- expect ( variation . result ) . toEqual ( {
2228- experiment : config . experimentKeyMap [ 'exp_1' ] ,
2229- variation : config . variationIdMap [ '5001' ] ,
2230- decisionSource : DECISION_SOURCES . FEATURE_TEST ,
2231- } ) ;
2232- } ) ;
2233-
22342150 it ( 'should handle multiple holdouts and use first matching one' , async ( ) => {
22352151 const { decisionService } = getDecisionService ( ) ;
22362152 const datafile = getHoldoutTestDatafile ( ) ;
0 commit comments