From 4eaa1525a0b62e967e7eda6ac2cedf215881c458 Mon Sep 17 00:00:00 2001 From: Simon Hornby Date: Fri, 14 Jun 2024 15:54:00 +0200 Subject: [PATCH] fix: make default for gradual rollout work on the correct strategy name (#7401) --- .../tests/client-feature-toggles.e2e.test.ts | 12 ++++++++++-- .../feature-toggle-strategies-store.ts | 2 +- .../feature-toggle-strategies-store.e2e.test.ts | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib/features/client-feature-toggles/tests/client-feature-toggles.e2e.test.ts b/src/lib/features/client-feature-toggles/tests/client-feature-toggles.e2e.test.ts index 4431ed95bc..7ccb82fe84 100644 --- a/src/lib/features/client-feature-toggles/tests/client-feature-toggles.e2e.test.ts +++ b/src/lib/features/client-feature-toggles/tests/client-feature-toggles.e2e.test.ts @@ -25,7 +25,11 @@ const apiClientResponse = [ { name: 'flexibleRollout', constraints: [], - parameters: { rollout: '100' }, + parameters: { + rollout: '100', + stickiness: 'default', + groupId: 'test1', + }, variants: [], }, ], @@ -169,7 +173,11 @@ test('should return correct data structure from /api/client/features', async () { name: 'flexibleRollout', constraints: [], - parameters: { rollout: '100' }, + parameters: { + rollout: '100', + stickiness: 'default', + groupId: 'test1', + }, }, DEFAULT_ENV, 'test1', diff --git a/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts b/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts index c21afcb667..15fbc34c55 100644 --- a/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts +++ b/src/lib/features/feature-toggle/feature-toggle-strategies-store.ts @@ -159,7 +159,7 @@ const defaultParameters = ( params: PartialSome, stickiness: string, ) => { - if (params.strategyName === 'gradualRollout') { + if (params.strategyName === 'flexibleRollout') { return { rollout: '100', stickiness, diff --git a/src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts index 002ec8198b..db1ce7a2b4 100644 --- a/src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggle-strategies-store.e2e.test.ts @@ -164,7 +164,7 @@ describe('strategy parameters default to sane defaults', () => { createdByUserId: 9999, }); const strategy = await featureStrategiesStore.createStrategyFeatureEnv({ - strategyName: 'gradualRollout', + strategyName: 'flexibleRollout', projectId: 'default', environment: 'default', featureName: toggle.name, @@ -184,7 +184,7 @@ describe('strategy parameters default to sane defaults', () => { createdByUserId: 9999, }); const strategy = await featureStrategiesStore.createStrategyFeatureEnv({ - strategyName: 'gradualRollout', + strategyName: 'flexibleRollout', projectId: 'default', environment: 'default', featureName: toggle.name, @@ -236,7 +236,7 @@ describe('strategy parameters default to sane defaults', () => { createdByUserId: 9999, }); const strategy = await featureStrategiesStore.createStrategyFeatureEnv({ - strategyName: 'gradualRollout', + strategyName: 'flexibleRollout', projectId: project.id, environment: 'default', featureName: toggle.name,