botium-core 1.13.2 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -3
- package/dist/botium-cjs.js +214 -61
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +213 -61
- package/dist/botium-es.js.map +1 -1
- package/package.json +3 -1
- package/src/Capabilities.js +2 -1
- package/src/containers/plugins/SimpleRestContainer.js +20 -16
- package/src/grid/inbound/proxy.js +2 -1
- package/src/scripting/Convo.js +16 -10
- package/src/scripting/MatchFunctions.js +10 -0
- package/src/scripting/ScriptingProvider.js +106 -37
- package/src/scripting/logichook/LogicHookConsts.js +1 -1
- package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
- package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
- package/test/compiler/compilercsv.spec.js +104 -3
- package/test/compiler/compilerjson.spec.js +0 -2
- package/test/compiler/compilerxlsx.spec.js +1 -1
- package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
- package/test/connectors/simplerest.spec.js +1012 -969
- package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
- package/test/convo/partialconvo.spec.js +345 -339
- package/test/driver/capabilities.spec.js +156 -151
- package/test/logichooks/hookfromsrc.spec.js +79 -73
- package/test/plugins/plugins.spec.js +44 -42
- package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
- package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
- package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
- package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
- package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
- package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
- package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
- package/test/scripting/asserters/werAsserter.spec.js +51 -0
- package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
- package/test/scripting/matching/matchingmode.spec.js +306 -258
- package/test/scripting/scriptingProvider.spec.js +666 -633
- package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
- package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
- package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
- package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
- package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
- package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
- package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
- package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
- package/test/security/allowUnsafe.spec.js +274 -268
- package/test/utils.spec.js +40 -38
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const assert = require('chai').assert
|
|
3
|
+
const { Convo } = require('../../../src/scripting/Convo')
|
|
4
|
+
const ScriptingProvider = require('../../../src/scripting/ScriptingProvider')
|
|
5
|
+
const DefaultCapabilities = require('../../../src/Defaults').Capabilities
|
|
6
|
+
const Capabilities = require('../../../src/Capabilities')
|
|
7
|
+
|
|
8
|
+
const CAPS = Object.assign({}, DefaultCapabilities, {
|
|
9
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_MODE]: 'index',
|
|
10
|
+
[Capabilities.USER_INPUTS]: [
|
|
11
|
+
{
|
|
12
|
+
ref: 'MEDIA',
|
|
13
|
+
src: 'MediaInput',
|
|
14
|
+
args: {
|
|
15
|
+
downloadMedia: true,
|
|
16
|
+
baseDir: path.join(__dirname, 'files')
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
describe('scripting.utteranceexpansion.associateByIndex', function () {
|
|
23
|
+
it('should associate utterances by index', async function () {
|
|
24
|
+
const scriptingProvider = new ScriptingProvider(CAPS)
|
|
25
|
+
await scriptingProvider.Build()
|
|
26
|
+
// adding more utterances as batch is not working
|
|
27
|
+
scriptingProvider.AddUtterances({
|
|
28
|
+
name: 'UTT_HELLO',
|
|
29
|
+
utterances: ['UTT_HELLO_SAMPLE_1', 'UTT_HELLO_SAMPLE_2', 'UTT_HELLO_SAMPLE_3']
|
|
30
|
+
})
|
|
31
|
+
scriptingProvider.AddUtterances({
|
|
32
|
+
name: 'UTT_BODY',
|
|
33
|
+
utterances: ['UTT_BODY_SAMPLE_1']
|
|
34
|
+
})
|
|
35
|
+
scriptingProvider.AddUtterances({
|
|
36
|
+
name: 'UTT_GOODBYE',
|
|
37
|
+
utterances: ['UTT_GOODBYE_SAMPLE_1', 'UTT_GOODBYE_SAMPLE_2', 'UTT_GOODBYE_SAMPLE_3', 'UTT_GOODBYE_SAMPLE_4', 'UTT_GOODBYE_SAMPLE_5']
|
|
38
|
+
})
|
|
39
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
40
|
+
header: {
|
|
41
|
+
name: 'test convo'
|
|
42
|
+
},
|
|
43
|
+
conversation: [
|
|
44
|
+
{
|
|
45
|
+
sender: 'me',
|
|
46
|
+
messageText: 'UTT_HELLO'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
sender: 'bot',
|
|
50
|
+
messageText: 'hello'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
sender: 'me',
|
|
54
|
+
messageText: 'UTT_BODY'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
sender: 'bot',
|
|
58
|
+
messageText: 'body'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
sender: 'me',
|
|
62
|
+
messageText: 'UTT_GOODBYE'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
sender: 'bot',
|
|
66
|
+
messageText: 'goodbye'
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}))
|
|
70
|
+
scriptingProvider.ExpandConvos()
|
|
71
|
+
|
|
72
|
+
assert.equal(scriptingProvider.convos.length, 5)
|
|
73
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_BODY-L1/UTT_GOODBYE-L1')
|
|
74
|
+
assert.deepEqual(scriptingProvider.convos[0].conversation.length, 6)
|
|
75
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_BODY-L1/UTT_GOODBYE-L2')
|
|
76
|
+
assert.deepEqual(scriptingProvider.convos[1].conversation.length, 6)
|
|
77
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L3')
|
|
78
|
+
assert.deepEqual(scriptingProvider.convos[2].conversation.length, 6)
|
|
79
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L4')
|
|
80
|
+
assert.deepEqual(scriptingProvider.convos[3].conversation.length, 6)
|
|
81
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L5')
|
|
82
|
+
assert.deepEqual(scriptingProvider.convos[4].conversation.length, 6)
|
|
83
|
+
})
|
|
84
|
+
it('should associate media by index', async function () {
|
|
85
|
+
const scriptingProvider = new ScriptingProvider(CAPS)
|
|
86
|
+
await scriptingProvider.Build()
|
|
87
|
+
|
|
88
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
89
|
+
header: {
|
|
90
|
+
name: 'test convo'
|
|
91
|
+
},
|
|
92
|
+
conversation: [
|
|
93
|
+
{
|
|
94
|
+
sender: 'me',
|
|
95
|
+
userInputs: [
|
|
96
|
+
{
|
|
97
|
+
name: 'MEDIA',
|
|
98
|
+
args: [
|
|
99
|
+
'step0*.wav'
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
sender: 'bot',
|
|
106
|
+
messageText: 'hello'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
sender: 'me',
|
|
110
|
+
userInputs: [
|
|
111
|
+
{
|
|
112
|
+
name: 'MEDIA',
|
|
113
|
+
args: [
|
|
114
|
+
'step1*.wav'
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
sender: 'bot',
|
|
121
|
+
messageText: 'ok'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
sender: 'me',
|
|
125
|
+
userInputs: [
|
|
126
|
+
{
|
|
127
|
+
name: 'MEDIA',
|
|
128
|
+
args: [
|
|
129
|
+
'step2*.wav'
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
sender: 'bot',
|
|
136
|
+
messageText: 'goodbye!'
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
}))
|
|
140
|
+
scriptingProvider.ExpandConvos()
|
|
141
|
+
|
|
142
|
+
assert.equal(scriptingProvider.convos.length, 5)
|
|
143
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-L1/MEDIA-L1/MEDIA-L1')
|
|
144
|
+
assert.deepEqual(scriptingProvider.convos[0].conversation.length, 6)
|
|
145
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-L2/MEDIA-L1/MEDIA-L2')
|
|
146
|
+
assert.deepEqual(scriptingProvider.convos[1].conversation.length, 6)
|
|
147
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-L3/MEDIA-L1/MEDIA-L3')
|
|
148
|
+
assert.deepEqual(scriptingProvider.convos[2].conversation.length, 6)
|
|
149
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/MEDIA-L3/MEDIA-L1/MEDIA-L4')
|
|
150
|
+
assert.deepEqual(scriptingProvider.convos[3].conversation.length, 6)
|
|
151
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/MEDIA-L3/MEDIA-L1/MEDIA-L5')
|
|
152
|
+
assert.deepEqual(scriptingProvider.convos[4].conversation.length, 6)
|
|
153
|
+
})
|
|
154
|
+
it('should associate utterance and media by index', async function () {
|
|
155
|
+
const scriptingProvider = new ScriptingProvider(CAPS)
|
|
156
|
+
await scriptingProvider.Build()
|
|
157
|
+
scriptingProvider.AddUtterances({
|
|
158
|
+
name: 'UTT_HELLO',
|
|
159
|
+
utterances: ['UTT_HELLO_SAMPLE_1', 'UTT_HELLO_SAMPLE_2', 'UTT_HELLO_SAMPLE_3']
|
|
160
|
+
})
|
|
161
|
+
scriptingProvider.AddUtterances({
|
|
162
|
+
name: 'UTT_BODY',
|
|
163
|
+
utterances: ['UTT_BODY_SAMPLE_1']
|
|
164
|
+
})
|
|
165
|
+
scriptingProvider.AddUtterances({
|
|
166
|
+
name: 'UTT_GOODBYE',
|
|
167
|
+
utterances: ['UTT_GOODBYE_SAMPLE_1', 'UTT_GOODBYE_SAMPLE_2', 'UTT_GOODBYE_SAMPLE_3', 'UTT_GOODBYE_SAMPLE_4', 'UTT_GOODBYE_SAMPLE_5']
|
|
168
|
+
})
|
|
169
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
170
|
+
header: {
|
|
171
|
+
name: 'test convo'
|
|
172
|
+
},
|
|
173
|
+
conversation: [
|
|
174
|
+
{
|
|
175
|
+
sender: 'me',
|
|
176
|
+
messageText: 'UTT_HELLO'
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
sender: 'bot',
|
|
180
|
+
messageText: 'hello'
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
sender: 'me',
|
|
184
|
+
messageText: 'UTT_BODY'
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
sender: 'bot',
|
|
188
|
+
messageText: 'body'
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
sender: 'me',
|
|
192
|
+
messageText: 'UTT_GOODBYE'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
sender: 'bot',
|
|
196
|
+
messageText: 'goodbye'
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
sender: 'me',
|
|
200
|
+
userInputs: [
|
|
201
|
+
{
|
|
202
|
+
name: 'MEDIA',
|
|
203
|
+
args: [
|
|
204
|
+
'step0*.wav'
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
]
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
sender: 'bot',
|
|
211
|
+
messageText: 'hello'
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
sender: 'me',
|
|
215
|
+
userInputs: [
|
|
216
|
+
{
|
|
217
|
+
name: 'MEDIA',
|
|
218
|
+
args: [
|
|
219
|
+
'step1*.wav'
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
sender: 'bot',
|
|
226
|
+
messageText: 'ok'
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
sender: 'me',
|
|
230
|
+
userInputs: [
|
|
231
|
+
{
|
|
232
|
+
name: 'MEDIA',
|
|
233
|
+
args: [
|
|
234
|
+
'step2*.wav'
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
sender: 'bot',
|
|
241
|
+
messageText: 'goodbye!'
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}))
|
|
245
|
+
scriptingProvider.ExpandConvos()
|
|
246
|
+
|
|
247
|
+
assert.equal(scriptingProvider.convos.length, 5)
|
|
248
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_BODY-L1/UTT_GOODBYE-L1/MEDIA-L1/MEDIA-L1/MEDIA-L1')
|
|
249
|
+
assert.deepEqual(scriptingProvider.convos[0].conversation.length, 12)
|
|
250
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_BODY-L1/UTT_GOODBYE-L2/MEDIA-L2/MEDIA-L1/MEDIA-L2')
|
|
251
|
+
assert.deepEqual(scriptingProvider.convos[1].conversation.length, 12)
|
|
252
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L3/MEDIA-L3/MEDIA-L1/MEDIA-L3')
|
|
253
|
+
assert.deepEqual(scriptingProvider.convos[2].conversation.length, 12)
|
|
254
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L4/MEDIA-L3/MEDIA-L1/MEDIA-L4')
|
|
255
|
+
assert.deepEqual(scriptingProvider.convos[3].conversation.length, 12)
|
|
256
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L5/MEDIA-L3/MEDIA-L1/MEDIA-L5')
|
|
257
|
+
assert.deepEqual(scriptingProvider.convos[4].conversation.length, 12)
|
|
258
|
+
})
|
|
259
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"convos": [
|
|
3
|
+
{
|
|
4
|
+
"name": "goodbye",
|
|
5
|
+
"description": "desc of convo goodbye",
|
|
6
|
+
"steps": [
|
|
7
|
+
{
|
|
8
|
+
"me": "UTT_GREETING"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"bot": "hello"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"me": "UTT_GOODBYE"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"bot": "goodbye"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"utterances": {
|
|
23
|
+
"UTT_GREETING": [
|
|
24
|
+
"hi",
|
|
25
|
+
"hello!",
|
|
26
|
+
"hey!"
|
|
27
|
+
],
|
|
28
|
+
"UTT_GOODBYE": [
|
|
29
|
+
"bye!",
|
|
30
|
+
"goodbye!"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|