@@ -2,10 +2,9 @@ import * as fs from 'fs';
22
33import { isEqual } from 'lodash' ;
44
5- import { AttributeType , ContextAttributes , IAssignmentDetails , Variation , VariationType } from '../src' ;
5+ import { AttributeType , ContextAttributes , IAssignmentDetails , VariationType } from '../src' ;
66import { IFlagEvaluationDetails } from '../src/flag-evaluation-details-builder' ;
77import { IBanditParametersResponse , IUniversalFlagConfigResponse } from '../src/http-client' ;
8- import { getMD5Hash } from '../src/obfuscation' ;
98
109export const TEST_DATA_DIR = './test/data/ufc/' ;
1110export const ASSIGNMENT_TEST_DATA_DIR = TEST_DATA_DIR + 'tests/' ;
@@ -114,6 +113,9 @@ export function getTestAssignments(
114113 return assignments ;
115114}
116115
116+ const configCreatedAt = readMockUFCResponse ( MOCK_UFC_RESPONSE_FILE ) . createdAt ;
117+ const testHelperInstantiationDate = new Date ( ) ;
118+
117119export function validateTestAssignments (
118120 assignments : {
119121 subject : SubjectTestCase ;
@@ -168,15 +170,18 @@ export function validateTestAssignments(
168170 expect ( assignmentDetails . variationValue ?. toString ( ) ) . toBe (
169171 subject . evaluationDetails . variationValue ?. toString ( ) ,
170172 ) ;
171- // TODO: below needs to be fixed
172- //expect(assignmentDetails.configFetchedAt).toBe(subject.evaluationDetails.configFetchedAt);
173- //expect(assignmentDetails.configPublishedAt).toBe(subject.evaluationDetails.configPublishedAt);
173+ expect ( assignmentDetails . configPublishedAt ) . toBe ( configCreatedAt ) ;
174+ // cannot do an exact match for configFetchedAt because it will change based on fetch
175+ expect ( new Date ( assignmentDetails . configFetchedAt ) . getTime ( ) ) . toBeGreaterThan (
176+ testHelperInstantiationDate . getTime ( ) ,
177+ ) ;
174178
175179 if ( ! isObfuscated ) {
176180 expect ( assignmentDetails . matchedRule ) . toEqual ( subject . evaluationDetails . matchedRule ) ;
177181 } else {
178182 // When obfuscated, rules may be one-way hashed (e.g., for ONE_OF checks) so cannot be unobfuscated
179- // Thus we'll just check that the number of conditions is equal
183+ // Thus we'll just check that the number of conditions is equal and relay on the unobfuscated
184+ // tests for correctness
180185 expect ( assignmentDetails . matchedRule ?. conditions || [ ] ) . toHaveLength (
181186 subject . evaluationDetails . matchedRule ?. conditions . length || 0 ,
182187 ) ;
0 commit comments