Skip to content

Commit

Permalink
refactor: arrange code to be more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarco committed May 22, 2024
1 parent f228a8f commit 74bdff7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/shared-web/src/hooks/useFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const useFeatureFlags = (organization?: IOrganizationEntity) => {
return ldClient;
};

function getFlagValueFromLD(key: FeatureFlagsKeysEnum, keysFromLunchDarkly: { [key: string]: boolean }) {
function isflagMissingInLdResponse(key: FeatureFlagsKeysEnum, keysFromLunchDarkly: { [key: string]: boolean }) {
return keysFromLunchDarkly[key] === undefined;
}

Expand All @@ -47,7 +47,7 @@ function e2eExplicitFlagAssertion(key: FeatureFlagsKeysEnum) {
const isPlaywright = window && (window as any).isPlaywright;
const featureFlagValueMap = checkShouldUseLaunchDarkly() ? useFlags() : {};
const isFeatureFlagsPopulated = Object.keys(featureFlagValueMap).length !== 0;
if (isFeatureFlagsPopulated && getFlagValueFromLD(key, featureFlagValueMap) && isPlaywright) {
if (isFeatureFlagsPopulated && isflagMissingInLdResponse(key, featureFlagValueMap) && isPlaywright) {
throw new Error(
`Feature flag "${key}" Must be mocked in playwright tests use mockFeatureFlags in your test file as a before each
Existing flags ${JSON.stringify(useFlags() || {})}`
Expand Down

0 comments on commit 74bdff7

Please sign in to comment.