From f168761c01f22c3cfc57e3cf683dc26c85d90e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivar=20Conradi=20=C3=98sthus?= Date: Wed, 21 Jul 2021 09:04:50 +0200 Subject: [PATCH] fix: variant stickiness should not revert to default when updating (#318) --- .../src/component/feature/variant/AddVariant/AddVariant.jsx | 2 ++ .../__snapshots__/update-variant-component-test.jsx.snap | 2 +- .../component/feature/variant/update-variant-component.jsx | 5 ++--- .../component/feature/variant/update-variant-container.jsx | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx b/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx index ece66d3af8..62ac98fc01 100644 --- a/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx +++ b/frontend/src/component/feature/variant/AddVariant/AddVariant.jsx @@ -46,6 +46,7 @@ const AddVariant = ({ name: editVariant.name, weight: editVariant.weight / 10, weightType: editVariant.weightType || weightTypes.VARIABLE, + stickiness: editVariant.stickiness }); if (editVariant.payload) { setPayload(editVariant.payload); @@ -100,6 +101,7 @@ const AddVariant = ({ name: data.name, weight: data.weight * 10, weightType: data.weightType, + stickiness: data.stickiness, payload: payload.value ? payload : undefined, overrides: overrides .map(o => ({ diff --git a/frontend/src/component/feature/variant/__tests__/__snapshots__/update-variant-component-test.jsx.snap b/frontend/src/component/feature/variant/__tests__/__snapshots__/update-variant-component-test.jsx.snap index 9e86b3c067..ed8e643691 100644 --- a/frontend/src/component/feature/variant/__tests__/__snapshots__/update-variant-component-test.jsx.snap +++ b/frontend/src/component/feature/variant/__tests__/__snapshots__/update-variant-component-test.jsx.snap @@ -522,7 +522,7 @@ exports[`renders correctly with with variants 1`] = ` By overriding the stickiness you can control which parameter you want to be used in order to ensure consistent traffic allocation across variants. diff --git a/frontend/src/component/feature/variant/update-variant-component.jsx b/frontend/src/component/feature/variant/update-variant-component.jsx index 8154add14d..4305f8513f 100644 --- a/frontend/src/component/feature/variant/update-variant-component.jsx +++ b/frontend/src/component/feature/variant/update-variant-component.jsx @@ -129,9 +129,8 @@ class UpdateVariantComponent extends Component { you want to be used in order to ensure consistent traffic allocation across variants.{' '} Read more diff --git a/frontend/src/component/feature/variant/update-variant-container.jsx b/frontend/src/component/feature/variant/update-variant-container.jsx index 20868a5221..063cb5cd3a 100644 --- a/frontend/src/component/feature/variant/update-variant-container.jsx +++ b/frontend/src/component/feature/variant/update-variant-container.jsx @@ -16,6 +16,9 @@ const mapDispatchToProps = (dispatch, ownProps) => ({ addVariant: variant => { const { featureToggle } = ownProps; const currentVariants = featureToggle.variants || []; + const stickiness = currentVariants[0].stickiness || 'default'; + variant.stickiness = stickiness; + const variants = [...currentVariants, variant]; updateWeight(variants, 1000); return requestUpdateFeatureToggleVariants(