@@ -41,8 +41,12 @@ import { ISyncStore } from '../configuration-store/configuration-store';
41
41
42
42
// Use a known salt to produce deterministic hashes
43
43
const salt = base64 . fromUint8Array ( new Uint8Array ( [ 7 , 53 , 17 , 78 ] ) ) ;
44
+ jest . mock ( '../salt' , ( ) => ( {
45
+ generateSalt : ( ) => salt ,
46
+ } ) ) ;
44
47
45
48
describe ( 'EppoClient E2E test' , ( ) => {
49
+
46
50
// Configure fetch mock for tests that still need it
47
51
global . fetch = jest . fn ( ( ) => {
48
52
const ufc = readMockUFCResponse ( MOCK_UFC_RESPONSE_FILE ) ;
@@ -254,14 +258,12 @@ describe('EppoClient E2E test', () => {
254
258
} ) ;
255
259
256
260
it ( 'skips disabled flags' , ( ) => {
257
- const encodedPrecomputedWire = client . getPrecomputedConfiguration ( 'subject' , { } , { } , salt ) ;
258
- const { precomputed } = JSON . parse ( encodedPrecomputedWire ) as IConfigurationWire ;
261
+ const configuration = client . getPrecomputedConfiguration ( 'subject' , { } , { } ) ;
262
+ const precomputed = configuration . getPrecomputedConfiguration ( ) ;
259
263
if ( ! precomputed ) {
260
264
fail ( 'Precomputed data not in Configuration response' ) ;
261
265
}
262
- const precomputedResponse = JSON . parse (
263
- precomputed . response ,
264
- ) as ObfuscatedPrecomputedConfigurationResponse ;
266
+ const precomputedResponse = precomputed . response ;
265
267
266
268
expect ( precomputedResponse ) . toBeTruthy ( ) ;
267
269
const precomputedFlags = precomputedResponse ?. flags ?? { } ;
@@ -273,14 +275,12 @@ describe('EppoClient E2E test', () => {
273
275
} ) ;
274
276
275
277
it ( 'evaluates and returns assignments' , ( ) => {
276
- const encodedPrecomputedWire = client . getPrecomputedConfiguration ( 'subject' , { } , { } , salt ) ;
277
- const { precomputed } = JSON . parse ( encodedPrecomputedWire ) as IConfigurationWire ;
278
+ const configuration = client . getPrecomputedConfiguration ( 'subject' , { } , { } ) ;
279
+ const precomputed = configuration . getPrecomputedConfiguration ( ) ;
278
280
if ( ! precomputed ) {
279
281
fail ( 'Precomputed data not in Configuration response' ) ;
280
282
}
281
- const precomputedResponse = JSON . parse (
282
- precomputed . response ,
283
- ) as IObfuscatedPrecomputedConfigurationResponse ;
283
+ const precomputedResponse = precomputed . response ;
284
284
285
285
expect ( precomputedResponse ) . toBeTruthy ( ) ;
286
286
const precomputedFlags = precomputedResponse ?. flags ?? { } ;
@@ -291,12 +291,12 @@ describe('EppoClient E2E test', () => {
291
291
} ) ;
292
292
293
293
it ( 'obfuscates assignments' , ( ) => {
294
- const encodedPrecomputedWire = client . getPrecomputedConfiguration ( 'subject' , { } , { } , salt ) ;
295
- const { precomputed } = JSON . parse ( encodedPrecomputedWire ) as IConfigurationWire ;
294
+ const configuration = client . getPrecomputedConfiguration ( 'subject' , { } , { } ) ;
295
+ const precomputed = configuration . getPrecomputedConfiguration ( ) ;
296
296
if ( ! precomputed ) {
297
297
fail ( 'Precomputed data not in Configuration response' ) ;
298
298
}
299
- const precomputedResponse = JSON . parse ( precomputed . response ) ;
299
+ const precomputedResponse = precomputed . response ;
300
300
301
301
expect ( precomputedResponse ) . toBeTruthy ( ) ;
302
302
expect ( precomputedResponse . salt ) . toEqual ( 'BzURTg==' ) ;
0 commit comments