@nyaruka/temba-components 0.129.1 → 0.129.3
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/build.yml +6 -5
- package/.github/workflows/coverage.yml +80 -0
- package/CHANGELOG.md +32 -0
- package/README.md +6 -0
- package/check-coverage.js +133 -0
- package/demo/components/alert/example.html +71 -0
- package/demo/components/button/example.html +167 -0
- package/demo/{chart → components/chart}/example.html +3 -3
- package/demo/components/chart/horizontal-demo.html +160 -0
- package/demo/components/checkbox/example.html +68 -0
- package/demo/components/compose/example.html +69 -0
- package/demo/components/datepicker/example.html +3 -3
- package/demo/components/datepicker/range-picker-demo.html +2 -2
- package/demo/{dialog → components/dialog}/example.html +3 -3
- package/demo/components/dropdown/example.html +95 -0
- package/demo/{flow → components/flow}/example.html +1 -1
- package/demo/{misc → components/misc}/example.html +3 -3
- package/demo/components/progress/example.html +62 -0
- package/demo/components/select/drag-and-drop.html +162 -0
- package/demo/components/select/example.html +76 -0
- package/demo/components/select/multi.html +72 -0
- package/demo/components/slider/example.html +55 -0
- package/demo/{sortable-list → components/sortable-list}/example.html +3 -3
- package/demo/components/tabs/example.html +91 -0
- package/demo/{textinput → components/textinput}/completion.html +3 -3
- package/demo/components/textinput/example.html +141 -0
- package/demo/{webchat → components/webchat}/example.html +3 -3
- package/demo/data/flows/sample-flow.json +107 -100
- package/demo/index.html +21 -21
- package/demo/static/css/styles.css +253 -0
- package/demo/sticky-note-demo.html +88 -85
- package/demo/styles.css +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 +2 -11
- 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 +893 -476
- package/dist/temba-components.js.map +1 -1
- package/generate-coverage-badge.sh +69 -0
- package/out-tsc/src/{vectoricon/index.js → Icons.js} +1 -1
- package/out-tsc/src/Icons.js.map +1 -0
- package/out-tsc/src/display/Alert.js.map +1 -0
- package/out-tsc/src/display/Anchor.js.map +1 -0
- package/out-tsc/src/display/Button.js.map +1 -0
- package/out-tsc/src/{charcount → display}/CharCount.js +159 -2
- package/out-tsc/src/display/CharCount.js.map +1 -0
- package/out-tsc/src/display/Chat.js.map +1 -0
- package/out-tsc/src/display/ContactName.js.map +1 -0
- package/out-tsc/src/display/ContactUrn.js.map +1 -0
- package/out-tsc/src/display/Dropdown.js.map +1 -0
- package/out-tsc/src/{vectoricon/VectorIcon.js → display/Icon.js} +2 -2
- package/out-tsc/src/display/Icon.js.map +1 -0
- package/out-tsc/src/display/Label.js.map +1 -0
- package/out-tsc/src/{leafletmap → display}/LeafletMap.js +16 -1
- package/out-tsc/src/display/LeafletMap.js.map +1 -0
- package/out-tsc/src/display/Lightbox.js.map +1 -0
- package/out-tsc/src/{loading → display}/Loading.js.map +1 -1
- package/out-tsc/src/{options → display}/Options.js.map +1 -1
- package/out-tsc/src/display/ProgressBar.js.map +1 -0
- package/out-tsc/src/display/TembaDate.js.map +1 -0
- package/out-tsc/src/display/TembaUser.js.map +1 -0
- package/out-tsc/src/display/Thumbnail.js.map +1 -0
- package/out-tsc/src/{tip → display}/Tip.js +1 -2
- package/out-tsc/src/display/Tip.js.map +1 -0
- package/out-tsc/src/display/Toast.js.map +1 -0
- package/out-tsc/src/display/sms/gsmsplitter.js.map +1 -0
- package/out-tsc/src/display/sms/gsmvalidator.js.map +1 -0
- package/out-tsc/src/display/sms/index.js.map +1 -0
- package/out-tsc/src/display/sms/unicodesplitter.js.map +1 -0
- package/out-tsc/src/events.js +2 -0
- package/out-tsc/src/events.js.map +1 -0
- package/out-tsc/src/excellent/ExcellentParser.js.map +1 -0
- package/out-tsc/src/excellent/helpers.js.map +1 -0
- package/out-tsc/src/flow/Editor.js +533 -140
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/EditorNode.js +287 -20
- package/out-tsc/src/flow/EditorNode.js.map +1 -1
- package/out-tsc/src/flow/Plumber.js +154 -74
- package/out-tsc/src/flow/Plumber.js.map +1 -1
- package/out-tsc/src/flow/StickyNote.js +153 -9
- package/out-tsc/src/flow/StickyNote.js.map +1 -1
- package/out-tsc/src/flow/config.js +88 -18
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/render.js +327 -10
- package/out-tsc/src/flow/render.js.map +1 -1
- package/out-tsc/src/{checkbox → form}/Checkbox.js +2 -2
- package/out-tsc/src/form/Checkbox.js.map +1 -0
- package/out-tsc/src/{colorpicker → form}/ColorPicker.js +1 -1
- package/out-tsc/src/form/ColorPicker.js.map +1 -0
- package/out-tsc/src/{completion → form}/Completion.js +2 -2
- package/out-tsc/src/form/Completion.js.map +1 -0
- package/out-tsc/src/{compose → form}/Compose.js +1 -1
- package/out-tsc/src/form/Compose.js.map +1 -0
- package/out-tsc/src/{contactsearch → form}/ContactSearch.js +2 -2
- package/out-tsc/src/form/ContactSearch.js.map +1 -0
- package/out-tsc/src/form/CroppieCSS.js.map +1 -0
- package/out-tsc/src/{datepicker → form}/DatePicker.js +1 -1
- package/out-tsc/src/form/DatePicker.js.map +1 -0
- package/out-tsc/src/{FormElement.js → form/FormElement.js} +1 -1
- package/out-tsc/src/form/FormElement.js.map +1 -0
- package/out-tsc/src/form/FormField.js.map +1 -0
- package/out-tsc/src/{imagepicker → form}/ImagePicker.js +2 -2
- package/out-tsc/src/form/ImagePicker.js.map +1 -0
- package/out-tsc/src/{mediapicker → form}/MediaPicker.js +1 -1
- package/out-tsc/src/form/MediaPicker.js.map +1 -0
- package/out-tsc/src/{datepicker → form}/RangePicker.js +3 -2
- package/out-tsc/src/form/RangePicker.js.map +1 -0
- package/out-tsc/src/{slider → form}/TembaSlider.js +1 -1
- package/out-tsc/src/form/TembaSlider.js.map +1 -0
- package/out-tsc/src/{templates → form}/TemplateEditor.js +1 -1
- package/out-tsc/src/form/TemplateEditor.js.map +1 -0
- package/out-tsc/src/{textinput → form}/TextInput.js +3 -3
- package/out-tsc/src/form/TextInput.js.map +1 -0
- package/out-tsc/src/{omnibox → form/select}/Omnibox.js +2 -2
- package/out-tsc/src/form/select/Omnibox.js.map +1 -0
- package/out-tsc/src/{select → form/select}/PopupSelect.js +1 -1
- package/out-tsc/src/form/select/PopupSelect.js.map +1 -0
- package/out-tsc/src/{select → form/select}/Select.js +86 -87
- package/out-tsc/src/form/select/Select.js.map +1 -0
- package/out-tsc/src/{select → form/select}/UserSelect.js +1 -1
- package/out-tsc/src/form/select/UserSelect.js.map +1 -0
- package/out-tsc/src/{select → form/select}/WorkspaceSelect.js +1 -1
- package/out-tsc/src/form/select/WorkspaceSelect.js.map +1 -0
- package/out-tsc/src/interfaces.js +1 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/layout/Dialog.js.map +1 -0
- package/out-tsc/src/layout/Mask.js.map +1 -0
- package/out-tsc/src/{dialog → layout}/Modax.js.map +1 -1
- package/out-tsc/src/layout/Resizer.js.map +1 -0
- package/out-tsc/src/layout/Tab.js.map +1 -0
- package/out-tsc/src/layout/TabPane.js.map +1 -0
- package/out-tsc/src/list/NotificationList.js +1 -1
- package/out-tsc/src/list/NotificationList.js.map +1 -1
- package/out-tsc/src/list/RunList.js +1 -1
- package/out-tsc/src/list/RunList.js.map +1 -1
- package/out-tsc/src/list/ShortcutList.js.map +1 -1
- package/out-tsc/src/list/TembaMenu.js +1 -1
- package/out-tsc/src/list/TembaMenu.js.map +1 -1
- package/out-tsc/src/list/TicketList.js +1 -1
- package/out-tsc/src/list/TicketList.js.map +1 -1
- package/out-tsc/src/{aliaseditor → live}/AliasEditor.js +1 -1
- package/out-tsc/src/live/AliasEditor.js.map +1 -0
- package/out-tsc/src/{contacts → live}/ContactBadges.js +1 -1
- package/out-tsc/src/live/ContactBadges.js.map +1 -0
- package/out-tsc/src/{contacts → live}/ContactChat.js +79 -3
- package/out-tsc/src/live/ContactChat.js.map +1 -0
- package/out-tsc/src/{contacts → live}/ContactDetails.js +1 -1
- package/out-tsc/src/live/ContactDetails.js.map +1 -0
- package/out-tsc/src/{contacts → live}/ContactFieldEditor.js +2 -2
- package/out-tsc/src/live/ContactFieldEditor.js.map +1 -0
- package/out-tsc/src/live/ContactFields.js.map +1 -0
- package/out-tsc/src/live/ContactNameFetch.js.map +1 -0
- package/out-tsc/src/{contacts → live}/ContactNotepad.js +1 -1
- package/out-tsc/src/{contacts → live}/ContactNotepad.js.map +1 -1
- package/out-tsc/src/{contacts → live}/ContactPending.js +1 -1
- package/out-tsc/src/live/ContactPending.js.map +1 -0
- package/out-tsc/src/live/ContactStoreElement.js.map +1 -0
- package/out-tsc/src/live/FieldManager.js.map +1 -0
- package/out-tsc/src/live/StartProgress.js.map +1 -0
- package/out-tsc/src/{chart → live}/TembaChart.js +5 -1
- package/out-tsc/src/live/TembaChart.js.map +1 -0
- 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 +2 -11
- 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/store/AppState.js +54 -24
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/src/store/Store.js +1 -1
- package/out-tsc/src/store/Store.js.map +1 -1
- package/out-tsc/src/{utils/index.js → utils.js} +22 -1
- package/out-tsc/src/utils.js.map +1 -0
- package/out-tsc/src/webchat/WebChat.js +1 -1
- package/out-tsc/src/webchat/WebChat.js.map +1 -1
- package/out-tsc/temba-components.js +2 -2
- package/out-tsc/temba-components.js.map +1 -1
- package/out-tsc/temba-modules.js +54 -54
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/temba-webchat.js +2 -2
- package/out-tsc/temba-webchat.js.map +1 -1
- package/out-tsc/test/temba-alert.test.js +1 -1
- package/out-tsc/test/temba-alert.test.js.map +1 -1
- package/out-tsc/test/temba-appstate-language.test.js +90 -0
- package/out-tsc/test/temba-appstate-language.test.js.map +1 -1
- package/out-tsc/test/temba-charcount.test.js.map +1 -1
- package/out-tsc/test/temba-chart.test.js +1 -1
- package/out-tsc/test/temba-chart.test.js.map +1 -1
- package/out-tsc/test/temba-checkbox.test.js.map +1 -1
- package/out-tsc/test/temba-color-picker.test.js +1 -1
- package/out-tsc/test/temba-color-picker.test.js.map +1 -1
- package/out-tsc/test/temba-completion.test.js +1 -1
- package/out-tsc/test/temba-completion.test.js.map +1 -1
- package/out-tsc/test/temba-compose.test.js +1 -1
- package/out-tsc/test/temba-compose.test.js.map +1 -1
- package/out-tsc/test/temba-contact-badges.test.js +1 -1
- package/out-tsc/test/temba-contact-badges.test.js.map +1 -1
- package/out-tsc/test/temba-contact-chat.test.js +3 -1
- package/out-tsc/test/temba-contact-chat.test.js.map +1 -1
- package/out-tsc/test/temba-contact-details.test.js +1 -1
- package/out-tsc/test/temba-contact-details.test.js.map +1 -1
- package/out-tsc/test/temba-contact-fields.test.js +1 -1
- package/out-tsc/test/temba-contact-fields.test.js.map +1 -1
- package/out-tsc/test/temba-contact-search.test.js +1 -1
- package/out-tsc/test/temba-contact-search.test.js.map +1 -1
- package/out-tsc/test/temba-date.test.js +5 -1
- package/out-tsc/test/temba-date.test.js.map +1 -1
- package/out-tsc/test/temba-datepicker.test.js +1 -1
- package/out-tsc/test/temba-datepicker.test.js.map +1 -1
- package/out-tsc/test/temba-dialog.test.js +1 -1
- package/out-tsc/test/temba-dialog.test.js.map +1 -1
- package/out-tsc/test/temba-dropdown.test.js +1 -1
- package/out-tsc/test/temba-dropdown.test.js.map +1 -1
- package/out-tsc/test/temba-excellent-helpers.test.js +316 -0
- package/out-tsc/test/temba-excellent-helpers.test.js.map +1 -0
- package/out-tsc/test/temba-field-manager.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor-node.test.js +414 -1
- package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +185 -0
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber-connections.test.js +113 -0
- package/out-tsc/test/temba-flow-plumber-connections.test.js.map +1 -0
- package/out-tsc/test/temba-flow-plumber.test.js +73 -93
- package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
- package/out-tsc/test/temba-flow-render.test.js +624 -1
- package/out-tsc/test/temba-flow-render.test.js.map +1 -1
- package/out-tsc/test/temba-flow-self-routing.test.js +172 -0
- package/out-tsc/test/temba-flow-self-routing.test.js.map +1 -0
- package/out-tsc/test/temba-formfield.test.js.map +1 -1
- package/out-tsc/test/temba-icon.test.js +1 -1
- package/out-tsc/test/temba-icon.test.js.map +1 -1
- package/out-tsc/test/temba-integration-markdown.test.js.map +1 -1
- package/out-tsc/test/temba-label.test.js +1 -1
- package/out-tsc/test/temba-label.test.js.map +1 -1
- package/out-tsc/test/temba-lightbox.test.js +1 -1
- package/out-tsc/test/temba-lightbox.test.js.map +1 -1
- package/out-tsc/test/temba-markdown.test.js +127 -0
- package/out-tsc/test/temba-markdown.test.js.map +1 -0
- package/out-tsc/test/temba-menu.test.js +1 -1
- package/out-tsc/test/temba-menu.test.js.map +1 -1
- package/out-tsc/test/temba-modax.test.js +1 -1
- package/out-tsc/test/temba-modax.test.js.map +1 -1
- package/out-tsc/test/temba-modules.test.js +47 -0
- package/out-tsc/test/temba-modules.test.js.map +1 -0
- package/out-tsc/test/temba-omnibox.test.js +1 -1
- package/out-tsc/test/temba-omnibox.test.js.map +1 -1
- package/out-tsc/test/temba-options.test.js.map +1 -1
- package/out-tsc/test/temba-range-picker.test.js +9 -2
- package/out-tsc/test/temba-range-picker.test.js.map +1 -1
- package/out-tsc/test/temba-rapid-element.test.js +273 -0
- package/out-tsc/test/temba-rapid-element.test.js.map +1 -0
- package/out-tsc/test/temba-resize-element.test.js +85 -0
- package/out-tsc/test/temba-resize-element.test.js.map +1 -0
- package/out-tsc/test/temba-select.test.js +2 -2
- package/out-tsc/test/temba-select.test.js.map +1 -1
- package/out-tsc/test/temba-slider.test.js.map +1 -1
- package/out-tsc/test/temba-sticky-note.test.js +194 -0
- package/out-tsc/test/temba-sticky-note.test.js.map +1 -0
- package/out-tsc/test/temba-template-editor.test.js.map +1 -1
- package/out-tsc/test/temba-textinput.test.js +1 -1
- package/out-tsc/test/temba-textinput.test.js.map +1 -1
- package/out-tsc/test/temba-tip.test.js +1 -1
- package/out-tsc/test/temba-tip.test.js.map +1 -1
- package/out-tsc/test/temba-toast.test.js +1 -1
- package/out-tsc/test/temba-toast.test.js.map +1 -1
- package/out-tsc/test/temba-utils-index.test.js +1 -1
- package/out-tsc/test/temba-utils-index.test.js.map +1 -1
- package/out-tsc/test/temba-utils-uuid.test.js +38 -0
- package/out-tsc/test/temba-utils-uuid.test.js.map +1 -0
- package/out-tsc/test/temba-webchat.test.js +28 -12
- package/out-tsc/test/temba-webchat.test.js.map +1 -1
- package/out-tsc/test/utils.test.js +2 -6
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +18 -9
- package/rollup.components.mjs +1 -1
- package/screenshots/truth/datepicker/range-picker-all.png +0 -0
- package/screenshots/truth/datepicker/range-picker-button-states.png +0 -0
- package/screenshots/truth/datepicker/range-picker-default.png +0 -0
- package/screenshots/truth/datepicker/range-picker-editing-start.png +0 -0
- package/screenshots/truth/datepicker/range-picker-initial-values.png +0 -0
- package/screenshots/truth/datepicker/range-picker-week.png +0 -0
- package/screenshots/truth/datepicker/range-picker-year.png +0 -0
- package/screenshots/truth/sticky-note/blue-color.png +0 -0
- package/screenshots/truth/sticky-note/blue.png +0 -0
- package/screenshots/truth/sticky-note/color-picker-expanded.png +0 -0
- package/screenshots/truth/sticky-note/default.png +0 -0
- package/screenshots/truth/sticky-note/gray-color.png +0 -0
- package/screenshots/truth/sticky-note/gray.png +0 -0
- package/screenshots/truth/sticky-note/green-color.png +0 -0
- package/screenshots/truth/sticky-note/green.png +0 -0
- package/screenshots/truth/sticky-note/pink-color.png +0 -0
- package/screenshots/truth/sticky-note/pink.png +0 -0
- package/screenshots/truth/sticky-note/yellow-color.png +0 -0
- package/screenshots/truth/sticky-note/yellow.png +0 -0
- package/src/{charcount → display}/CharCount.ts +164 -2
- package/src/{vectoricon/VectorIcon.ts → display/Icon.ts} +1 -1
- package/src/{leafletmap → display}/LeafletMap.ts +19 -1
- package/src/{thumbnail → display}/Thumbnail.ts +1 -1
- package/src/{tip → display}/Tip.ts +1 -2
- package/src/{contacts/events.ts → events.ts} +1 -64
- package/src/flow/Editor.ts +655 -165
- package/src/flow/EditorNode.ts +337 -22
- package/src/flow/Plumber.ts +186 -79
- package/src/flow/StickyNote.ts +165 -9
- package/src/flow/config.ts +114 -18
- package/src/flow/render.ts +398 -11
- package/src/{checkbox → form}/Checkbox.ts +2 -2
- package/src/{colorpicker → form}/ColorPicker.ts +2 -2
- package/src/{completion → form}/Completion.ts +3 -3
- package/src/{compose → form}/Compose.ts +7 -7
- package/src/{contactsearch → form}/ContactSearch.ts +6 -6
- package/src/{datepicker → form}/DatePicker.ts +1 -1
- package/src/{FormElement.ts → form/FormElement.ts} +1 -1
- package/src/{imagepicker → form}/ImagePicker.ts +2 -2
- package/src/{mediapicker → form}/MediaPicker.ts +1 -1
- package/src/{datepicker → form}/RangePicker.ts +3 -2
- package/src/{slider → form}/TembaSlider.ts +1 -1
- package/src/{templates → form}/TemplateEditor.ts +2 -2
- package/src/{textinput → form}/TextInput.ts +5 -5
- package/src/{omnibox → form/select}/Omnibox.ts +2 -2
- package/src/{select → form/select}/PopupSelect.ts +1 -1
- package/src/{select → form/select}/Select.ts +124 -126
- package/src/{select → form/select}/UserSelect.ts +1 -1
- package/src/{select → form/select}/WorkspaceSelect.ts +1 -1
- package/src/interfaces.ts +2 -1
- package/src/{dialog → layout}/Dialog.ts +1 -1
- package/src/list/NotificationList.ts +2 -2
- package/src/list/RunList.ts +3 -3
- package/src/list/ShortcutList.ts +1 -1
- package/src/list/TembaMenu.ts +2 -2
- package/src/list/TicketList.ts +1 -1
- package/src/{aliaseditor → live}/AliasEditor.ts +3 -3
- package/src/{contacts → live}/ContactBadges.ts +1 -1
- package/src/{contacts → live}/ContactChat.ts +118 -8
- package/src/{contacts → live}/ContactDetails.ts +1 -1
- package/src/{contacts → live}/ContactFieldEditor.ts +4 -4
- package/src/{contacts → live}/ContactFields.ts +1 -1
- package/src/{contacts → live}/ContactNotepad.ts +1 -1
- package/src/{contacts → live}/ContactPending.ts +1 -1
- package/src/{chart → live}/TembaChart.ts +5 -2
- package/src/locales/es.ts +13 -18
- package/src/locales/fr.ts +13 -18
- package/src/locales/locale-codes.ts +2 -11
- package/src/locales/pt.ts +13 -18
- package/src/store/AppState.ts +75 -29
- package/src/store/Store.ts +1 -1
- package/src/store/flow-definition.d.ts +125 -0
- package/src/{utils/index.ts → utils.ts} +26 -10
- package/src/webchat/WebChat.ts +1 -1
- package/static/css/temba-components.css +1 -0
- package/svg.js +1 -4
- package/temba-components.ts +2 -2
- package/temba-modules.ts +54 -54
- package/temba-webchat.ts +2 -2
- package/test/temba-alert.test.ts +1 -1
- package/test/temba-appstate-language.test.ts +108 -0
- package/test/temba-charcount.test.ts +1 -1
- package/test/temba-chart.test.ts +1 -1
- package/test/temba-checkbox.test.ts +1 -1
- package/test/temba-color-picker.test.ts +1 -1
- package/test/temba-completion.test.ts +1 -1
- package/test/temba-compose.test.ts +1 -1
- package/test/temba-contact-badges.test.ts +1 -1
- package/test/temba-contact-chat.test.ts +6 -4
- package/test/temba-contact-details.test.ts +1 -1
- package/test/temba-contact-fields.test.ts +1 -1
- package/test/temba-contact-search.test.ts +2 -2
- package/test/temba-date.test.ts +8 -3
- package/test/temba-datepicker.test.ts +1 -1
- package/test/temba-dialog.test.ts +1 -1
- package/test/temba-dropdown.test.ts +1 -1
- package/test/temba-excellent-helpers.test.ts +417 -0
- package/test/temba-field-manager.test.ts +2 -2
- package/test/temba-flow-editor-node.test.ts +536 -1
- package/test/temba-flow-editor.test.ts +224 -0
- package/test/temba-flow-editor.test.ts.backup +563 -0
- package/test/temba-flow-plumber-connections.test.ts +142 -0
- package/test/temba-flow-plumber.test.ts +83 -120
- package/test/temba-flow-render.test.ts +787 -4
- package/test/temba-flow-self-routing.test.ts +215 -0
- package/test/temba-formfield.test.ts +1 -1
- package/test/temba-icon.test.ts +1 -1
- package/test/temba-integration-markdown.test.ts +1 -1
- package/test/temba-label.test.ts +1 -1
- package/test/temba-lightbox.test.ts +1 -1
- package/test/temba-markdown.test.ts +162 -0
- package/test/temba-menu.test.ts +1 -1
- package/test/temba-modax.test.ts +2 -2
- package/test/temba-modules.test.ts +56 -0
- package/test/temba-omnibox.test.ts +1 -1
- package/test/temba-options.test.ts +1 -1
- package/test/temba-range-picker.test.ts +17 -2
- package/test/temba-rapid-element.test.ts +341 -0
- package/test/temba-resize-element.test.ts +104 -0
- package/test/temba-select.test.ts +2 -2
- package/test/temba-slider.test.ts +1 -1
- package/test/temba-sticky-note.test.ts +281 -0
- package/test/temba-template-editor.test.ts +1 -1
- package/test/temba-textinput.test.ts +1 -1
- package/test/temba-tip.test.ts +1 -1
- package/test/temba-toast.test.ts +1 -1
- package/test/temba-utils-index.test.ts +1 -1
- package/test/temba-utils-index.test.ts.backup +1737 -0
- package/test/temba-utils-uuid.test.ts +48 -0
- package/test/temba-webchat.test.ts +30 -12
- package/test/utils.test.ts +5 -9
- package/web-dev-server.config.mjs +1 -1
- package/demo/alert/example.html +0 -65
- package/demo/button/example.html +0 -71
- package/demo/chart/horizontal-demo.html +0 -81
- package/demo/checkbox/example.html +0 -72
- package/demo/compose/example.html +0 -72
- package/demo/dropdown/example.html +0 -99
- package/demo/progress/example.html +0 -59
- package/demo/select/drag-and-drop.html +0 -142
- package/demo/select/example.html +0 -82
- package/demo/select/multi.html +0 -73
- package/demo/slider/example.html +0 -59
- package/demo/tabs/example.html +0 -91
- package/demo/textinput/example.html +0 -61
- package/out-tsc/src/FormElement.js.map +0 -1
- package/out-tsc/src/alert/Alert.js.map +0 -1
- package/out-tsc/src/aliaseditor/AliasEditor.js.map +0 -1
- package/out-tsc/src/anchor/Anchor.js.map +0 -1
- package/out-tsc/src/button/Button.js.map +0 -1
- package/out-tsc/src/charcount/CharCount.js.map +0 -1
- package/out-tsc/src/charcount/helpers.js +0 -159
- package/out-tsc/src/charcount/helpers.js.map +0 -1
- package/out-tsc/src/chart/TembaChart.js.map +0 -1
- package/out-tsc/src/chat/Chat.js.map +0 -1
- package/out-tsc/src/checkbox/Checkbox.js.map +0 -1
- package/out-tsc/src/colorpicker/ColorPicker.js.map +0 -1
- package/out-tsc/src/completion/Completion.js.map +0 -1
- package/out-tsc/src/completion/ExcellentParser.js.map +0 -1
- package/out-tsc/src/completion/helpers.js.map +0 -1
- package/out-tsc/src/compose/Compose.js.map +0 -1
- package/out-tsc/src/contacts/ContactBadges.js.map +0 -1
- package/out-tsc/src/contacts/ContactChat.js.map +0 -1
- package/out-tsc/src/contacts/ContactDetails.js.map +0 -1
- package/out-tsc/src/contacts/ContactFieldEditor.js.map +0 -1
- package/out-tsc/src/contacts/ContactFields.js.map +0 -1
- package/out-tsc/src/contacts/ContactName.js.map +0 -1
- package/out-tsc/src/contacts/ContactNameFetch.js.map +0 -1
- package/out-tsc/src/contacts/ContactPending.js.map +0 -1
- package/out-tsc/src/contacts/ContactStoreElement.js.map +0 -1
- package/out-tsc/src/contacts/ContactUrn.js.map +0 -1
- package/out-tsc/src/contacts/events.js +0 -65
- package/out-tsc/src/contacts/events.js.map +0 -1
- package/out-tsc/src/contacts/helpers.js +0 -77
- package/out-tsc/src/contacts/helpers.js.map +0 -1
- package/out-tsc/src/contactsearch/ContactSearch.js.map +0 -1
- package/out-tsc/src/date/TembaDate.js.map +0 -1
- package/out-tsc/src/datepicker/DatePicker.js.map +0 -1
- package/out-tsc/src/datepicker/RangePicker.js.map +0 -1
- package/out-tsc/src/dialog/Dialog.js.map +0 -1
- package/out-tsc/src/dropdown/Dropdown.js.map +0 -1
- package/out-tsc/src/fields/FieldManager.js.map +0 -1
- package/out-tsc/src/formfield/FormField.js.map +0 -1
- package/out-tsc/src/imagepicker/CroppieCSS.js.map +0 -1
- package/out-tsc/src/imagepicker/ImagePicker.js.map +0 -1
- package/out-tsc/src/label/Label.js.map +0 -1
- package/out-tsc/src/leafletmap/LeafletMap.js.map +0 -1
- package/out-tsc/src/leafletmap/helpers.js +0 -17
- package/out-tsc/src/leafletmap/helpers.js.map +0 -1
- package/out-tsc/src/lightbox/Lightbox.js.map +0 -1
- package/out-tsc/src/mask/Mask.js.map +0 -1
- package/out-tsc/src/mediapicker/MediaPicker.js.map +0 -1
- package/out-tsc/src/omnibox/Omnibox.js.map +0 -1
- package/out-tsc/src/options/helpers.js +0 -28
- package/out-tsc/src/options/helpers.js.map +0 -1
- package/out-tsc/src/progress/ProgressBar.js.map +0 -1
- package/out-tsc/src/progress/StartProgress.js.map +0 -1
- package/out-tsc/src/resizer/Resizer.js.map +0 -1
- package/out-tsc/src/select/PopupSelect.js.map +0 -1
- package/out-tsc/src/select/Select.js.map +0 -1
- package/out-tsc/src/select/UserSelect.js.map +0 -1
- package/out-tsc/src/select/WorkspaceSelect.js.map +0 -1
- package/out-tsc/src/select/helpers.js +0 -1
- package/out-tsc/src/select/helpers.js.map +0 -1
- package/out-tsc/src/shadowless/Shadowless.js +0 -33
- package/out-tsc/src/shadowless/Shadowless.js.map +0 -1
- package/out-tsc/src/slider/TembaSlider.js.map +0 -1
- package/out-tsc/src/sms/gsmsplitter.js.map +0 -1
- package/out-tsc/src/sms/gsmvalidator.js.map +0 -1
- package/out-tsc/src/sms/index.js.map +0 -1
- package/out-tsc/src/sms/unicodesplitter.js.map +0 -1
- package/out-tsc/src/tabpane/Tab.js.map +0 -1
- package/out-tsc/src/tabpane/TabPane.js.map +0 -1
- package/out-tsc/src/templates/TemplateEditor.js.map +0 -1
- package/out-tsc/src/textinput/TextInput.js.map +0 -1
- package/out-tsc/src/textinput/helpers.js +0 -12
- package/out-tsc/src/textinput/helpers.js.map +0 -1
- package/out-tsc/src/thumbnail/Thumbnail.js.map +0 -1
- package/out-tsc/src/tip/Tip.js.map +0 -1
- package/out-tsc/src/tip/helpers.js +0 -7
- package/out-tsc/src/tip/helpers.js.map +0 -1
- package/out-tsc/src/toast/Toast.js.map +0 -1
- package/out-tsc/src/user/TembaUser.js.map +0 -1
- package/out-tsc/src/utils/index.js.map +0 -1
- package/out-tsc/src/vectoricon/VectorIcon.js.map +0 -1
- package/out-tsc/src/vectoricon/index.js.map +0 -1
- package/src/charcount/helpers.ts +0 -162
- package/src/contacts/helpers.ts +0 -103
- package/src/leafletmap/helpers.ts +0 -18
- package/src/options/helpers.ts +0 -37
- package/src/select/helpers.ts +0 -0
- package/src/shadowless/Shadowless.ts +0 -32
- package/src/textinput/helpers.ts +0 -11
- package/src/tip/helpers.ts +0 -7
- /package/out-tsc/src/{alert → display}/Alert.js +0 -0
- /package/out-tsc/src/{anchor → display}/Anchor.js +0 -0
- /package/out-tsc/src/{button → display}/Button.js +0 -0
- /package/out-tsc/src/{chat → display}/Chat.js +0 -0
- /package/out-tsc/src/{contacts → display}/ContactName.js +0 -0
- /package/out-tsc/src/{contacts → display}/ContactUrn.js +0 -0
- /package/out-tsc/src/{dropdown → display}/Dropdown.js +0 -0
- /package/out-tsc/src/{label → display}/Label.js +0 -0
- /package/out-tsc/src/{lightbox → display}/Lightbox.js +0 -0
- /package/out-tsc/src/{loading → display}/Loading.js +0 -0
- /package/out-tsc/src/{options → display}/Options.js +0 -0
- /package/out-tsc/src/{progress → display}/ProgressBar.js +0 -0
- /package/out-tsc/src/{date → display}/TembaDate.js +0 -0
- /package/out-tsc/src/{user → display}/TembaUser.js +0 -0
- /package/out-tsc/src/{thumbnail → display}/Thumbnail.js +0 -0
- /package/out-tsc/src/{toast → display}/Toast.js +0 -0
- /package/out-tsc/src/{sms → display/sms}/gsmsplitter.js +0 -0
- /package/out-tsc/src/{sms → display/sms}/gsmvalidator.js +0 -0
- /package/out-tsc/src/{sms → display/sms}/index.js +0 -0
- /package/out-tsc/src/{sms → display/sms}/unicodesplitter.js +0 -0
- /package/out-tsc/src/{completion → excellent}/ExcellentParser.js +0 -0
- /package/out-tsc/src/{completion → excellent}/helpers.js +0 -0
- /package/out-tsc/src/{imagepicker → form}/CroppieCSS.js +0 -0
- /package/out-tsc/src/{formfield → form}/FormField.js +0 -0
- /package/out-tsc/src/{dialog → layout}/Dialog.js +0 -0
- /package/out-tsc/src/{mask → layout}/Mask.js +0 -0
- /package/out-tsc/src/{dialog → layout}/Modax.js +0 -0
- /package/out-tsc/src/{resizer → layout}/Resizer.js +0 -0
- /package/out-tsc/src/{tabpane → layout}/Tab.js +0 -0
- /package/out-tsc/src/{tabpane → layout}/TabPane.js +0 -0
- /package/out-tsc/src/{contacts → live}/ContactFields.js +0 -0
- /package/out-tsc/src/{contacts → live}/ContactNameFetch.js +0 -0
- /package/out-tsc/src/{contacts → live}/ContactStoreElement.js +0 -0
- /package/out-tsc/src/{fields → live}/FieldManager.js +0 -0
- /package/out-tsc/src/{progress → live}/StartProgress.js +0 -0
- /package/src/{vectoricon/index.ts → Icons.ts} +0 -0
- /package/src/{alert → display}/Alert.ts +0 -0
- /package/src/{anchor → display}/Anchor.ts +0 -0
- /package/src/{button → display}/Button.ts +0 -0
- /package/src/{chat → display}/Chat.ts +0 -0
- /package/src/{contacts → display}/ContactName.ts +0 -0
- /package/src/{contacts → display}/ContactUrn.ts +0 -0
- /package/src/{dropdown → display}/Dropdown.ts +0 -0
- /package/src/{label → display}/Label.ts +0 -0
- /package/src/{lightbox → display}/Lightbox.ts +0 -0
- /package/src/{loading → display}/Loading.ts +0 -0
- /package/src/{options → display}/Options.ts +0 -0
- /package/src/{progress → display}/ProgressBar.ts +0 -0
- /package/src/{date → display}/TembaDate.ts +0 -0
- /package/src/{user → display}/TembaUser.ts +0 -0
- /package/src/{toast → display}/Toast.ts +0 -0
- /package/src/{sms → display/sms}/gsmsplitter.ts +0 -0
- /package/src/{sms → display/sms}/gsmvalidator.ts +0 -0
- /package/src/{sms → display/sms}/index.ts +0 -0
- /package/src/{sms → display/sms}/unicodesplitter.ts +0 -0
- /package/src/{completion → excellent}/ExcellentParser.ts +0 -0
- /package/src/{completion → excellent}/helpers.ts +0 -0
- /package/src/{imagepicker → form}/CroppieCSS.ts +0 -0
- /package/src/{formfield → form}/FormField.ts +0 -0
- /package/src/{mask → layout}/Mask.ts +0 -0
- /package/src/{dialog → layout}/Modax.ts +0 -0
- /package/src/{resizer → layout}/Resizer.ts +0 -0
- /package/src/{tabpane → layout}/Tab.ts +0 -0
- /package/src/{tabpane → layout}/TabPane.ts +0 -0
- /package/src/{contacts → live}/ContactNameFetch.ts +0 -0
- /package/src/{contacts → live}/ContactStoreElement.ts +0 -0
- /package/src/{fields → live}/FieldManager.ts +0 -0
- /package/src/{progress → live}/StartProgress.ts +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { stub, useFakeTimers } from 'sinon';
|
|
3
|
+
import { Plumber } from '../src/flow/Plumber';
|
|
4
|
+
describe('Plumber - Connection Management', () => {
|
|
5
|
+
let plumber;
|
|
6
|
+
let mockCanvas;
|
|
7
|
+
let clock;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
// Use fake timers to control setTimeout
|
|
10
|
+
clock = useFakeTimers();
|
|
11
|
+
// Create mock canvas and make getElementById return a mock element
|
|
12
|
+
mockCanvas = document.createElement('div');
|
|
13
|
+
const mockElement = document.createElement('div');
|
|
14
|
+
stub(document, 'getElementById').returns(mockElement);
|
|
15
|
+
// Create a new plumber instance
|
|
16
|
+
plumber = new Plumber(mockCanvas);
|
|
17
|
+
// Replace the internal jsPlumb instance with mocks
|
|
18
|
+
plumber.jsPlumb = {
|
|
19
|
+
getConnections: stub().returns([]),
|
|
20
|
+
addClass: stub(),
|
|
21
|
+
removeClass: stub(),
|
|
22
|
+
batch: stub().callsFake((fn) => fn()),
|
|
23
|
+
addEndpoint: stub().returns({}),
|
|
24
|
+
connect: stub(),
|
|
25
|
+
selectEndpoints: stub().returns({
|
|
26
|
+
deleteAll: stub()
|
|
27
|
+
}),
|
|
28
|
+
deleteConnection: stub(),
|
|
29
|
+
removeAllEndpoints: stub(),
|
|
30
|
+
repaintEverything: stub()
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
// Restore the original document.getElementById
|
|
36
|
+
(_b = (_a = document.getElementById).restore) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
37
|
+
clock.restore();
|
|
38
|
+
});
|
|
39
|
+
describe('setConnectionRemovingState', () => {
|
|
40
|
+
it('returns false when no connections are found', () => {
|
|
41
|
+
const result = plumber.setConnectionRemovingState('test-exit', true);
|
|
42
|
+
expect(result).to.be.false;
|
|
43
|
+
expect(plumber.jsPlumb.getConnections).to.have.been.called;
|
|
44
|
+
});
|
|
45
|
+
it('sets removing class on connections when isRemoving is true', () => {
|
|
46
|
+
const mockConnections = [
|
|
47
|
+
{ id: 'conn1', addClass: stub() },
|
|
48
|
+
{ id: 'conn2', addClass: stub() }
|
|
49
|
+
];
|
|
50
|
+
plumber.jsPlumb.getConnections = stub().returns(mockConnections);
|
|
51
|
+
const result = plumber.setConnectionRemovingState('test-exit', true);
|
|
52
|
+
expect(result).to.be.true;
|
|
53
|
+
expect(mockConnections[0].addClass).to.have.been.calledWith('removing');
|
|
54
|
+
expect(mockConnections[1].addClass).to.have.been.calledWith('removing');
|
|
55
|
+
});
|
|
56
|
+
it('removes removing class from connections when isRemoving is false', () => {
|
|
57
|
+
const mockConnections = [
|
|
58
|
+
{ id: 'conn1', removeClass: stub() },
|
|
59
|
+
{ id: 'conn2', removeClass: stub() }
|
|
60
|
+
];
|
|
61
|
+
plumber.jsPlumb.getConnections = stub().returns(mockConnections);
|
|
62
|
+
const result = plumber.setConnectionRemovingState('test-exit', false);
|
|
63
|
+
expect(result).to.be.true;
|
|
64
|
+
expect(mockConnections[0].removeClass).to.have.been.calledWith('removing');
|
|
65
|
+
expect(mockConnections[1].removeClass).to.have.been.calledWith('removing');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('connectIds and processPendingConnections', () => {
|
|
69
|
+
it('adds connection to pending connections', () => {
|
|
70
|
+
// Call connectIds which should add to pending connections
|
|
71
|
+
plumber.connectIds('test-node', 'test-from', 'test-to');
|
|
72
|
+
// Verify pendingConnections has the new connection
|
|
73
|
+
expect(plumber.pendingConnections.length).to.equal(1);
|
|
74
|
+
// Advance timer to trigger the timeout
|
|
75
|
+
clock.tick(51); // Just past the 50ms timeout
|
|
76
|
+
// Now the batch should have been called
|
|
77
|
+
expect(plumber.jsPlumb.batch).to.have.been.called;
|
|
78
|
+
expect(plumber.jsPlumb.addEndpoint).to.have.been.called;
|
|
79
|
+
expect(plumber.jsPlumb.connect).to.have.been.called;
|
|
80
|
+
});
|
|
81
|
+
it('clears previous timeout when called multiple times', () => {
|
|
82
|
+
// Set up spies for window.setTimeout and window.clearTimeout instead of global
|
|
83
|
+
const clearTimeoutSpy = stub(window, 'clearTimeout');
|
|
84
|
+
const setTimeoutSpy = stub(window, 'setTimeout').returns(123);
|
|
85
|
+
// Call twice
|
|
86
|
+
plumber.processPendingConnections();
|
|
87
|
+
plumber.processPendingConnections();
|
|
88
|
+
// Should have called clearTimeout once and setTimeout twice
|
|
89
|
+
expect(clearTimeoutSpy).to.have.been.calledOnce;
|
|
90
|
+
expect(setTimeoutSpy).to.have.been.calledTwice;
|
|
91
|
+
// Clean up
|
|
92
|
+
clearTimeoutSpy.restore();
|
|
93
|
+
setTimeoutSpy.restore();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('removeExitConnection', () => {
|
|
97
|
+
it('removes connections for an exit', () => {
|
|
98
|
+
const mockConnections = [{ id: 'conn1' }, { id: 'conn2' }];
|
|
99
|
+
plumber.jsPlumb.getConnections = stub().returns(mockConnections);
|
|
100
|
+
const result = plumber.removeExitConnection('test-exit');
|
|
101
|
+
expect(result).to.be.true;
|
|
102
|
+
expect(plumber.jsPlumb.deleteConnection).to.have.been
|
|
103
|
+
.calledTwice;
|
|
104
|
+
expect(plumber.jsPlumb.removeAllEndpoints).to.have.been.called;
|
|
105
|
+
});
|
|
106
|
+
it('returns false when no connections exist', () => {
|
|
107
|
+
plumber.jsPlumb.getConnections = stub().returns([]);
|
|
108
|
+
const result = plumber.removeExitConnection('test-exit');
|
|
109
|
+
expect(result).to.be.false;
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=temba-flow-plumber-connections.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temba-flow-plumber-connections.test.js","sourceRoot":"","sources":["../../test/temba-flow-plumber-connections.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,aAAa,EAAmB,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,IAAI,OAAgB,CAAC;IACrB,IAAI,UAAuB,CAAC;IAC5B,IAAI,KAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE;QACd,wCAAwC;QACxC,KAAK,GAAG,aAAa,EAAE,CAAC;QAExB,mEAAmE;QACnE,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAEtD,gCAAgC;QAChC,OAAO,GAAG,IAAI,O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AW,CAAC,CAAC;YAEzD,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect } from '@open-wc/testing';\nimport { stub, useFakeTimers, SinonFakeTimers } from 'sinon';\nimport { Plumber } from '../src/flow/Plumber';\n\ndescribe('Plumber - Connection Management', () => {\n let plumber: Plumber;\n let mockCanvas: HTMLElement;\n let clock: SinonFakeTimers;\n\n beforeEach(() => {\n // Use fake timers to control setTimeout\n clock = useFakeTimers();\n\n // Create mock canvas and make getElementById return a mock element\n mockCanvas = document.createElement('div');\n const mockElement = document.createElement('div');\n stub(document, 'getElementById').returns(mockElement);\n\n // Create a new plumber instance\n plumber = new Plumber(mockCanvas);\n\n // Replace the internal jsPlumb instance with mocks\n (plumber as any).jsPlumb = {\n getConnections: stub().returns([]),\n addClass: stub(),\n removeClass: stub(),\n batch: stub().callsFake((fn: any) => fn()),\n addEndpoint: stub().returns({}),\n connect: stub(),\n selectEndpoints: stub().returns({\n deleteAll: stub()\n }),\n deleteConnection: stub(),\n removeAllEndpoints: stub(),\n repaintEverything: stub()\n };\n });\n\n afterEach(() => {\n // Restore the original document.getElementById\n (document.getElementById as any).restore?.();\n clock.restore();\n });\n\n describe('setConnectionRemovingState', () => {\n it('returns false when no connections are found', () => {\n const result = plumber.setConnectionRemovingState('test-exit', true);\n expect(result).to.be.false;\n expect((plumber as any).jsPlumb.getConnections).to.have.been.called;\n });\n\n it('sets removing class on connections when isRemoving is true', () => {\n const mockConnections = [\n { id: 'conn1', addClass: stub() },\n { id: 'conn2', addClass: stub() }\n ];\n\n (plumber as any).jsPlumb.getConnections = stub().returns(mockConnections);\n\n const result = plumber.setConnectionRemovingState('test-exit', true);\n expect(result).to.be.true;\n expect(mockConnections[0].addClass).to.have.been.calledWith('removing');\n expect(mockConnections[1].addClass).to.have.been.calledWith('removing');\n });\n\n it('removes removing class from connections when isRemoving is false', () => {\n const mockConnections = [\n { id: 'conn1', removeClass: stub() },\n { id: 'conn2', removeClass: stub() }\n ];\n\n (plumber as any).jsPlumb.getConnections = stub().returns(mockConnections);\n\n const result = plumber.setConnectionRemovingState('test-exit', false);\n expect(result).to.be.true;\n expect(mockConnections[0].removeClass).to.have.been.calledWith(\n 'removing'\n );\n expect(mockConnections[1].removeClass).to.have.been.calledWith(\n 'removing'\n );\n });\n });\n\n describe('connectIds and processPendingConnections', () => {\n it('adds connection to pending connections', () => {\n // Call connectIds which should add to pending connections\n plumber.connectIds('test-node', 'test-from', 'test-to');\n\n // Verify pendingConnections has the new connection\n expect((plumber as any).pendingConnections.length).to.equal(1);\n\n // Advance timer to trigger the timeout\n clock.tick(51); // Just past the 50ms timeout\n\n // Now the batch should have been called\n expect((plumber as any).jsPlumb.batch).to.have.been.called;\n expect((plumber as any).jsPlumb.addEndpoint).to.have.been.called;\n expect((plumber as any).jsPlumb.connect).to.have.been.called;\n });\n\n it('clears previous timeout when called multiple times', () => {\n // Set up spies for window.setTimeout and window.clearTimeout instead of global\n const clearTimeoutSpy = stub(window, 'clearTimeout');\n const setTimeoutSpy = stub(window, 'setTimeout').returns(123 as any);\n\n // Call twice\n plumber.processPendingConnections();\n plumber.processPendingConnections();\n\n // Should have called clearTimeout once and setTimeout twice\n expect(clearTimeoutSpy).to.have.been.calledOnce;\n expect(setTimeoutSpy).to.have.been.calledTwice;\n\n // Clean up\n clearTimeoutSpy.restore();\n setTimeoutSpy.restore();\n });\n });\n\n describe('removeExitConnection', () => {\n it('removes connections for an exit', () => {\n const mockConnections = [{ id: 'conn1' }, { id: 'conn2' }];\n (plumber as any).jsPlumb.getConnections = stub().returns(mockConnections);\n\n const result = plumber.removeExitConnection('test-exit');\n\n expect(result).to.be.true;\n expect((plumber as any).jsPlumb.deleteConnection).to.have.been\n .calledTwice;\n expect((plumber as any).jsPlumb.removeAllEndpoints).to.have.been.called;\n });\n\n it('returns false when no connections exist', () => {\n (plumber as any).jsPlumb.getConnections = stub().returns([]);\n\n const result = plumber.removeExitConnection('test-exit');\n\n expect(result).to.be.false;\n });\n });\n});\n"]}
|
|
@@ -1,35 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
2
|
import { Plumber, SOURCE_DEFAULTS, TARGET_DEFAULTS } from '../src/flow/Plumber';
|
|
3
|
-
import { stub,
|
|
3
|
+
import { stub, useFakeTimers } from 'sinon';
|
|
4
4
|
describe('Plumber', () => {
|
|
5
5
|
let plumber;
|
|
6
6
|
let mockJsPlumb;
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const canvas = container.querySelector('#test-canvas');
|
|
20
|
-
// Mock jsPlumb functionality
|
|
7
|
+
let mockCanvas;
|
|
8
|
+
let clock;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
// Use fake timers to control setTimeout
|
|
11
|
+
clock = useFakeTimers();
|
|
12
|
+
// Create mock canvas and make getElementById return a mock element
|
|
13
|
+
mockCanvas = document.createElement('div');
|
|
14
|
+
const mockElement = document.createElement('div');
|
|
15
|
+
stub(document, 'getElementById').returns(mockElement);
|
|
16
|
+
// Create a new plumber instance
|
|
17
|
+
plumber = new Plumber(mockCanvas);
|
|
18
|
+
// Replace the internal jsPlumb instance with mocks
|
|
21
19
|
mockJsPlumb = {
|
|
22
|
-
|
|
20
|
+
getConnections: stub().returns([]),
|
|
21
|
+
addClass: stub(),
|
|
22
|
+
removeClass: stub(),
|
|
23
|
+
batch: stub().callsFake((fn) => fn()),
|
|
24
|
+
addEndpoint: stub().returns({}),
|
|
23
25
|
connect: stub(),
|
|
24
|
-
|
|
26
|
+
selectEndpoints: stub().returns({
|
|
27
|
+
deleteAll: stub()
|
|
28
|
+
}),
|
|
29
|
+
deleteConnection: stub(),
|
|
30
|
+
removeAllEndpoints: stub(),
|
|
31
|
+
repaintEverything: stub(),
|
|
32
|
+
revalidate: stub(),
|
|
33
|
+
bind: stub()
|
|
25
34
|
};
|
|
26
|
-
// Create plumber instance and replace jsPlumb
|
|
27
|
-
plumber = new Plumber(canvas);
|
|
28
|
-
// Access private property for testing
|
|
29
35
|
plumber.jsPlumb = mockJsPlumb;
|
|
36
|
+
// Reset the connectionWait to avoid timing issues
|
|
37
|
+
plumber.connectionWait = null;
|
|
30
38
|
});
|
|
31
39
|
afterEach(() => {
|
|
32
|
-
|
|
40
|
+
var _a, _b;
|
|
41
|
+
// Restore the original document.getElementById
|
|
42
|
+
(_b = (_a = document.getElementById).restore) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
43
|
+
clock.restore();
|
|
33
44
|
});
|
|
34
45
|
describe('constructor', () => {
|
|
35
46
|
it('creates a new plumber instance', () => {
|
|
@@ -39,106 +50,75 @@ describe('Plumber', () => {
|
|
|
39
50
|
describe('makeTarget', () => {
|
|
40
51
|
it('creates a target endpoint for the specified element', () => {
|
|
41
52
|
plumber.makeTarget('test-target');
|
|
42
|
-
expect(mockJsPlumb.addEndpoint).to.have.been.
|
|
43
|
-
});
|
|
44
|
-
it('handles non-existent elements gracefully', () => {
|
|
45
|
-
plumber.makeTarget('non-existent');
|
|
46
|
-
expect(mockJsPlumb.addEndpoint).to.have.been.calledWith(null, TARGET_DEFAULTS);
|
|
53
|
+
expect(mockJsPlumb.addEndpoint).to.have.been.called;
|
|
47
54
|
});
|
|
48
55
|
});
|
|
49
56
|
describe('makeSource', () => {
|
|
50
57
|
it('creates a source endpoint for the specified element', () => {
|
|
51
58
|
plumber.makeSource('test-source');
|
|
52
|
-
expect(mockJsPlumb.addEndpoint).to.have.been.
|
|
53
|
-
});
|
|
54
|
-
it('handles non-existent elements gracefully', () => {
|
|
55
|
-
plumber.makeSource('non-existent');
|
|
56
|
-
expect(mockJsPlumb.addEndpoint).to.have.been.calledWith(null, SOURCE_DEFAULTS);
|
|
59
|
+
expect(mockJsPlumb.addEndpoint).to.have.been.called;
|
|
57
60
|
});
|
|
58
61
|
});
|
|
59
62
|
describe('connectIds', () => {
|
|
60
63
|
it('adds connection to pending connections and processes them', () => {
|
|
61
|
-
plumber.connectIds('test-from', 'test-to');
|
|
62
|
-
// Verify
|
|
63
|
-
expect(plumber).to.
|
|
64
|
+
plumber.connectIds('test-node', 'test-from', 'test-to');
|
|
65
|
+
// Verify pendingConnections has the new connection
|
|
66
|
+
expect(plumber.pendingConnections.length).to.equal(1);
|
|
67
|
+
// Advance timer to trigger the timeout
|
|
68
|
+
clock.tick(51); // Just past the 50ms timeout
|
|
69
|
+
// Now the batch should have been called
|
|
70
|
+
expect(mockJsPlumb.batch).to.have.been.called;
|
|
64
71
|
});
|
|
65
72
|
});
|
|
66
73
|
describe('processPendingConnections', () => {
|
|
67
|
-
it('processes pending connections with timeout', (
|
|
74
|
+
it('processes pending connections with timeout', () => {
|
|
68
75
|
// Add a connection to pending connections
|
|
69
|
-
plumber.connectIds('test-from', 'test-to');
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
done();
|
|
74
|
-
}, 60); // Wait longer than the 50ms timeout
|
|
76
|
+
plumber.connectIds('test-node', 'test-from', 'test-to');
|
|
77
|
+
// Fast-forward clock past the timeout
|
|
78
|
+
clock.tick(51); // Just past the 50ms timeout
|
|
79
|
+
expect(mockJsPlumb.batch).to.have.been.called;
|
|
75
80
|
});
|
|
76
|
-
it('creates endpoints and connections for pending connections', (
|
|
77
|
-
plumber.connectIds('test-from', 'test-to');
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, 60);
|
|
81
|
+
it('creates endpoints and connections for pending connections', () => {
|
|
82
|
+
plumber.connectIds('test-node', 'test-from', 'test-to');
|
|
83
|
+
// Fast-forward clock past the timeout
|
|
84
|
+
clock.tick(51); // Just past the 50ms timeout
|
|
85
|
+
expect(mockJsPlumb.addEndpoint).to.have.been.called;
|
|
86
|
+
expect(mockJsPlumb.connect).to.have.been.called;
|
|
83
87
|
});
|
|
84
88
|
it('clears existing timeout when called multiple times', () => {
|
|
85
|
-
//
|
|
89
|
+
// Set up spies for window.setTimeout and window.clearTimeout
|
|
90
|
+
const clearTimeoutSpy = stub(window, 'clearTimeout');
|
|
91
|
+
const setTimeoutSpy = stub(window, 'setTimeout').returns(123);
|
|
92
|
+
// Call twice
|
|
86
93
|
plumber.processPendingConnections();
|
|
87
94
|
plumber.processPendingConnections();
|
|
88
|
-
//
|
|
89
|
-
expect(
|
|
95
|
+
// Should have called clearTimeout once and setTimeout twice
|
|
96
|
+
expect(clearTimeoutSpy).to.have.been.calledOnce;
|
|
97
|
+
expect(setTimeoutSpy).to.have.been.calledTwice;
|
|
98
|
+
// Clean up
|
|
99
|
+
clearTimeoutSpy.restore();
|
|
100
|
+
setTimeoutSpy.restore();
|
|
90
101
|
});
|
|
91
|
-
it('handles empty pending connections', (
|
|
102
|
+
it('handles empty pending connections', () => {
|
|
92
103
|
// Call without adding any connections
|
|
93
104
|
plumber.processPendingConnections();
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}, 60);
|
|
105
|
+
// Fast-forward clock past the timeout
|
|
106
|
+
clock.tick(51); // Just past the 50ms timeout
|
|
107
|
+
expect(mockJsPlumb.batch).to.have.been.called;
|
|
98
108
|
});
|
|
99
109
|
});
|
|
100
110
|
describe('constants', () => {
|
|
101
|
-
it('
|
|
111
|
+
it('has correct properties in SOURCE_DEFAULTS', () => {
|
|
102
112
|
expect(SOURCE_DEFAULTS).to.have.property('endpoint');
|
|
103
|
-
expect(SOURCE_DEFAULTS.endpoint).to.have.property('type');
|
|
104
|
-
expect(SOURCE_DEFAULTS.endpoint).to.have.property('options');
|
|
105
113
|
expect(SOURCE_DEFAULTS).to.have.property('anchors');
|
|
106
|
-
expect(SOURCE_DEFAULTS).to.have.property('maxConnections'
|
|
107
|
-
expect(SOURCE_DEFAULTS).to.have.property('
|
|
108
|
-
expect(SOURCE_DEFAULTS).to.have.property('dragAllowedWhenFull', false);
|
|
109
|
-
expect(SOURCE_DEFAULTS).to.have.property('deleteEndpointsOnEmpty', true);
|
|
114
|
+
expect(SOURCE_DEFAULTS).to.have.property('maxConnections');
|
|
115
|
+
expect(SOURCE_DEFAULTS).to.have.property('source');
|
|
110
116
|
});
|
|
111
|
-
it('
|
|
117
|
+
it('has correct properties in TARGET_DEFAULTS', () => {
|
|
112
118
|
expect(TARGET_DEFAULTS).to.have.property('endpoint');
|
|
113
|
-
expect(TARGET_DEFAULTS.endpoint).to.have.property('type');
|
|
114
|
-
expect(TARGET_DEFAULTS.endpoint).to.have.property('options');
|
|
115
119
|
expect(TARGET_DEFAULTS).to.have.property('anchor');
|
|
116
|
-
expect(TARGET_DEFAULTS).to.have.property('
|
|
117
|
-
expect(TARGET_DEFAULTS).to.have.property('
|
|
118
|
-
expect(TARGET_DEFAULTS).to.have.property('deleteEndpointsOnEmpty', true);
|
|
119
|
-
});
|
|
120
|
-
it('has correct SOURCE_DEFAULTS endpoint options', () => {
|
|
121
|
-
const options = SOURCE_DEFAULTS.endpoint.options;
|
|
122
|
-
expect(options).to.have.property('radius', 6);
|
|
123
|
-
expect(options).to.have.property('cssClass', 'plumb-source');
|
|
124
|
-
expect(options).to.have.property('hoverClass', 'plumb-source-hover');
|
|
125
|
-
expect(options).to.have.property('connectedClass', 'plumb-connected');
|
|
126
|
-
});
|
|
127
|
-
it('has correct TARGET_DEFAULTS endpoint options', () => {
|
|
128
|
-
const options = TARGET_DEFAULTS.endpoint.options;
|
|
129
|
-
expect(options).to.have.property('width', 23);
|
|
130
|
-
expect(options).to.have.property('height', 23);
|
|
131
|
-
expect(options).to.have.property('cssClass', 'plumb-target');
|
|
132
|
-
expect(options).to.have.property('hoverClass', 'plumb-target-hover');
|
|
133
|
-
});
|
|
134
|
-
it('has correct TARGET_DEFAULTS anchor options', () => {
|
|
135
|
-
const anchor = TARGET_DEFAULTS.anchor;
|
|
136
|
-
expect(anchor).to.have.property('type', 'Continuous');
|
|
137
|
-
expect(anchor.options).to.have.property('faces');
|
|
138
|
-
expect(anchor.options.faces).to.include('top');
|
|
139
|
-
expect(anchor.options.faces).to.include('left');
|
|
140
|
-
expect(anchor.options.faces).to.include('right');
|
|
141
|
-
expect(anchor.options).to.have.property('cssClass', 'continuos plumb-target-anchor');
|
|
120
|
+
expect(TARGET_DEFAULTS).to.have.property('maxConnections');
|
|
121
|
+
expect(TARGET_DEFAULTS).to.have.property('target');
|
|
142
122
|
});
|
|
143
123
|
});
|
|
144
124
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temba-flow-plumber.test.js","sourceRoot":"","sources":["../../test/temba-flow-plumber.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEtC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,OAAgB,CAAC;IACrB,IAAI,WAAgB,CAAC;IACrB,IAAI,SAAsB,CAAC;IAE3B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,wCAAwC;QACxC,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA;;;;;;;;KAQ7B,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,SAAS,CAAC,aAAa,CAAC,cAAc,CAAgB,CAAC;QAEtE,6BAA6B;QAC7B,WAAW,GAAG;YACZ,WAAW,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;YACtD,OAAO,EAAE,IAAI,EAAE;YACf,KAAK,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC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AY,EAAE,oBAAoB,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/C,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAChD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACjD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CACrC,UAAU,EACV,+BAA+B,CAChC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, fixture, expect } from '@open-wc/testing';\nimport { Plumber, SOURCE_DEFAULTS, TARGET_DEFAULTS } from '../src/flow/Plumber';\nimport { stub, restore } from 'sinon';\n\ndescribe('Plumber', () => {\n let plumber: Plumber;\n let mockJsPlumb: any;\n let container: HTMLElement;\n\n beforeEach(async () => {\n // Create a container with mock elements\n container = await fixture(html`\n <div>\n <div id=\"test-canvas\"></div>\n <div id=\"test-source\">Source Element</div>\n <div id=\"test-target\">Target Element</div>\n <div id=\"test-from\">From Element</div>\n <div id=\"test-to\">To Element</div>\n </div>\n `);\n\n const canvas = container.querySelector('#test-canvas') as HTMLElement;\n\n // Mock jsPlumb functionality\n mockJsPlumb = {\n addEndpoint: stub().returns({ uuid: 'mock-endpoint' }),\n connect: stub(),\n batch: stub().callsFake((fn: () => void) => fn())\n };\n\n // Create plumber instance and replace jsPlumb\n plumber = new Plumber(canvas);\n // Access private property for testing\n (plumber as any).jsPlumb = mockJsPlumb;\n });\n\n afterEach(() => {\n restore();\n });\n\n describe('constructor', () => {\n it('creates a new plumber instance', () => {\n expect(plumber).to.be.instanceOf(Plumber);\n });\n });\n\n describe('makeTarget', () => {\n it('creates a target endpoint for the specified element', () => {\n plumber.makeTarget('test-target');\n\n expect(mockJsPlumb.addEndpoint).to.have.been.calledWith(\n container.querySelector('#test-target'),\n TARGET_DEFAULTS\n );\n });\n\n it('handles non-existent elements gracefully', () => {\n plumber.makeTarget('non-existent');\n\n expect(mockJsPlumb.addEndpoint).to.have.been.calledWith(\n null,\n TARGET_DEFAULTS\n );\n });\n });\n\n describe('makeSource', () => {\n it('creates a source endpoint for the specified element', () => {\n plumber.makeSource('test-source');\n\n expect(mockJsPlumb.addEndpoint).to.have.been.calledWith(\n container.querySelector('#test-source'),\n SOURCE_DEFAULTS\n );\n });\n\n it('handles non-existent elements gracefully', () => {\n plumber.makeSource('non-existent');\n\n expect(mockJsPlumb.addEndpoint).to.have.been.calledWith(\n null,\n SOURCE_DEFAULTS\n );\n });\n });\n\n describe('connectIds', () => {\n it('adds connection to pending connections and processes them', () => {\n plumber.connectIds('test-from', 'test-to');\n\n // Verify that the method doesn't throw and plumber exists\n expect(plumber).to.exist;\n });\n });\n\n describe('processPendingConnections', () => {\n it('processes pending connections with timeout', (done) => {\n // Add a connection to pending connections\n plumber.connectIds('test-from', 'test-to');\n\n // Wait for the debounced timeout\n setTimeout(() => {\n expect(mockJsPlumb.batch).to.have.been.called;\n done();\n }, 60); // Wait longer than the 50ms timeout\n });\n\n it('creates endpoints and connections for pending connections', (done) => {\n plumber.connectIds('test-from', 'test-to');\n\n setTimeout(() => {\n expect(mockJsPlumb.addEndpoint).to.have.been.called;\n expect(mockJsPlumb.connect).to.have.been.called;\n done();\n }, 60);\n });\n\n it('clears existing timeout when called multiple times', () => {\n // Call processPendingConnections directly\n plumber.processPendingConnections();\n plumber.processPendingConnections();\n\n // This mainly tests that no errors are thrown\n expect(plumber).to.exist;\n });\n\n it('handles empty pending connections', (done) => {\n // Call without adding any connections\n plumber.processPendingConnections();\n\n setTimeout(() => {\n expect(mockJsPlumb.batch).to.have.been.called;\n done();\n }, 60);\n });\n });\n\n describe('constants', () => {\n it('exports SOURCE_DEFAULTS with correct structure', () => {\n expect(SOURCE_DEFAULTS).to.have.property('endpoint');\n expect(SOURCE_DEFAULTS.endpoint).to.have.property('type');\n expect(SOURCE_DEFAULTS.endpoint).to.have.property('options');\n expect(SOURCE_DEFAULTS).to.have.property('anchors');\n expect(SOURCE_DEFAULTS).to.have.property('maxConnections', 1);\n expect(SOURCE_DEFAULTS).to.have.property('isSource', true);\n expect(SOURCE_DEFAULTS).to.have.property('dragAllowedWhenFull', false);\n expect(SOURCE_DEFAULTS).to.have.property('deleteEndpointsOnEmpty', true);\n });\n\n it('exports TARGET_DEFAULTS with correct structure', () => {\n expect(TARGET_DEFAULTS).to.have.property('endpoint');\n expect(TARGET_DEFAULTS.endpoint).to.have.property('type');\n expect(TARGET_DEFAULTS.endpoint).to.have.property('options');\n expect(TARGET_DEFAULTS).to.have.property('anchor');\n expect(TARGET_DEFAULTS).to.have.property('isTarget', true);\n expect(TARGET_DEFAULTS).to.have.property('dragAllowedWhenFull', false);\n expect(TARGET_DEFAULTS).to.have.property('deleteEndpointsOnEmpty', true);\n });\n\n it('has correct SOURCE_DEFAULTS endpoint options', () => {\n const options = SOURCE_DEFAULTS.endpoint.options;\n expect(options).to.have.property('radius', 6);\n expect(options).to.have.property('cssClass', 'plumb-source');\n expect(options).to.have.property('hoverClass', 'plumb-source-hover');\n expect(options).to.have.property('connectedClass', 'plumb-connected');\n });\n\n it('has correct TARGET_DEFAULTS endpoint options', () => {\n const options = TARGET_DEFAULTS.endpoint.options;\n expect(options).to.have.property('width', 23);\n expect(options).to.have.property('height', 23);\n expect(options).to.have.property('cssClass', 'plumb-target');\n expect(options).to.have.property('hoverClass', 'plumb-target-hover');\n });\n\n it('has correct TARGET_DEFAULTS anchor options', () => {\n const anchor = TARGET_DEFAULTS.anchor;\n expect(anchor).to.have.property('type', 'Continuous');\n expect(anchor.options).to.have.property('faces');\n expect(anchor.options.faces).to.include('top');\n expect(anchor.options.faces).to.include('left');\n expect(anchor.options.faces).to.include('right');\n expect(anchor.options).to.have.property(\n 'cssClass',\n 'continuos plumb-target-anchor'\n );\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"temba-flow-plumber.test.js","sourceRoot":"","sources":["../../test/temba-flow-plumber.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,IAAI,EAAE,aAAa,EAAmB,MAAM,OAAO,CAAC;AAE7D,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,IAAI,OAAgB,CAAC;IACrB,IAAI,WAAgB,CAAC;IACrB,IAAI,UAAuB,CAAC;IAC5B,IAAI,KAAsB,CAAC;IAE3B,UAAU,CAAC,GAAG,EAAE;QACd,wCAAwC;QACxC,KAAK,GAAG,aAAa,EAAE,CAAC;QAExB,mEAAmE;QACnE,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAEtD,gCAAgC;QAChC,OAAO,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;QAElC,mDA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FAULTS, TARGET_DEFAULTS } from '../src/flow/Plumber';\nimport { stub, useFakeTimers, SinonFakeTimers } from 'sinon';\n\ndescribe('Plumber', () => {\n let plumber: Plumber;\n let mockJsPlumb: any;\n let mockCanvas: HTMLElement;\n let clock: SinonFakeTimers;\n\n beforeEach(() => {\n // Use fake timers to control setTimeout\n clock = useFakeTimers();\n\n // Create mock canvas and make getElementById return a mock element\n mockCanvas = document.createElement('div');\n const mockElement = document.createElement('div');\n stub(document, 'getElementById').returns(mockElement);\n\n // Create a new plumber instance\n plumber = new Plumber(mockCanvas);\n\n // Replace the internal jsPlumb instance with mocks\n mockJsPlumb = {\n getConnections: stub().returns([]),\n addClass: stub(),\n removeClass: stub(),\n batch: stub().callsFake((fn) => fn()),\n addEndpoint: stub().returns({}),\n connect: stub(),\n selectEndpoints: stub().returns({\n deleteAll: stub()\n }),\n deleteConnection: stub(),\n removeAllEndpoints: stub(),\n repaintEverything: stub(),\n revalidate: stub(),\n bind: stub()\n };\n\n (plumber as any).jsPlumb = mockJsPlumb;\n // Reset the connectionWait to avoid timing issues\n (plumber as any).connectionWait = null;\n });\n\n afterEach(() => {\n // Restore the original document.getElementById\n (document.getElementById as any).restore?.();\n clock.restore();\n });\n\n describe('constructor', () => {\n it('creates a new plumber instance', () => {\n expect(plumber).to.be.instanceOf(Plumber);\n });\n });\n\n describe('makeTarget', () => {\n it('creates a target endpoint for the specified element', () => {\n plumber.makeTarget('test-target');\n expect(mockJsPlumb.addEndpoint).to.have.been.called;\n });\n });\n\n describe('makeSource', () => {\n it('creates a source endpoint for the specified element', () => {\n plumber.makeSource('test-source');\n expect(mockJsPlumb.addEndpoint).to.have.been.called;\n });\n });\n\n describe('connectIds', () => {\n it('adds connection to pending connections and processes them', () => {\n plumber.connectIds('test-node', 'test-from', 'test-to');\n\n // Verify pendingConnections has the new connection\n expect((plumber as any).pendingConnections.length).to.equal(1);\n\n // Advance timer to trigger the timeout\n clock.tick(51); // Just past the 50ms timeout\n\n // Now the batch should have been called\n expect(mockJsPlumb.batch).to.have.been.called;\n });\n });\n\n describe('processPendingConnections', () => {\n it('processes pending connections with timeout', () => {\n // Add a connection to pending connections\n plumber.connectIds('test-node', 'test-from', 'test-to');\n\n // Fast-forward clock past the timeout\n clock.tick(51); // Just past the 50ms timeout\n\n expect(mockJsPlumb.batch).to.have.been.called;\n });\n\n it('creates endpoints and connections for pending connections', () => {\n plumber.connectIds('test-node', 'test-from', 'test-to');\n\n // Fast-forward clock past the timeout\n clock.tick(51); // Just past the 50ms timeout\n\n expect(mockJsPlumb.addEndpoint).to.have.been.called;\n expect(mockJsPlumb.connect).to.have.been.called;\n });\n\n it('clears existing timeout when called multiple times', () => {\n // Set up spies for window.setTimeout and window.clearTimeout\n const clearTimeoutSpy = stub(window, 'clearTimeout');\n const setTimeoutSpy = stub(window, 'setTimeout').returns(123 as any);\n\n // Call twice\n plumber.processPendingConnections();\n plumber.processPendingConnections();\n\n // Should have called clearTimeout once and setTimeout twice\n expect(clearTimeoutSpy).to.have.been.calledOnce;\n expect(setTimeoutSpy).to.have.been.calledTwice;\n\n // Clean up\n clearTimeoutSpy.restore();\n setTimeoutSpy.restore();\n });\n\n it('handles empty pending connections', () => {\n // Call without adding any connections\n plumber.processPendingConnections();\n\n // Fast-forward clock past the timeout\n clock.tick(51); // Just past the 50ms timeout\n\n expect(mockJsPlumb.batch).to.have.been.called;\n });\n });\n\n describe('constants', () => {\n it('has correct properties in SOURCE_DEFAULTS', () => {\n expect(SOURCE_DEFAULTS).to.have.property('endpoint');\n expect(SOURCE_DEFAULTS).to.have.property('anchors');\n expect(SOURCE_DEFAULTS).to.have.property('maxConnections');\n expect(SOURCE_DEFAULTS).to.have.property('source');\n });\n\n it('has correct properties in TARGET_DEFAULTS', () => {\n expect(TARGET_DEFAULTS).to.have.property('endpoint');\n expect(TARGET_DEFAULTS).to.have.property('anchor');\n expect(TARGET_DEFAULTS).to.have.property('maxConnections');\n expect(TARGET_DEFAULTS).to.have.property('target');\n });\n });\n});\n"]}
|