File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 1
1
/****************************************************************************
2
- * Copyright 2017-2022 Optimizely, Inc. and contributors *
2
+ * Copyright 2017-2022,2024 Optimizely, Inc. and contributors *
3
3
* *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); *
5
5
* you may not use this file except in compliance with the License. *
@@ -392,20 +392,21 @@ describe('lib/core/decision_service', function() {
392
392
optimizely : { } ,
393
393
userId : 'decision_service_user' ,
394
394
} ) ;
395
+
395
396
assert . strictEqual (
396
397
'control' ,
397
398
decisionServiceInstance . getVariation ( configObj , experiment , user ) . result
398
399
) ;
399
400
sinon . assert . calledWith ( userProfileLookupStub , 'decision_service_user' ) ;
400
401
sinon . assert . calledOnce ( bucketerStub ) ; // should still go through with bucketing
401
- assert . strictEqual (
402
- buildLogMessageFromArgs ( mockLogger . log . args [ 1 ] ) ,
403
- 'DECISION_SERVICE: User decision_service_user is not in the forced variation map.'
404
- ) ;
405
402
assert . strictEqual (
406
403
buildLogMessageFromArgs ( mockLogger . log . args [ 0 ] ) ,
407
404
'DECISION_SERVICE: Error while looking up user profile for user ID "decision_service_user": I am an error.'
408
405
) ;
406
+ assert . strictEqual (
407
+ buildLogMessageFromArgs ( mockLogger . log . args [ 1 ] ) ,
408
+ 'DECISION_SERVICE: User decision_service_user is not in the forced variation map.'
409
+ ) ;
409
410
} ) ;
410
411
411
412
it ( 'should log an error message if "save" throws an error' , function ( ) {
Original file line number Diff line number Diff line change 1
1
/****************************************************************************
2
- * Copyright 2017-2022 Optimizely, Inc. and contributors *
2
+ * Copyright 2017-2022,2024 Optimizely, Inc. and contributors *
3
3
* *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); *
5
5
* you may not use this file except in compliance with the License. *
Original file line number Diff line number Diff line change @@ -5926,6 +5926,7 @@ describe('lib/optimizely', function() {
5926
5926
5927
5927
sinon . stub ( optlyInstance . decisionService . userProfileService , 'lookup' )
5928
5928
sinon . stub ( optlyInstance . decisionService . userProfileService , 'save' )
5929
+ //
5929
5930
} ) ;
5930
5931
5931
5932
it ( 'Should call UPS methods only once' , function ( ) {
@@ -5956,13 +5957,24 @@ describe('lib/optimizely', function() {
5956
5957
userContext : user ,
5957
5958
reasons : [ ] ,
5958
5959
} ;
5960
+ var userProfile = {
5961
+ user_id : userId ,
5962
+ experiment_bucket_map : {
5963
+ '10420810910' : { // ruleKey from expectedDecision1
5964
+ variation_id : '10418551353' // variationKey from expectedDecision1
5965
+ }
5966
+ }
5967
+ } ;
5959
5968
5960
5969
assert . deepEqual ( Object . values ( decisionsMap ) . length , 2 ) ;
5961
5970
assert . deepEqual ( decision1 , expectedDecision1 ) ;
5962
5971
assert . deepEqual ( decision2 , expectedDecision2 ) ;
5963
5972
// UPS batch assertion
5964
5973
sinon . assert . calledOnce ( optlyInstance . decisionService . userProfileService . lookup ) ;
5965
5974
sinon . assert . calledOnce ( optlyInstance . decisionService . userProfileService . save ) ;
5975
+
5976
+ // UPS save assertion
5977
+ sinon . assert . calledWithExactly ( optlyInstance . decisionService . userProfileService . save , userProfile ) ;
5966
5978
} ) ;
5967
5979
} )
5968
5980
Original file line number Diff line number Diff line change 1
1
/****************************************************************************
2
- * Copyright 2020-2023 , Optimizely, Inc. and contributors *
2
+ * Copyright 2020-2024 , Optimizely, Inc. and contributors *
3
3
* *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); *
5
5
* you may not use this file except in compliance with the License. *
You can’t perform that action at this time.
0 commit comments