@tellescope/sdk 1.249.0 → 1.249.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,7 +50,7 @@ import { appointment_rescheduled_trigger_tests } from "./api_tests/appointment_r
50
50
  import { journey_error_branching_tests } from "./api_tests/journey_error_branching.test"
51
51
  import { afteraction_day_of_month_delay_tests } from "./api_tests/afteraction_day_of_month_delay.test"
52
52
  import { setup_tests } from "./setup"
53
- import { evaluate_conditional_logic_for_enduser_fields, FORM_LOGIC_CALCULATED_FIELDS, get_care_team_primary, get_flattened_fields, get_next_reminder_timestamp, object_is_empty, replace_enduser_template_values, responses_satisfy_conditions, truncate_string, weighted_round_robin, YYYY_MM_DD_to_MM_DD_YYYY } from "@tellescope/utilities"
53
+ import { evaluate_conditional_logic_for_enduser_fields, FORM_LOGIC_CALCULATED_FIELDS, get_care_team_primary, get_flattened_fields, get_next_reminder_timestamp, object_is_empty, replace_enduser_template_values, replace_form_field_template_values, responses_satisfy_conditions, truncate_string, weighted_round_robin, YYYY_MM_DD_to_MM_DD_YYYY } from "@tellescope/utilities"
54
54
  import { DEFAULT_OPERATIONS, PLACEHOLDER_ID, ZENDESK_INTEGRATIONS_TITLE, ZOOM_TITLE } from "@tellescope/constants"
55
55
  import {
56
56
  schema,
@@ -12907,6 +12907,87 @@ const replace_enduser_template_values_tests = async () => {
12907
12907
  await sdk.api.endusers.deleteOne(enduser.id)
12908
12908
  }
12909
12909
 
12910
+ const replace_form_field_template_values_tests = async () => {
12911
+ log_header("Replace Form Field Template Values Tests")
12912
+
12913
+ const enduserWithMultilineField = {
12914
+ fname: "Multi",
12915
+ lname: "Line",
12916
+ fields: { Locations: 'NYC\nSF\nLA' },
12917
+ } as Partial<Enduser>
12918
+
12919
+ // With escapeNewlinesAsHTMLBreaks: true — newlines in substituted value become <br />
12920
+ assert(
12921
+ replace_form_field_template_values(
12922
+ '<p>Locations: {{enduser.Locations}}</p>',
12923
+ { enduser: enduserWithMultilineField, escapeNewlinesAsHTMLBreaks: true }
12924
+ ) === '<p>Locations: NYC<br />SF<br />LA</p>',
12925
+ 'fail escapeNewlinesAsHTMLBreaks true', 'escapeNewlinesAsHTMLBreaks true'
12926
+ )
12927
+
12928
+ // Default (option absent) — newlines preserved as \n
12929
+ assert(
12930
+ replace_form_field_template_values(
12931
+ '<p>Locations: {{enduser.Locations}}</p>',
12932
+ { enduser: enduserWithMultilineField }
12933
+ ) === '<p>Locations: NYC\nSF\nLA</p>',
12934
+ 'fail default newline preserved', 'default newline preserved'
12935
+ )
12936
+
12937
+ // Explicit false — same as default
12938
+ assert(
12939
+ replace_form_field_template_values(
12940
+ '<p>Locations: {{enduser.Locations}}</p>',
12941
+ { enduser: enduserWithMultilineField, escapeNewlinesAsHTMLBreaks: false }
12942
+ ) === '<p>Locations: NYC\nSF\nLA</p>',
12943
+ 'fail escapeNewlinesAsHTMLBreaks false', 'escapeNewlinesAsHTMLBreaks false'
12944
+ )
12945
+
12946
+ // \n in original template (not in substituted value) is left alone
12947
+ assert(
12948
+ replace_form_field_template_values(
12949
+ '<p>Header</p>\n<p>{{enduser.fname}}</p>',
12950
+ { enduser: enduserWithMultilineField, escapeNewlinesAsHTMLBreaks: true }
12951
+ ) === '<p>Header</p>\n<p>Multi</p>',
12952
+ 'fail template newline untouched', 'template newline untouched'
12953
+ )
12954
+
12955
+ // Single-line value unaffected when option is enabled
12956
+ assert(
12957
+ replace_form_field_template_values(
12958
+ '<p>Hello {{enduser.fname}}</p>',
12959
+ { enduser: enduserWithMultilineField, escapeNewlinesAsHTMLBreaks: true }
12960
+ ) === '<p>Hello Multi</p>',
12961
+ 'fail single-line value', 'single-line value'
12962
+ )
12963
+
12964
+ // Substituted value containing literal two-char \n escape sequence is also converted
12965
+ const enduserWithLiteralEscapeField = {
12966
+ fname: "Multi",
12967
+ fields: { Locations: 'NYC\\nSF\\nLA' },
12968
+ } as Partial<Enduser>
12969
+ assert(
12970
+ replace_form_field_template_values(
12971
+ '<p>Locations: {{enduser.Locations}}</p>',
12972
+ { enduser: enduserWithLiteralEscapeField, escapeNewlinesAsHTMLBreaks: true }
12973
+ ) === '<p>Locations: NYC<br />SF<br />LA</p>',
12974
+ 'fail literal \\n escape in substituted value', 'literal \\n escape in substituted value'
12975
+ )
12976
+
12977
+ // Substituted value with \r\n is also converted (single break per CRLF, not two)
12978
+ const enduserWithCRLFField = {
12979
+ fname: "Multi",
12980
+ fields: { Locations: 'NYC\r\nSF\r\nLA' },
12981
+ } as Partial<Enduser>
12982
+ assert(
12983
+ replace_form_field_template_values(
12984
+ '<p>Locations: {{enduser.Locations}}</p>',
12985
+ { enduser: enduserWithCRLFField, escapeNewlinesAsHTMLBreaks: true }
12986
+ ) === '<p>Locations: NYC<br />SF<br />LA</p>',
12987
+ 'fail CRLF in substituted value', 'CRLF in substituted value'
12988
+ )
12989
+ }
12990
+
12910
12991
  const inbox_threads_building_tests = async () => {
12911
12992
  log_header("Inbox Thread Building Tests")
12912
12993
 
@@ -14203,6 +14284,7 @@ const ip_address_form_tests = async () => {
14203
14284
 
14204
14285
  await enduser_conditional_logic_tests()
14205
14286
  await replace_enduser_template_values_tests()
14287
+ await replace_form_field_template_values_tests()
14206
14288
  await mfa_tests()
14207
14289
  await setup_tests(sdk, sdkNonAdmin)
14208
14290
  await eom_procedure_codes_tests({ sdk, sdkNonAdmin })
Binary file