@@ -25,16 +25,14 @@ describe('EppoAssignmentLogger', () => {
2525 subject : 'user-123' ,
2626 experiment : 'experiment-abc' ,
2727 variant : 'control' ,
28- entityId : 456 , // Changed to number
28+ entityId : 456 ,
2929 holdoutKey : 'holdout-xyz' ,
3030 holdoutVariation : 'holdout-variant-1' ,
31- // Add required properties based on the IAssignmentEvent interface
3231 allocation : 'allocation-1' ,
3332 featureFlag : 'feature-flag-1' ,
3433 variation : 'variation-1' ,
3534 timestamp : new Date ( ) . toISOString ( ) ,
3635 subjectAttributes : { } ,
37- flagKey : 'flag-key-1' ,
3836 format : 'json' ,
3937 evaluationDetails : null ,
4038 } ;
@@ -60,13 +58,12 @@ describe('EppoAssignmentLogger', () => {
6058 subject : 'user-123' ,
6159 experiment : 'experiment-abc' ,
6260 variant : 'control' ,
63- // Add required properties based on the IAssignmentEvent interface
61+ entityId : 789 ,
6462 allocation : 'allocation-1' ,
6563 featureFlag : 'feature-flag-1' ,
6664 variation : 'variation-1' ,
6765 timestamp : new Date ( ) . toISOString ( ) ,
6866 subjectAttributes : { } ,
69- flagKey : 'flag-key-1' ,
7067 format : 'json' ,
7168 evaluationDetails : null ,
7269 } ;
@@ -80,9 +77,54 @@ describe('EppoAssignmentLogger', () => {
8077 subject_id : 'user-123' ,
8178 experiment : 'experiment-abc' ,
8279 variant : 'control' ,
83- entity_id : undefined ,
80+ entity_id : 789 ,
8481 holdout : undefined ,
8582 holdout_variant : undefined ,
8683 } ) ;
8784 } ) ;
85+
86+ it ( 'should skip tracking when entityId is null' , ( ) => {
87+ // Arrange
88+ const assignmentEvent : IAssignmentEvent = {
89+ subject : 'user-123' ,
90+ experiment : 'experiment-abc' ,
91+ variant : 'control' ,
92+ entityId : null ,
93+ allocation : 'allocation-1' ,
94+ featureFlag : 'feature-flag-1' ,
95+ variation : 'variation-1' ,
96+ timestamp : new Date ( ) . toISOString ( ) ,
97+ subjectAttributes : { } ,
98+ format : 'json' ,
99+ evaluationDetails : null ,
100+ } ;
101+
102+ // Act
103+ logger . logAssignment ( assignmentEvent ) ;
104+
105+ // Assert
106+ expect ( mockEppoClient . track ) . not . toHaveBeenCalled ( ) ;
107+ } ) ;
108+
109+ it ( 'should skip tracking when entityId is undefined' , ( ) => {
110+ // Arrange
111+ const assignmentEvent : IAssignmentEvent = {
112+ subject : 'user-123' ,
113+ experiment : 'experiment-abc' ,
114+ variant : 'control' ,
115+ allocation : 'allocation-1' ,
116+ featureFlag : 'feature-flag-1' ,
117+ variation : 'variation-1' ,
118+ timestamp : new Date ( ) . toISOString ( ) ,
119+ subjectAttributes : { } ,
120+ format : 'json' ,
121+ evaluationDetails : null ,
122+ } ;
123+
124+ // Act
125+ logger . logAssignment ( assignmentEvent ) ;
126+
127+ // Assert
128+ expect ( mockEppoClient . track ) . not . toHaveBeenCalled ( ) ;
129+ } ) ;
88130} ) ;
0 commit comments