@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.
- package/.github/copilot-instructions.md +181 -0
- package/.github/workflows/build.yml +3 -3
- package/.github/workflows/cla.yml +6 -6
- package/.github/workflows/copilot-setup-steps.yml +86 -0
- package/CHANGELOG.md +44 -0
- package/demo/drag-drop-demo.html +141 -0
- package/demo/index.html +57 -0
- package/demo/test-drag-drop.html +94 -0
- package/dist/locales/es.js +1 -0
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.js +1 -0
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/pt.js +1 -0
- package/dist/locales/pt.js.map +1 -1
- package/dist/temba-components.js +366 -247
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/chart/TembaChart.js +81 -14
- package/out-tsc/src/chart/TembaChart.js.map +1 -1
- package/out-tsc/src/fields/FieldManager.js +27 -34
- package/out-tsc/src/fields/FieldManager.js.map +1 -1
- package/out-tsc/src/list/RunList.js +13 -8
- package/out-tsc/src/list/RunList.js.map +1 -1
- package/out-tsc/src/list/SortableList.js +257 -60
- package/out-tsc/src/list/SortableList.js.map +1 -1
- package/out-tsc/src/locales/es.js +1 -0
- package/out-tsc/src/locales/es.js.map +1 -1
- package/out-tsc/src/locales/fr.js +1 -0
- package/out-tsc/src/locales/fr.js.map +1 -1
- package/out-tsc/src/locales/pt.js +1 -0
- package/out-tsc/src/locales/pt.js.map +1 -1
- package/out-tsc/src/omnibox/Omnibox.js +1 -1
- package/out-tsc/src/omnibox/Omnibox.js.map +1 -1
- package/out-tsc/src/options/Options.js +36 -13
- package/out-tsc/src/options/Options.js.map +1 -1
- package/out-tsc/src/select/Select.js +226 -43
- package/out-tsc/src/select/Select.js.map +1 -1
- package/out-tsc/src/store/AppState.js +3 -3
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/src/utils/index.js +6 -1
- package/out-tsc/src/utils/index.js.map +1 -1
- package/out-tsc/src/vectoricon/VectorIcon.js +2 -1
- package/out-tsc/src/vectoricon/VectorIcon.js.map +1 -1
- package/out-tsc/src/webchat/WebChat.js +5 -2
- package/out-tsc/src/webchat/WebChat.js.map +1 -1
- package/out-tsc/temba-modules.js +0 -2
- package/out-tsc/temba-modules.js.map +1 -1
- package/out-tsc/test/temba-appstate-language.test.js +176 -0
- package/out-tsc/test/temba-appstate-language.test.js.map +1 -0
- package/out-tsc/test/temba-chart.test.js +125 -0
- package/out-tsc/test/temba-chart.test.js.map +1 -1
- package/out-tsc/test/temba-dropdown.test.js +317 -0
- package/out-tsc/test/temba-dropdown.test.js.map +1 -0
- package/out-tsc/test/temba-flow-editor-node.test.js +273 -0
- package/out-tsc/test/temba-flow-editor-node.test.js.map +1 -0
- package/out-tsc/test/temba-flow-editor.test.js +244 -0
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -0
- package/out-tsc/test/temba-flow-plumber.test.js +145 -0
- package/out-tsc/test/temba-flow-plumber.test.js.map +1 -0
- package/out-tsc/test/temba-flow-render.test.js +171 -0
- package/out-tsc/test/temba-flow-render.test.js.map +1 -0
- package/out-tsc/test/temba-omnibox.test.js +2 -3
- package/out-tsc/test/temba-omnibox.test.js.map +1 -1
- package/out-tsc/test/temba-run-list.test.js +588 -0
- package/out-tsc/test/temba-run-list.test.js.map +1 -0
- package/out-tsc/test/temba-select.test.js +149 -52
- package/out-tsc/test/temba-select.test.js.map +1 -1
- package/out-tsc/test/temba-sortable-list.test.js +91 -15
- package/out-tsc/test/temba-sortable-list.test.js.map +1 -1
- package/out-tsc/test/temba-toast.test.js +299 -0
- package/out-tsc/test/temba-toast.test.js.map +1 -0
- package/out-tsc/test/temba-utils-index.test.js +1178 -0
- package/out-tsc/test/temba-utils-index.test.js.map +1 -0
- package/out-tsc/test/temba-webchat-lightbox-fix.test.js +42 -0
- package/out-tsc/test/temba-webchat-lightbox-fix.test.js.map +1 -0
- package/out-tsc/test/temba-webchat.test.js +816 -0
- package/out-tsc/test/temba-webchat.test.js.map +1 -0
- package/out-tsc/test/utils.test.js +33 -1
- package/out-tsc/test/utils.test.js.map +1 -1
- package/package.json +6 -8
- package/screenshots/truth/alert/error.png +0 -0
- package/screenshots/truth/alert/info.png +0 -0
- package/screenshots/truth/alert/warning.png +0 -0
- package/screenshots/truth/checkbox/checkbox-label-background-hover.png +0 -0
- package/screenshots/truth/checkbox/checked.png +0 -0
- package/screenshots/truth/checkbox/default.png +0 -0
- package/screenshots/truth/colorpicker/default.png +0 -0
- package/screenshots/truth/colorpicker/focused.png +0 -0
- package/screenshots/truth/colorpicker/initialized.png +0 -0
- package/screenshots/truth/colorpicker/selected.png +0 -0
- package/screenshots/truth/compose/attachments-tab.png +0 -0
- package/screenshots/truth/compose/attachments-with-files-focused.png +0 -0
- package/screenshots/truth/compose/attachments-with-files.png +0 -0
- package/screenshots/truth/compose/intial-text.png +0 -0
- package/screenshots/truth/compose/no-counter.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-spaces.png +0 -0
- package/screenshots/truth/compose/wraps-text-and-url.png +0 -0
- package/screenshots/truth/compose/wraps-text-no-spaces.png +0 -0
- package/screenshots/truth/contacts/badges.png +0 -0
- package/screenshots/truth/contacts/chat-failure.png +0 -0
- package/screenshots/truth/contacts/chat-for-active-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-archived-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-blocked-contact.png +0 -0
- package/screenshots/truth/contacts/chat-for-stopped-contact.png +0 -0
- package/screenshots/truth/contacts/chat-sends-attachments-only.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-and-attachments.png +0 -0
- package/screenshots/truth/contacts/chat-sends-text-only.png +0 -0
- package/screenshots/truth/content-menu/button-no-items.png +0 -0
- package/screenshots/truth/content-menu/items-and-buttons.png +0 -0
- package/screenshots/truth/counter/summary.png +0 -0
- package/screenshots/truth/counter/text.png +0 -0
- package/screenshots/truth/counter/unicode-variables.png +0 -0
- package/screenshots/truth/counter/unicode.png +0 -0
- package/screenshots/truth/counter/variable.png +0 -0
- package/screenshots/truth/date/date-inline.png +0 -0
- package/screenshots/truth/date/date.png +0 -0
- package/screenshots/truth/date/datetime.png +0 -0
- package/screenshots/truth/date/duration.png +0 -0
- package/screenshots/truth/date/timedate.png +0 -0
- package/screenshots/truth/datepicker/date-truncated-time.png +0 -0
- package/screenshots/truth/datepicker/date.png +0 -0
- package/screenshots/truth/datepicker/initial-timezone.png +0 -0
- package/screenshots/truth/datepicker/updated-keyboard-date.png +0 -0
- package/screenshots/truth/dialog/focused.png +0 -0
- package/screenshots/truth/dropdown/after-blur.png +0 -0
- package/screenshots/truth/dropdown/bottom-edge-collision.png +0 -0
- package/screenshots/truth/dropdown/custom-arrow-size.png +0 -0
- package/screenshots/truth/dropdown/default.png +0 -0
- package/screenshots/truth/dropdown/narrow-toggle.png +0 -0
- package/screenshots/truth/dropdown/no-mask.png +0 -0
- package/screenshots/truth/dropdown/opened.png +0 -0
- package/screenshots/truth/dropdown/positioned.png +0 -0
- package/screenshots/truth/dropdown/right-edge-collision.png +0 -0
- package/screenshots/truth/dropdown/with-mask.png +0 -0
- package/screenshots/truth/flow/editor-basic.png +0 -0
- package/screenshots/truth/label/custom.png +0 -0
- package/screenshots/truth/label/danger.png +0 -0
- package/screenshots/truth/label/dark.png +0 -0
- package/screenshots/truth/label/default-icon.png +0 -0
- package/screenshots/truth/label/no-icon.png +0 -0
- package/screenshots/truth/label/primary.png +0 -0
- package/screenshots/truth/label/secondary.png +0 -0
- package/screenshots/truth/label/shadow.png +0 -0
- package/screenshots/truth/label/tertiary.png +0 -0
- package/screenshots/truth/lightbox/img-zoomed.png +0 -0
- package/screenshots/truth/list/fields-dragging.png +0 -0
- package/screenshots/truth/list/fields-filtered.png +0 -0
- package/screenshots/truth/list/fields-hovered.png +0 -0
- package/screenshots/truth/list/fields.png +0 -0
- package/screenshots/truth/list/items-selected.png +0 -0
- package/screenshots/truth/list/items-updated.png +0 -0
- package/screenshots/truth/list/items.png +0 -0
- package/screenshots/truth/list/sortable-dragging.png +0 -0
- package/screenshots/truth/list/sortable-dropped.png +0 -0
- package/screenshots/truth/list/sortable.png +0 -0
- package/screenshots/truth/menu/menu-focused-with items.png +0 -0
- package/screenshots/truth/menu/menu-refresh-1.png +0 -0
- package/screenshots/truth/menu/menu-refresh-2.png +0 -0
- package/screenshots/truth/menu/menu-root.png +0 -0
- package/screenshots/truth/menu/menu-submenu.png +0 -0
- package/screenshots/truth/menu/menu-tasks-nextup.png +0 -0
- package/screenshots/truth/menu/menu-tasks.png +0 -0
- package/screenshots/truth/modax/form.png +0 -0
- package/screenshots/truth/modax/simple.png +0 -0
- package/screenshots/truth/omnibox/selected.png +0 -0
- package/screenshots/truth/options/block.png +0 -0
- package/screenshots/truth/run-list/basic.png +0 -0
- package/screenshots/truth/select/disabled-multi-selection.png +0 -0
- package/screenshots/truth/select/disabled-selection.png +0 -0
- package/screenshots/truth/select/disabled.png +0 -0
- package/screenshots/truth/select/embedded.png +0 -0
- package/screenshots/truth/select/empty-options.png +0 -0
- package/screenshots/truth/select/expression-selected.png +0 -0
- package/screenshots/truth/select/expressions.png +0 -0
- package/screenshots/truth/select/functions.png +0 -0
- package/screenshots/truth/select/local-options.png +0 -0
- package/screenshots/truth/select/multi-reorder-final.png +0 -0
- package/screenshots/truth/select/multi-reorder-initial.png +0 -0
- package/screenshots/truth/select/multi-with-endpoint.png +0 -0
- package/screenshots/truth/select/multiple-initial-values.png +0 -0
- package/screenshots/truth/select/remote-options.png +0 -0
- package/screenshots/truth/select/search-enabled.png +0 -0
- package/screenshots/truth/select/search-multi-no-matches.png +0 -0
- package/screenshots/truth/select/search-selected-focus.png +0 -0
- package/screenshots/truth/select/search-selected.png +0 -0
- package/screenshots/truth/select/search-with-selected.png +0 -0
- package/screenshots/truth/select/searching.png +0 -0
- package/screenshots/truth/select/selected-multi-maxitems-reached.png +0 -0
- package/screenshots/truth/select/selected-multi.png +0 -0
- package/screenshots/truth/select/selected-single.png +0 -0
- package/screenshots/truth/select/selection-clearable.png +0 -0
- package/screenshots/truth/select/static-initial-value.png +0 -0
- package/screenshots/truth/select/static-initial-via-selected.png +0 -0
- package/screenshots/truth/select/truncated-selection.png +0 -0
- package/screenshots/truth/select/with-placeholder.png +0 -0
- package/screenshots/truth/select/without-placeholder.png +0 -0
- package/screenshots/truth/slider/custom-min-custom-max-valid-value.png +0 -0
- package/screenshots/truth/slider/custom-min-default-max-no-value.png +0 -0
- package/screenshots/truth/slider/default-min-custom-max-no-value.png +0 -0
- package/screenshots/truth/slider/default-min-default-max-invalid-value.png +0 -0
- package/screenshots/truth/slider/default-min-default-max-valid-value.png +0 -0
- package/screenshots/truth/slider/update-slider-on-value-change.png +0 -0
- package/screenshots/truth/templates/default.png +0 -0
- package/screenshots/truth/templates/unapproved.png +0 -0
- package/screenshots/truth/textinput/input-disabled.png +0 -0
- package/screenshots/truth/textinput/input-focused.png +0 -0
- package/screenshots/truth/textinput/input-form.png +0 -0
- package/screenshots/truth/textinput/input-inserted.png +0 -0
- package/screenshots/truth/textinput/input-placeholder.png +0 -0
- package/screenshots/truth/textinput/input-updated.png +0 -0
- package/screenshots/truth/textinput/input.png +0 -0
- package/screenshots/truth/textinput/textarea-focused.png +0 -0
- package/screenshots/truth/textinput/textarea.png +0 -0
- package/screenshots/truth/tip/bottom.png +0 -0
- package/screenshots/truth/tip/left.png +0 -0
- package/screenshots/truth/tip/right.png +0 -0
- package/screenshots/truth/tip/top.png +0 -0
- package/screenshots/truth/webchat/closed-widget.png +0 -0
- package/screenshots/truth/webchat/connected-state.png +0 -0
- package/screenshots/truth/webchat/connecting-state.png +0 -0
- package/screenshots/truth/webchat/disconnected-state.png +0 -0
- package/screenshots/truth/webchat/opened-widget.png +0 -0
- package/src/chart/TembaChart.ts +86 -15
- package/src/fields/FieldManager.ts +30 -38
- package/src/list/RunList.ts +11 -8
- package/src/list/SortableList.ts +291 -67
- package/src/locales/es.ts +1 -0
- package/src/locales/fr.ts +1 -0
- package/src/locales/pt.ts +1 -0
- package/src/omnibox/Omnibox.ts +1 -1
- package/src/options/Options.ts +38 -13
- package/src/select/Select.ts +245 -47
- package/src/store/AppState.ts +3 -3
- package/src/utils/index.ts +17 -5
- package/src/vectoricon/VectorIcon.ts +2 -1
- package/src/webchat/WebChat.ts +5 -2
- package/temba-modules.ts +0 -2
- package/test/temba-appstate-language.test.ts +218 -0
- package/test/temba-chart.test.ts +161 -1
- package/test/temba-dropdown.test.ts +444 -0
- package/test/temba-flow-editor-node.test.ts +344 -0
- package/test/temba-flow-editor.test.ts +301 -0
- package/test/temba-flow-plumber.test.ts +189 -0
- package/test/temba-flow-render.test.ts +220 -0
- package/test/temba-omnibox.test.ts +2 -3
- package/test/temba-run-list.test.ts +774 -0
- package/test/temba-select.test.ts +206 -78
- package/test/temba-sortable-list.test.ts +108 -15
- package/test/temba-toast.test.ts +386 -0
- package/test/temba-utils-index.test.ts +1547 -0
- package/test/temba-webchat-lightbox-fix.test.ts +57 -0
- package/test/temba-webchat.test.ts +1095 -0
- package/test/utils.test.ts +56 -2
- package/test-assets/list/flow-results.json +17 -0
- package/test-assets/list/runs.json +126 -0
- package/test-assets/style.css +23 -0
- package/web-test-runner.config.mjs +33 -7
- package/xliff/es.xlf +3 -0
- package/xliff/fr.xlf +3 -0
- package/xliff/pt.xlf +3 -0
- package/out-tsc/src/outboxmonitor/OutboxMonitor.js +0 -136
- package/out-tsc/src/outboxmonitor/OutboxMonitor.js.map +0 -1
- 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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AE,EAAE;gBACnC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC1B,OAAO,IAAI,CAAA;cACP,IAAI,CAAC,yCAAyC;mBACzC,KAAK,CAAC,IAAI;iBACZ,CAAC;gBACV,CAAC,CAAC,CAAC;YACL,CAAC,CAAC;YAEF,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;YACxC,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,QAAQ,MAAM,QAAQ,CAAC,CAAC;YAE5D,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACrD,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,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:
|
|
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,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,
|
|
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,aAAa,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,CAAC,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;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, '"')}\"`;\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"]}
|