Skip to content
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

feat: Added a new getFeatureVariableJson Api #467

Merged
merged 9 commits into from
Apr 30, 2020
Merged

Conversation

zashraf1985
Copy link
Contributor

Summary

Implemented getFeatureVariableJson API

Test plan

Added unit tests for getFeatureVariableJson.

@zashraf1985 zashraf1985 removed their assignment Apr 30, 2020
Copy link
Contributor

@mjc1283 mjc1283 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few small comments about comments.

Comment on lines 84 to 86
if (variable.type === 'string' && variable.subType === 'json') {
variable.type = 'json';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment explaining why this is overwritten? Also I think it's a bad idea to mutate datafile; it is assigned once at the top of the file and could be used in other tests.

Instead could we do something like this?

var expectedVariableType =
  variable.type === "string" && variable.subType === "json"
    ? "json"
    : variable.type;
assert.include(variablesMap[variable.key], {
  id: variable.id,
  key: variable.key,
  type: expectedVariableType,
  value: variable.defaultValue,
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -119,6 +119,13 @@ export var createProjectConfig = function(datafile) {

projectConfig.featureKeyMap = fns.keyBy(projectConfig.featureFlags || [], 'key');
objectValues(projectConfig.featureKeyMap || {}).forEach(function(feature) {
// Convert type:string and subType:json to type:json to generalize implementation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment needs a little more information. We can mention that json variables in the datafile have a type of "string" for backwards compatibility, but we want to erase the concept of subType, and represent them as a first-class type within the project config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -3000,6 +3000,36 @@ describe('lib/optimizely', function() {
});
});

it('returns the right value from getFeatureVariable and send notification with featureEnabled true', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These strings passed to it() should mention the type of variable being tested (I know you are following what was already here). It's weird that they all have the same description string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zashraf1985 zashraf1985 removed their assignment Apr 30, 2020
@mjc1283 mjc1283 merged commit 10b939b into master Apr 30, 2020
@mjc1283 mjc1283 deleted the zeeshan/feature-json branch April 30, 2020 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants