@nyaruka/temba-components 0.140.0 → 0.141.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.
- package/.lintstagedrc.js +10 -0
- package/CHANGELOG.md +22 -0
- package/dist/locales/es.js +5 -5
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.js +5 -5
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/locale-codes.js +11 -2
- package/dist/locales/locale-codes.js.map +1 -1
- package/dist/locales/pt.js +5 -5
- package/dist/locales/pt.js.map +1 -1
- package/dist/temba-components.js +263 -156
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/display/FloatingTab.js +1 -1
- package/out-tsc/src/display/FloatingTab.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +1 -1
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +239 -43
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/Plumber.js +61 -14
- package/out-tsc/src/flow/Plumber.js.map +1 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js +4 -1
- package/out-tsc/src/flow/actions/add_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/add_input_labels.js +4 -1
- package/out-tsc/src/flow/actions/add_input_labels.js.map +1 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js +6 -1
- package/out-tsc/src/flow/actions/remove_contact_groups.js.map +1 -1
- package/out-tsc/src/flow/actions/send_broadcast.js +6 -2
- package/out-tsc/src/flow/actions/send_broadcast.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_channel.js +13 -0
- package/out-tsc/src/flow/actions/set_contact_channel.js.map +1 -1
- package/out-tsc/src/flow/actions/set_contact_status.js +7 -5
- package/out-tsc/src/flow/actions/set_contact_status.js.map +1 -1
- package/out-tsc/src/flow/actions/start_session.js +10 -3
- package/out-tsc/src/flow/actions/start_session.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_contact_field.js +18 -5
- package/out-tsc/src/flow/nodes/split_by_contact_field.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_expression.js +1 -1
- package/out-tsc/src/flow/nodes/split_by_expression.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js +0 -1
- package/out-tsc/src/flow/nodes/split_by_llm_categorize.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_random.js +0 -1
- package/out-tsc/src/flow/nodes/split_by_random.js.map +1 -1
- package/out-tsc/src/flow/nodes/split_by_run_result.js +10 -4
- package/out-tsc/src/flow/nodes/split_by_run_result.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js +1 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js +1 -1
- package/out-tsc/src/flow/nodes/wait_for_response.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +7 -0
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/layout/Dialog.js +0 -1
- package/out-tsc/src/layout/Dialog.js.map +1 -1
- package/out-tsc/src/layout/Modax.js +20 -2
- package/out-tsc/src/layout/Modax.js.map +1 -1
- package/out-tsc/src/list/ContentMenu.js +14 -1
- package/out-tsc/src/list/ContentMenu.js.map +1 -1
- package/out-tsc/src/live/ContactChat.js +10 -1
- package/out-tsc/src/live/ContactChat.js.map +1 -1
- package/out-tsc/src/live/TembaChart.js.map +1 -1
- package/out-tsc/src/locales/es.js +5 -5
- package/out-tsc/src/locales/es.js.map +1 -1
- package/out-tsc/src/locales/fr.js +5 -5
- package/out-tsc/src/locales/fr.js.map +1 -1
- package/out-tsc/src/locales/locale-codes.js +11 -2
- package/out-tsc/src/locales/locale-codes.js.map +1 -1
- package/out-tsc/src/locales/pt.js +5 -5
- package/out-tsc/src/locales/pt.js.map +1 -1
- package/out-tsc/src/simulator/Simulator.js +11 -0
- package/out-tsc/src/simulator/Simulator.js.map +1 -1
- package/out-tsc/src/store/AppState.js +13 -0
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/src/version.js +9 -0
- package/out-tsc/src/version.js.map +1 -0
- package/out-tsc/test/actions/add_contact_groups.test.js +35 -0
- package/out-tsc/test/actions/add_contact_groups.test.js.map +1 -1
- package/out-tsc/test/actions/add_input_labels.test.js +53 -0
- package/out-tsc/test/actions/add_input_labels.test.js.map +1 -0
- package/out-tsc/test/actions/enter_flow.test.js +71 -0
- package/out-tsc/test/actions/enter_flow.test.js.map +1 -0
- package/out-tsc/test/actions/remove_contact_groups.test.js +24 -0
- package/out-tsc/test/actions/remove_contact_groups.test.js.map +1 -1
- package/out-tsc/test/actions/send_broadcast.test.js +41 -0
- package/out-tsc/test/actions/send_broadcast.test.js.map +1 -1
- package/out-tsc/test/actions/set_contact_channel.test.js +67 -0
- package/out-tsc/test/actions/set_contact_channel.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_field.test.js +52 -0
- package/out-tsc/test/actions/set_contact_field.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_language.test.js +39 -0
- package/out-tsc/test/actions/set_contact_language.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_name.test.js +28 -0
- package/out-tsc/test/actions/set_contact_name.test.js.map +1 -0
- package/out-tsc/test/actions/set_contact_status.test.js +44 -0
- package/out-tsc/test/actions/set_contact_status.test.js.map +1 -0
- package/out-tsc/test/actions/set_run_result.test.js +47 -0
- package/out-tsc/test/actions/set_run_result.test.js.map +1 -0
- package/out-tsc/test/actions/start_session.test.js +76 -0
- package/out-tsc/test/actions/start_session.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_contact_field.test.js +50 -0
- package/out-tsc/test/nodes/split_by_contact_field.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_run_result.test.js +82 -0
- package/out-tsc/test/nodes/split_by_run_result.test.js.map +1 -1
- package/out-tsc/test/nodes/split_by_ticket.test.js +139 -0
- package/out-tsc/test/nodes/split_by_ticket.test.js.map +1 -0
- package/out-tsc/test/nodes/split_by_webhook.test.js +111 -0
- package/out-tsc/test/nodes/split_by_webhook.test.js.map +1 -0
- package/out-tsc/test/temba-contact-chat.test.js +12 -0
- package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +206 -0
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber.test.js +19 -0
- package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
- package/out-tsc/test/temba-select.test.js +4 -1
- package/out-tsc/test/temba-select.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +4 -2
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +3 -9
- package/rollup.components.mjs +7 -1
- package/screenshots/truth/actions/add_contact_groups/render/descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/long-group-names.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/add_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-facebook.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/expression-phone.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/facebook-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/instagram-handle.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/line-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/phone-number.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/telegram-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/viber-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/wechat-id.png +0 -0
- package/screenshots/truth/actions/add_contact_urn/render/whatsapp.png +0 -0
- package/screenshots/truth/actions/add_input_labels/editor/multiple-labels.png +0 -0
- package/screenshots/truth/actions/add_input_labels/editor/single-label.png +0 -0
- package/screenshots/truth/actions/add_input_labels/render/multiple-labels.png +0 -0
- package/screenshots/truth/actions/add_input_labels/render/single-label.png +0 -0
- package/screenshots/truth/actions/enter_flow/editor/basic-flow.png +0 -0
- package/screenshots/truth/actions/enter_flow/editor/long-flow-name.png +0 -0
- package/screenshots/truth/actions/enter_flow/render/basic-flow.png +0 -0
- package/screenshots/truth/actions/enter_flow/render/long-flow-name.png +0 -0
- package/screenshots/truth/actions/play_audio/render/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/static-url.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/cleanup-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/long-descriptive-group-names.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/many-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/multiple-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/remove-from-all-groups.png +0 -0
- package/screenshots/truth/actions/remove_contact_groups/render/single-group.png +0 -0
- package/screenshots/truth/actions/say_msg/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/text-with-audio-url.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/groups-only.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/many-groups.png +0 -0
- package/screenshots/truth/actions/send_broadcast/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/send_email/render/complex-business-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/empty-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/long-subject.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiline-body.png +0 -0
- package/screenshots/truth/actions/send_email/render/multiple-recipients.png +0 -0
- package/screenshots/truth/actions/send_email/render/simple-email.png +0 -0
- package/screenshots/truth/actions/send_email/render/with-expressions.png +0 -0
- package/screenshots/truth/actions/send_msg/render/long-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/multiline-text-with-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-linebreaks.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-many-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-with-quick-replies.png +0 -0
- package/screenshots/truth/actions/send_msg/render/text-without-quick-replies.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/editor/sms-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/editor/whatsapp-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/render/sms-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_channel/render/whatsapp-channel.png +0 -0
- package/screenshots/truth/actions/set_contact_field/editor/clear-value.png +0 -0
- package/screenshots/truth/actions/set_contact_field/editor/set-value.png +0 -0
- package/screenshots/truth/actions/set_contact_field/render/clear-value.png +0 -0
- package/screenshots/truth/actions/set_contact_field/render/set-value.png +0 -0
- package/screenshots/truth/actions/set_contact_language/editor/english.png +0 -0
- package/screenshots/truth/actions/set_contact_language/editor/french.png +0 -0
- package/screenshots/truth/actions/set_contact_language/render/english.png +0 -0
- package/screenshots/truth/actions/set_contact_language/render/french.png +0 -0
- package/screenshots/truth/actions/set_contact_name/editor/expression-name.png +0 -0
- package/screenshots/truth/actions/set_contact_name/editor/static-name.png +0 -0
- package/screenshots/truth/actions/set_contact_name/render/expression-name.png +0 -0
- package/screenshots/truth/actions/set_contact_name/render/static-name.png +0 -0
- package/screenshots/truth/actions/set_contact_status/editor/active.png +0 -0
- package/screenshots/truth/actions/set_contact_status/editor/archived.png +0 -0
- package/screenshots/truth/actions/set_contact_status/editor/blocked.png +0 -0
- package/screenshots/truth/actions/set_contact_status/render/active.png +0 -0
- package/screenshots/truth/actions/set_contact_status/render/archived.png +0 -0
- package/screenshots/truth/actions/set_contact_status/render/blocked.png +0 -0
- package/screenshots/truth/actions/set_run_result/editor/expression-value.png +0 -0
- package/screenshots/truth/actions/set_run_result/editor/with-category.png +0 -0
- package/screenshots/truth/actions/set_run_result/render/expression-value.png +0 -0
- package/screenshots/truth/actions/set_run_result/render/with-category.png +0 -0
- package/screenshots/truth/actions/start_session/render/contact-query.png +0 -0
- package/screenshots/truth/actions/start_session/render/contacts-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/create-contact.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-and-contacts.png +0 -0
- package/screenshots/truth/actions/start_session/render/groups-only.png +0 -0
- package/screenshots/truth/actions/start_session/render/many-recipients.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/information-extraction.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/sentiment-analysis.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/summarization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm/render/translation-task.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/editor/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/basic-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/custom-input-and-result-name.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/feedback-categorization.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/many-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_llm_categorize/render/minimal-categories.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/editor/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/ab-test-multiple-variants.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/sampling-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/three-way-split.png +0 -0
- package/screenshots/truth/nodes/split_by_random/render/two-bucket-split.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/dial-with-limits.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/render/menu-with-digits.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
- package/src/display/FloatingTab.ts +1 -1
- package/src/flow/CanvasNode.ts +1 -1
- package/src/flow/Editor.ts +299 -88
- package/src/flow/Plumber.ts +89 -14
- package/src/flow/actions/add_contact_groups.ts +4 -1
- package/src/flow/actions/add_input_labels.ts +4 -1
- package/src/flow/actions/remove_contact_groups.ts +6 -1
- package/src/flow/actions/send_broadcast.ts +6 -2
- package/src/flow/actions/set_contact_channel.ts +13 -1
- package/src/flow/actions/set_contact_status.ts +7 -5
- package/src/flow/actions/start_session.ts +10 -3
- package/src/flow/nodes/split_by_contact_field.ts +16 -5
- package/src/flow/nodes/split_by_expression.ts +1 -1
- package/src/flow/nodes/split_by_llm_categorize.ts +0 -1
- package/src/flow/nodes/split_by_random.ts +0 -1
- package/src/flow/nodes/split_by_run_result.ts +10 -4
- package/src/flow/nodes/wait_for_digits.ts +2 -1
- package/src/flow/nodes/wait_for_response.ts +1 -1
- package/src/form/FieldRenderer.ts +7 -0
- package/src/layout/Dialog.ts +0 -1
- package/src/layout/Modax.ts +19 -2
- package/src/list/ContentMenu.ts +15 -1
- package/src/live/ContactChat.ts +10 -1
- package/src/live/TembaChart.ts +1 -1
- package/src/locales/es.ts +18 -13
- package/src/locales/fr.ts +18 -13
- package/src/locales/locale-codes.ts +11 -2
- package/src/locales/pt.ts +18 -13
- package/src/simulator/Simulator.ts +12 -0
- package/src/store/AppState.ts +15 -0
- package/src/store/flow-definition.d.ts +1 -0
- package/src/version.ts +10 -0
- package/test/actions/add_contact_groups.test.ts +38 -0
- package/test/actions/add_input_labels.test.ts +67 -0
- package/test/actions/enter_flow.test.ts +88 -0
- package/test/actions/remove_contact_groups.test.ts +29 -0
- package/test/actions/send_broadcast.test.ts +44 -0
- package/test/actions/set_contact_channel.test.ts +88 -0
- package/test/actions/set_contact_field.test.ts +68 -0
- package/test/actions/set_contact_language.test.ts +55 -0
- package/test/actions/set_contact_name.test.ts +39 -0
- package/test/actions/set_contact_status.test.ts +64 -0
- package/test/actions/set_run_result.test.ts +61 -0
- package/test/actions/start_session.test.ts +82 -0
- package/test/nodes/split_by_contact_field.test.ts +59 -0
- package/test/nodes/split_by_run_result.test.ts +100 -0
- package/test/nodes/split_by_ticket.test.ts +157 -0
- package/test/nodes/split_by_webhook.test.ts +131 -0
- package/test/temba-contact-chat.test.ts +17 -0
- package/test/temba-flow-editor.test.ts +264 -0
- package/test/temba-flow-plumber.test.ts +62 -0
- package/test/temba-select.test.ts +6 -1
- package/test/utils.test.ts +4 -2
- package/web-dev-server.config.mjs +5 -1
- package/web-test-runner.config.mjs +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send_broadcast.test.js","sourceRoot":"","sources":["../../../test/actions/send_broadcast.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAEhE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,6CAA6C;YACnD,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE;gBACxC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE;aACzC;YACD,QAAQ,EAAE,EAAE;SACI,EAClB,aAAa,CACd,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAA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AAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { send_broadcast } from '../../src/flow/actions/send_broadcast';\nimport { SendBroadcast } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the send_broadcast action configuration.\n */\ndescribe('send_broadcast action config', () => {\n const helper = new ActionTest(send_broadcast, 'send_broadcast');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(send_broadcast.name).to.equal('Send Broadcast');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'send_broadcast',\n text: 'Important announcement for all subscribers!',\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'VIP Members' }\n ],\n contacts: []\n } as SendBroadcast,\n 'groups-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'send_broadcast',\n text: 'Personal message to specific contacts.',\n groups: [],\n contacts: [\n { uuid: 'contact-1', name: 'Alice Johnson' },\n { uuid: 'contact-2', name: 'Bob Smith' }\n ]\n } as SendBroadcast,\n 'contacts-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'send_broadcast',\n text: 'Urgent update for everyone!',\n groups: [{ uuid: 'group-1', name: 'All Members' }],\n contacts: [{ uuid: 'contact-1', name: 'Admin' }]\n } as SendBroadcast,\n 'groups-and-contacts'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'send_broadcast',\n text: 'Multi-line broadcast message.\\n\\nThis is the second paragraph.\\n\\nAnd the third.',\n groups: [{ uuid: 'group-1', name: 'Newsletter Subscribers' }],\n contacts: []\n } as SendBroadcast,\n 'multiline-text'\n );\n\n /* TODO: flaky test having to do with attachment render times\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'send_broadcast',\n text: 'Broadcast with attachments',\n groups: [{ uuid: 'group-1', name: 'Members' }],\n contacts: [],\n attachments: [\n 'image/jpeg:https://example.com/photo.jpg',\n 'application/pdf:https://example.com/document.pdf'\n ]\n } as SendBroadcast,\n 'with-attachments',\n true\n );*/\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'send_broadcast',\n text: 'Message to many groups',\n groups: [\n { uuid: 'group-1', name: 'Group A' },\n { uuid: 'group-2', name: 'Group B' },\n { uuid: 'group-3', name: 'Group C' },\n { uuid: 'group-4', name: 'Group D' }\n ],\n contacts: []\n } as SendBroadcast,\n 'many-groups'\n );\n });\n\n describe('form data conversion', () => {\n it('converts action to form data correctly', () => {\n const action: SendBroadcast = {\n uuid: 'test-uuid',\n type: 'send_broadcast',\n text: 'Test message',\n groups: [{ uuid: 'group-1', name: 'Test Group' }],\n contacts: [{ uuid: 'contact-1', name: 'Test Contact' }],\n attachments: ['image/jpeg:test.jpg']\n };\n\n const formData = send_broadcast.toFormData(action);\n\n expect(formData.uuid).to.equal('test-uuid');\n expect(formData.text).to.equal('Test message');\n expect(formData.recipients).to.have.lengthOf(2);\n expect(formData.attachments).to.deep.equal(['image/jpeg:test.jpg']);\n });\n\n it('converts form data to action correctly with contacts only', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'contact-2', name: 'Contact 2' }\n ],\n text: 'Test message',\n attachments: []\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.uuid).to.equal('test-uuid');\n expect(action.type).to.equal('send_broadcast');\n expect(action.text).to.equal('Test message');\n expect(action.contacts).to.have.lengthOf(2);\n expect(action.groups).to.have.lengthOf(0);\n expect(action.attachments).to.be.undefined;\n });\n\n it('converts form data to action correctly with groups only', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n { uuid: 'group-1', name: 'Group 1', group: true },\n { uuid: 'group-2', name: 'Group 2', group: true }\n ],\n text: 'Test message',\n attachments: []\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.contacts).to.have.lengthOf(0);\n expect(action.groups).to.have.lengthOf(2);\n });\n\n it('converts form data to action correctly with mixed recipients', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'group-1', name: 'Group 1', group: true }\n ],\n text: 'Test message',\n attachments: ['image/jpeg:test.jpg']\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.contacts).to.have.lengthOf(1);\n expect(action.groups).to.have.lengthOf(1);\n expect(action.attachments).to.deep.equal(['image/jpeg:test.jpg']);\n });\n\n it('sanitizes text by trimming whitespace', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [{ uuid: 'contact-1', name: 'Test Contact' }],\n text: ' Test message \\n '\n };\n\n send_broadcast.sanitize(formData);\n\n expect(formData.text).to.equal('Test message');\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"send_broadcast.test.js","sourceRoot":"","sources":["../../../test/actions/send_broadcast.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAEhE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC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GAAG,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAkB,CAAC;YAEtE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC5C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACvC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;YACH,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACrC,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,aAAa;aACpB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { send_broadcast } from '../../src/flow/actions/send_broadcast';\nimport { SendBroadcast } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the send_broadcast action configuration.\n */\ndescribe('send_broadcast action config', () => {\n const helper = new ActionTest(send_broadcast, 'send_broadcast');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(send_broadcast.name).to.equal('Send Broadcast');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'send_broadcast',\n text: 'Important announcement for all subscribers!',\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'VIP Members' }\n ],\n contacts: []\n } as SendBroadcast,\n 'groups-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'send_broadcast',\n text: 'Personal message to specific contacts.',\n groups: [],\n contacts: [\n { uuid: 'contact-1', name: 'Alice Johnson' },\n { uuid: 'contact-2', name: 'Bob Smith' }\n ]\n } as SendBroadcast,\n 'contacts-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'send_broadcast',\n text: 'Urgent update for everyone!',\n groups: [{ uuid: 'group-1', name: 'All Members' }],\n contacts: [{ uuid: 'contact-1', name: 'Admin' }]\n } as SendBroadcast,\n 'groups-and-contacts'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'send_broadcast',\n text: 'Multi-line broadcast message.\\n\\nThis is the second paragraph.\\n\\nAnd the third.',\n groups: [{ uuid: 'group-1', name: 'Newsletter Subscribers' }],\n contacts: []\n } as SendBroadcast,\n 'multiline-text'\n );\n\n /* TODO: flaky test having to do with attachment render times\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'send_broadcast',\n text: 'Broadcast with attachments',\n groups: [{ uuid: 'group-1', name: 'Members' }],\n contacts: [],\n attachments: [\n 'image/jpeg:https://example.com/photo.jpg',\n 'application/pdf:https://example.com/document.pdf'\n ]\n } as SendBroadcast,\n 'with-attachments',\n true\n );*/\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'send_broadcast',\n text: 'Message to many groups',\n groups: [\n { uuid: 'group-1', name: 'Group A' },\n { uuid: 'group-2', name: 'Group B' },\n { uuid: 'group-3', name: 'Group C' },\n { uuid: 'group-4', name: 'Group D' }\n ],\n contacts: []\n } as SendBroadcast,\n 'many-groups'\n );\n });\n\n describe('form data conversion', () => {\n it('converts action to form data correctly', () => {\n const action: SendBroadcast = {\n uuid: 'test-uuid',\n type: 'send_broadcast',\n text: 'Test message',\n groups: [{ uuid: 'group-1', name: 'Test Group' }],\n contacts: [{ uuid: 'contact-1', name: 'Test Contact' }],\n attachments: ['image/jpeg:test.jpg']\n };\n\n const formData = send_broadcast.toFormData(action);\n\n expect(formData.uuid).to.equal('test-uuid');\n expect(formData.text).to.equal('Test message');\n expect(formData.recipients).to.have.lengthOf(2);\n expect(formData.attachments).to.deep.equal(['image/jpeg:test.jpg']);\n });\n\n it('converts form data to action correctly with contacts only', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'contact-2', name: 'Contact 2' }\n ],\n text: 'Test message',\n attachments: []\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.uuid).to.equal('test-uuid');\n expect(action.type).to.equal('send_broadcast');\n expect(action.text).to.equal('Test message');\n expect(action.contacts).to.have.lengthOf(2);\n expect(action.groups).to.have.lengthOf(0);\n expect(action.attachments).to.be.undefined;\n });\n\n it('converts form data to action correctly with groups only', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n { uuid: 'group-1', name: 'Group 1', group: true },\n { uuid: 'group-2', name: 'Group 2', group: true }\n ],\n text: 'Test message',\n attachments: []\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.contacts).to.have.lengthOf(0);\n expect(action.groups).to.have.lengthOf(2);\n });\n\n it('converts form data to action correctly with mixed recipients', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'group-1', name: 'Group 1', group: true }\n ],\n text: 'Test message',\n attachments: ['image/jpeg:test.jpg']\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.contacts).to.have.lengthOf(1);\n expect(action.groups).to.have.lengthOf(1);\n expect(action.attachments).to.deep.equal(['image/jpeg:test.jpg']);\n });\n\n it('sanitizes text by trimming whitespace', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [{ uuid: 'contact-1', name: 'Test Contact' }],\n text: ' Test message \\n '\n };\n\n send_broadcast.sanitize(formData);\n\n expect(formData.text).to.equal('Test message');\n });\n\n it('should strip superfluous API metadata from contacts and groups', () => {\n const formData = {\n uuid: 'test-uuid',\n recipients: [\n {\n uuid: 'contact-1',\n name: 'Alice',\n status: 'active',\n language: 'eng',\n urns: ['tel:+250788123456'],\n groups: [{ uuid: 'g-1', name: 'G1' }],\n fields: { age: '30' },\n created_on: '2024-01-01T00:00:00.000Z',\n modified_on: '2024-06-15T12:00:00.000Z',\n last_seen_on: '2024-06-14T10:00:00.000Z'\n },\n {\n uuid: 'group-1',\n name: 'Subscribers',\n group: true,\n query: null,\n status: 'ready',\n count: 500,\n system: false\n }\n ],\n text: 'Hello!',\n attachments: []\n };\n\n const action = send_broadcast.fromFormData(formData) as SendBroadcast;\n\n expect(action.contacts).to.have.lengthOf(1);\n expect(action.contacts[0]).to.deep.equal({\n uuid: 'contact-1',\n name: 'Alice'\n });\n expect(action.groups).to.have.lengthOf(1);\n expect(action.groups[0]).to.deep.equal({\n uuid: 'group-1',\n name: 'Subscribers'\n });\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { set_contact_channel } from '../../src/flow/actions/set_contact_channel';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the set_contact_channel action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('set_contact_channel action config', () => {
|
|
8
|
+
const helper = new ActionTest(set_contact_channel, 'set_contact_channel');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(set_contact_channel.name).to.equal('Update Channel');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('action scenarios', () => {
|
|
16
|
+
helper.testAction({
|
|
17
|
+
uuid: 'test-action-1',
|
|
18
|
+
type: 'set_contact_channel',
|
|
19
|
+
channel: { uuid: 'channel-1', name: 'WhatsApp Channel' }
|
|
20
|
+
}, 'whatsapp-channel');
|
|
21
|
+
helper.testAction({
|
|
22
|
+
uuid: 'test-action-2',
|
|
23
|
+
type: 'set_contact_channel',
|
|
24
|
+
channel: { uuid: 'channel-2', name: 'Twilio SMS' }
|
|
25
|
+
}, 'sms-channel');
|
|
26
|
+
});
|
|
27
|
+
describe('metadata stripping', () => {
|
|
28
|
+
it('should strip superfluous API metadata from channel', () => {
|
|
29
|
+
const formData = {
|
|
30
|
+
uuid: 'test-uuid',
|
|
31
|
+
channel: [
|
|
32
|
+
{
|
|
33
|
+
uuid: 'channel-1',
|
|
34
|
+
name: 'WhatsApp Channel',
|
|
35
|
+
address: '+250788123456',
|
|
36
|
+
country: 'RW',
|
|
37
|
+
schemes: ['whatsapp'],
|
|
38
|
+
roles: ['send', 'receive'],
|
|
39
|
+
created_on: '2024-01-01T00:00:00.000Z'
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
const action = set_contact_channel.fromFormData(formData);
|
|
44
|
+
expect(action.channel).to.deep.equal({
|
|
45
|
+
uuid: 'channel-1',
|
|
46
|
+
name: 'WhatsApp Channel'
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
it('should handle channel selected via value key', () => {
|
|
50
|
+
const formData = {
|
|
51
|
+
uuid: 'test-uuid',
|
|
52
|
+
channel: [
|
|
53
|
+
{
|
|
54
|
+
value: 'channel-1',
|
|
55
|
+
name: 'WhatsApp Channel'
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
const action = set_contact_channel.fromFormData(formData);
|
|
60
|
+
expect(action.channel).to.deep.equal({
|
|
61
|
+
uuid: 'channel-1',
|
|
62
|
+
name: 'WhatsApp Channel'
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=set_contact_channel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_contact_channel.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_channel.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CA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,OAAO,EAAE,CAAC,UAAU,CAAC;wBACrB,KAAK,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;wBAC1B,UAAU,EAAE,0BAA0B;qBACvC;iBACF;aACF,CAAC;YAEF,MAAM,MAAM,GAAG,mBAAmB,CAAC,YAAY,CAC7C,QAAQ,CACY,CAAC;YAEvB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACnC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB;aACzB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;YACtD,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,WAAW;wBAClB,IAAI,EAAE,kBAAkB;qBACzB;iBACF;aACF,CAAC;YAEF,MAAM,MAAM,GAAG,mBAAmB,CAAC,YAAY,CAC7C,QAAQ,CACY,CAAC;YAEvB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACnC,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,kBAAkB;aACzB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_channel } from '../../src/flow/actions/set_contact_channel';\nimport { SetContactChannel } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_channel action configuration.\n */\ndescribe('set_contact_channel action config', () => {\n const helper = new ActionTest(set_contact_channel, 'set_contact_channel');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_channel.name).to.equal('Update Channel');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_channel',\n channel: { uuid: 'channel-1', name: 'WhatsApp Channel' }\n } as SetContactChannel,\n 'whatsapp-channel'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_channel',\n channel: { uuid: 'channel-2', name: 'Twilio SMS' }\n } as SetContactChannel,\n 'sms-channel'\n );\n });\n\n describe('metadata stripping', () => {\n it('should strip superfluous API metadata from channel', () => {\n const formData = {\n uuid: 'test-uuid',\n channel: [\n {\n uuid: 'channel-1',\n name: 'WhatsApp Channel',\n address: '+250788123456',\n country: 'RW',\n schemes: ['whatsapp'],\n roles: ['send', 'receive'],\n created_on: '2024-01-01T00:00:00.000Z'\n }\n ]\n };\n\n const action = set_contact_channel.fromFormData(\n formData\n ) as SetContactChannel;\n\n expect(action.channel).to.deep.equal({\n uuid: 'channel-1',\n name: 'WhatsApp Channel'\n });\n });\n\n it('should handle channel selected via value key', () => {\n const formData = {\n uuid: 'test-uuid',\n channel: [\n {\n value: 'channel-1',\n name: 'WhatsApp Channel'\n }\n ]\n };\n\n const action = set_contact_channel.fromFormData(\n formData\n ) as SetContactChannel;\n\n expect(action.channel).to.deep.equal({\n uuid: 'channel-1',\n name: 'WhatsApp Channel'\n });\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { set_contact_field } from '../../src/flow/actions/set_contact_field';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the set_contact_field action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('set_contact_field action config', () => {
|
|
8
|
+
const helper = new ActionTest(set_contact_field, 'set_contact_field');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(set_contact_field.name).to.equal('Update Field');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('action scenarios', () => {
|
|
16
|
+
helper.testAction({
|
|
17
|
+
uuid: 'test-action-1',
|
|
18
|
+
type: 'set_contact_field',
|
|
19
|
+
field: { key: 'favorite_color', name: 'Favorite Color' },
|
|
20
|
+
value: 'Blue'
|
|
21
|
+
}, 'set-value');
|
|
22
|
+
helper.testAction({
|
|
23
|
+
uuid: 'test-action-2',
|
|
24
|
+
type: 'set_contact_field',
|
|
25
|
+
field: { key: 'age', name: 'Age' },
|
|
26
|
+
value: ''
|
|
27
|
+
}, 'clear-value');
|
|
28
|
+
});
|
|
29
|
+
describe('metadata stripping', () => {
|
|
30
|
+
it('should strip superfluous API metadata from field', () => {
|
|
31
|
+
const formData = {
|
|
32
|
+
uuid: 'test-uuid',
|
|
33
|
+
field: [
|
|
34
|
+
{
|
|
35
|
+
key: 'favorite_color',
|
|
36
|
+
name: 'Favorite Color',
|
|
37
|
+
value_type: 'text',
|
|
38
|
+
featured: true,
|
|
39
|
+
usages: { campaign_events: 0, flows: 3, groups: 1 }
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
value: 'Red'
|
|
43
|
+
};
|
|
44
|
+
const action = set_contact_field.fromFormData(formData);
|
|
45
|
+
expect(action.field).to.deep.equal({
|
|
46
|
+
key: 'favorite_color',
|
|
47
|
+
name: 'Favorite Color'
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=set_contact_field.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_contact_field.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_field.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/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aACb,CAAC;YAEF,MAAM,MAAM,GAAG,iBAAiB,CAAC,YAAY,CAC3C,QAAQ,CACU,CAAC;YAErB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACjC,GAAG,EAAE,gBAAgB;gBACrB,IAAI,EAAE,gBAAgB;aACvB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_field } from '../../src/flow/actions/set_contact_field';\nimport { SetContactField } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_field action configuration.\n */\ndescribe('set_contact_field action config', () => {\n const helper = new ActionTest(set_contact_field, 'set_contact_field');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_field.name).to.equal('Update Field');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_field',\n field: { key: 'favorite_color', name: 'Favorite Color' },\n value: 'Blue'\n } as SetContactField,\n 'set-value'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_field',\n field: { key: 'age', name: 'Age' },\n value: ''\n } as SetContactField,\n 'clear-value'\n );\n });\n\n describe('metadata stripping', () => {\n it('should strip superfluous API metadata from field', () => {\n const formData = {\n uuid: 'test-uuid',\n field: [\n {\n key: 'favorite_color',\n name: 'Favorite Color',\n value_type: 'text',\n featured: true,\n usages: { campaign_events: 0, flows: 3, groups: 1 }\n }\n ],\n value: 'Red'\n };\n\n const action = set_contact_field.fromFormData(\n formData\n ) as SetContactField;\n\n expect(action.field).to.deep.equal({\n key: 'favorite_color',\n name: 'Favorite Color'\n });\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { set_contact_language } from '../../src/flow/actions/set_contact_language';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the set_contact_language action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('set_contact_language action config', () => {
|
|
8
|
+
const helper = new ActionTest(set_contact_language, 'set_contact_language');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(set_contact_language.name).to.equal('Update Language');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('action scenarios', () => {
|
|
16
|
+
helper.testAction({
|
|
17
|
+
uuid: 'test-action-1',
|
|
18
|
+
type: 'set_contact_language',
|
|
19
|
+
language: 'eng'
|
|
20
|
+
}, 'english');
|
|
21
|
+
helper.testAction({
|
|
22
|
+
uuid: 'test-action-2',
|
|
23
|
+
type: 'set_contact_language',
|
|
24
|
+
language: 'fra'
|
|
25
|
+
}, 'french');
|
|
26
|
+
});
|
|
27
|
+
describe('round-trip', () => {
|
|
28
|
+
it('should extract language code from select option', () => {
|
|
29
|
+
const formData = {
|
|
30
|
+
uuid: 'test-uuid',
|
|
31
|
+
language: [{ value: 'spa', name: 'Spanish' }]
|
|
32
|
+
};
|
|
33
|
+
const action = set_contact_language.fromFormData(formData);
|
|
34
|
+
expect(action.language).to.equal('spa');
|
|
35
|
+
expect(action.type).to.equal('set_contact_language');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=set_contact_language.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_contact_language.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_language.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAEnF,OAAO,EAAE,UAAU,EAAE,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CAAC,sBAAsB,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_language } from '../../src/flow/actions/set_contact_language';\nimport { SetContactLanguage } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_language action configuration.\n */\ndescribe('set_contact_language action config', () => {\n const helper = new ActionTest(set_contact_language, 'set_contact_language');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_language.name).to.equal('Update Language');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_language',\n language: 'eng'\n } as SetContactLanguage,\n 'english'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_language',\n language: 'fra'\n } as SetContactLanguage,\n 'french'\n );\n });\n\n describe('round-trip', () => {\n it('should extract language code from select option', () => {\n const formData = {\n uuid: 'test-uuid',\n language: [{ value: 'spa', name: 'Spanish' }]\n };\n\n const action = set_contact_language.fromFormData(\n formData\n ) as SetContactLanguage;\n\n expect(action.language).to.equal('spa');\n expect(action.type).to.equal('set_contact_language');\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { set_contact_name } from '../../src/flow/actions/set_contact_name';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the set_contact_name action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('set_contact_name action config', () => {
|
|
8
|
+
const helper = new ActionTest(set_contact_name, 'set_contact_name');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(set_contact_name.name).to.equal('Update Name');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('action scenarios', () => {
|
|
16
|
+
helper.testAction({
|
|
17
|
+
uuid: 'test-action-1',
|
|
18
|
+
type: 'set_contact_name',
|
|
19
|
+
name: 'Alice Johnson'
|
|
20
|
+
}, 'static-name');
|
|
21
|
+
helper.testAction({
|
|
22
|
+
uuid: 'test-action-2',
|
|
23
|
+
type: 'set_contact_name',
|
|
24
|
+
name: '@(title(input))'
|
|
25
|
+
}, 'expression-name');
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=set_contact_name.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_contact_name.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_name.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;IAEpE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,eAAe;SACJ,EACnB,aAAa,CACd,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,iBAAiB;SACN,EACnB,iBAAiB,CAClB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_name } from '../../src/flow/actions/set_contact_name';\nimport { SetContactName } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_name action configuration.\n */\ndescribe('set_contact_name action config', () => {\n const helper = new ActionTest(set_contact_name, 'set_contact_name');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_name.name).to.equal('Update Name');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_name',\n name: 'Alice Johnson'\n } as SetContactName,\n 'static-name'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_name',\n name: '@(title(input))'\n } as SetContactName,\n 'expression-name'\n );\n });\n});\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { set_contact_status } from '../../src/flow/actions/set_contact_status';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the set_contact_status action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('set_contact_status action config', () => {
|
|
8
|
+
const helper = new ActionTest(set_contact_status, 'set_contact_status');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(set_contact_status.name).to.equal('Update Status');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('action scenarios', () => {
|
|
16
|
+
helper.testAction({
|
|
17
|
+
uuid: 'test-action-1',
|
|
18
|
+
type: 'set_contact_status',
|
|
19
|
+
status: 'active'
|
|
20
|
+
}, 'active');
|
|
21
|
+
helper.testAction({
|
|
22
|
+
uuid: 'test-action-2',
|
|
23
|
+
type: 'set_contact_status',
|
|
24
|
+
status: 'blocked'
|
|
25
|
+
}, 'blocked');
|
|
26
|
+
helper.testAction({
|
|
27
|
+
uuid: 'test-action-3',
|
|
28
|
+
type: 'set_contact_status',
|
|
29
|
+
status: 'archived'
|
|
30
|
+
}, 'archived');
|
|
31
|
+
});
|
|
32
|
+
describe('round-trip', () => {
|
|
33
|
+
it('should extract status value from select option', () => {
|
|
34
|
+
const formData = {
|
|
35
|
+
uuid: 'test-uuid',
|
|
36
|
+
status: [{ value: 'stopped', name: 'Stopped' }]
|
|
37
|
+
};
|
|
38
|
+
const action = set_contact_status.fromFormData(formData);
|
|
39
|
+
expect(action.status).to.equal('stopped');
|
|
40
|
+
expect(action.type).to.equal('set_contact_status');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=set_contact_status.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_contact_status.test.js","sourceRoot":"","sources":["../../../test/actions/set_contact_status.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;IAExE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,QAAQ;SACG,EACrB,QAAQ,CACT,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,SAAS;SACE,EACrB,SAAS,CACV,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,oBAAoB;YAC1B,MAAM,EAAE,UAAU;SACC,EACrB,UAAU,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;QAC1B,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;aAChD,CAAC;YAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC,YAAY,CAC5C,QAAQ,CACW,CAAC;YAEtB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_contact_status } from '../../src/flow/actions/set_contact_status';\nimport { SetContactStatus } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_contact_status action configuration.\n */\ndescribe('set_contact_status action config', () => {\n const helper = new ActionTest(set_contact_status, 'set_contact_status');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_contact_status.name).to.equal('Update Status');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_contact_status',\n status: 'active'\n } as SetContactStatus,\n 'active'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_contact_status',\n status: 'blocked'\n } as SetContactStatus,\n 'blocked'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'set_contact_status',\n status: 'archived'\n } as SetContactStatus,\n 'archived'\n );\n });\n\n describe('round-trip', () => {\n it('should extract status value from select option', () => {\n const formData = {\n uuid: 'test-uuid',\n status: [{ value: 'stopped', name: 'Stopped' }]\n };\n\n const action = set_contact_status.fromFormData(\n formData\n ) as SetContactStatus;\n\n expect(action.status).to.equal('stopped');\n expect(action.type).to.equal('set_contact_status');\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { set_run_result } from '../../src/flow/actions/set_run_result';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the set_run_result action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('set_run_result action config', () => {
|
|
8
|
+
const helper = new ActionTest(set_run_result, 'set_run_result');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(set_run_result.name).to.equal('Save Flow Result');
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('action scenarios', () => {
|
|
16
|
+
helper.testAction({
|
|
17
|
+
uuid: 'test-action-1',
|
|
18
|
+
type: 'set_run_result',
|
|
19
|
+
name: 'Score',
|
|
20
|
+
value: '100',
|
|
21
|
+
category: 'High'
|
|
22
|
+
}, 'with-category');
|
|
23
|
+
helper.testAction({
|
|
24
|
+
uuid: 'test-action-2',
|
|
25
|
+
type: 'set_run_result',
|
|
26
|
+
name: 'Response',
|
|
27
|
+
value: '@input.text',
|
|
28
|
+
category: ''
|
|
29
|
+
}, 'expression-value');
|
|
30
|
+
});
|
|
31
|
+
describe('round-trip', () => {
|
|
32
|
+
it('should extract name from select option array', () => {
|
|
33
|
+
const formData = {
|
|
34
|
+
uuid: 'test-uuid',
|
|
35
|
+
name: [{ value: 'Score', name: 'Score' }],
|
|
36
|
+
value: '42',
|
|
37
|
+
category: 'Medium'
|
|
38
|
+
};
|
|
39
|
+
const action = set_run_result.fromFormData(formData);
|
|
40
|
+
expect(action.name).to.equal('Score');
|
|
41
|
+
expect(action.value).to.equal('42');
|
|
42
|
+
expect(action.category).to.equal('Medium');
|
|
43
|
+
expect(action.type).to.equal('set_run_result');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=set_run_result.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set_run_result.test.js","sourceRoot":"","sources":["../../../test/actions/set_run_result.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAEhE,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,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,gBAAgB,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { set_run_result } from '../../src/flow/actions/set_run_result';\nimport { SetRunResult } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the set_run_result action configuration.\n */\ndescribe('set_run_result action config', () => {\n const helper = new ActionTest(set_run_result, 'set_run_result');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(set_run_result.name).to.equal('Save Flow Result');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'set_run_result',\n name: 'Score',\n value: '100',\n category: 'High'\n } as SetRunResult,\n 'with-category'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'set_run_result',\n name: 'Response',\n value: '@input.text',\n category: ''\n } as SetRunResult,\n 'expression-value'\n );\n });\n\n describe('round-trip', () => {\n it('should extract name from select option array', () => {\n const formData = {\n uuid: 'test-uuid',\n name: [{ value: 'Score', name: 'Score' }],\n value: '42',\n category: 'Medium'\n };\n\n const action = set_run_result.fromFormData(formData) as SetRunResult;\n\n expect(action.name).to.equal('Score');\n expect(action.value).to.equal('42');\n expect(action.category).to.equal('Medium');\n expect(action.type).to.equal('set_run_result');\n });\n });\n});\n"]}
|
|
@@ -112,5 +112,81 @@ describe('start_session action config', () => {
|
|
|
112
112
|
expect(result.valid).to.be.true;
|
|
113
113
|
expect(Object.keys(result.errors).length).to.equal(0);
|
|
114
114
|
});
|
|
115
|
+
describe('metadata stripping', () => {
|
|
116
|
+
it('should strip superfluous API metadata from flow', () => {
|
|
117
|
+
const formData = {
|
|
118
|
+
uuid: 'test-uuid',
|
|
119
|
+
flow: [
|
|
120
|
+
{
|
|
121
|
+
uuid: 'flow-1',
|
|
122
|
+
name: 'Registration Flow',
|
|
123
|
+
type: 'message',
|
|
124
|
+
archived: false,
|
|
125
|
+
labels: [],
|
|
126
|
+
expires: 720,
|
|
127
|
+
runs: {
|
|
128
|
+
active: 0,
|
|
129
|
+
waiting: 5,
|
|
130
|
+
completed: 100,
|
|
131
|
+
interrupted: 2,
|
|
132
|
+
expired: 1,
|
|
133
|
+
failed: 0
|
|
134
|
+
},
|
|
135
|
+
results: [],
|
|
136
|
+
parent_refs: [],
|
|
137
|
+
created_on: '2024-01-01T00:00:00.000Z',
|
|
138
|
+
modified_on: '2024-06-15T12:00:00.000Z'
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
startType: [{ value: 'create', name: 'Create a new contact' }]
|
|
142
|
+
};
|
|
143
|
+
const action = start_session.fromFormData(formData);
|
|
144
|
+
expect(action.flow).to.deep.equal({
|
|
145
|
+
uuid: 'flow-1',
|
|
146
|
+
name: 'Registration Flow'
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
it('should strip superfluous API metadata from contacts and groups', () => {
|
|
150
|
+
const formData = {
|
|
151
|
+
uuid: 'test-uuid',
|
|
152
|
+
flow: [{ uuid: 'flow-1', name: 'Test Flow' }],
|
|
153
|
+
startType: [{ value: 'manual', name: 'Select recipients manually' }],
|
|
154
|
+
recipients: [
|
|
155
|
+
{
|
|
156
|
+
uuid: 'contact-1',
|
|
157
|
+
name: 'Alice',
|
|
158
|
+
status: 'active',
|
|
159
|
+
language: 'eng',
|
|
160
|
+
urns: ['tel:+250788123456'],
|
|
161
|
+
groups: [{ uuid: 'g-1', name: 'G1' }],
|
|
162
|
+
fields: { age: '30' },
|
|
163
|
+
created_on: '2024-01-01T00:00:00.000Z',
|
|
164
|
+
modified_on: '2024-06-15T12:00:00.000Z',
|
|
165
|
+
last_seen_on: '2024-06-14T10:00:00.000Z'
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
uuid: 'group-1',
|
|
169
|
+
name: 'VIP',
|
|
170
|
+
group: true,
|
|
171
|
+
query: 'status = vip',
|
|
172
|
+
status: 'ready',
|
|
173
|
+
count: 42,
|
|
174
|
+
system: false
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
const action = start_session.fromFormData(formData);
|
|
179
|
+
expect(action.contacts).to.have.lengthOf(1);
|
|
180
|
+
expect(action.contacts[0]).to.deep.equal({
|
|
181
|
+
uuid: 'contact-1',
|
|
182
|
+
name: 'Alice'
|
|
183
|
+
});
|
|
184
|
+
expect(action.groups).to.have.lengthOf(1);
|
|
185
|
+
expect(action.groups[0]).to.deep.equal({
|
|
186
|
+
uuid: 'group-1',
|
|
187
|
+
name: 'VIP'
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
115
191
|
});
|
|
116
192
|
//# sourceMappingURL=start_session.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_session.test.js","sourceRoot":"","sources":["../../../test/actions/start_session.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAE9D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,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WAAW,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;YACxD,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC;SAC/D,CAAC;QAEF,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { start_session } from '../../src/flow/actions/start_session';\nimport { StartSession } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the start_session action configuration.\n */\ndescribe('start_session action config', () => {\n const helper = new ActionTest(start_session, 'start_session');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(start_session.name).to.equal('Start Flow');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Registration Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'Volunteers' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Norbert Kwizera' },\n { uuid: 'contact-2', name: 'Rowan Seymour' }\n ]\n } as StartSession,\n 'groups-and-contacts'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Welcome Flow' },\n groups: [],\n contacts: [],\n create_contact: true\n } as StartSession,\n 'create-contact'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Survey Flow' },\n groups: [],\n contacts: [],\n contact_query: 'household_id = @fields.household_id'\n } as StartSession & { contact_query?: string },\n 'contact-query'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Broadcast Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'VIP Members' },\n { uuid: 'group-3', name: 'Newsletter' }\n ],\n contacts: []\n } as StartSession,\n 'groups-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Personal Flow' },\n groups: [],\n contacts: [\n { uuid: 'contact-1', name: 'Alice Johnson' },\n { uuid: 'contact-2', name: 'Bob Smith' }\n ]\n } as StartSession,\n 'contacts-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Mass Flow' },\n groups: [\n { uuid: 'group-1', name: 'Group 1' },\n { uuid: 'group-2', name: 'Group 2' },\n { uuid: 'group-3', name: 'Group 3' },\n { uuid: 'group-4', name: 'Group 4' },\n { uuid: 'group-5', name: 'Group 5' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'contact-2', name: 'Contact 2' }\n ]\n } as StartSession,\n 'many-recipients'\n );\n });\n\n it('validates manual selection requires recipients', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'manual', name: 'Select contacts and groups' }],\n recipients: []\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.recipients).to.equal(\n 'At least one contact or group must be selected'\n );\n });\n\n it('validates query requires contact_query value', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'query', name: 'Query for a contact' }],\n contactQuery: ''\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.contactQuery).to.equal('Contact query is required');\n });\n\n it('validates create_contact requires no additional fields', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'create', name: 'Create a new contact' }]\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors).length).to.equal(0);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"start_session.test.js","sourceRoot":"","sources":["../../../test/actions/start_session.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAE9D,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE;YACnD,MAAM,EAAE;gBACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE;gBACxC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,Y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AAQ,CAAC,CAAC,CAAC,CAAC;YAC1C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;gBACrC,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,KAAK;aACZ,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { start_session } from '../../src/flow/actions/start_session';\nimport { StartSession } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the start_session action configuration.\n */\ndescribe('start_session action config', () => {\n const helper = new ActionTest(start_session, 'start_session');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(start_session.name).to.equal('Start Flow');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Registration Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'Volunteers' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Norbert Kwizera' },\n { uuid: 'contact-2', name: 'Rowan Seymour' }\n ]\n } as StartSession,\n 'groups-and-contacts'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Welcome Flow' },\n groups: [],\n contacts: [],\n create_contact: true\n } as StartSession,\n 'create-contact'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Survey Flow' },\n groups: [],\n contacts: [],\n contact_query: 'household_id = @fields.household_id'\n } as StartSession & { contact_query?: string },\n 'contact-query'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Broadcast Flow' },\n groups: [\n { uuid: 'group-1', name: 'Subscribers' },\n { uuid: 'group-2', name: 'VIP Members' },\n { uuid: 'group-3', name: 'Newsletter' }\n ],\n contacts: []\n } as StartSession,\n 'groups-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Personal Flow' },\n groups: [],\n contacts: [\n { uuid: 'contact-1', name: 'Alice Johnson' },\n { uuid: 'contact-2', name: 'Bob Smith' }\n ]\n } as StartSession,\n 'contacts-only'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'start_session',\n flow: { uuid: 'flow-1', name: 'Mass Flow' },\n groups: [\n { uuid: 'group-1', name: 'Group 1' },\n { uuid: 'group-2', name: 'Group 2' },\n { uuid: 'group-3', name: 'Group 3' },\n { uuid: 'group-4', name: 'Group 4' },\n { uuid: 'group-5', name: 'Group 5' }\n ],\n contacts: [\n { uuid: 'contact-1', name: 'Contact 1' },\n { uuid: 'contact-2', name: 'Contact 2' }\n ]\n } as StartSession,\n 'many-recipients'\n );\n });\n\n it('validates manual selection requires recipients', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'manual', name: 'Select contacts and groups' }],\n recipients: []\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.recipients).to.equal(\n 'At least one contact or group must be selected'\n );\n });\n\n it('validates query requires contact_query value', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'query', name: 'Query for a contact' }],\n contactQuery: ''\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.false;\n expect(result.errors.contactQuery).to.equal('Contact query is required');\n });\n\n it('validates create_contact requires no additional fields', async () => {\n const formData = {\n uuid: 'start-uuid',\n flow: [{ uuid: 'flow-uuid', name: 'Registration Flow' }],\n startType: [{ value: 'create', name: 'Create a new contact' }]\n };\n\n const result = start_session.validate(formData);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors).length).to.equal(0);\n });\n\n describe('metadata stripping', () => {\n it('should strip superfluous API metadata from flow', () => {\n const formData = {\n uuid: 'test-uuid',\n flow: [\n {\n uuid: 'flow-1',\n name: 'Registration Flow',\n type: 'message',\n archived: false,\n labels: [],\n expires: 720,\n runs: {\n active: 0,\n waiting: 5,\n completed: 100,\n interrupted: 2,\n expired: 1,\n failed: 0\n },\n results: [],\n parent_refs: [],\n created_on: '2024-01-01T00:00:00.000Z',\n modified_on: '2024-06-15T12:00:00.000Z'\n }\n ],\n startType: [{ value: 'create', name: 'Create a new contact' }]\n };\n\n const action = start_session.fromFormData(formData) as StartSession;\n\n expect(action.flow).to.deep.equal({\n uuid: 'flow-1',\n name: 'Registration Flow'\n });\n });\n\n it('should strip superfluous API metadata from contacts and groups', () => {\n const formData = {\n uuid: 'test-uuid',\n flow: [{ uuid: 'flow-1', name: 'Test Flow' }],\n startType: [{ value: 'manual', name: 'Select recipients manually' }],\n recipients: [\n {\n uuid: 'contact-1',\n name: 'Alice',\n status: 'active',\n language: 'eng',\n urns: ['tel:+250788123456'],\n groups: [{ uuid: 'g-1', name: 'G1' }],\n fields: { age: '30' },\n created_on: '2024-01-01T00:00:00.000Z',\n modified_on: '2024-06-15T12:00:00.000Z',\n last_seen_on: '2024-06-14T10:00:00.000Z'\n },\n {\n uuid: 'group-1',\n name: 'VIP',\n group: true,\n query: 'status = vip',\n status: 'ready',\n count: 42,\n system: false\n }\n ]\n };\n\n const action = start_session.fromFormData(formData) as StartSession;\n\n expect(action.contacts).to.have.lengthOf(1);\n expect(action.contacts[0]).to.deep.equal({\n uuid: 'contact-1',\n name: 'Alice'\n });\n expect(action.groups).to.have.lengthOf(1);\n expect(action.groups[0]).to.deep.equal({\n uuid: 'group-1',\n name: 'VIP'\n });\n });\n });\n});\n"]}
|
|
@@ -383,5 +383,55 @@ describe('split_by_contact_field', () => {
|
|
|
383
383
|
expect(uiConfig.operand.name).to.equal('Facebook');
|
|
384
384
|
expect(uiConfig.operand.type).to.equal('scheme');
|
|
385
385
|
});
|
|
386
|
+
it('should handle round-trip for custom field without re-selecting', () => {
|
|
387
|
+
// Reproduces the bug: toUIConfig saves { id, name, type } without 'key',
|
|
388
|
+
// then toFormData loads it, and fromFormData must still produce a valid operand.
|
|
389
|
+
const originalNode = {
|
|
390
|
+
uuid: 'test-node-uuid',
|
|
391
|
+
actions: [],
|
|
392
|
+
router: {
|
|
393
|
+
type: 'switch',
|
|
394
|
+
cases: [
|
|
395
|
+
{
|
|
396
|
+
uuid: 'case-1',
|
|
397
|
+
type: 'has_text',
|
|
398
|
+
arguments: ['red'],
|
|
399
|
+
category_uuid: 'cat-1'
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
categories: [
|
|
403
|
+
{ uuid: 'cat-1', name: 'Red', exit_uuid: 'exit-1' },
|
|
404
|
+
{ uuid: 'cat-other', name: 'Other', exit_uuid: 'exit-other' }
|
|
405
|
+
],
|
|
406
|
+
default_category_uuid: 'cat-other',
|
|
407
|
+
operand: '@fields.favorite_color',
|
|
408
|
+
result_name: ''
|
|
409
|
+
},
|
|
410
|
+
exits: [
|
|
411
|
+
{ uuid: 'exit-1', destination_uuid: null },
|
|
412
|
+
{ uuid: 'exit-other', destination_uuid: null }
|
|
413
|
+
]
|
|
414
|
+
};
|
|
415
|
+
// nodeUI as saved by toUIConfig - note: NO 'key' property, only 'id'
|
|
416
|
+
const nodeUI = {
|
|
417
|
+
type: 'split_by_contact_field',
|
|
418
|
+
position: { left: 0, top: 0 },
|
|
419
|
+
config: {
|
|
420
|
+
operand: {
|
|
421
|
+
id: 'favorite_color',
|
|
422
|
+
name: 'Favorite Color',
|
|
423
|
+
type: 'field'
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
// Step 1: toFormData (opening the editor)
|
|
428
|
+
const formData = split_by_contact_field.toFormData(originalNode, nodeUI);
|
|
429
|
+
// The field should have 'key' normalized from 'id'
|
|
430
|
+
expect(formData.field[0].key).to.equal('favorite_color');
|
|
431
|
+
// Step 2: fromFormData (saving without re-selecting the field)
|
|
432
|
+
const updatedNode = split_by_contact_field.fromFormData(formData, originalNode);
|
|
433
|
+
// The operand must NOT be @fields.undefined
|
|
434
|
+
expect(updatedNode.router.operand).to.equal('@fields.favorite_color');
|
|
435
|
+
});
|
|
386
436
|
});
|
|
387
437
|
//# sourceMappingURL=split_by_contact_field.test.js.map
|