@nyaruka/temba-components 0.139.0 → 0.141.0
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/.github/workflows/cla.yml +1 -1
- package/.github/workflows/copilot-setup-steps.yml +6 -1
- package/.lintstagedrc.js +10 -0
- package/CHANGELOG.md +32 -0
- package/demo/data/flows/sample-flow.json +24 -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 +702 -338
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/display/Chat.js +10 -7
- package/out-tsc/src/display/Chat.js.map +1 -1
- package/out-tsc/src/display/Dropdown.js +3 -1
- package/out-tsc/src/display/Dropdown.js.map +1 -1
- package/out-tsc/src/display/FloatingTab.js +4 -4
- package/out-tsc/src/display/FloatingTab.js.map +1 -1
- package/out-tsc/src/display/Thumbnail.js +163 -5
- package/out-tsc/src/display/Thumbnail.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +65 -23
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +369 -49
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +118 -10
- package/out-tsc/src/flow/NodeEditor.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/StickyNote.js +13 -4
- package/out-tsc/src/flow/StickyNote.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/audio-player.js +112 -0
- package/out-tsc/src/flow/actions/audio-player.js.map +1 -0
- package/out-tsc/src/flow/actions/enter_flow.js +43 -0
- package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
- package/out-tsc/src/flow/actions/play_audio.js +57 -4
- package/out-tsc/src/flow/actions/play_audio.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/say_msg.js +86 -3
- package/out-tsc/src/flow/actions/say_msg.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/config.js +11 -3
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.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/terminal.js +7 -0
- package/out-tsc/src/flow/nodes/terminal.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js +77 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js +151 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_digits.js +61 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_menu.js +173 -2
- package/out-tsc/src/flow/nodes/wait_for_menu.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/flow/operators.js +21 -5
- package/out-tsc/src/flow/operators.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/flow/utils.js +79 -3
- package/out-tsc/src/flow/utils.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +4 -2
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +56 -0
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/interfaces.js +1 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/layout/Dialog.js +51 -7
- 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/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 +21 -4
- package/out-tsc/src/simulator/Simulator.js.map +1 -1
- package/out-tsc/src/store/AppState.js +102 -3
- package/out-tsc/src/store/AppState.js.map +1 -1
- 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/play_audio.test.js +118 -0
- package/out-tsc/test/actions/play_audio.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/say_msg.test.js +158 -0
- package/out-tsc/test/actions/say_msg.test.js.map +1 -0
- 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/nodes/wait_for_audio.test.js +156 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js +336 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_digits.test.js +198 -84
- package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
- package/out-tsc/test/nodes/wait_for_menu.test.js +340 -0
- package/out-tsc/test/nodes/wait_for_menu.test.js.map +1 -0
- package/out-tsc/test/temba-flow-collision.test.js +261 -6
- package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +187 -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-node-type-selector.test.js +6 -6
- package/out-tsc/test/temba-node-type-selector.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/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/editor/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/editor/static-url.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/editor/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/text-with-audio-url.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/router.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/editor/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/dial-with-limits.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/editor/menu-with-digits.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/Chat.ts +13 -7
- package/src/display/Dropdown.ts +3 -1
- package/src/display/FloatingTab.ts +4 -4
- package/src/display/Thumbnail.ts +162 -2
- package/src/flow/CanvasNode.ts +70 -24
- package/src/flow/Editor.ts +440 -99
- package/src/flow/NodeEditor.ts +137 -9
- package/src/flow/Plumber.ts +89 -14
- package/src/flow/StickyNote.ts +14 -4
- package/src/flow/actions/add_contact_groups.ts +4 -1
- package/src/flow/actions/add_input_labels.ts +4 -1
- package/src/flow/actions/audio-player.ts +127 -0
- package/src/flow/actions/enter_flow.ts +44 -0
- package/src/flow/actions/play_audio.ts +64 -5
- package/src/flow/actions/remove_contact_groups.ts +6 -1
- package/src/flow/actions/say_msg.ts +94 -4
- 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/config.ts +11 -3
- package/src/flow/nodes/shared-rules.ts +1 -1
- 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/terminal.ts +9 -0
- package/src/flow/nodes/wait_for_audio.ts +88 -0
- package/src/flow/nodes/wait_for_dial.ts +176 -0
- package/src/flow/nodes/wait_for_digits.ts +87 -2
- package/src/flow/nodes/wait_for_menu.ts +209 -3
- package/src/flow/nodes/wait_for_response.ts +1 -1
- package/src/flow/operators.ts +23 -5
- package/src/flow/types.ts +23 -1
- package/src/flow/utils.ts +82 -3
- package/src/form/ArrayEditor.ts +4 -2
- package/src/form/FieldRenderer.ts +71 -1
- package/src/interfaces.ts +2 -1
- package/src/layout/Dialog.ts +52 -7
- package/src/layout/Modax.ts +19 -2
- package/src/list/ContentMenu.ts +15 -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 +25 -4
- package/src/store/AppState.ts +120 -1
- package/src/store/flow-definition.d.ts +2 -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/play_audio.test.ts +155 -0
- package/test/actions/remove_contact_groups.test.ts +29 -0
- package/test/actions/say_msg.test.ts +196 -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/nodes/wait_for_audio.test.ts +182 -0
- package/test/nodes/wait_for_dial.test.ts +382 -0
- package/test/nodes/wait_for_digits.test.ts +233 -109
- package/test/nodes/wait_for_menu.test.ts +383 -0
- package/test/temba-flow-collision.test.ts +286 -6
- package/test/temba-flow-editor.test.ts +240 -0
- package/test/temba-flow-plumber.test.ts +62 -0
- package/test/temba-node-type-selector.test.ts +6 -6
- package/test/temba-select.test.ts +6 -1
- package/test/utils.test.ts +4 -2
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { play_audio } from '../../src/flow/actions/play_audio';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the play_audio action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('play_audio action config', () => {
|
|
8
|
+
const helper = new ActionTest(play_audio, 'play_audio');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(play_audio.name).to.equal('Play Recording');
|
|
13
|
+
});
|
|
14
|
+
it('is voice-only', () => {
|
|
15
|
+
expect(play_audio.flowTypes).to.deep.equal(['voice']);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('action scenarios', () => {
|
|
19
|
+
helper.testAction({
|
|
20
|
+
uuid: 'test-play-1',
|
|
21
|
+
type: 'play_audio',
|
|
22
|
+
audio_url: '@results.voicemail'
|
|
23
|
+
}, 'expression-url');
|
|
24
|
+
helper.testAction({
|
|
25
|
+
uuid: 'test-play-2',
|
|
26
|
+
type: 'play_audio',
|
|
27
|
+
audio_url: 'https://example.com/greeting.mp3'
|
|
28
|
+
}, 'static-url');
|
|
29
|
+
});
|
|
30
|
+
describe('data transformation', () => {
|
|
31
|
+
it('converts action to form data', () => {
|
|
32
|
+
const action = {
|
|
33
|
+
uuid: 'test-action',
|
|
34
|
+
type: 'play_audio',
|
|
35
|
+
audio_url: '@results.voicemail'
|
|
36
|
+
};
|
|
37
|
+
const formData = play_audio.toFormData(action);
|
|
38
|
+
expect(formData.uuid).to.equal('test-action');
|
|
39
|
+
expect(formData.audio_url).to.equal('@results.voicemail');
|
|
40
|
+
});
|
|
41
|
+
it('handles missing audio_url', () => {
|
|
42
|
+
const action = {
|
|
43
|
+
uuid: 'test-action',
|
|
44
|
+
type: 'play_audio'
|
|
45
|
+
};
|
|
46
|
+
const formData = play_audio.toFormData(action);
|
|
47
|
+
expect(formData.audio_url).to.equal('');
|
|
48
|
+
});
|
|
49
|
+
it('converts form data to action', () => {
|
|
50
|
+
const formData = {
|
|
51
|
+
uuid: 'test-action',
|
|
52
|
+
audio_url: '@results.voicemail'
|
|
53
|
+
};
|
|
54
|
+
const action = play_audio.fromFormData(formData);
|
|
55
|
+
expect(action.uuid).to.equal('test-action');
|
|
56
|
+
expect(action.type).to.equal('play_audio');
|
|
57
|
+
expect(action.audio_url).to.equal('@results.voicemail');
|
|
58
|
+
});
|
|
59
|
+
it('trims whitespace from audio_url', () => {
|
|
60
|
+
const formData = {
|
|
61
|
+
uuid: 'test-action',
|
|
62
|
+
audio_url: ' @results.voicemail '
|
|
63
|
+
};
|
|
64
|
+
const action = play_audio.fromFormData(formData);
|
|
65
|
+
expect(action.audio_url).to.equal('@results.voicemail');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('localization', () => {
|
|
69
|
+
it('converts localization to form data', () => {
|
|
70
|
+
const action = {
|
|
71
|
+
uuid: 'test-action',
|
|
72
|
+
type: 'play_audio',
|
|
73
|
+
audio_url: '@results.voicemail'
|
|
74
|
+
};
|
|
75
|
+
const localization = {
|
|
76
|
+
audio_url: ['@results.voicemail_es']
|
|
77
|
+
};
|
|
78
|
+
const formData = play_audio.toLocalizationFormData(action, localization);
|
|
79
|
+
expect(formData.audio_url).to.equal('@results.voicemail_es');
|
|
80
|
+
});
|
|
81
|
+
it('handles missing localization', () => {
|
|
82
|
+
const action = {
|
|
83
|
+
uuid: 'test-action',
|
|
84
|
+
type: 'play_audio',
|
|
85
|
+
audio_url: '@results.voicemail'
|
|
86
|
+
};
|
|
87
|
+
const formData = play_audio.toLocalizationFormData(action, {});
|
|
88
|
+
expect(formData.audio_url).to.equal('');
|
|
89
|
+
});
|
|
90
|
+
it('converts form data to localization', () => {
|
|
91
|
+
const action = {
|
|
92
|
+
uuid: 'test-action',
|
|
93
|
+
type: 'play_audio',
|
|
94
|
+
audio_url: '@results.voicemail'
|
|
95
|
+
};
|
|
96
|
+
const formData = {
|
|
97
|
+
uuid: 'test-action',
|
|
98
|
+
audio_url: '@results.voicemail_es'
|
|
99
|
+
};
|
|
100
|
+
const localization = play_audio.fromLocalizationFormData(formData, action);
|
|
101
|
+
expect(localization.audio_url).to.deep.equal(['@results.voicemail_es']);
|
|
102
|
+
});
|
|
103
|
+
it('omits unchanged localization', () => {
|
|
104
|
+
const action = {
|
|
105
|
+
uuid: 'test-action',
|
|
106
|
+
type: 'play_audio',
|
|
107
|
+
audio_url: '@results.voicemail'
|
|
108
|
+
};
|
|
109
|
+
const formData = {
|
|
110
|
+
uuid: 'test-action',
|
|
111
|
+
audio_url: '@results.voicemail' // same as original
|
|
112
|
+
};
|
|
113
|
+
const localization = play_audio.fromLocalizationFormData(formData, action);
|
|
114
|
+
expect(localization.audio_url).to.be.undefined;
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
//# sourceMappingURL=play_audio.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"play_audio.test.js","sourceRoot":"","sources":["../../../test/actions/play_audio.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAExD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,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,aAAa;YACnB,IAAI,EAAE,YAAY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audio } from '../../src/flow/actions/play_audio';\nimport { PlayAudio } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the play_audio action configuration.\n */\ndescribe('play_audio action config', () => {\n const helper = new ActionTest(play_audio, 'play_audio');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(play_audio.name).to.equal('Play Recording');\n });\n\n it('is voice-only', () => {\n expect(play_audio.flowTypes).to.deep.equal(['voice']);\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-play-1',\n type: 'play_audio',\n audio_url: '@results.voicemail'\n } as PlayAudio,\n 'expression-url'\n );\n\n helper.testAction(\n {\n uuid: 'test-play-2',\n type: 'play_audio',\n audio_url: 'https://example.com/greeting.mp3'\n } as PlayAudio,\n 'static-url'\n );\n });\n\n describe('data transformation', () => {\n it('converts action to form data', () => {\n const action: PlayAudio = {\n uuid: 'test-action',\n type: 'play_audio',\n audio_url: '@results.voicemail'\n };\n\n const formData = play_audio.toFormData!(action);\n expect(formData.uuid).to.equal('test-action');\n expect(formData.audio_url).to.equal('@results.voicemail');\n });\n\n it('handles missing audio_url', () => {\n const action = {\n uuid: 'test-action',\n type: 'play_audio'\n } as PlayAudio;\n\n const formData = play_audio.toFormData!(action);\n expect(formData.audio_url).to.equal('');\n });\n\n it('converts form data to action', () => {\n const formData = {\n uuid: 'test-action',\n audio_url: '@results.voicemail'\n };\n\n const action = play_audio.fromFormData!(formData) as PlayAudio;\n expect(action.uuid).to.equal('test-action');\n expect(action.type).to.equal('play_audio');\n expect(action.audio_url).to.equal('@results.voicemail');\n });\n\n it('trims whitespace from audio_url', () => {\n const formData = {\n uuid: 'test-action',\n audio_url: ' @results.voicemail '\n };\n\n const action = play_audio.fromFormData!(formData) as PlayAudio;\n expect(action.audio_url).to.equal('@results.voicemail');\n });\n });\n\n describe('localization', () => {\n it('converts localization to form data', () => {\n const action: PlayAudio = {\n uuid: 'test-action',\n type: 'play_audio',\n audio_url: '@results.voicemail'\n };\n\n const localization = {\n audio_url: ['@results.voicemail_es']\n };\n\n const formData = play_audio.toLocalizationFormData!(action, localization);\n expect(formData.audio_url).to.equal('@results.voicemail_es');\n });\n\n it('handles missing localization', () => {\n const action: PlayAudio = {\n uuid: 'test-action',\n type: 'play_audio',\n audio_url: '@results.voicemail'\n };\n\n const formData = play_audio.toLocalizationFormData!(action, {});\n expect(formData.audio_url).to.equal('');\n });\n\n it('converts form data to localization', () => {\n const action: PlayAudio = {\n uuid: 'test-action',\n type: 'play_audio',\n audio_url: '@results.voicemail'\n };\n\n const formData = {\n uuid: 'test-action',\n audio_url: '@results.voicemail_es'\n };\n\n const localization = play_audio.fromLocalizationFormData!(\n formData,\n action\n );\n expect(localization.audio_url).to.deep.equal(['@results.voicemail_es']);\n });\n\n it('omits unchanged localization', () => {\n const action: PlayAudio = {\n uuid: 'test-action',\n type: 'play_audio',\n audio_url: '@results.voicemail'\n };\n\n const formData = {\n uuid: 'test-action',\n audio_url: '@results.voicemail' // same as original\n };\n\n const localization = play_audio.fromLocalizationFormData!(\n formData,\n action\n );\n expect(localization.audio_url).to.be.undefined;\n });\n });\n});\n"]}
|
|
@@ -222,5 +222,29 @@ describe('remove_contact_groups action config', () => {
|
|
|
222
222
|
expect(Object.keys(result.errors)).to.have.length(0);
|
|
223
223
|
});
|
|
224
224
|
});
|
|
225
|
+
describe('metadata stripping', () => {
|
|
226
|
+
it('should strip superfluous API metadata from groups', () => {
|
|
227
|
+
const formData = {
|
|
228
|
+
uuid: 'test-uuid',
|
|
229
|
+
all_groups: false,
|
|
230
|
+
groups: [
|
|
231
|
+
{
|
|
232
|
+
uuid: 'group-1',
|
|
233
|
+
name: 'VIP Customers',
|
|
234
|
+
query: 'status = vip',
|
|
235
|
+
status: 'ready',
|
|
236
|
+
count: 150,
|
|
237
|
+
system: false
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
};
|
|
241
|
+
const action = remove_contact_groups.fromFormData(formData);
|
|
242
|
+
expect(action.groups).to.have.lengthOf(1);
|
|
243
|
+
expect(action.groups[0]).to.deep.equal({
|
|
244
|
+
uuid: 'group-1',
|
|
245
|
+
name: 'VIP Customers'
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
});
|
|
225
249
|
});
|
|
226
250
|
//# sourceMappingURL=remove_contact_groups.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove_contact_groups.test.js","sourceRoot":"","sources":["../../../test/actions/remove_contact_groups.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;IAE9E,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnE,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,uBAAuB;YAC7B,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,eAAe;oBACrB,MAAM,EAAE,OAAO;oBACf,MAAM,EAAE,KAAK;oBACb,KAAK,EAAE,EAAE;oBACT,KAAK,EAAE,GAAG;iBACX;aACF;YACD,UAAU,EAAE,K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,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { remove_contact_groups } from '../../src/flow/actions/remove_contact_groups';\nimport { RemoveFromGroup } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the remove_contact_groups action configuration.\n */\ndescribe('remove_contact_groups action config', () => {\n const helper = new ActionTest(remove_contact_groups, 'remove_contact_groups');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(remove_contact_groups.name).to.equal('Remove from Group');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'VIP Customers',\n status: 'ready',\n system: false,\n query: '',\n count: 150\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'single-group'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Newsletter Subscribers',\n status: 'ready',\n system: false,\n query: '',\n count: 1250\n },\n {\n uuid: 'group-2',\n name: 'Beta Testers',\n status: 'ready',\n system: false,\n query: '',\n count: 45\n },\n {\n uuid: 'group-3',\n name: 'Inactive Users',\n status: 'ready',\n system: false,\n query: '',\n count: 300\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'multiple-groups'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'remove_contact_groups',\n groups: [],\n all_groups: true\n } as RemoveFromGroup,\n 'remove-from-all-groups'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Customers - Premium Subscription (Annual Billing)',\n status: 'ready',\n system: false,\n query: '',\n count: 89\n },\n {\n uuid: 'group-2',\n name: 'Users - Trial Period Expired (30+ Days)',\n status: 'ready',\n system: false,\n query: '',\n count: 234\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'long-descriptive-group-names'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Sales Team',\n status: 'ready',\n system: false,\n query: '',\n count: 12\n },\n {\n uuid: 'group-2',\n name: 'Marketing Team',\n status: 'ready',\n system: false,\n query: '',\n count: 8\n },\n {\n uuid: 'group-3',\n name: 'Support Team',\n status: 'ready',\n system: false,\n query: '',\n count: 15\n },\n {\n uuid: 'group-4',\n name: 'Development Team',\n status: 'ready',\n system: false,\n query: '',\n count: 25\n },\n {\n uuid: 'group-5',\n name: 'QA Team',\n status: 'ready',\n system: false,\n query: '',\n count: 6\n },\n {\n uuid: 'group-6',\n name: 'Management Team',\n status: 'ready',\n system: false,\n query: '',\n count: 4\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'many-groups'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Unsubscribed Users',\n status: 'ready',\n system: false,\n query: '',\n count: 567\n },\n {\n uuid: 'group-2',\n name: 'Bounced Email Addresses',\n status: 'ready',\n system: false,\n query: '',\n count: 89\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'cleanup-groups'\n );\n });\n\n describe('validation edge cases', () => {\n it('fails validation when no groups selected and all_groups is false', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: [],\n all_groups: false\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.false;\n expect(result.errors.groups).to.equal(\n 'At least one group must be selected or check \"Remove from All Groups\"'\n );\n });\n\n it('fails validation when groups is undefined and all_groups is false', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: undefined as any,\n all_groups: false\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.false;\n expect(result.errors.groups).to.equal(\n 'At least one group must be selected or check \"Remove from All Groups\"'\n );\n });\n\n it('passes validation when all_groups is true even with empty groups', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: [],\n all_groups: true\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors)).to.have.length(0);\n });\n\n it('passes validation when groups are provided and all_groups is false', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Test Group',\n status: 'ready',\n system: false,\n query: '',\n count: 10\n }\n ],\n all_groups: false\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors)).to.have.length(0);\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"remove_contact_groups.test.js","sourceRoot":"","sources":["../../../test/actions/remove_contact_groups.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAErF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;IACnD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,qBAAqB,EAAE,uBAAuB,CAAC,CAAC;IAE9E,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACnE,CA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C,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { remove_contact_groups } from '../../src/flow/actions/remove_contact_groups';\nimport { RemoveFromGroup } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the remove_contact_groups action configuration.\n */\ndescribe('remove_contact_groups action config', () => {\n const helper = new ActionTest(remove_contact_groups, 'remove_contact_groups');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(remove_contact_groups.name).to.equal('Remove from Group');\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-action-1',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'VIP Customers',\n status: 'ready',\n system: false,\n query: '',\n count: 150\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'single-group'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-2',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Newsletter Subscribers',\n status: 'ready',\n system: false,\n query: '',\n count: 1250\n },\n {\n uuid: 'group-2',\n name: 'Beta Testers',\n status: 'ready',\n system: false,\n query: '',\n count: 45\n },\n {\n uuid: 'group-3',\n name: 'Inactive Users',\n status: 'ready',\n system: false,\n query: '',\n count: 300\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'multiple-groups'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-3',\n type: 'remove_contact_groups',\n groups: [],\n all_groups: true\n } as RemoveFromGroup,\n 'remove-from-all-groups'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-4',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Customers - Premium Subscription (Annual Billing)',\n status: 'ready',\n system: false,\n query: '',\n count: 89\n },\n {\n uuid: 'group-2',\n name: 'Users - Trial Period Expired (30+ Days)',\n status: 'ready',\n system: false,\n query: '',\n count: 234\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'long-descriptive-group-names'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-5',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Sales Team',\n status: 'ready',\n system: false,\n query: '',\n count: 12\n },\n {\n uuid: 'group-2',\n name: 'Marketing Team',\n status: 'ready',\n system: false,\n query: '',\n count: 8\n },\n {\n uuid: 'group-3',\n name: 'Support Team',\n status: 'ready',\n system: false,\n query: '',\n count: 15\n },\n {\n uuid: 'group-4',\n name: 'Development Team',\n status: 'ready',\n system: false,\n query: '',\n count: 25\n },\n {\n uuid: 'group-5',\n name: 'QA Team',\n status: 'ready',\n system: false,\n query: '',\n count: 6\n },\n {\n uuid: 'group-6',\n name: 'Management Team',\n status: 'ready',\n system: false,\n query: '',\n count: 4\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'many-groups'\n );\n\n helper.testAction(\n {\n uuid: 'test-action-6',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Unsubscribed Users',\n status: 'ready',\n system: false,\n query: '',\n count: 567\n },\n {\n uuid: 'group-2',\n name: 'Bounced Email Addresses',\n status: 'ready',\n system: false,\n query: '',\n count: 89\n }\n ],\n all_groups: false\n } as RemoveFromGroup,\n 'cleanup-groups'\n );\n });\n\n describe('validation edge cases', () => {\n it('fails validation when no groups selected and all_groups is false', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: [],\n all_groups: false\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.false;\n expect(result.errors.groups).to.equal(\n 'At least one group must be selected or check \"Remove from All Groups\"'\n );\n });\n\n it('fails validation when groups is undefined and all_groups is false', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: undefined as any,\n all_groups: false\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.false;\n expect(result.errors.groups).to.equal(\n 'At least one group must be selected or check \"Remove from All Groups\"'\n );\n });\n\n it('passes validation when all_groups is true even with empty groups', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: [],\n all_groups: true\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors)).to.have.length(0);\n });\n\n it('passes validation when groups are provided and all_groups is false', () => {\n const action: RemoveFromGroup = {\n uuid: 'test-action',\n type: 'remove_contact_groups',\n groups: [\n {\n uuid: 'group-1',\n name: 'Test Group',\n status: 'ready',\n system: false,\n query: '',\n count: 10\n }\n ],\n all_groups: false\n };\n\n const result = remove_contact_groups.validate(action);\n expect(result.valid).to.be.true;\n expect(Object.keys(result.errors)).to.have.length(0);\n });\n });\n\n describe('metadata stripping', () => {\n it('should strip superfluous API metadata from groups', () => {\n const formData = {\n uuid: 'test-uuid',\n all_groups: false,\n groups: [\n {\n uuid: 'group-1',\n name: 'VIP Customers',\n query: 'status = vip',\n status: 'ready',\n count: 150,\n system: false\n }\n ]\n };\n\n const action = remove_contact_groups.fromFormData(\n formData\n ) as RemoveFromGroup;\n\n expect(action.groups).to.have.lengthOf(1);\n expect(action.groups[0]).to.deep.equal({\n uuid: 'group-1',\n name: 'VIP Customers'\n });\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { say_msg } from '../../src/flow/actions/say_msg';
|
|
3
|
+
import { ActionTest } from '../ActionHelper';
|
|
4
|
+
/**
|
|
5
|
+
* Test suite for the say_msg action configuration.
|
|
6
|
+
*/
|
|
7
|
+
describe('say_msg action config', () => {
|
|
8
|
+
const helper = new ActionTest(say_msg, 'say_msg');
|
|
9
|
+
describe('basic properties', () => {
|
|
10
|
+
helper.testBasicProperties();
|
|
11
|
+
it('has correct name', () => {
|
|
12
|
+
expect(say_msg.name).to.equal('Say Message');
|
|
13
|
+
});
|
|
14
|
+
it('is voice-only', () => {
|
|
15
|
+
expect(say_msg.flowTypes).to.deep.equal(['voice']);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('action scenarios', () => {
|
|
19
|
+
helper.testAction({
|
|
20
|
+
uuid: 'test-say-1',
|
|
21
|
+
type: 'say_msg',
|
|
22
|
+
text: 'Hello, welcome to our service.'
|
|
23
|
+
}, 'simple-text');
|
|
24
|
+
helper.testAction({
|
|
25
|
+
uuid: 'test-say-2',
|
|
26
|
+
type: 'say_msg',
|
|
27
|
+
text: 'Press 1 for sales.\nPress 2 for support.\nPress 3 to leave a message.'
|
|
28
|
+
}, 'multiline-text');
|
|
29
|
+
helper.testAction({
|
|
30
|
+
uuid: 'test-say-3',
|
|
31
|
+
type: 'say_msg',
|
|
32
|
+
text: 'Please listen to the following recording.',
|
|
33
|
+
audio_url: 'https://example.com/greeting.mp3'
|
|
34
|
+
}, 'text-with-audio-url');
|
|
35
|
+
});
|
|
36
|
+
describe('data transformation', () => {
|
|
37
|
+
it('converts action to form data', () => {
|
|
38
|
+
const action = {
|
|
39
|
+
uuid: 'test-action',
|
|
40
|
+
type: 'say_msg',
|
|
41
|
+
text: 'Hello world',
|
|
42
|
+
audio_url: 'https://example.com/audio.mp3'
|
|
43
|
+
};
|
|
44
|
+
const formData = say_msg.toFormData(action);
|
|
45
|
+
expect(formData.uuid).to.equal('test-action');
|
|
46
|
+
expect(formData.text).to.equal('Hello world');
|
|
47
|
+
expect(formData.audio_url).to.equal('https://example.com/audio.mp3');
|
|
48
|
+
});
|
|
49
|
+
it('handles missing audio_url in toFormData', () => {
|
|
50
|
+
const action = {
|
|
51
|
+
uuid: 'test-action',
|
|
52
|
+
type: 'say_msg',
|
|
53
|
+
text: 'Hello'
|
|
54
|
+
};
|
|
55
|
+
const formData = say_msg.toFormData(action);
|
|
56
|
+
expect(formData.audio_url).to.equal('');
|
|
57
|
+
});
|
|
58
|
+
it('converts form data to action', () => {
|
|
59
|
+
const formData = {
|
|
60
|
+
uuid: 'test-action',
|
|
61
|
+
text: 'Hello world',
|
|
62
|
+
audio_url: 'https://example.com/audio.mp3'
|
|
63
|
+
};
|
|
64
|
+
const action = say_msg.fromFormData(formData);
|
|
65
|
+
expect(action.uuid).to.equal('test-action');
|
|
66
|
+
expect(action.type).to.equal('say_msg');
|
|
67
|
+
expect(action.text).to.equal('Hello world');
|
|
68
|
+
expect(action.audio_url).to.equal('https://example.com/audio.mp3');
|
|
69
|
+
});
|
|
70
|
+
it('omits empty audio_url in fromFormData', () => {
|
|
71
|
+
const formData = {
|
|
72
|
+
uuid: 'test-action',
|
|
73
|
+
text: 'Hello world',
|
|
74
|
+
audio_url: ''
|
|
75
|
+
};
|
|
76
|
+
const action = say_msg.fromFormData(formData);
|
|
77
|
+
expect(action.audio_url).to.be.undefined;
|
|
78
|
+
});
|
|
79
|
+
it('trims whitespace from audio_url', () => {
|
|
80
|
+
const formData = {
|
|
81
|
+
uuid: 'test-action',
|
|
82
|
+
text: 'Hello',
|
|
83
|
+
audio_url: ' https://example.com/audio.mp3 '
|
|
84
|
+
};
|
|
85
|
+
const action = say_msg.fromFormData(formData);
|
|
86
|
+
expect(action.audio_url).to.equal('https://example.com/audio.mp3');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
describe('sanitize', () => {
|
|
90
|
+
it('trims text whitespace', () => {
|
|
91
|
+
const formData = { text: ' Hello world ' };
|
|
92
|
+
say_msg.sanitize(formData);
|
|
93
|
+
expect(formData.text).to.equal('Hello world');
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('localization', () => {
|
|
97
|
+
it('converts localization to form data', () => {
|
|
98
|
+
const action = {
|
|
99
|
+
uuid: 'test-action',
|
|
100
|
+
type: 'say_msg',
|
|
101
|
+
text: 'Hello',
|
|
102
|
+
audio_url: 'https://example.com/en.mp3'
|
|
103
|
+
};
|
|
104
|
+
const localization = {
|
|
105
|
+
text: ['Hola'],
|
|
106
|
+
audio_url: ['https://example.com/es.mp3']
|
|
107
|
+
};
|
|
108
|
+
const formData = say_msg.toLocalizationFormData(action, localization);
|
|
109
|
+
expect(formData.text).to.equal('Hola');
|
|
110
|
+
expect(formData.audio_url).to.equal('https://example.com/es.mp3');
|
|
111
|
+
});
|
|
112
|
+
it('handles missing localization fields', () => {
|
|
113
|
+
const action = {
|
|
114
|
+
uuid: 'test-action',
|
|
115
|
+
type: 'say_msg',
|
|
116
|
+
text: 'Hello'
|
|
117
|
+
};
|
|
118
|
+
const formData = say_msg.toLocalizationFormData(action, {});
|
|
119
|
+
expect(formData.text).to.equal('');
|
|
120
|
+
expect(formData.audio_url).to.equal('');
|
|
121
|
+
});
|
|
122
|
+
it('converts form data to localization', () => {
|
|
123
|
+
const action = {
|
|
124
|
+
uuid: 'test-action',
|
|
125
|
+
type: 'say_msg',
|
|
126
|
+
text: 'Hello',
|
|
127
|
+
audio_url: 'https://example.com/en.mp3'
|
|
128
|
+
};
|
|
129
|
+
const formData = {
|
|
130
|
+
uuid: 'test-action',
|
|
131
|
+
text: 'Hola',
|
|
132
|
+
audio_url: 'https://example.com/es.mp3'
|
|
133
|
+
};
|
|
134
|
+
const localization = say_msg.fromLocalizationFormData(formData, action);
|
|
135
|
+
expect(localization.text).to.deep.equal(['Hola']);
|
|
136
|
+
expect(localization.audio_url).to.deep.equal([
|
|
137
|
+
'https://example.com/es.mp3'
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
it('omits unchanged localization fields', () => {
|
|
141
|
+
const action = {
|
|
142
|
+
uuid: 'test-action',
|
|
143
|
+
type: 'say_msg',
|
|
144
|
+
text: 'Hello',
|
|
145
|
+
audio_url: 'https://example.com/en.mp3'
|
|
146
|
+
};
|
|
147
|
+
const formData = {
|
|
148
|
+
uuid: 'test-action',
|
|
149
|
+
text: 'Hello', // same as original
|
|
150
|
+
audio_url: 'https://example.com/en.mp3' // same as original
|
|
151
|
+
};
|
|
152
|
+
const localization = say_msg.fromLocalizationFormData(formData, action);
|
|
153
|
+
expect(localization.text).to.be.undefined;
|
|
154
|
+
expect(localization.audio_url).to.be.undefined;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=say_msg.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"say_msg.test.js","sourceRoot":"","sources":["../../../test/actions/say_msg.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAElD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;YACvB,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,gCAAgC;SAC7B,EACX,aAAa,CACd,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,SAAS;YACf,IAAI,EAAE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EAAE,MAAM,CAAC,CAAC;YACzE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;YAC1C,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { say_msg } from '../../src/flow/actions/say_msg';\nimport { SayMsg } from '../../src/store/flow-definition';\nimport { ActionTest } from '../ActionHelper';\n\n/**\n * Test suite for the say_msg action configuration.\n */\ndescribe('say_msg action config', () => {\n const helper = new ActionTest(say_msg, 'say_msg');\n\n describe('basic properties', () => {\n helper.testBasicProperties();\n\n it('has correct name', () => {\n expect(say_msg.name).to.equal('Say Message');\n });\n\n it('is voice-only', () => {\n expect(say_msg.flowTypes).to.deep.equal(['voice']);\n });\n });\n\n describe('action scenarios', () => {\n helper.testAction(\n {\n uuid: 'test-say-1',\n type: 'say_msg',\n text: 'Hello, welcome to our service.'\n } as SayMsg,\n 'simple-text'\n );\n\n helper.testAction(\n {\n uuid: 'test-say-2',\n type: 'say_msg',\n text: 'Press 1 for sales.\\nPress 2 for support.\\nPress 3 to leave a message.'\n } as SayMsg,\n 'multiline-text'\n );\n\n helper.testAction(\n {\n uuid: 'test-say-3',\n type: 'say_msg',\n text: 'Please listen to the following recording.',\n audio_url: 'https://example.com/greeting.mp3'\n } as SayMsg,\n 'text-with-audio-url'\n );\n });\n\n describe('data transformation', () => {\n it('converts action to form data', () => {\n const action: SayMsg = {\n uuid: 'test-action',\n type: 'say_msg',\n text: 'Hello world',\n audio_url: 'https://example.com/audio.mp3'\n };\n\n const formData = say_msg.toFormData!(action);\n expect(formData.uuid).to.equal('test-action');\n expect(formData.text).to.equal('Hello world');\n expect(formData.audio_url).to.equal('https://example.com/audio.mp3');\n });\n\n it('handles missing audio_url in toFormData', () => {\n const action: SayMsg = {\n uuid: 'test-action',\n type: 'say_msg',\n text: 'Hello'\n } as SayMsg;\n\n const formData = say_msg.toFormData!(action);\n expect(formData.audio_url).to.equal('');\n });\n\n it('converts form data to action', () => {\n const formData = {\n uuid: 'test-action',\n text: 'Hello world',\n audio_url: 'https://example.com/audio.mp3'\n };\n\n const action = say_msg.fromFormData!(formData) as SayMsg;\n expect(action.uuid).to.equal('test-action');\n expect(action.type).to.equal('say_msg');\n expect(action.text).to.equal('Hello world');\n expect(action.audio_url).to.equal('https://example.com/audio.mp3');\n });\n\n it('omits empty audio_url in fromFormData', () => {\n const formData = {\n uuid: 'test-action',\n text: 'Hello world',\n audio_url: ''\n };\n\n const action = say_msg.fromFormData!(formData) as SayMsg;\n expect(action.audio_url).to.be.undefined;\n });\n\n it('trims whitespace from audio_url', () => {\n const formData = {\n uuid: 'test-action',\n text: 'Hello',\n audio_url: ' https://example.com/audio.mp3 '\n };\n\n const action = say_msg.fromFormData!(formData) as SayMsg;\n expect(action.audio_url).to.equal('https://example.com/audio.mp3');\n });\n });\n\n describe('sanitize', () => {\n it('trims text whitespace', () => {\n const formData = { text: ' Hello world ' };\n say_msg.sanitize!(formData);\n expect(formData.text).to.equal('Hello world');\n });\n });\n\n describe('localization', () => {\n it('converts localization to form data', () => {\n const action: SayMsg = {\n uuid: 'test-action',\n type: 'say_msg',\n text: 'Hello',\n audio_url: 'https://example.com/en.mp3'\n };\n\n const localization = {\n text: ['Hola'],\n audio_url: ['https://example.com/es.mp3']\n };\n\n const formData = say_msg.toLocalizationFormData!(action, localization);\n expect(formData.text).to.equal('Hola');\n expect(formData.audio_url).to.equal('https://example.com/es.mp3');\n });\n\n it('handles missing localization fields', () => {\n const action: SayMsg = {\n uuid: 'test-action',\n type: 'say_msg',\n text: 'Hello'\n } as SayMsg;\n\n const formData = say_msg.toLocalizationFormData!(action, {});\n expect(formData.text).to.equal('');\n expect(formData.audio_url).to.equal('');\n });\n\n it('converts form data to localization', () => {\n const action: SayMsg = {\n uuid: 'test-action',\n type: 'say_msg',\n text: 'Hello',\n audio_url: 'https://example.com/en.mp3'\n };\n\n const formData = {\n uuid: 'test-action',\n text: 'Hola',\n audio_url: 'https://example.com/es.mp3'\n };\n\n const localization = say_msg.fromLocalizationFormData!(formData, action);\n expect(localization.text).to.deep.equal(['Hola']);\n expect(localization.audio_url).to.deep.equal([\n 'https://example.com/es.mp3'\n ]);\n });\n\n it('omits unchanged localization fields', () => {\n const action: SayMsg = {\n uuid: 'test-action',\n type: 'say_msg',\n text: 'Hello',\n audio_url: 'https://example.com/en.mp3'\n };\n\n const formData = {\n uuid: 'test-action',\n text: 'Hello', // same as original\n audio_url: 'https://example.com/en.mp3' // same as original\n };\n\n const localization = say_msg.fromLocalizationFormData!(formData, action);\n expect(localization.text).to.be.undefined;\n expect(localization.audio_url).to.be.undefined;\n });\n });\n});\n"]}
|
|
@@ -148,6 +148,47 @@ describe('send_broadcast action config', () => {
|
|
|
148
148
|
send_broadcast.sanitize(formData);
|
|
149
149
|
expect(formData.text).to.equal('Test message');
|
|
150
150
|
});
|
|
151
|
+
it('should strip superfluous API metadata from contacts and groups', () => {
|
|
152
|
+
const formData = {
|
|
153
|
+
uuid: 'test-uuid',
|
|
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: 'Subscribers',
|
|
170
|
+
group: true,
|
|
171
|
+
query: null,
|
|
172
|
+
status: 'ready',
|
|
173
|
+
count: 500,
|
|
174
|
+
system: false
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
text: 'Hello!',
|
|
178
|
+
attachments: []
|
|
179
|
+
};
|
|
180
|
+
const action = send_broadcast.fromFormData(formData);
|
|
181
|
+
expect(action.contacts).to.have.lengthOf(1);
|
|
182
|
+
expect(action.contacts[0]).to.deep.equal({
|
|
183
|
+
uuid: 'contact-1',
|
|
184
|
+
name: 'Alice'
|
|
185
|
+
});
|
|
186
|
+
expect(action.groups).to.have.lengthOf(1);
|
|
187
|
+
expect(action.groups[0]).to.deep.equal({
|
|
188
|
+
uuid: 'group-1',
|
|
189
|
+
name: 'Subscribers'
|
|
190
|
+
});
|
|
191
|
+
});
|
|
151
192
|
});
|
|
152
193
|
});
|
|
153
194
|
//# sourceMappingURL=send_broadcast.test.js.map
|
|
@@ -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,kBAAk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,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;YAC/C,MAAM,QAAQ,GAAG;gBACf,IAAI,EAAE,WAAW;gBACjB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;gBACzD,IAAI,EAAE,sBAAsB;aAC7B,CAAC;YAEF,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAElC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,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;AAC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I,EAAE;wBACrB,UAAU,EAAE,0BAA0B;wBACtC,WAAW,EAAE,0BAA0B;wBACvC,YAAY,EAAE,0BAA0B;qBACzC;oBACD;wBACE,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,aAAa;wBACnB,KAAK,EAAE,IAAI;wBACX,KAAK,EAAE,IAAI;wBACX,MAAM,EAAE,OAAO;wBACf,KAAK,EAAE,GAAG;wBACV,MAAM,EAAE,KAAK;qBACd;iBACF;gBACD,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE;aAChB,CAAC;YAEF,MAAM,MAAM,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,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;GAEG;AACH,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,mBAAmB,EAAE,qBAAqB,CAAC,CAAC;IAE1E,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAChC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAE7B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC9D,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,qBAAqB;YAC3B,OAAO,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,kBAAkB,EAAE;SACpC,EACtB,kBAAkB,CACnB,CAAC;QAEF,MAAM,CAAC,UAAU,CACf;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,EAAE,IAAI,EAA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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"]}
|