The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add some tests to the variable resolver to ensure static JSON is properly evaluated (#9104)
Baptiste Devessierf05a217f62b1
diff --git a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/variable-resolver.util.spec.ts b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/variable-resolver.util.spec.tsindex dc41cb81dfb..4d5634a3c97 100644--- a/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/variable-resolver.util.spec.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-executor/utils/__tests__/variable-resolver.util.spec.ts@@ -74,4 +74,40 @@ describe('resolveInput', () => {expect(resolveInput(input, context)).toEqual(expected);});++ it('does not wrap string variables with double quotes', () => {+ expect(+ resolveInput('{ {{test}}: 2 }', {+ test: 'prop',+ }),+ ).toBe('{ prop: 2 }');+ });++ it('does not modify static JSON', () => {+ expect(resolveInput('{ "a": 2 }', {})).toBe('{ "a": 2 }');+ });++ it('supports variable as JSON object property name', () => {+ expect(+ resolveInput('{ "{{test}}": 2 }', {+ test: 'prop',+ }),+ ).toBe('{ "prop": 2 }');+ });++ it('supports variable as JSON number value', () => {+ expect(+ resolveInput('{ "a": {{test}} }', {+ test: 2,+ }),+ ).toBe('{ "a": 2 }');+ });++ it('supports variable as JSON string value', () => {+ expect(+ resolveInput('{ "a": "{{test}}" }', {+ test: 'str',+ }),+ ).toBe('{ "a": "str" }');+ });});