-
Notifications
You must be signed in to change notification settings - Fork 83
feat: Implement decideAll api #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2d902fb
to
2767d02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A couple of more tests suggested.
userId, | ||
}); | ||
var decisionMap = user.decideAll(); | ||
assert.deepEqual(decisionMap, fakeDecisionMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. Can we validate "userId" and "options" passing down to fakeOptimizely ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated tests to validate the parameters fakeOptimizely is called with including options
and user
, where userId
is an attribute of user
.
userId, | ||
}); | ||
var decisionMap = user.decideForKeys([ flagKey1, flagKey2 ]); | ||
assert.deepEqual(decisionMap, fakeDecisionMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we validate "userId" and "options" passing down to fakeOptimizely ok?
}); | ||
}); | ||
|
||
describe('with ENABLED_FLAGS_ONLY flag in default decide options', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the same test with ENABLED_FLAGS_ONLY in decide call parameter?
* Returns a key-map of decision results for multiple flag keys and a user context. | ||
* If the SDK finds an error for a key, the response will include a decision for the key showing reasons for the error. | ||
* The SDK will always return key-mapped decisions. When it cannot process requests, it will return an empty map after logging the errors. | ||
* @param {OptimizelyUserContext} user A user context associated with this OptimizelyClient | ||
* @param {string[]} keys An array of flag keys for which decisions will be made. | ||
* @param {OptimizelyDecideOptions[]} options An array of options for decision-making. | ||
* @return {[key: string]: OptimizelyDecision} All decision results mapped by flag keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest using "object" rather than key-map or map.
sinon.assert.calledThrice(optlyInstance.eventDispatcher.dispatchEvent); | ||
}); | ||
|
||
it('should return decision results map with only enabled flags and excluded variables when EXCLUDE_VARIABLES_FLAG is passed in', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it supposed to return all flags (not only enabled flags)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should return enabled flags only because [ OptimizelyDecideOptions. ENABLED_FLAGS_ONLY ]
is passed in defaultDecideOptions when instantiating optimizely client
} | ||
|
||
const allDecideOptions = this.getAllDecideOptions(options); | ||
let optimizelyDecision: OptimizelyDecision; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: suggest moving optimizelyDecision
inside the scope that uses it
ac9a96b
to
5d91f24
Compare
5b09e01
to
b9fab5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary
decideAll
anddecideForKeys
Test plan
Issues