Skip to content

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


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

});
});

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.

4 participants