From d1d7e3ce10af103ffa2488cff439c7cc1b63c9c2 Mon Sep 17 00:00:00 2001 From: braluna Date: Thu, 11 Jun 2026 13:23:57 -0700 Subject: [PATCH] fix: prevent treatments features object serialization --- src/library/zoid/treatments/component.js | 6 +++++- tests/unit/spec/src/zoid/treatments/component.test.js | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/library/zoid/treatments/component.js b/src/library/zoid/treatments/component.js index 1db27aae32..00805b5464 100644 --- a/src/library/zoid/treatments/component.js +++ b/src/library/zoid/treatments/component.js @@ -48,6 +48,10 @@ function getTreatmentPayerId() { return account && !account.startsWith(CLIENT_ID_ACCOUNT_PREFIX) ? account : undefined; } +function getTreatmentFeatures({ props = {} }) { + return getFeatures(typeof props.features === 'string' ? props.features : undefined); +} + export default createGlobalVariableGetter('__paypal_credit_treatments__', () => create({ tag: TAG.TREATEMENTS, @@ -86,7 +90,7 @@ export default createGlobalVariableGetter('__paypal_credit_treatments__', () => type: 'string', queryParam: 'features', required: false, - value: getFeatures + value: getTreatmentFeatures }, namespace: { type: 'string', diff --git a/tests/unit/spec/src/zoid/treatments/component.test.js b/tests/unit/spec/src/zoid/treatments/component.test.js index 443997bb99..9c64f40ebf 100644 --- a/tests/unit/spec/src/zoid/treatments/component.test.js +++ b/tests/unit/spec/src/zoid/treatments/component.test.js @@ -104,6 +104,15 @@ describe('treatments component', () => { expect(treatmentsComponent.props.payerId).toBeUndefined(); }); + test('does not stringify zoid value options into features', () => { + const treatmentsComponent = getTreatmentsComponent(); + + expect(treatmentsComponent.props.features).toBe('native-modal'); + expect(treatmentsComponent.config.props.features.value({ props: { features: 'test-feature' } })).toBe( + 'test-feature,native-modal' + ); + }); + test('handles treatment data', () => { const { props: { onReady }