@gooddata/js-utils
Advanced tools
Comparing version 3.10.1-alpha-khanh.le-kl-SD-912-featureFlags-utils-2020-04-07T08-10-09-396Z to 3.10.1-alpha-khanh.le-kl-SD-912-featureFlags-utils-2020-04-07T09-22-50-029Z
@@ -14,7 +14,7 @@ "use strict"; | ||
function shouldHidePPExperience(featureFlags) { | ||
var hidePPExperience = featureFlags.hidePixelPerfectExperience; | ||
var enablePPExperience = featureFlags.enablePixelPerfectExperience; | ||
var hidePPExperience = featureFlags.hidePixelPerfectExperience; | ||
var platformEdition = featureFlags.platformEdition; | ||
var isFreemiumUser = isFreemiumEdition(platformEdition); | ||
return hidePPExperience || (isFreemiumUser && !enablePPExperience); | ||
return hidePPExperience || (isFreemiumUser && enablePPExperience !== 'true'); | ||
} | ||
@@ -35,3 +35,4 @@ exports.shouldHidePPExperience = shouldHidePPExperience; | ||
privateFeatureFlags.forEach(function (name) { | ||
var featureFlagValue = featureFlags[name] && featureFlags[name].value; | ||
var featureFlag = featureFlags[name]; | ||
var featureFlagValue = featureFlag && featureFlag.value; | ||
if (featureFlagValue) { | ||
@@ -38,0 +39,0 @@ set_1.default(bootstapData, CURRENT_FEATURE_FLAGS_PATH + "." + name, featureFlagValue); |
{ | ||
"name": "@gooddata/js-utils", | ||
"version": "3.10.1-alpha-khanh.le-kl-SD-912-featureFlags-utils-2020-04-07T08-10-09-396Z", | ||
"version": "3.10.1-alpha-khanh.le-kl-SD-912-featureFlags-utils-2020-04-07T09-22-50-029Z", | ||
"description": "Various utils shared on GoodData frontend", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -34,8 +34,8 @@ // (C) 2020 GoodData Corporation | ||
export function shouldHidePPExperience(featureFlags: IFeatureFlags): boolean { | ||
const enablePPExperience = featureFlags.enablePixelPerfectExperience as boolean; | ||
const hidePPExperience = featureFlags.hidePixelPerfectExperience as boolean; | ||
const enablePPExperience = featureFlags.enablePixelPerfectExperience as string; | ||
const platformEdition = featureFlags.platformEdition as string; | ||
const isFreemiumUser = isFreemiumEdition(platformEdition as string); | ||
return hidePPExperience || (isFreemiumUser && !enablePPExperience); | ||
return hidePPExperience || (isFreemiumUser && enablePPExperience !== 'true'); | ||
} | ||
@@ -59,3 +59,4 @@ | ||
privateFeatureFlags.forEach((name: string): void => { | ||
const featureFlagValue = featureFlags[name] && featureFlags[name].value; | ||
const featureFlag = featureFlags[name]; | ||
const featureFlagValue = featureFlag && featureFlag.value; | ||
if (featureFlagValue) { | ||
@@ -62,0 +63,0 @@ set(bootstapData, `${CURRENT_FEATURE_FLAGS_PATH}.${name}`, featureFlagValue); |
@@ -7,3 +7,3 @@ // (C) 2020 GoodData Corporation | ||
it('should not hide pixel perfect experience for free/growth user', () => { | ||
const shouldHidePixelperfect = shouldHidePPExperience({ enablePixelPerfectExperience: true, platformEdition: 'growth' }); | ||
const shouldHidePixelperfect = shouldHidePPExperience({ enablePixelPerfectExperience: 'true', platformEdition: 'growth' }); | ||
expect(shouldHidePixelperfect).toBe(false); | ||
@@ -13,3 +13,3 @@ }); | ||
it('should hide pixel perfect experience for free/growth user when enablePixelPerfectExperience is false', () => { | ||
const shouldHidePixelperfect = shouldHidePPExperience({ enablePixelPerfectExperience: false, platformEdition: 'growth' }); | ||
const shouldHidePixelperfect = shouldHidePPExperience({ enablePixelPerfectExperience: 'false', platformEdition: 'growth' }); | ||
expect(shouldHidePixelperfect).toBe(true); | ||
@@ -43,3 +43,3 @@ }); | ||
platformEdition: 'free', | ||
enablePixelPerfectExperience: false, | ||
enablePixelPerfectExperience: 'false', | ||
} | ||
@@ -55,11 +55,12 @@ } | ||
enablePixelPerfectExperience: { | ||
value: true, | ||
value: 'true', | ||
source: 'user' | ||
} | ||
}; | ||
const bootstrapDataUpdated = updatePrivateFFforPPInBootstrap(bootstrapData, normalizedFeatureFlags); | ||
const bootstapDataResult = updatePrivateFFforPPInBootstrap(bootstrapData, normalizedFeatureFlags); | ||
const { featureFlags } = bootstapDataResult.bootstrapResource.current; | ||
expect(bootstrapDataUpdated.bootstrapResource.current.featureFlags).toEqual({ | ||
expect(featureFlags).toEqual({ | ||
platformEdition: 'growth', | ||
enablePixelPerfectExperience: true | ||
enablePixelPerfectExperience: 'true' | ||
}) | ||
@@ -66,0 +67,0 @@ }) |
Sorry, the diff of this file is not supported yet
66025
1316