7
7
testCasesByFileName ,
8
8
BanditTestCase ,
9
9
BANDIT_TEST_DATA_DIR ,
10
+ readMockConfigurationWireResponse ,
11
+ SHARED_BOOTSTRAP_BANDIT_FLAGS_FILE ,
10
12
} from '../../test/testHelpers' ;
11
13
import ApiEndpoints from '../api-endpoints' ;
12
14
import { IAssignmentEvent , IAssignmentLogger } from '../assignment-logger' ;
@@ -19,6 +21,7 @@ import {
19
21
IConfigurationWire ,
20
22
IPrecomputedConfiguration ,
21
23
IObfuscatedPrecomputedConfigurationResponse ,
24
+ ConfigurationWireV1 ,
22
25
} from '../configuration-wire/configuration-wire-types' ;
23
26
import { Evaluator , FlagEvaluation } from '../evaluator' ;
24
27
import {
@@ -94,8 +97,8 @@ describe('EppoClient Bandits E2E test', () => {
94
97
describe ( 'Shared test cases' , ( ) => {
95
98
const testCases = testCasesByFileName < BanditTestCase > ( BANDIT_TEST_DATA_DIR ) ;
96
99
97
- it . each ( Object . keys ( testCases ) ) ( 'Shared bandit test case - %s' , async ( fileName : string ) => {
98
- const { flag : flagKey , defaultValue, subjects } = testCases [ fileName ] ;
100
+ function testBanditCaseAgainstClient ( client : EppoClient , testCase : BanditTestCase ) {
101
+ const { flag : flagKey , defaultValue, subjects } = testCase ;
99
102
let numAssignmentsChecked = 0 ;
100
103
subjects . forEach ( ( subject ) => {
101
104
// test files have actions as an array, so we convert them to a map as expected by the client
@@ -131,6 +134,35 @@ describe('EppoClient Bandits E2E test', () => {
131
134
} ) ;
132
135
// Ensure that this test case correctly checked some test assignments
133
136
expect ( numAssignmentsChecked ) . toBeGreaterThan ( 0 ) ;
137
+ }
138
+
139
+ describe ( 'bootstrapped client' , ( ) => {
140
+ const banditFlagsConfig = ConfigurationWireV1 . fromString (
141
+ readMockConfigurationWireResponse ( SHARED_BOOTSTRAP_BANDIT_FLAGS_FILE ) ,
142
+ ) ;
143
+
144
+ let client : EppoClient ;
145
+ beforeAll ( async ( ) => {
146
+ client = new EppoClient ( {
147
+ flagConfigurationStore : new MemoryOnlyConfigurationStore ( ) ,
148
+ banditVariationConfigurationStore : new MemoryOnlyConfigurationStore ( ) ,
149
+ banditModelConfigurationStore : new MemoryOnlyConfigurationStore ( ) ,
150
+ } ) ;
151
+ client . setIsGracefulFailureMode ( false ) ;
152
+
153
+ // Bootstrap using the bandit flag config.
154
+ await client . bootstrap ( banditFlagsConfig ) ;
155
+ } ) ;
156
+
157
+ it . each ( Object . keys ( testCases ) ) ( 'Shared bandit test case - %s' , async ( fileName : string ) => {
158
+ testBanditCaseAgainstClient ( client , testCases [ fileName ] ) ;
159
+ } ) ;
160
+ } ) ;
161
+
162
+ describe ( 'traditional client' , ( ) => {
163
+ it . each ( Object . keys ( testCases ) ) ( 'Shared bandit test case - %s' , async ( fileName : string ) => {
164
+ testBanditCaseAgainstClient ( client , testCases [ fileName ] ) ;
165
+ } ) ;
134
166
} ) ;
135
167
} ) ;
136
168
0 commit comments