FFL-2510: Add tests for allocationKey in OpenFeature flagMetadata#1303
Open
typotter wants to merge 5 commits into
Open
FFL-2510: Add tests for allocationKey in OpenFeature flagMetadata#1303typotter wants to merge 5 commits into
typotter wants to merge 5 commits into
Conversation
…tadata - Add extraLogging field to FlagDetails<T> typed as Record<string, PrimitiveValue> - Add buildExtraLogging helper in FlagsClient that filters to primitives and drops allocationKey key - Populate extraLogging in getDetails from flag cache entry - Update toFlagResolution in provider.ts to spread extraLogging into flagMetadata, with allocationKey winning on collision - Add __mocks__/react-native.ts to openfeature package for test infrastructure - Add provider.test.ts covering extraLogging threading and allocationKey collision semantics
…ation - Fix prettier formatting on multi-line import in FlagsClient.ts - Add curly braces to if/continue statements in buildExtraLogging (curly rule) - Fix import ordering and remove blank line between same-section imports in provider.test.ts (arca rules) - Narrow flagMetadata type to Record<string, string | number | boolean> in provider.ts to match OpenFeature FlagMetadata; filter null values when building flagMetadata
Comment on lines
+171
to
+188
| // Build flagMetadata: extraLogging primitives first, allocationKey last (wins on collision). | ||
| // OpenFeature FlagMetadata does not support null values, so null entries are omitted. | ||
| let flagMetadata: Record<string, string | number | boolean> | undefined; | ||
| const hasExtraLogging = | ||
| extraLogging && Object.keys(extraLogging).length > 0; | ||
| if (allocationKey || hasExtraLogging) { | ||
| flagMetadata = {}; | ||
| if (extraLogging) { | ||
| for (const [k, v] of Object.entries(extraLogging)) { | ||
| if (v !== null) { | ||
| flagMetadata[k] = v; | ||
| } | ||
| } | ||
| } | ||
| if (allocationKey) { | ||
| flagMetadata.allocationKey = allocationKey; | ||
| } | ||
| } |
|
It looks like this PR didn't actually touch any docs files, so I've dismissed |
hasExtraLogging now checks for at least one non-null value rather than
any key at all, so extraLogging with only null entries no longer
produces an empty {} flagMetadata when allocationKey is absent.
Only allocationKey is surfaced in flagMetadata; extraLogging is no longer built or stored on FlagDetails. Remove buildExtraLogging(), FlagDetails.extraLogging, and related provider logic and tests.
leoromanovsky
requested changes
Jun 30, 2026
leoromanovsky
left a comment
Contributor
There was a problem hiding this comment.
The PR description doesn't match what's in the diff; it appears as though only tests are being added here?
Contributor
Apart from this, the description does not follow the PR template set on the repository, could you please modify it? |
Author
|
my bad. we're just adding tests here now, pr updated |
leoromanovsky
approved these changes
Jul 6, 2026
leoromanovsky
left a comment
Contributor
There was a problem hiding this comment.
nice structuring of test cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds test coverage for
allocationKeysurfacing in OpenFeatureflagMetadata. The threading itself (toFlagResolutionsettingflagMetadata: allocationKey ? { allocationKey } : undefined) was already present inmain. This PR verifies the behavior with tests.Motivation
FFL-2510 — ensures
allocationKeythreading is covered by tests, consistent with Android and iOS.Additional Notes
packages/react-native-openfeature/src/__tests__/provider.test.ts: testsallocationKeypresent inflagMetadataand absent (null) when not setpackages/react-native-openfeature/__mocks__/react-native.ts: mock module needed by the new test suitepackages/core/src/flags/__tests__/FlagsClient.test.ts: coverage forallocationKeyinFlagDetailspackages/react-native-openfeature/src/provider.ts: import cleanup (PrimitiveValuemoved to correct source)Review checklist (to be filled by reviewers)