@nyaruka/temba-components 0.122.0 → 0.124.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.
Files changed (262) hide show
  1. package/.github/copilot-instructions.md +181 -0
  2. package/.github/workflows/build.yml +3 -3
  3. package/.github/workflows/cla.yml +6 -6
  4. package/.github/workflows/copilot-setup-steps.yml +86 -0
  5. package/CHANGELOG.md +44 -0
  6. package/demo/drag-drop-demo.html +141 -0
  7. package/demo/index.html +57 -0
  8. package/demo/test-drag-drop.html +94 -0
  9. package/dist/locales/es.js +1 -0
  10. package/dist/locales/es.js.map +1 -1
  11. package/dist/locales/fr.js +1 -0
  12. package/dist/locales/fr.js.map +1 -1
  13. package/dist/locales/pt.js +1 -0
  14. package/dist/locales/pt.js.map +1 -1
  15. package/dist/temba-components.js +366 -247
  16. package/dist/temba-components.js.map +1 -1
  17. package/out-tsc/src/chart/TembaChart.js +81 -14
  18. package/out-tsc/src/chart/TembaChart.js.map +1 -1
  19. package/out-tsc/src/fields/FieldManager.js +27 -34
  20. package/out-tsc/src/fields/FieldManager.js.map +1 -1
  21. package/out-tsc/src/list/RunList.js +13 -8
  22. package/out-tsc/src/list/RunList.js.map +1 -1
  23. package/out-tsc/src/list/SortableList.js +257 -60
  24. package/out-tsc/src/list/SortableList.js.map +1 -1
  25. package/out-tsc/src/locales/es.js +1 -0
  26. package/out-tsc/src/locales/es.js.map +1 -1
  27. package/out-tsc/src/locales/fr.js +1 -0
  28. package/out-tsc/src/locales/fr.js.map +1 -1
  29. package/out-tsc/src/locales/pt.js +1 -0
  30. package/out-tsc/src/locales/pt.js.map +1 -1
  31. package/out-tsc/src/omnibox/Omnibox.js +1 -1
  32. package/out-tsc/src/omnibox/Omnibox.js.map +1 -1
  33. package/out-tsc/src/options/Options.js +36 -13
  34. package/out-tsc/src/options/Options.js.map +1 -1
  35. package/out-tsc/src/select/Select.js +226 -43
  36. package/out-tsc/src/select/Select.js.map +1 -1
  37. package/out-tsc/src/store/AppState.js +3 -3
  38. package/out-tsc/src/store/AppState.js.map +1 -1
  39. package/out-tsc/src/utils/index.js +6 -1
  40. package/out-tsc/src/utils/index.js.map +1 -1
  41. package/out-tsc/src/vectoricon/VectorIcon.js +2 -1
  42. package/out-tsc/src/vectoricon/VectorIcon.js.map +1 -1
  43. package/out-tsc/src/webchat/WebChat.js +5 -2
  44. package/out-tsc/src/webchat/WebChat.js.map +1 -1
  45. package/out-tsc/temba-modules.js +0 -2
  46. package/out-tsc/temba-modules.js.map +1 -1
  47. package/out-tsc/test/temba-appstate-language.test.js +176 -0
  48. package/out-tsc/test/temba-appstate-language.test.js.map +1 -0
  49. package/out-tsc/test/temba-chart.test.js +125 -0
  50. package/out-tsc/test/temba-chart.test.js.map +1 -1
  51. package/out-tsc/test/temba-dropdown.test.js +317 -0
  52. package/out-tsc/test/temba-dropdown.test.js.map +1 -0
  53. package/out-tsc/test/temba-flow-editor-node.test.js +273 -0
  54. package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -0
  55. package/out-tsc/test/temba-flow-editor.test.js +244 -0
  56. package/out-tsc/test/temba-flow-editor.test.js.map +1 -0
  57. package/out-tsc/test/temba-flow-plumber.test.js +145 -0
  58. package/out-tsc/test/temba-flow-plumber.test.js.map +1 -0
  59. package/out-tsc/test/temba-flow-render.test.js +171 -0
  60. package/out-tsc/test/temba-flow-render.test.js.map +1 -0
  61. package/out-tsc/test/temba-omnibox.test.js +2 -3
  62. package/out-tsc/test/temba-omnibox.test.js.map +1 -1
  63. package/out-tsc/test/temba-run-list.test.js +588 -0
  64. package/out-tsc/test/temba-run-list.test.js.map +1 -0
  65. package/out-tsc/test/temba-select.test.js +149 -52
  66. package/out-tsc/test/temba-select.test.js.map +1 -1
  67. package/out-tsc/test/temba-sortable-list.test.js +91 -15
  68. package/out-tsc/test/temba-sortable-list.test.js.map +1 -1
  69. package/out-tsc/test/temba-toast.test.js +299 -0
  70. package/out-tsc/test/temba-toast.test.js.map +1 -0
  71. package/out-tsc/test/temba-utils-index.test.js +1178 -0
  72. package/out-tsc/test/temba-utils-index.test.js.map +1 -0
  73. package/out-tsc/test/temba-webchat-lightbox-fix.test.js +42 -0
  74. package/out-tsc/test/temba-webchat-lightbox-fix.test.js.map +1 -0
  75. package/out-tsc/test/temba-webchat.test.js +816 -0
  76. package/out-tsc/test/temba-webchat.test.js.map +1 -0
  77. package/out-tsc/test/utils.test.js +33 -1
  78. package/out-tsc/test/utils.test.js.map +1 -1
  79. package/package.json +6 -8
  80. package/screenshots/truth/alert/error.png +0 -0
  81. package/screenshots/truth/alert/info.png +0 -0
  82. package/screenshots/truth/alert/warning.png +0 -0
  83. package/screenshots/truth/checkbox/checkbox-label-background-hover.png +0 -0
  84. package/screenshots/truth/checkbox/checked.png +0 -0
  85. package/screenshots/truth/checkbox/default.png +0 -0
  86. package/screenshots/truth/colorpicker/default.png +0 -0
  87. package/screenshots/truth/colorpicker/focused.png +0 -0
  88. package/screenshots/truth/colorpicker/initialized.png +0 -0
  89. package/screenshots/truth/colorpicker/selected.png +0 -0
  90. package/screenshots/truth/compose/attachments-tab.png +0 -0
  91. package/screenshots/truth/compose/attachments-with-files-focused.png +0 -0
  92. package/screenshots/truth/compose/attachments-with-files.png +0 -0
  93. package/screenshots/truth/compose/intial-text.png +0 -0
  94. package/screenshots/truth/compose/no-counter.png +0 -0
  95. package/screenshots/truth/compose/wraps-text-and-spaces.png +0 -0
  96. package/screenshots/truth/compose/wraps-text-and-url.png +0 -0
  97. package/screenshots/truth/compose/wraps-text-no-spaces.png +0 -0
  98. package/screenshots/truth/contacts/badges.png +0 -0
  99. package/screenshots/truth/contacts/chat-failure.png +0 -0
  100. package/screenshots/truth/contacts/chat-for-active-contact.png +0 -0
  101. package/screenshots/truth/contacts/chat-for-archived-contact.png +0 -0
  102. package/screenshots/truth/contacts/chat-for-blocked-contact.png +0 -0
  103. package/screenshots/truth/contacts/chat-for-stopped-contact.png +0 -0
  104. package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
  105. package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
  106. package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
  107. package/screenshots/truth/content-menu/button-no-items.png +0 -0
  108. package/screenshots/truth/content-menu/items-and-buttons.png +0 -0
  109. package/screenshots/truth/counter/summary.png +0 -0
  110. package/screenshots/truth/counter/text.png +0 -0
  111. package/screenshots/truth/counter/unicode-variables.png +0 -0
  112. package/screenshots/truth/counter/unicode.png +0 -0
  113. package/screenshots/truth/counter/variable.png +0 -0
  114. package/screenshots/truth/date/date-inline.png +0 -0
  115. package/screenshots/truth/date/date.png +0 -0
  116. package/screenshots/truth/date/datetime.png +0 -0
  117. package/screenshots/truth/date/duration.png +0 -0
  118. package/screenshots/truth/date/timedate.png +0 -0
  119. package/screenshots/truth/datepicker/date-truncated-time.png +0 -0
  120. package/screenshots/truth/datepicker/date.png +0 -0
  121. package/screenshots/truth/datepicker/initial-timezone.png +0 -0
  122. package/screenshots/truth/datepicker/updated-keyboard-date.png +0 -0
  123. package/screenshots/truth/dialog/focused.png +0 -0
  124. package/screenshots/truth/dropdown/after-blur.png +0 -0
  125. package/screenshots/truth/dropdown/bottom-edge-collision.png +0 -0
  126. package/screenshots/truth/dropdown/custom-arrow-size.png +0 -0
  127. package/screenshots/truth/dropdown/default.png +0 -0
  128. package/screenshots/truth/dropdown/narrow-toggle.png +0 -0
  129. package/screenshots/truth/dropdown/no-mask.png +0 -0
  130. package/screenshots/truth/dropdown/opened.png +0 -0
  131. package/screenshots/truth/dropdown/positioned.png +0 -0
  132. package/screenshots/truth/dropdown/right-edge-collision.png +0 -0
  133. package/screenshots/truth/dropdown/with-mask.png +0 -0
  134. package/screenshots/truth/flow/editor-basic.png +0 -0
  135. package/screenshots/truth/label/custom.png +0 -0
  136. package/screenshots/truth/label/danger.png +0 -0
  137. package/screenshots/truth/label/dark.png +0 -0
  138. package/screenshots/truth/label/default-icon.png +0 -0
  139. package/screenshots/truth/label/no-icon.png +0 -0
  140. package/screenshots/truth/label/primary.png +0 -0
  141. package/screenshots/truth/label/secondary.png +0 -0
  142. package/screenshots/truth/label/shadow.png +0 -0
  143. package/screenshots/truth/label/tertiary.png +0 -0
  144. package/screenshots/truth/lightbox/img-zoomed.png +0 -0
  145. package/screenshots/truth/list/fields-dragging.png +0 -0
  146. package/screenshots/truth/list/fields-filtered.png +0 -0
  147. package/screenshots/truth/list/fields-hovered.png +0 -0
  148. package/screenshots/truth/list/fields.png +0 -0
  149. package/screenshots/truth/list/items-selected.png +0 -0
  150. package/screenshots/truth/list/items-updated.png +0 -0
  151. package/screenshots/truth/list/items.png +0 -0
  152. package/screenshots/truth/list/sortable-dragging.png +0 -0
  153. package/screenshots/truth/list/sortable-dropped.png +0 -0
  154. package/screenshots/truth/list/sortable.png +0 -0
  155. package/screenshots/truth/menu/menu-focused-with items.png +0 -0
  156. package/screenshots/truth/menu/menu-refresh-1.png +0 -0
  157. package/screenshots/truth/menu/menu-refresh-2.png +0 -0
  158. package/screenshots/truth/menu/menu-root.png +0 -0
  159. package/screenshots/truth/menu/menu-submenu.png +0 -0
  160. package/screenshots/truth/menu/menu-tasks-nextup.png +0 -0
  161. package/screenshots/truth/menu/menu-tasks.png +0 -0
  162. package/screenshots/truth/modax/form.png +0 -0
  163. package/screenshots/truth/modax/simple.png +0 -0
  164. package/screenshots/truth/omnibox/selected.png +0 -0
  165. package/screenshots/truth/options/block.png +0 -0
  166. package/screenshots/truth/run-list/basic.png +0 -0
  167. package/screenshots/truth/select/disabled-multi-selection.png +0 -0
  168. package/screenshots/truth/select/disabled-selection.png +0 -0
  169. package/screenshots/truth/select/disabled.png +0 -0
  170. package/screenshots/truth/select/embedded.png +0 -0
  171. package/screenshots/truth/select/empty-options.png +0 -0
  172. package/screenshots/truth/select/expression-selected.png +0 -0
  173. package/screenshots/truth/select/expressions.png +0 -0
  174. package/screenshots/truth/select/functions.png +0 -0
  175. package/screenshots/truth/select/local-options.png +0 -0
  176. package/screenshots/truth/select/multi-reorder-final.png +0 -0
  177. package/screenshots/truth/select/multi-reorder-initial.png +0 -0
  178. package/screenshots/truth/select/multi-with-endpoint.png +0 -0
  179. package/screenshots/truth/select/multiple-initial-values.png +0 -0
  180. package/screenshots/truth/select/remote-options.png +0 -0
  181. package/screenshots/truth/select/search-enabled.png +0 -0
  182. package/screenshots/truth/select/search-multi-no-matches.png +0 -0
  183. package/screenshots/truth/select/search-selected-focus.png +0 -0
  184. package/screenshots/truth/select/search-selected.png +0 -0
  185. package/screenshots/truth/select/search-with-selected.png +0 -0
  186. package/screenshots/truth/select/searching.png +0 -0
  187. package/screenshots/truth/select/selected-multi-maxitems-reached.png +0 -0
  188. package/screenshots/truth/select/selected-multi.png +0 -0
  189. package/screenshots/truth/select/selected-single.png +0 -0
  190. package/screenshots/truth/select/selection-clearable.png +0 -0
  191. package/screenshots/truth/select/static-initial-value.png +0 -0
  192. package/screenshots/truth/select/static-initial-via-selected.png +0 -0
  193. package/screenshots/truth/select/truncated-selection.png +0 -0
  194. package/screenshots/truth/select/with-placeholder.png +0 -0
  195. package/screenshots/truth/select/without-placeholder.png +0 -0
  196. package/screenshots/truth/slider/custom-min-custom-max-valid-value.png +0 -0
  197. package/screenshots/truth/slider/custom-min-default-max-no-value.png +0 -0
  198. package/screenshots/truth/slider/default-min-custom-max-no-value.png +0 -0
  199. package/screenshots/truth/slider/default-min-default-max-invalid-value.png +0 -0
  200. package/screenshots/truth/slider/default-min-default-max-valid-value.png +0 -0
  201. package/screenshots/truth/slider/update-slider-on-value-change.png +0 -0
  202. package/screenshots/truth/templates/default.png +0 -0
  203. package/screenshots/truth/templates/unapproved.png +0 -0
  204. package/screenshots/truth/textinput/input-disabled.png +0 -0
  205. package/screenshots/truth/textinput/input-focused.png +0 -0
  206. package/screenshots/truth/textinput/input-form.png +0 -0
  207. package/screenshots/truth/textinput/input-inserted.png +0 -0
  208. package/screenshots/truth/textinput/input-placeholder.png +0 -0
  209. package/screenshots/truth/textinput/input-updated.png +0 -0
  210. package/screenshots/truth/textinput/input.png +0 -0
  211. package/screenshots/truth/textinput/textarea-focused.png +0 -0
  212. package/screenshots/truth/textinput/textarea.png +0 -0
  213. package/screenshots/truth/tip/bottom.png +0 -0
  214. package/screenshots/truth/tip/left.png +0 -0
  215. package/screenshots/truth/tip/right.png +0 -0
  216. package/screenshots/truth/tip/top.png +0 -0
  217. package/screenshots/truth/webchat/closed-widget.png +0 -0
  218. package/screenshots/truth/webchat/connected-state.png +0 -0
  219. package/screenshots/truth/webchat/connecting-state.png +0 -0
  220. package/screenshots/truth/webchat/disconnected-state.png +0 -0
  221. package/screenshots/truth/webchat/opened-widget.png +0 -0
  222. package/src/chart/TembaChart.ts +86 -15
  223. package/src/fields/FieldManager.ts +30 -38
  224. package/src/list/RunList.ts +11 -8
  225. package/src/list/SortableList.ts +291 -67
  226. package/src/locales/es.ts +1 -0
  227. package/src/locales/fr.ts +1 -0
  228. package/src/locales/pt.ts +1 -0
  229. package/src/omnibox/Omnibox.ts +1 -1
  230. package/src/options/Options.ts +38 -13
  231. package/src/select/Select.ts +245 -47
  232. package/src/store/AppState.ts +3 -3
  233. package/src/utils/index.ts +17 -5
  234. package/src/vectoricon/VectorIcon.ts +2 -1
  235. package/src/webchat/WebChat.ts +5 -2
  236. package/temba-modules.ts +0 -2
  237. package/test/temba-appstate-language.test.ts +218 -0
  238. package/test/temba-chart.test.ts +161 -1
  239. package/test/temba-dropdown.test.ts +444 -0
  240. package/test/temba-flow-editor-node.test.ts +344 -0
  241. package/test/temba-flow-editor.test.ts +301 -0
  242. package/test/temba-flow-plumber.test.ts +189 -0
  243. package/test/temba-flow-render.test.ts +220 -0
  244. package/test/temba-omnibox.test.ts +2 -3
  245. package/test/temba-run-list.test.ts +774 -0
  246. package/test/temba-select.test.ts +206 -78
  247. package/test/temba-sortable-list.test.ts +108 -15
  248. package/test/temba-toast.test.ts +386 -0
  249. package/test/temba-utils-index.test.ts +1547 -0
  250. package/test/temba-webchat-lightbox-fix.test.ts +57 -0
  251. package/test/temba-webchat.test.ts +1095 -0
  252. package/test/utils.test.ts +56 -2
  253. package/test-assets/list/flow-results.json +17 -0
  254. package/test-assets/list/runs.json +126 -0
  255. package/test-assets/style.css +23 -0
  256. package/web-test-runner.config.mjs +33 -7
  257. package/xliff/es.xlf +3 -0
  258. package/xliff/fr.xlf +3 -0
  259. package/xliff/pt.xlf +3 -0
  260. package/out-tsc/src/outboxmonitor/OutboxMonitor.js +0 -136
  261. package/out-tsc/src/outboxmonitor/OutboxMonitor.js.map +0 -1
  262. package/src/outboxmonitor/OutboxMonitor.ts +0 -148
@@ -0,0 +1,171 @@
1
+ import { html, fixture, expect } from '@open-wc/testing';
2
+ import { renderSendMsg, renderSetContactName, renderSetRunResult, renderCallWebhook, renderAddToGroups } from '../src/flow/render';
3
+ describe('Flow Render Functions', () => {
4
+ const mockNode = {
5
+ uuid: 'test-node-uuid',
6
+ actions: [],
7
+ exits: []
8
+ };
9
+ describe('renderSendMsg', () => {
10
+ it('renders message text with line breaks', async () => {
11
+ const action = {
12
+ type: 'send_msg',
13
+ uuid: 'action-uuid-1',
14
+ text: 'Hello world\nThis is a new line',
15
+ quick_replies: []
16
+ };
17
+ const result = renderSendMsg(mockNode, action);
18
+ const container = await fixture(html `<div>${result}</div>`);
19
+ expect(container.innerHTML).to.contain('Hello world<br>This is a new line');
20
+ });
21
+ it('renders quick replies when present', async () => {
22
+ const action = {
23
+ type: 'send_msg',
24
+ uuid: 'action-uuid-2',
25
+ text: 'Choose an option:',
26
+ quick_replies: ['Yes', 'No', 'Maybe']
27
+ };
28
+ const result = renderSendMsg(mockNode, action);
29
+ const container = await fixture(html `<div>${result}</div>`);
30
+ expect(container.innerHTML).to.contain('Choose an option:');
31
+ expect(container.innerHTML).to.contain('quick-replies');
32
+ expect(container.innerHTML).to.contain('Yes');
33
+ expect(container.innerHTML).to.contain('No');
34
+ expect(container.innerHTML).to.contain('Maybe');
35
+ });
36
+ it('renders without quick replies when none provided', async () => {
37
+ const action = {
38
+ type: 'send_msg',
39
+ uuid: 'action-uuid-3',
40
+ text: 'Simple message',
41
+ quick_replies: []
42
+ };
43
+ const result = renderSendMsg(mockNode, action);
44
+ const container = await fixture(html `<div>${result}</div>`);
45
+ expect(container.innerHTML).to.contain('Simple message');
46
+ expect(container.innerHTML).to.not.contain('quick-replies');
47
+ });
48
+ });
49
+ describe('renderSetContactName', () => {
50
+ it('renders contact name setting', async () => {
51
+ const action = {
52
+ type: 'set_contact_name',
53
+ uuid: 'action-uuid-4',
54
+ name: 'John Doe'
55
+ };
56
+ const result = renderSetContactName(mockNode, action);
57
+ const container = await fixture(html `<div>${result}</div>`);
58
+ expect(container.textContent).to.contain('Set contact name to');
59
+ expect(container.textContent).to.contain('John Doe');
60
+ expect(container.querySelector('b')).to.exist;
61
+ });
62
+ });
63
+ describe('renderSetRunResult', () => {
64
+ it('renders run result setting', async () => {
65
+ const action = {
66
+ type: 'set_run_result',
67
+ uuid: 'action-uuid-5',
68
+ category: 'success',
69
+ name: 'favorite_color',
70
+ value: 'blue'
71
+ };
72
+ const result = renderSetRunResult(mockNode, action);
73
+ const container = await fixture(html `<div>${result}</div>`);
74
+ expect(container.textContent).to.contain('Save blue as');
75
+ expect(container.textContent).to.contain('favorite_color');
76
+ expect(container.querySelector('b')).to.exist;
77
+ });
78
+ });
79
+ describe('renderCallWebhook', () => {
80
+ it('renders webhook URL', async () => {
81
+ const action = {
82
+ type: 'call_webhook',
83
+ uuid: 'action-uuid-6',
84
+ url: 'https://example.com/webhook'
85
+ };
86
+ const result = renderCallWebhook(mockNode, action);
87
+ const container = await fixture(html `<div>${result}</div>`);
88
+ expect(container.innerHTML).to.contain('https://example.com/webhook');
89
+ expect(container.querySelector('div')).to.have.style('word-break', 'break-all');
90
+ });
91
+ });
92
+ describe('renderAddToGroups', () => {
93
+ it('renders groups with icons', async () => {
94
+ const action = {
95
+ type: 'add_contact_groups',
96
+ uuid: 'action-uuid-7',
97
+ groups: [
98
+ {
99
+ uuid: 'group1',
100
+ name: 'VIP Customers',
101
+ status: 'active',
102
+ system: false,
103
+ query: '',
104
+ count: 10
105
+ },
106
+ {
107
+ uuid: 'group2',
108
+ name: 'Newsletter Subscribers',
109
+ status: 'active',
110
+ system: false,
111
+ query: '',
112
+ count: 25
113
+ }
114
+ ]
115
+ };
116
+ const result = renderAddToGroups(mockNode, action);
117
+ const container = await fixture(html `<div>${result}</div>`);
118
+ expect(container.innerHTML).to.contain('VIP Customers');
119
+ expect(container.innerHTML).to.contain('Newsletter Subscribers');
120
+ expect(container.querySelectorAll('temba-icon')).to.have.length(2);
121
+ const icons = container.querySelectorAll('temba-icon');
122
+ icons.forEach((icon) => {
123
+ expect(icon.getAttribute('name')).to.equal('group');
124
+ });
125
+ });
126
+ it('renders empty groups array', async () => {
127
+ const action = {
128
+ type: 'add_contact_groups',
129
+ uuid: 'action-uuid-8',
130
+ groups: []
131
+ };
132
+ const result = renderAddToGroups(mockNode, action);
133
+ const container = await fixture(html `<div>${result}</div>`);
134
+ expect(container.querySelectorAll('temba-icon')).to.have.length(0);
135
+ });
136
+ it('renders groups without icons when undefined', async () => {
137
+ // Test the renderNamedObjects function without an icon parameter
138
+ const action = {
139
+ type: 'add_contact_groups',
140
+ uuid: 'action-uuid-9',
141
+ groups: [
142
+ {
143
+ uuid: 'group1',
144
+ name: 'Test Group',
145
+ status: 'active',
146
+ system: false,
147
+ query: '',
148
+ count: 5
149
+ }
150
+ ]
151
+ };
152
+ // Create a test version that calls renderNamedObjects without icon
153
+ // to cover the null case in the render.ts file
154
+ const namedObjects = action.groups;
155
+ // Create a test version that calls renderNamedObjects without icon
156
+ const testRender = (assets) => {
157
+ return assets.map((asset) => {
158
+ return html `<div style="display:flex;items-align:center">
159
+ ${null /* This should trigger the null branch */}
160
+ <div>${asset.name}</div>
161
+ </div>`;
162
+ });
163
+ };
164
+ const result = testRender(namedObjects);
165
+ const container = await fixture(html `<div>${result}</div>`);
166
+ expect(container.innerHTML).to.contain('Test Group');
167
+ expect(container.querySelectorAll('temba-icon')).to.have.length(0);
168
+ });
169
+ });
170
+ });
171
+ //# sourceMappingURL=temba-flow-render.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temba-flow-render.test.js","sourceRoot":"","sources":["../../test/temba-flow-render.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAU5B,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,MAAM,QAAQ,GAAS;QACrB,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;KACV,CAAC;IAEF,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;YACrD,MAAM,MAAM,GAAY;gBACtB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,iCAAiC;gBACvC,aAAa,EAAE,EAAE;aAClB,CAAC;YAEF,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC/C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,QAAQ,MAAM,QAAQ,CAAC,CAAC;YAE5D,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,OAAO,CACpC,mCAAmC,CACpC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;YAClD,MAAM,MAAM,GAAY;gBACtB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,mBAAmB;gBACzB,aAAa,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,OA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L,CAAC,CAAC,CAAC","sourcesContent":["import { html, fixture, expect } from '@open-wc/testing';\nimport {\n renderSendMsg,\n renderSetContactName,\n renderSetRunResult,\n renderCallWebhook,\n renderAddToGroups\n} from '../src/flow/render';\nimport {\n Node,\n SendMsg,\n SetContactName,\n SetRunResult,\n CallWebhook,\n AddToGroup\n} from '../src/store/flow-definition.d';\n\ndescribe('Flow Render Functions', () => {\n const mockNode: Node = {\n uuid: 'test-node-uuid',\n actions: [],\n exits: []\n };\n\n describe('renderSendMsg', () => {\n it('renders message text with line breaks', async () => {\n const action: SendMsg = {\n type: 'send_msg',\n uuid: 'action-uuid-1',\n text: 'Hello world\\nThis is a new line',\n quick_replies: []\n };\n\n const result = renderSendMsg(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.innerHTML).to.contain(\n 'Hello world<br>This is a new line'\n );\n });\n\n it('renders quick replies when present', async () => {\n const action: SendMsg = {\n type: 'send_msg',\n uuid: 'action-uuid-2',\n text: 'Choose an option:',\n quick_replies: ['Yes', 'No', 'Maybe']\n };\n\n const result = renderSendMsg(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.innerHTML).to.contain('Choose an option:');\n expect(container.innerHTML).to.contain('quick-replies');\n expect(container.innerHTML).to.contain('Yes');\n expect(container.innerHTML).to.contain('No');\n expect(container.innerHTML).to.contain('Maybe');\n });\n\n it('renders without quick replies when none provided', async () => {\n const action: SendMsg = {\n type: 'send_msg',\n uuid: 'action-uuid-3',\n text: 'Simple message',\n quick_replies: []\n };\n\n const result = renderSendMsg(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.innerHTML).to.contain('Simple message');\n expect(container.innerHTML).to.not.contain('quick-replies');\n });\n });\n\n describe('renderSetContactName', () => {\n it('renders contact name setting', async () => {\n const action: SetContactName = {\n type: 'set_contact_name',\n uuid: 'action-uuid-4',\n name: 'John Doe'\n };\n\n const result = renderSetContactName(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.textContent).to.contain('Set contact name to');\n expect(container.textContent).to.contain('John Doe');\n expect(container.querySelector('b')).to.exist;\n });\n });\n\n describe('renderSetRunResult', () => {\n it('renders run result setting', async () => {\n const action: SetRunResult = {\n type: 'set_run_result',\n uuid: 'action-uuid-5',\n category: 'success',\n name: 'favorite_color',\n value: 'blue'\n };\n\n const result = renderSetRunResult(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.textContent).to.contain('Save blue as');\n expect(container.textContent).to.contain('favorite_color');\n expect(container.querySelector('b')).to.exist;\n });\n });\n\n describe('renderCallWebhook', () => {\n it('renders webhook URL', async () => {\n const action: CallWebhook = {\n type: 'call_webhook',\n uuid: 'action-uuid-6',\n url: 'https://example.com/webhook'\n };\n\n const result = renderCallWebhook(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.innerHTML).to.contain('https://example.com/webhook');\n expect(container.querySelector('div')).to.have.style(\n 'word-break',\n 'break-all'\n );\n });\n });\n\n describe('renderAddToGroups', () => {\n it('renders groups with icons', async () => {\n const action: AddToGroup = {\n type: 'add_contact_groups',\n uuid: 'action-uuid-7',\n groups: [\n {\n uuid: 'group1',\n name: 'VIP Customers',\n status: 'active',\n system: false,\n query: '',\n count: 10\n },\n {\n uuid: 'group2',\n name: 'Newsletter Subscribers',\n status: 'active',\n system: false,\n query: '',\n count: 25\n }\n ]\n };\n\n const result = renderAddToGroups(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.innerHTML).to.contain('VIP Customers');\n expect(container.innerHTML).to.contain('Newsletter Subscribers');\n expect(container.querySelectorAll('temba-icon')).to.have.length(2);\n\n const icons = container.querySelectorAll('temba-icon');\n icons.forEach((icon) => {\n expect(icon.getAttribute('name')).to.equal('group');\n });\n });\n\n it('renders empty groups array', async () => {\n const action: AddToGroup = {\n type: 'add_contact_groups',\n uuid: 'action-uuid-8',\n groups: []\n };\n\n const result = renderAddToGroups(mockNode, action);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.querySelectorAll('temba-icon')).to.have.length(0);\n });\n\n it('renders groups without icons when undefined', async () => {\n // Test the renderNamedObjects function without an icon parameter\n const action: AddToGroup = {\n type: 'add_contact_groups',\n uuid: 'action-uuid-9',\n groups: [\n {\n uuid: 'group1',\n name: 'Test Group',\n status: 'active',\n system: false,\n query: '',\n count: 5\n }\n ]\n };\n\n // Create a test version that calls renderNamedObjects without icon\n // to cover the null case in the render.ts file\n const namedObjects = action.groups;\n\n // Create a test version that calls renderNamedObjects without icon\n const testRender = (assets: any[]) => {\n return assets.map((asset) => {\n return html`<div style=\"display:flex;items-align:center\">\n ${null /* This should trigger the null branch */}\n <div>${asset.name}</div>\n </div>`;\n });\n };\n\n const result = testRender(namedObjects);\n const container = await fixture(html`<div>${result}</div>`);\n\n expect(container.innerHTML).to.contain('Test Group');\n expect(container.querySelectorAll('temba-icon')).to.have.length(0);\n });\n });\n});\n"]}
@@ -1,7 +1,6 @@
1
1
  import { fixture, assert } from '@open-wc/testing';
2
2
  import { Omnibox } from '../src/omnibox/Omnibox';
3
- import { assertScreenshot, getClip } from './utils.test';
4
- import { openAndClick } from './temba-select.test';
3
+ import { assertScreenshot, getClip, openAndClick } from './utils.test';
5
4
  import { useFakeTimers, spy } from 'sinon';
6
5
  export const getHTML = (attrs = { name: 'recipients' }) => {
7
6
  const selectHTML = `
@@ -19,7 +18,7 @@ export const getHTML = (attrs = { name: 'recipients' }) => {
19
18
  };
20
19
  export const createOmnibox = async (clock, attrs = {}) => {
21
20
  const parentNode = document.createElement('div');
22
- parentNode.setAttribute('style', 'width: 250px;');
21
+ parentNode.setAttribute('style', 'width: 400px;');
23
22
  const omnibox = await fixture(getHTML(attrs), { parentNode });
24
23
  clock.runAll();
25
24
  await omnibox.updateComplete;
@@ -1 +1 @@
1
- {"version":3,"file":"temba-omnibox.test.js","sourceRoot":"","sources":["../../test/temba-omnibox.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,O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O,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,IAAI,KAAU,CAAC;IACf,UAAU,CAAC;QACT,KAAK,GAAG,aAAa,EAAE,CAAC;QACxB,WAAW,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC;QACR,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,OAAO,GAAY,MAAM,OAAO,CACpC,OAAO,CAAC,EAAE,QAAQ,EAAE,kCAAkC,EAAE,CAAC,CAC1D,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,OAAO,GAAY,MAAM,aAAa,CAAC,KAAK,EAAE;YAClD,QAAQ,EAAE,kCAAkC;SAC7C,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC;QAC1B,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAEhD,MAAM,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAErD,MAAM,gBAAgB,CAAC,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, assert } from '@open-wc/testing';\nimport { Omnibox } from '../src/omnibox/Omnibox';\nimport { assertScreenshot, getClip } from './utils.test';\nimport { openAndClick } from './temba-select.test';\nimport { useFakeTimers, spy } from 'sinon';\n\nexport const getHTML = (attrs: any = { name: 'recipients' }): string => {\n const selectHTML = `\n <temba-omnibox${Object.keys(attrs)\n .map((name: string) => {\n // check if it's a string attribute\n if (typeof attrs[name] === 'string') {\n return ` ${name}=\"${attrs[name].replace(/\"/g, '&quot;')}\"`;\n }\n return ` ${name}=\"${attrs[name]}\"`;\n })\n .join(' ')}>\n </temba-select>`;\n return selectHTML;\n};\n\nexport const createOmnibox = async (\n clock: any,\n attrs: any = {}\n): Promise<Omnibox> => {\n const parentNode = document.createElement('div');\n parentNode.setAttribute('style', 'width: 250px;');\n\n const omnibox: Omnibox = await fixture(getHTML(attrs), { parentNode });\n clock.runAll();\n await omnibox.updateComplete;\n return omnibox;\n};\n\ndescribe('temba-omnibox', () => {\n let clock: any;\n beforeEach(function () {\n clock = useFakeTimers();\n setViewport({ width: 500, height: 1000, deviceScaleFactor: 2 });\n });\n\n afterEach(function () {\n clock.restore();\n });\n\n it('can be created', async () => {\n const omnibox: Omnibox = await fixture(\n getHTML({ endpoint: '/test-assets/select/omnibox.json' })\n );\n assert.instanceOf(omnibox, Omnibox);\n });\n\n it('fires change events on selection', async () => {\n const omnibox: Omnibox = await createOmnibox(clock, {\n endpoint: '/test-assets/select/omnibox.json'\n });\n\n const changeEvent = spy();\n omnibox.addEventListener('change', changeEvent);\n\n await openAndClick(clock, omnibox, 0);\n assert(changeEvent.called, 'change event not fired');\n\n await assertScreenshot('omnibox/selected', getClip(omnibox));\n });\n});\n"]}
1
+ {"version":3,"file":"temba-omnibox.test.js","sourceRoot":"","sources":["../../test/temba-omnibox.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE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,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC;QACR,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,OAAO,GAAY,MAAM,OAAO,CACpC,OAAO,CAAC,EAAE,QAAQ,EAAE,kCAAkC,EAAE,CAAC,CAC1D,CAAC;QACF,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,OAAO,GAAY,MAAM,aAAa,CAAC,KAAK,EAAE;YAClD,QAAQ,EAAE,kCAAkC;SAC7C,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC;QAC1B,OAAO,CAAC,gBAAgB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAEhD,MAAM,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QACtC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAErD,MAAM,gBAAgB,CAAC,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, assert } from '@open-wc/testing';\nimport { Omnibox } from '../src/omnibox/Omnibox';\nimport { assertScreenshot, getClip, openAndClick } from './utils.test';\nimport { useFakeTimers, spy } from 'sinon';\n\nexport const getHTML = (attrs: any = { name: 'recipients' }): string => {\n const selectHTML = `\n <temba-omnibox${Object.keys(attrs)\n .map((name: string) => {\n // check if it's a string attribute\n if (typeof attrs[name] === 'string') {\n return ` ${name}=\"${attrs[name].replace(/\"/g, '&quot;')}\"`;\n }\n return ` ${name}=\"${attrs[name]}\"`;\n })\n .join(' ')}>\n </temba-select>`;\n return selectHTML;\n};\n\nexport const createOmnibox = async (\n clock: any,\n attrs: any = {}\n): Promise<Omnibox> => {\n const parentNode = document.createElement('div');\n parentNode.setAttribute('style', 'width: 400px;');\n\n const omnibox: Omnibox = await fixture(getHTML(attrs), { parentNode });\n clock.runAll();\n await omnibox.updateComplete;\n return omnibox;\n};\n\ndescribe('temba-omnibox', () => {\n let clock: any;\n beforeEach(function () {\n clock = useFakeTimers();\n setViewport({ width: 500, height: 1000, deviceScaleFactor: 2 });\n });\n\n afterEach(function () {\n clock.restore();\n });\n\n it('can be created', async () => {\n const omnibox: Omnibox = await fixture(\n getHTML({ endpoint: '/test-assets/select/omnibox.json' })\n );\n assert.instanceOf(omnibox, Omnibox);\n });\n\n it('fires change events on selection', async () => {\n const omnibox: Omnibox = await createOmnibox(clock, {\n endpoint: '/test-assets/select/omnibox.json'\n });\n\n const changeEvent = spy();\n omnibox.addEventListener('change', changeEvent);\n\n await openAndClick(clock, omnibox, 0);\n assert(changeEvent.called, 'change event not fired');\n\n await assertScreenshot('omnibox/selected', getClip(omnibox));\n });\n});\n"]}