Skip to content

Commit

Permalink
fix: Use clientSideAvailability instead of clientSide for filtering c…
Browse files Browse the repository at this point in the history
…lient side flags.
  • Loading branch information
kinyoklion committed Sep 6, 2023
1 parent fa9e45b commit 584f48a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions packages/shared/sdk-server/__tests__/LDClient.allFlags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,28 @@ describe('given an LDClient with test data', () => {
on: false,
offVariation: 0,
variations: ['a'],
clientSide: false,
});
td.usePreconfiguredFlag({
key: 'server-side-2',
on: false,
offVariation: 0,
variations: ['b'],
clientSide: false,
// Absence and false should be equivalent, so we add a false one here.
clientSideAvailability: { usingEnvironmentId: false },
});
td.usePreconfiguredFlag({
key: 'client-side-1',
on: false,
offVariation: 0,
variations: ['value1'],
clientSide: true,
clientSideAvailability: { usingEnvironmentId: true },
});
td.usePreconfiguredFlag({
key: 'client-side-2',
on: false,
offVariation: 0,
variations: ['value2'],
clientSide: true,
clientSideAvailability: { usingEnvironmentId: true },
});
const state = await client.allFlagsState(defaultUser, { clientSideOnly: true });
expect(state.valid).toEqual(true);
Expand Down Expand Up @@ -241,28 +241,26 @@ describe('given an LDClient with test data', () => {
on: false,
offVariation: 0,
variations: ['a'],
clientSide: false,
});
td.usePreconfiguredFlag({
key: 'server-side-2',
on: false,
offVariation: 0,
variations: ['b'],
clientSide: false,
});
td.usePreconfiguredFlag({
key: 'client-side-1',
on: false,
offVariation: 0,
variations: ['value1'],
clientSide: true,
clientSideAvailability: { usingEnvironmentId: true },
});
td.usePreconfiguredFlag({
key: 'client-side-2',
on: false,
offVariation: 0,
variations: ['value2'],
clientSide: true,
clientSideAvailability: { usingEnvironmentId: true },
});
client.allFlagsState(defaultUser, { clientSideOnly: true }, (err, state) => {
expect(state.valid).toEqual(true);
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/sdk-server/src/LDClientImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export default class LDClientImpl implements LDClient {
Object.values(allFlags),
(storeItem, iterCb) => {
const flag = storeItem as Flag;
if (clientOnly && !flag.clientSide) {
if (clientOnly && !flag.clientSideAvailability?.usingEnvironmentId) {
iterCb(true);
return;
}
Expand Down

0 comments on commit 584f48a

Please sign in to comment.