@nyaruka/temba-components 0.138.6 → 0.140.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/cla.yml +1 -1
- package/.github/workflows/copilot-setup-steps.yml +6 -1
- package/CHANGELOG.md +26 -0
- package/demo/data/flows/sample-flow.json +24 -0
- package/dist/locales/es.js +5 -5
- package/dist/locales/es.js.map +1 -1
- package/dist/locales/fr.js +5 -5
- package/dist/locales/fr.js.map +1 -1
- package/dist/locales/locale-codes.js +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 +1112 -882
- package/dist/temba-components.js.map +1 -1
- package/out-tsc/src/display/Chat.js +10 -7
- package/out-tsc/src/display/Chat.js.map +1 -1
- package/out-tsc/src/display/Dropdown.js +3 -1
- package/out-tsc/src/display/Dropdown.js.map +1 -1
- package/out-tsc/src/display/FloatingTab.js +25 -32
- package/out-tsc/src/display/FloatingTab.js.map +1 -1
- package/out-tsc/src/display/Thumbnail.js +163 -5
- package/out-tsc/src/display/Thumbnail.js.map +1 -1
- package/out-tsc/src/flow/CanvasMenu.js +5 -3
- package/out-tsc/src/flow/CanvasMenu.js.map +1 -1
- package/out-tsc/src/flow/CanvasNode.js +70 -29
- package/out-tsc/src/flow/CanvasNode.js.map +1 -1
- package/out-tsc/src/flow/Editor.js +290 -239
- package/out-tsc/src/flow/Editor.js.map +1 -1
- package/out-tsc/src/flow/NodeEditor.js +118 -10
- package/out-tsc/src/flow/NodeEditor.js.map +1 -1
- package/out-tsc/src/flow/Plumber.js +757 -403
- package/out-tsc/src/flow/Plumber.js.map +1 -1
- package/out-tsc/src/flow/StickyNote.js +13 -4
- package/out-tsc/src/flow/StickyNote.js.map +1 -1
- package/out-tsc/src/flow/actions/audio-player.js +112 -0
- package/out-tsc/src/flow/actions/audio-player.js.map +1 -0
- package/out-tsc/src/flow/actions/enter_flow.js +43 -0
- package/out-tsc/src/flow/actions/enter_flow.js.map +1 -0
- package/out-tsc/src/flow/actions/play_audio.js +57 -4
- package/out-tsc/src/flow/actions/play_audio.js.map +1 -1
- package/out-tsc/src/flow/actions/say_msg.js +86 -3
- package/out-tsc/src/flow/actions/say_msg.js.map +1 -1
- package/out-tsc/src/flow/config.js +11 -3
- package/out-tsc/src/flow/config.js.map +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js +1 -1
- package/out-tsc/src/flow/nodes/shared-rules.js.map +1 -1
- package/out-tsc/src/flow/nodes/terminal.js +7 -0
- package/out-tsc/src/flow/nodes/terminal.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js +77 -0
- package/out-tsc/src/flow/nodes/wait_for_audio.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js +151 -0
- package/out-tsc/src/flow/nodes/wait_for_dial.js.map +1 -0
- package/out-tsc/src/flow/nodes/wait_for_digits.js +61 -1
- package/out-tsc/src/flow/nodes/wait_for_digits.js.map +1 -1
- package/out-tsc/src/flow/nodes/wait_for_menu.js +173 -2
- package/out-tsc/src/flow/nodes/wait_for_menu.js.map +1 -1
- package/out-tsc/src/flow/operators.js +21 -5
- package/out-tsc/src/flow/operators.js.map +1 -1
- package/out-tsc/src/flow/types.js.map +1 -1
- package/out-tsc/src/flow/utils.js +213 -65
- package/out-tsc/src/flow/utils.js.map +1 -1
- package/out-tsc/src/form/ArrayEditor.js +4 -2
- package/out-tsc/src/form/ArrayEditor.js.map +1 -1
- package/out-tsc/src/form/FieldRenderer.js +49 -0
- package/out-tsc/src/form/FieldRenderer.js.map +1 -1
- package/out-tsc/src/interfaces.js +2 -0
- package/out-tsc/src/interfaces.js.map +1 -1
- package/out-tsc/src/layout/Dialog.js +52 -7
- package/out-tsc/src/layout/Dialog.js.map +1 -1
- package/out-tsc/src/list/TicketList.js +4 -1
- package/out-tsc/src/list/TicketList.js.map +1 -1
- package/out-tsc/src/live/TembaChart.js.map +1 -1
- package/out-tsc/src/locales/es.js +5 -5
- package/out-tsc/src/locales/es.js.map +1 -1
- package/out-tsc/src/locales/fr.js +5 -5
- package/out-tsc/src/locales/fr.js.map +1 -1
- package/out-tsc/src/locales/locale-codes.js +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/simulator/Simulator.js +10 -3
- package/out-tsc/src/simulator/Simulator.js.map +1 -1
- package/out-tsc/src/store/AppState.js +89 -3
- package/out-tsc/src/store/AppState.js.map +1 -1
- package/out-tsc/test/actions/play_audio.test.js +118 -0
- package/out-tsc/test/actions/play_audio.test.js.map +1 -0
- package/out-tsc/test/actions/say_msg.test.js +158 -0
- package/out-tsc/test/actions/say_msg.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js +156 -0
- package/out-tsc/test/nodes/wait_for_audio.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js +336 -0
- package/out-tsc/test/nodes/wait_for_dial.test.js.map +1 -0
- package/out-tsc/test/nodes/wait_for_digits.test.js +198 -84
- package/out-tsc/test/nodes/wait_for_digits.test.js.map +1 -1
- package/out-tsc/test/nodes/wait_for_menu.test.js +340 -0
- package/out-tsc/test/nodes/wait_for_menu.test.js.map +1 -0
- package/out-tsc/test/temba-floating-tab.test.js +4 -6
- package/out-tsc/test/temba-floating-tab.test.js.map +1 -1
- package/out-tsc/test/temba-flow-collision.test.js +473 -220
- package/out-tsc/test/temba-flow-collision.test.js.map +1 -1
- package/out-tsc/test/temba-flow-editor.test.js +0 -2
- package/out-tsc/test/temba-flow-editor.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber-connections.test.js +83 -84
- package/out-tsc/test/temba-flow-plumber-connections.test.js.map +1 -1
- package/out-tsc/test/temba-flow-plumber.test.js +102 -93
- package/out-tsc/test/temba-flow-plumber.test.js.map +1 -1
- package/out-tsc/test/temba-node-type-selector.test.js +6 -6
- package/out-tsc/test/temba-node-type-selector.test.js.map +1 -1
- package/package.json +1 -1
- package/screenshots/truth/actions/play_audio/editor/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/editor/static-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/expression-url.png +0 -0
- package/screenshots/truth/actions/play_audio/render/static-url.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/editor/text-with-audio-url.png +0 -0
- package/screenshots/truth/actions/say_msg/render/multiline-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/simple-text.png +0 -0
- package/screenshots/truth/actions/say_msg/render/text-with-audio-url.png +0 -0
- package/screenshots/truth/editor/router.png +0 -0
- package/screenshots/truth/editor/wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/editor/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_audio/render/basic-audio-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/editor/dial-with-limits.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/basic-dial.png +0 -0
- package/screenshots/truth/nodes/wait_for_dial/render/dial-with-limits.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/basic-digits-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/digits-with-rules.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/editor/menu-with-digits.png +0 -0
- package/screenshots/truth/nodes/wait_for_menu/render/menu-with-digits.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/editor/short-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/basic-wait.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/custom-result-name.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/no-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_response/render/short-timeout.png +0 -0
- package/src/display/Chat.ts +13 -7
- package/src/display/Dropdown.ts +3 -1
- package/src/display/FloatingTab.ts +24 -33
- package/src/display/Thumbnail.ts +162 -2
- package/src/flow/CanvasMenu.ts +8 -3
- package/src/flow/CanvasNode.ts +75 -30
- package/src/flow/Editor.ts +336 -288
- package/src/flow/NodeEditor.ts +137 -9
- package/src/flow/Plumber.ts +1011 -457
- package/src/flow/StickyNote.ts +14 -4
- package/src/flow/actions/audio-player.ts +127 -0
- package/src/flow/actions/enter_flow.ts +44 -0
- package/src/flow/actions/play_audio.ts +64 -5
- package/src/flow/actions/say_msg.ts +94 -4
- package/src/flow/config.ts +11 -3
- package/src/flow/nodes/shared-rules.ts +1 -1
- package/src/flow/nodes/terminal.ts +9 -0
- package/src/flow/nodes/wait_for_audio.ts +88 -0
- package/src/flow/nodes/wait_for_dial.ts +176 -0
- package/src/flow/nodes/wait_for_digits.ts +86 -2
- package/src/flow/nodes/wait_for_menu.ts +209 -3
- package/src/flow/operators.ts +23 -5
- package/src/flow/types.ts +23 -1
- package/src/flow/utils.ts +238 -81
- package/src/form/ArrayEditor.ts +4 -2
- package/src/form/FieldRenderer.ts +64 -1
- package/src/interfaces.ts +3 -1
- package/src/layout/Dialog.ts +53 -7
- package/src/list/TicketList.ts +4 -1
- package/src/live/TembaChart.ts +1 -1
- 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/simulator/Simulator.ts +13 -3
- package/src/store/AppState.ts +105 -1
- package/src/store/flow-definition.d.ts +2 -0
- package/test/actions/play_audio.test.ts +155 -0
- package/test/actions/say_msg.test.ts +196 -0
- package/test/nodes/wait_for_audio.test.ts +182 -0
- package/test/nodes/wait_for_dial.test.ts +382 -0
- package/test/nodes/wait_for_digits.test.ts +233 -109
- package/test/nodes/wait_for_menu.test.ts +383 -0
- package/test/temba-floating-tab.test.ts +4 -6
- package/test/temba-flow-collision.test.ts +495 -293
- package/test/temba-flow-editor.test.ts +0 -2
- package/test/temba-flow-plumber-connections.test.ts +97 -97
- package/test/temba-flow-plumber.test.ts +116 -103
- package/test/temba-node-type-selector.test.ts +6 -6
- package/screenshots/truth/nodes/wait_for_digits/editor/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/editor/verification-code.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/phone-number-collection.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/single-digit-with-timeout.png +0 -0
- package/screenshots/truth/nodes/wait_for_digits/render/verification-code.png +0 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { wait_for_audio } from '../../src/flow/nodes/wait_for_audio';
|
|
3
|
+
import { Node } from '../../src/store/flow-definition';
|
|
4
|
+
import { NodeTest } from '../NodeHelper';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Test suite for the wait_for_audio node configuration.
|
|
8
|
+
*/
|
|
9
|
+
describe('wait_for_audio node config', () => {
|
|
10
|
+
const helper = new NodeTest(wait_for_audio, 'wait_for_audio');
|
|
11
|
+
|
|
12
|
+
describe('basic properties', () => {
|
|
13
|
+
helper.testBasicProperties();
|
|
14
|
+
|
|
15
|
+
it('has correct name', () => {
|
|
16
|
+
expect(wait_for_audio.name).to.equal('Make Recording');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('has correct type', () => {
|
|
20
|
+
expect(wait_for_audio.type).to.equal('wait_for_audio');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('is voice-only', () => {
|
|
24
|
+
expect(wait_for_audio.flowTypes).to.deep.equal(['voice']);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('has form with result_name field', () => {
|
|
28
|
+
expect(wait_for_audio.form).to.exist;
|
|
29
|
+
expect(wait_for_audio.form!.result_name).to.exist;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('has layout', () => {
|
|
33
|
+
expect(wait_for_audio.layout).to.deep.equal(['result_name']);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('node scenarios', () => {
|
|
38
|
+
it('renders basic audio wait', async () => {
|
|
39
|
+
await helper.testNode(
|
|
40
|
+
{
|
|
41
|
+
uuid: 'test-audio-node-1',
|
|
42
|
+
actions: [],
|
|
43
|
+
router: {
|
|
44
|
+
type: 'switch',
|
|
45
|
+
operand: '@input',
|
|
46
|
+
wait: {
|
|
47
|
+
type: 'msg',
|
|
48
|
+
hint: { type: 'audio' }
|
|
49
|
+
},
|
|
50
|
+
result_name: 'recording',
|
|
51
|
+
default_category_uuid: 'all-cat-1',
|
|
52
|
+
cases: [],
|
|
53
|
+
categories: [
|
|
54
|
+
{
|
|
55
|
+
uuid: 'all-cat-1',
|
|
56
|
+
name: 'All Responses',
|
|
57
|
+
exit_uuid: 'all-exit-1'
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
exits: [{ uuid: 'all-exit-1', destination_uuid: null }]
|
|
62
|
+
} as Node,
|
|
63
|
+
{ type: 'wait_for_audio' },
|
|
64
|
+
'basic-audio-wait'
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('data transformation', () => {
|
|
70
|
+
it('converts node to form data', () => {
|
|
71
|
+
const node: Node = {
|
|
72
|
+
uuid: 'test-node',
|
|
73
|
+
actions: [],
|
|
74
|
+
router: {
|
|
75
|
+
type: 'switch',
|
|
76
|
+
result_name: 'my_recording',
|
|
77
|
+
categories: []
|
|
78
|
+
},
|
|
79
|
+
exits: []
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const formData = wait_for_audio.toFormData!(node);
|
|
83
|
+
expect(formData.uuid).to.equal('test-node');
|
|
84
|
+
expect(formData.result_name).to.equal('my_recording');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('handles missing result_name', () => {
|
|
88
|
+
const node: Node = {
|
|
89
|
+
uuid: 'test-node',
|
|
90
|
+
actions: [],
|
|
91
|
+
router: {
|
|
92
|
+
type: 'switch',
|
|
93
|
+
categories: []
|
|
94
|
+
},
|
|
95
|
+
exits: []
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const formData = wait_for_audio.toFormData!(node);
|
|
99
|
+
expect(formData.result_name).to.equal('');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('creates node with All Responses category', () => {
|
|
103
|
+
const formData = {
|
|
104
|
+
uuid: 'test-node',
|
|
105
|
+
result_name: 'recording'
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const originalNode: Node = {
|
|
109
|
+
uuid: 'test-node',
|
|
110
|
+
actions: [],
|
|
111
|
+
exits: [],
|
|
112
|
+
router: {
|
|
113
|
+
type: 'switch',
|
|
114
|
+
categories: []
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const result = wait_for_audio.fromFormData!(formData, originalNode);
|
|
119
|
+
|
|
120
|
+
expect(result.router?.categories).to.have.length(1);
|
|
121
|
+
expect(result.router?.categories[0].name).to.equal('All Responses');
|
|
122
|
+
expect(result.router?.wait?.type).to.equal('msg');
|
|
123
|
+
expect(result.router?.wait?.hint?.type).to.equal('audio');
|
|
124
|
+
expect(result.router?.result_name).to.equal('recording');
|
|
125
|
+
expect(result.exits).to.have.length(1);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('preserves existing All Responses category UUID', () => {
|
|
129
|
+
const formData = {
|
|
130
|
+
uuid: 'test-node',
|
|
131
|
+
result_name: 'recording'
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const originalNode: Node = {
|
|
135
|
+
uuid: 'test-node',
|
|
136
|
+
actions: [],
|
|
137
|
+
router: {
|
|
138
|
+
type: 'switch',
|
|
139
|
+
categories: [
|
|
140
|
+
{
|
|
141
|
+
uuid: 'existing-cat-uuid',
|
|
142
|
+
name: 'All Responses',
|
|
143
|
+
exit_uuid: 'existing-exit-uuid'
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
exits: [
|
|
148
|
+
{
|
|
149
|
+
uuid: 'existing-exit-uuid',
|
|
150
|
+
destination_uuid: 'some-destination'
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const result = wait_for_audio.fromFormData!(formData, originalNode);
|
|
156
|
+
|
|
157
|
+
expect(result.router?.categories[0].uuid).to.equal('existing-cat-uuid');
|
|
158
|
+
expect(result.router?.categories[0].exit_uuid).to.equal(
|
|
159
|
+
'existing-exit-uuid'
|
|
160
|
+
);
|
|
161
|
+
expect(result.exits[0].uuid).to.equal('existing-exit-uuid');
|
|
162
|
+
expect(result.exits[0].destination_uuid).to.equal('some-destination');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('omits result_name when empty', () => {
|
|
166
|
+
const formData = {
|
|
167
|
+
uuid: 'test-node',
|
|
168
|
+
result_name: ''
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const originalNode: Node = {
|
|
172
|
+
uuid: 'test-node',
|
|
173
|
+
actions: [],
|
|
174
|
+
exits: [],
|
|
175
|
+
router: { type: 'switch', categories: [] }
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const result = wait_for_audio.fromFormData!(formData, originalNode);
|
|
179
|
+
expect(result.router?.result_name).to.be.undefined;
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { wait_for_dial } from '../../src/flow/nodes/wait_for_dial';
|
|
3
|
+
import { Node } from '../../src/store/flow-definition';
|
|
4
|
+
import { NodeTest } from '../NodeHelper';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Test suite for the wait_for_dial node configuration.
|
|
8
|
+
*/
|
|
9
|
+
describe('wait_for_dial node config', () => {
|
|
10
|
+
const helper = new NodeTest(wait_for_dial, 'wait_for_dial');
|
|
11
|
+
|
|
12
|
+
describe('basic properties', () => {
|
|
13
|
+
helper.testBasicProperties();
|
|
14
|
+
|
|
15
|
+
it('has correct name', () => {
|
|
16
|
+
expect(wait_for_dial.name).to.equal('Redirect Call');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('has correct type', () => {
|
|
20
|
+
expect(wait_for_dial.type).to.equal('wait_for_dial');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('is voice-only', () => {
|
|
24
|
+
expect(wait_for_dial.flowTypes).to.deep.equal(['voice']);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('has form with phone and limit fields', () => {
|
|
28
|
+
expect(wait_for_dial.form).to.exist;
|
|
29
|
+
expect(wait_for_dial.form!.phone).to.exist;
|
|
30
|
+
expect(wait_for_dial.form!.dial_limit_seconds).to.exist;
|
|
31
|
+
expect(wait_for_dial.form!.call_limit_seconds).to.exist;
|
|
32
|
+
expect(wait_for_dial.form!.result_name).to.exist;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('has fixed router rules', () => {
|
|
36
|
+
expect(wait_for_dial.router).to.exist;
|
|
37
|
+
expect(wait_for_dial.router!.type).to.equal('switch');
|
|
38
|
+
expect(wait_for_dial.router!.defaultCategory).to.equal('Failed');
|
|
39
|
+
expect(wait_for_dial.router!.rules).to.have.length(3);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('node scenarios', () => {
|
|
44
|
+
it('renders basic dial', async () => {
|
|
45
|
+
await helper.testNode(
|
|
46
|
+
{
|
|
47
|
+
uuid: 'test-dial-node-1',
|
|
48
|
+
actions: [],
|
|
49
|
+
router: {
|
|
50
|
+
type: 'switch',
|
|
51
|
+
operand: '@(default(resume.dial.status, ""))',
|
|
52
|
+
wait: {
|
|
53
|
+
type: 'dial',
|
|
54
|
+
phone: '+12065551234'
|
|
55
|
+
},
|
|
56
|
+
result_name: 'dial_result',
|
|
57
|
+
default_category_uuid: 'failed-cat',
|
|
58
|
+
cases: [
|
|
59
|
+
{
|
|
60
|
+
uuid: 'case-answered',
|
|
61
|
+
type: 'has_only_text',
|
|
62
|
+
arguments: ['answered'],
|
|
63
|
+
category_uuid: 'answered-cat'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
uuid: 'case-no-answer',
|
|
67
|
+
type: 'has_only_text',
|
|
68
|
+
arguments: ['no_answer'],
|
|
69
|
+
category_uuid: 'no-answer-cat'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
uuid: 'case-busy',
|
|
73
|
+
type: 'has_only_text',
|
|
74
|
+
arguments: ['busy'],
|
|
75
|
+
category_uuid: 'busy-cat'
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
categories: [
|
|
79
|
+
{
|
|
80
|
+
uuid: 'answered-cat',
|
|
81
|
+
name: 'Answered',
|
|
82
|
+
exit_uuid: 'answered-exit'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
uuid: 'no-answer-cat',
|
|
86
|
+
name: 'No Answer',
|
|
87
|
+
exit_uuid: 'no-answer-exit'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
uuid: 'busy-cat',
|
|
91
|
+
name: 'Busy',
|
|
92
|
+
exit_uuid: 'busy-exit'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
uuid: 'failed-cat',
|
|
96
|
+
name: 'Failed',
|
|
97
|
+
exit_uuid: 'failed-exit'
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
exits: [
|
|
102
|
+
{ uuid: 'answered-exit', destination_uuid: null },
|
|
103
|
+
{ uuid: 'no-answer-exit', destination_uuid: null },
|
|
104
|
+
{ uuid: 'busy-exit', destination_uuid: null },
|
|
105
|
+
{ uuid: 'failed-exit', destination_uuid: null }
|
|
106
|
+
]
|
|
107
|
+
} as Node,
|
|
108
|
+
{ type: 'wait_for_dial' },
|
|
109
|
+
'basic-dial'
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('renders dial with limits', async () => {
|
|
114
|
+
await helper.testNode(
|
|
115
|
+
{
|
|
116
|
+
uuid: 'test-dial-node-2',
|
|
117
|
+
actions: [],
|
|
118
|
+
router: {
|
|
119
|
+
type: 'switch',
|
|
120
|
+
operand: '@(default(resume.dial.status, ""))',
|
|
121
|
+
wait: {
|
|
122
|
+
type: 'dial',
|
|
123
|
+
phone: '@contact.phone',
|
|
124
|
+
dial_limit_seconds: 30,
|
|
125
|
+
call_limit_seconds: 3600
|
|
126
|
+
},
|
|
127
|
+
default_category_uuid: 'failed-cat',
|
|
128
|
+
cases: [
|
|
129
|
+
{
|
|
130
|
+
uuid: 'case-answered',
|
|
131
|
+
type: 'has_only_text',
|
|
132
|
+
arguments: ['answered'],
|
|
133
|
+
category_uuid: 'answered-cat'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
uuid: 'case-no-answer',
|
|
137
|
+
type: 'has_only_text',
|
|
138
|
+
arguments: ['no_answer'],
|
|
139
|
+
category_uuid: 'no-answer-cat'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
uuid: 'case-busy',
|
|
143
|
+
type: 'has_only_text',
|
|
144
|
+
arguments: ['busy'],
|
|
145
|
+
category_uuid: 'busy-cat'
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
categories: [
|
|
149
|
+
{
|
|
150
|
+
uuid: 'answered-cat',
|
|
151
|
+
name: 'Answered',
|
|
152
|
+
exit_uuid: 'answered-exit'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
uuid: 'no-answer-cat',
|
|
156
|
+
name: 'No Answer',
|
|
157
|
+
exit_uuid: 'no-answer-exit'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
uuid: 'busy-cat',
|
|
161
|
+
name: 'Busy',
|
|
162
|
+
exit_uuid: 'busy-exit'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
uuid: 'failed-cat',
|
|
166
|
+
name: 'Failed',
|
|
167
|
+
exit_uuid: 'failed-exit'
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
exits: [
|
|
172
|
+
{ uuid: 'answered-exit', destination_uuid: null },
|
|
173
|
+
{ uuid: 'no-answer-exit', destination_uuid: null },
|
|
174
|
+
{ uuid: 'busy-exit', destination_uuid: null },
|
|
175
|
+
{ uuid: 'failed-exit', destination_uuid: null }
|
|
176
|
+
]
|
|
177
|
+
} as Node,
|
|
178
|
+
{ type: 'wait_for_dial' },
|
|
179
|
+
'dial-with-limits'
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('data transformation', () => {
|
|
185
|
+
it('converts node to form data', () => {
|
|
186
|
+
const node: Node = {
|
|
187
|
+
uuid: 'test-node',
|
|
188
|
+
actions: [],
|
|
189
|
+
router: {
|
|
190
|
+
type: 'switch',
|
|
191
|
+
result_name: 'dial_result',
|
|
192
|
+
wait: {
|
|
193
|
+
type: 'dial',
|
|
194
|
+
phone: '+12065551234',
|
|
195
|
+
dial_limit_seconds: 60,
|
|
196
|
+
call_limit_seconds: 7200
|
|
197
|
+
},
|
|
198
|
+
categories: []
|
|
199
|
+
},
|
|
200
|
+
exits: []
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const formData = wait_for_dial.toFormData!(node);
|
|
204
|
+
expect(formData.uuid).to.equal('test-node');
|
|
205
|
+
expect(formData.phone).to.equal('+12065551234');
|
|
206
|
+
expect(formData.dial_limit_seconds).to.equal('60');
|
|
207
|
+
expect(formData.call_limit_seconds).to.equal('7200');
|
|
208
|
+
expect(formData.result_name).to.equal('dial_result');
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('handles missing wait config', () => {
|
|
212
|
+
const node: Node = {
|
|
213
|
+
uuid: 'test-node',
|
|
214
|
+
actions: [],
|
|
215
|
+
router: {
|
|
216
|
+
type: 'switch',
|
|
217
|
+
categories: []
|
|
218
|
+
},
|
|
219
|
+
exits: []
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const formData = wait_for_dial.toFormData!(node);
|
|
223
|
+
expect(formData.phone).to.equal('');
|
|
224
|
+
expect(formData.dial_limit_seconds).to.equal('');
|
|
225
|
+
expect(formData.call_limit_seconds).to.equal('');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('creates node with fixed dial categories', () => {
|
|
229
|
+
const formData = {
|
|
230
|
+
uuid: 'test-node',
|
|
231
|
+
phone: '+12065551234',
|
|
232
|
+
dial_limit_seconds: '60',
|
|
233
|
+
call_limit_seconds: '7200',
|
|
234
|
+
result_name: 'dial_result'
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const originalNode: Node = {
|
|
238
|
+
uuid: 'test-node',
|
|
239
|
+
actions: [],
|
|
240
|
+
exits: [],
|
|
241
|
+
router: { type: 'switch', categories: [] }
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const result = wait_for_dial.fromFormData!(formData, originalNode);
|
|
245
|
+
|
|
246
|
+
// Should have 4 fixed categories
|
|
247
|
+
expect(result.router?.categories).to.have.length(4);
|
|
248
|
+
const names = result.router!.categories.map((c) => c.name);
|
|
249
|
+
expect(names).to.deep.equal(['Answered', 'No Answer', 'Busy', 'Failed']);
|
|
250
|
+
|
|
251
|
+
// Should have 3 cases (Failed is default, no case needed)
|
|
252
|
+
expect(result.router?.cases).to.have.length(3);
|
|
253
|
+
|
|
254
|
+
// Check wait config
|
|
255
|
+
expect(result.router?.wait?.type).to.equal('dial');
|
|
256
|
+
expect(result.router?.wait?.phone).to.equal('+12065551234');
|
|
257
|
+
expect(result.router?.wait?.dial_limit_seconds).to.equal(60);
|
|
258
|
+
expect(result.router?.wait?.call_limit_seconds).to.equal(7200);
|
|
259
|
+
|
|
260
|
+
// Check operand
|
|
261
|
+
expect(result.router?.operand).to.equal(
|
|
262
|
+
'@(default(resume.dial.status, ""))'
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
// Check result name
|
|
266
|
+
expect(result.router?.result_name).to.equal('dial_result');
|
|
267
|
+
|
|
268
|
+
// Should have 4 exits
|
|
269
|
+
expect(result.exits).to.have.length(4);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('omits limits when empty', () => {
|
|
273
|
+
const formData = {
|
|
274
|
+
uuid: 'test-node',
|
|
275
|
+
phone: '+12065551234',
|
|
276
|
+
dial_limit_seconds: '',
|
|
277
|
+
call_limit_seconds: '',
|
|
278
|
+
result_name: ''
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const originalNode: Node = {
|
|
282
|
+
uuid: 'test-node',
|
|
283
|
+
actions: [],
|
|
284
|
+
exits: [],
|
|
285
|
+
router: { type: 'switch', categories: [] }
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const result = wait_for_dial.fromFormData!(formData, originalNode);
|
|
289
|
+
|
|
290
|
+
expect(result.router?.wait?.dial_limit_seconds).to.be.undefined;
|
|
291
|
+
expect(result.router?.wait?.call_limit_seconds).to.be.undefined;
|
|
292
|
+
expect(result.router?.result_name).to.be.undefined;
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('preserves existing category UUIDs', () => {
|
|
296
|
+
const formData = {
|
|
297
|
+
uuid: 'test-node',
|
|
298
|
+
phone: '+12065551234',
|
|
299
|
+
dial_limit_seconds: '',
|
|
300
|
+
call_limit_seconds: '',
|
|
301
|
+
result_name: ''
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const originalNode: Node = {
|
|
305
|
+
uuid: 'test-node',
|
|
306
|
+
actions: [],
|
|
307
|
+
router: {
|
|
308
|
+
type: 'switch',
|
|
309
|
+
categories: [
|
|
310
|
+
{
|
|
311
|
+
uuid: 'orig-answered',
|
|
312
|
+
name: 'Answered',
|
|
313
|
+
exit_uuid: 'orig-answered-exit'
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
uuid: 'orig-no-answer',
|
|
317
|
+
name: 'No Answer',
|
|
318
|
+
exit_uuid: 'orig-no-answer-exit'
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
uuid: 'orig-busy',
|
|
322
|
+
name: 'Busy',
|
|
323
|
+
exit_uuid: 'orig-busy-exit'
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
uuid: 'orig-failed',
|
|
327
|
+
name: 'Failed',
|
|
328
|
+
exit_uuid: 'orig-failed-exit'
|
|
329
|
+
}
|
|
330
|
+
],
|
|
331
|
+
cases: [
|
|
332
|
+
{
|
|
333
|
+
uuid: 'orig-case-answered',
|
|
334
|
+
type: 'has_only_text',
|
|
335
|
+
arguments: ['answered'],
|
|
336
|
+
category_uuid: 'orig-answered'
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
uuid: 'orig-case-no-answer',
|
|
340
|
+
type: 'has_only_text',
|
|
341
|
+
arguments: ['no_answer'],
|
|
342
|
+
category_uuid: 'orig-no-answer'
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
uuid: 'orig-case-busy',
|
|
346
|
+
type: 'has_only_text',
|
|
347
|
+
arguments: ['busy'],
|
|
348
|
+
category_uuid: 'orig-busy'
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
},
|
|
352
|
+
exits: [
|
|
353
|
+
{ uuid: 'orig-answered-exit', destination_uuid: 'dest-1' },
|
|
354
|
+
{ uuid: 'orig-no-answer-exit', destination_uuid: 'dest-2' },
|
|
355
|
+
{ uuid: 'orig-busy-exit', destination_uuid: null },
|
|
356
|
+
{ uuid: 'orig-failed-exit', destination_uuid: null }
|
|
357
|
+
]
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const result = wait_for_dial.fromFormData!(formData, originalNode);
|
|
361
|
+
|
|
362
|
+
// Category UUIDs should be preserved
|
|
363
|
+
const answered = result.router!.categories.find(
|
|
364
|
+
(c) => c.name === 'Answered'
|
|
365
|
+
);
|
|
366
|
+
expect(answered?.uuid).to.equal('orig-answered');
|
|
367
|
+
expect(answered?.exit_uuid).to.equal('orig-answered-exit');
|
|
368
|
+
|
|
369
|
+
// Exit destinations should be preserved
|
|
370
|
+
const answeredExit = result.exits.find(
|
|
371
|
+
(e) => e.uuid === 'orig-answered-exit'
|
|
372
|
+
);
|
|
373
|
+
expect(answeredExit?.destination_uuid).to.equal('dest-1');
|
|
374
|
+
|
|
375
|
+
// Case UUIDs should be preserved
|
|
376
|
+
const answeredCase = result.router!.cases.find(
|
|
377
|
+
(c: any) => c.arguments[0] === 'answered'
|
|
378
|
+
);
|
|
379
|
+
expect(answeredCase?.uuid).to.equal('orig-case-answered');
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
});
|