@@ -209,6 +209,76 @@ test('test_identity_with_transient_traits', async () => {
209209 expect ( identityFlags [ 0 ] . featureName ) . toBe ( 'some_feature' ) ;
210210} ) ;
211211
212+ test ( 'getIdentityFlags local evaluation with plain traits matches segment' , async ( ) => {
213+ const identifier = 'identifier' ;
214+ // Plain trait format: age=30 should match segment rule "age LESS_THAN 40"
215+ const traits = { age : 30 } ;
216+
217+ const flg = flagsmith ( {
218+ environmentKey : 'ser.key' ,
219+ enableLocalEvaluation : true
220+ } ) ;
221+
222+ const flags = await flg . getIdentityFlags ( identifier , traits ) ;
223+
224+ // Should get segment override value, not the default
225+ expect ( flags . getFeatureValue ( 'some_feature' ) ) . toBe ( 'segment_override' ) ;
226+ expect ( flags . isFeatureEnabled ( 'some_feature' ) ) . toBe ( false ) ;
227+ } ) ;
228+
229+ test ( 'getIdentityFlags local evaluation with TraitConfig format matches segment' , async ( ) => {
230+ const identifier = 'identifier' ;
231+ // TraitConfig format: same trait value wrapped with transient metadata
232+ const traits = { age : { value : 30 , transient : true } } ;
233+
234+ const flg = flagsmith ( {
235+ environmentKey : 'ser.key' ,
236+ enableLocalEvaluation : true
237+ } ) ;
238+
239+ const flags = await flg . getIdentityFlags ( identifier , traits ) ;
240+
241+ // Should get segment override value — same result as plain trait format
242+ expect ( flags . getFeatureValue ( 'some_feature' ) ) . toBe ( 'segment_override' ) ;
243+ expect ( flags . isFeatureEnabled ( 'some_feature' ) ) . toBe ( false ) ;
244+ } ) ;
245+
246+ test ( 'getIdentityFlags local evaluation with mixed trait formats matches segment' , async ( ) => {
247+ const identifier = 'identifier' ;
248+ // Mix of plain and TraitConfig formats
249+ const traits = {
250+ age : { value : 30 , transient : true } ,
251+ some_other_trait : 'plain_value'
252+ } ;
253+
254+ const flg = flagsmith ( {
255+ environmentKey : 'ser.key' ,
256+ enableLocalEvaluation : true
257+ } ) ;
258+
259+ const flags = await flg . getIdentityFlags ( identifier , traits ) ;
260+
261+ // Should get segment override value
262+ expect ( flags . getFeatureValue ( 'some_feature' ) ) . toBe ( 'segment_override' ) ;
263+ expect ( flags . isFeatureEnabled ( 'some_feature' ) ) . toBe ( false ) ;
264+ } ) ;
265+
266+ test ( 'getIdentitySegments with TraitConfig format matches segment' , async ( ) => {
267+ const identifier = 'identifier' ;
268+ // TraitConfig format should work for getIdentitySegments too
269+ const traits = { age : { value : 30 , transient : true } } ;
270+
271+ const flg = flagsmith ( {
272+ environmentKey : 'ser.key' ,
273+ enableLocalEvaluation : true
274+ } ) ;
275+
276+ const segments = await flg . getIdentitySegments ( identifier , traits ) ;
277+
278+ expect ( segments ) . toHaveLength ( 1 ) ;
279+ expect ( segments [ 0 ] . name ) . toBe ( 'regular_segment' ) ;
280+ } ) ;
281+
212282test ( 'getIdentityFlags fails if API call failed and no default flag handler was provided' , async ( ) => {
213283 const flg = flagsmith ( {
214284 fetch : badFetch
0 commit comments