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.
Files changed (54) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +214 -61
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +213 -61
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +3 -1
  7. package/src/Capabilities.js +2 -1
  8. package/src/containers/plugins/SimpleRestContainer.js +20 -16
  9. package/src/grid/inbound/proxy.js +2 -1
  10. package/src/scripting/Convo.js +16 -10
  11. package/src/scripting/MatchFunctions.js +10 -0
  12. package/src/scripting/ScriptingProvider.js +106 -37
  13. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  14. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  15. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  16. package/test/compiler/compilercsv.spec.js +104 -3
  17. package/test/compiler/compilerjson.spec.js +0 -2
  18. package/test/compiler/compilerxlsx.spec.js +1 -1
  19. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  20. package/test/connectors/simplerest.spec.js +1012 -969
  21. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  22. package/test/convo/partialconvo.spec.js +345 -339
  23. package/test/driver/capabilities.spec.js +156 -151
  24. package/test/logichooks/hookfromsrc.spec.js +79 -73
  25. package/test/plugins/plugins.spec.js +44 -42
  26. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  27. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  28. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  29. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  30. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  31. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  32. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  33. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  34. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  35. package/test/scripting/matching/matchingmode.spec.js +306 -258
  36. package/test/scripting/scriptingProvider.spec.js +666 -633
  37. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  38. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  39. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  40. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  41. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  42. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  43. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  44. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  45. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  46. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  47. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  53. package/test/security/allowUnsafe.spec.js +274 -268
  54. package/test/utils.spec.js +40 -38
@@ -4,149 +4,119 @@ const MediaCountAsserter = require('../../../src/scripting/logichook/asserter/Me
4
4
  const MediaCountRecAsserter = require('../../../src/scripting/logichook/asserter/MediaCountRecAsserter')
5
5
 
6
6
  describe('scripting.asserters.mediaAsserter', function () {
7
- beforeEach(async function () {
8
- this.mediaAsserter = new MediaAsserter({
9
- Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
10
- }, {})
11
- })
12
-
13
- it('should succeed on existing media', async function () {
14
- await this.mediaAsserter.assertConvoStep({
15
- convoStep: { stepTag: 'test' },
16
- args: ['test.jpg'],
17
- botMsg: {
18
- media: [
19
- {
20
- mediaUri: 'test.jpg'
21
- }
22
- ]
23
- }
24
- })
25
- })
26
- it('should succeed on existing card image', async function () {
27
- await this.mediaAsserter.assertConvoStep({
28
- convoStep: { stepTag: 'test' },
29
- args: ['test.jpg'],
30
- botMsg: {
31
- cards: [
32
- {
33
- image: { mediaUri: 'test.jpg' }
34
- }
35
- ]
36
- }
7
+ describe('mediaAsserter', function () {
8
+ beforeEach(async function () {
9
+ this.mediaAsserter = new MediaAsserter({
10
+ Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
11
+ }, {})
37
12
  })
38
- })
39
- it('should succeed on existing card media', async function () {
40
- await this.mediaAsserter.assertConvoStep({
41
- convoStep: { stepTag: 'test' },
42
- args: ['test.jpg', 'test1.jpg'],
43
- botMsg: {
44
- cards: [
45
- {
46
- image: { mediaUri: 'test.jpg' },
47
- media: [
48
- {
49
- mediaUri: 'test1.jpg'
50
- }
51
- ]
52
- }
53
- ]
54
- }
13
+
14
+ it('should succeed on existing media', async function () {
15
+ await this.mediaAsserter.assertConvoStep({
16
+ convoStep: { stepTag: 'test' },
17
+ args: ['test.jpg'],
18
+ botMsg: {
19
+ media: [
20
+ {
21
+ mediaUri: 'test.jpg'
22
+ }
23
+ ]
24
+ }
25
+ })
55
26
  })
56
- })
57
- it('should fail on missing media', async function () {
58
- try {
27
+ it('should succeed on existing card image', async function () {
59
28
  await this.mediaAsserter.assertConvoStep({
60
29
  convoStep: { stepTag: 'test' },
61
30
  args: ['test.jpg'],
62
- botMsg: { }
31
+ botMsg: {
32
+ cards: [
33
+ {
34
+ image: { mediaUri: 'test.jpg' }
35
+ }
36
+ ]
37
+ }
63
38
  })
64
- assert.fail('should have failed')
65
- } catch (err) {
66
- assert.isTrue(err.message.indexOf('Expected media with uri "test.jpg"') > 0)
67
- assert.isNotNull(err.context)
68
- assert.isNotNull(err.context.cause)
69
- assert.isArray(err.context.cause.expected)
70
- assert.isNotTrue(err.context.cause.not)
71
- assert.deepEqual(err.context.cause.expected, ['test.jpg'])
72
- assert.deepEqual(err.context.cause.actual, [])
73
- assert.deepEqual(err.context.cause.diff, ['test.jpg'])
74
- }
75
- })
76
- it('should succeed on not existing media', async function () {
77
- await this.mediaAsserter.assertNotConvoStep({
78
- convoStep: { stepTag: 'test' },
79
- args: ['test1.jpg'],
80
- botMsg: {
81
- media: [
82
- {
83
- mediaUri: 'test.jpg'
84
- }
85
- ]
39
+ })
40
+ it('should succeed on existing card media', async function () {
41
+ await this.mediaAsserter.assertConvoStep({
42
+ convoStep: { stepTag: 'test' },
43
+ args: ['test.jpg', 'test1.jpg'],
44
+ botMsg: {
45
+ cards: [
46
+ {
47
+ image: { mediaUri: 'test.jpg' },
48
+ media: [
49
+ {
50
+ mediaUri: 'test1.jpg'
51
+ }
52
+ ]
53
+ }
54
+ ]
55
+ }
56
+ })
57
+ })
58
+ it('should fail on missing media', async function () {
59
+ try {
60
+ await this.mediaAsserter.assertConvoStep({
61
+ convoStep: { stepTag: 'test' },
62
+ args: ['test.jpg'],
63
+ botMsg: { }
64
+ })
65
+ assert.fail('should have failed')
66
+ } catch (err) {
67
+ assert.isTrue(err.message.indexOf('Expected media with uri "test.jpg"') > 0)
68
+ assert.isNotNull(err.context)
69
+ assert.isNotNull(err.context.cause)
70
+ assert.isArray(err.context.cause.expected)
71
+ assert.isNotTrue(err.context.cause.not)
72
+ assert.deepEqual(err.context.cause.expected, ['test.jpg'])
73
+ assert.deepEqual(err.context.cause.actual, [])
74
+ assert.deepEqual(err.context.cause.diff, ['test.jpg'])
86
75
  }
87
76
  })
88
- })
89
- it('should fail on unexpected media', async function () {
90
- try {
77
+ it('should succeed on not existing media', async function () {
91
78
  await this.mediaAsserter.assertNotConvoStep({
92
79
  convoStep: { stepTag: 'test' },
93
80
  args: ['test1.jpg'],
94
81
  botMsg: {
95
82
  media: [
96
83
  {
97
- mediaUri: 'test1.jpg'
98
- },
99
- {
100
- mediaUri: 'test2.jpg'
84
+ mediaUri: 'test.jpg'
101
85
  }
102
86
  ]
103
87
  }
104
88
  })
105
- assert.fail('should have failed')
106
- } catch (err) {
107
- assert.isTrue(err.message.indexOf('Not expected media with uri "test1.jpg"') > 0)
108
- assert.isNotNull(err.context)
109
- assert.isNotNull(err.context.cause)
110
- assert.isArray(err.context.cause.expected)
111
- assert.isTrue(err.context.cause.not)
112
- assert.deepEqual(err.context.cause.expected, ['test1.jpg'])
113
- assert.deepEqual(err.context.cause.actual, ['test1.jpg', 'test2.jpg'])
114
- assert.deepEqual(err.context.cause.diff, ['test1.jpg'])
115
- }
116
- })
117
- it('should succeed on existing media if has no arg', async function () {
118
- await this.mediaAsserter.assertConvoStep({
119
- convoStep: { stepTag: 'test' },
120
- args: [],
121
- botMsg: {
122
- media: [
123
- {
124
- mediaUri: 'test'
89
+ })
90
+ it('should fail on unexpected media', async function () {
91
+ try {
92
+ await this.mediaAsserter.assertNotConvoStep({
93
+ convoStep: { stepTag: 'test' },
94
+ args: ['test1.jpg'],
95
+ botMsg: {
96
+ media: [
97
+ {
98
+ mediaUri: 'test1.jpg'
99
+ },
100
+ {
101
+ mediaUri: 'test2.jpg'
102
+ }
103
+ ]
125
104
  }
126
- ]
105
+ })
106
+ assert.fail('should have failed')
107
+ } catch (err) {
108
+ assert.isTrue(err.message.indexOf('Not expected media with uri "test1.jpg"') > 0)
109
+ assert.isNotNull(err.context)
110
+ assert.isNotNull(err.context.cause)
111
+ assert.isArray(err.context.cause.expected)
112
+ assert.isTrue(err.context.cause.not)
113
+ assert.deepEqual(err.context.cause.expected, ['test1.jpg'])
114
+ assert.deepEqual(err.context.cause.actual, ['test1.jpg', 'test2.jpg'])
115
+ assert.deepEqual(err.context.cause.diff, ['test1.jpg'])
127
116
  }
128
117
  })
129
- })
130
- it('should fail on no media if has no arg', async function () {
131
- try {
132
- await this.mediaAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
133
- assert.fail('should have failed')
134
- } catch (err) {
135
- assert.isTrue(err.message.indexOf('Expected some media') > 0)
136
- assert.isNotNull(err.context)
137
- assert.isNotNull(err.context.cause)
138
- assert.isArray(err.context.cause.expected)
139
- assert.isNotTrue(err.context.cause.not)
140
- assert.deepEqual(err.context.cause.expected, [])
141
- assert.deepEqual(err.context.cause.actual, [])
142
- }
143
- })
144
- it('should succeed on not existing media if has no arg and negated', async function () {
145
- await this.mediaAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
146
- })
147
- it('should fail on media if has no arg and negated', async function () {
148
- try {
149
- await this.mediaAsserter.assertNotConvoStep({
118
+ it('should succeed on existing media if has no arg', async function () {
119
+ await this.mediaAsserter.assertConvoStep({
150
120
  convoStep: { stepTag: 'test' },
151
121
  args: [],
152
122
  botMsg: {
@@ -157,155 +127,187 @@ describe('scripting.asserters.mediaAsserter', function () {
157
127
  ]
158
128
  }
159
129
  })
160
- assert.fail('should have failed')
161
- } catch (err) {
162
- assert.isTrue(err.message.indexOf('Not expected media with uri "test"') > 0)
163
- assert.isNotNull(err.context)
164
- assert.isNotNull(err.context.cause)
165
- assert.isArray(err.context.cause.expected)
166
- assert.isTrue(err.context.cause.not)
167
- assert.deepEqual(err.context.cause.expected, [])
168
- assert.deepEqual(err.context.cause.actual, ['test'])
169
- }
170
- })
171
- })
172
-
173
- describe('scripting.asserters.mediaCountAsserter', function () {
174
- beforeEach(async function () {
175
- this.mediaCountAsserter = new MediaCountAsserter({}, {})
176
- this.mediaCountRecAsserter = new MediaCountRecAsserter({}, {})
177
- })
178
-
179
- it('should succeed on no args with one media', async function () {
180
- await this.mediaCountAsserter.assertConvoStep({
181
- convoStep: { stepTag: 'test' },
182
- args: [],
183
- botMsg: {
184
- media: [{ mediaUri: 'test.jpg' }]
130
+ })
131
+ it('should fail on no media if has no arg', async function () {
132
+ try {
133
+ await this.mediaAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
134
+ assert.fail('should have failed')
135
+ } catch (err) {
136
+ assert.isTrue(err.message.indexOf('Expected some media') > 0)
137
+ assert.isNotNull(err.context)
138
+ assert.isNotNull(err.context.cause)
139
+ assert.isArray(err.context.cause.expected)
140
+ assert.isNotTrue(err.context.cause.not)
141
+ assert.deepEqual(err.context.cause.expected, [])
142
+ assert.deepEqual(err.context.cause.actual, [])
143
+ }
144
+ })
145
+ it('should succeed on not existing media if has no arg and negated', async function () {
146
+ await this.mediaAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
147
+ })
148
+ it('should fail on media if has no arg and negated', async function () {
149
+ try {
150
+ await this.mediaAsserter.assertNotConvoStep({
151
+ convoStep: { stepTag: 'test' },
152
+ args: [],
153
+ botMsg: {
154
+ media: [
155
+ {
156
+ mediaUri: 'test'
157
+ }
158
+ ]
159
+ }
160
+ })
161
+ assert.fail('should have failed')
162
+ } catch (err) {
163
+ assert.isTrue(err.message.indexOf('Not expected media with uri "test"') > 0)
164
+ assert.isNotNull(err.context)
165
+ assert.isNotNull(err.context.cause)
166
+ assert.isArray(err.context.cause.expected)
167
+ assert.isTrue(err.context.cause.not)
168
+ assert.deepEqual(err.context.cause.expected, [])
169
+ assert.deepEqual(err.context.cause.actual, ['test'])
185
170
  }
186
171
  })
187
172
  })
188
- it('should fail on no args with no media', async function () {
189
- try {
173
+
174
+ describe('mediaCountAsserter', function () {
175
+ beforeEach(async function () {
176
+ this.mediaCountAsserter = new MediaCountAsserter({}, {})
177
+ this.mediaCountRecAsserter = new MediaCountRecAsserter({}, {})
178
+ })
179
+
180
+ it('should succeed on no args with one media', async function () {
190
181
  await this.mediaCountAsserter.assertConvoStep({
191
182
  convoStep: { stepTag: 'test' },
192
183
  args: [],
193
184
  botMsg: {
194
- media: []
185
+ media: [{ mediaUri: 'test.jpg' }]
195
186
  }
196
187
  })
197
- assert.fail('should have failed')
198
- } catch (err) {
199
- assert.isTrue(err.message.indexOf('Expected Media count 0 to be >0') >= 0)
200
- }
201
- })
202
- it('should succeed on >=0 with one media', async function () {
203
- await this.mediaCountAsserter.assertConvoStep({
204
- convoStep: { stepTag: 'test' },
205
- args: ['>=0'],
206
- botMsg: {
207
- media: [{ mediaUri: 'test.jpg' }]
208
- }
209
188
  })
210
- })
211
- it('should succeed on >0 with one media', async function () {
212
- await this.mediaCountAsserter.assertConvoStep({
213
- convoStep: { stepTag: 'test' },
214
- args: ['>0'],
215
- botMsg: {
216
- media: [{ mediaUri: 'test.jpg' }]
189
+ it('should fail on no args with no media', async function () {
190
+ try {
191
+ await this.mediaCountAsserter.assertConvoStep({
192
+ convoStep: { stepTag: 'test' },
193
+ args: [],
194
+ botMsg: {
195
+ media: []
196
+ }
197
+ })
198
+ assert.fail('should have failed')
199
+ } catch (err) {
200
+ assert.isTrue(err.message.indexOf('Expected Media count 0 to be >0') >= 0)
217
201
  }
218
202
  })
219
- })
220
- it('should fail on >1 with one media', async function () {
221
- try {
203
+ it('should succeed on >=0 with one media', async function () {
222
204
  await this.mediaCountAsserter.assertConvoStep({
223
205
  convoStep: { stepTag: 'test' },
224
- args: ['>1'],
206
+ args: ['>=0'],
225
207
  botMsg: {
226
208
  media: [{ mediaUri: 'test.jpg' }]
227
209
  }
228
210
  })
229
- assert.fail('should have failed')
230
- } catch (err) {
231
- assert.isTrue(err.message.indexOf('Expected Media count 1 to be >1') >= 0)
232
- }
233
- })
234
- it('should succeed on <=1 with one media', async function () {
235
- await this.mediaCountAsserter.assertConvoStep({
236
- convoStep: { stepTag: 'test' },
237
- args: ['<=1'],
238
- botMsg: {
239
- media: [{ mediaUri: 'test.jpg' }]
240
- }
241
211
  })
242
- })
243
- it('should succeed on <2 with one media', async function () {
244
- await this.mediaCountAsserter.assertConvoStep({
245
- convoStep: { stepTag: 'test' },
246
- args: ['<2'],
247
- botMsg: {
248
- media: [{ mediaUri: 'test.jpg' }]
249
- }
212
+ it('should succeed on >0 with one media', async function () {
213
+ await this.mediaCountAsserter.assertConvoStep({
214
+ convoStep: { stepTag: 'test' },
215
+ args: ['>0'],
216
+ botMsg: {
217
+ media: [{ mediaUri: 'test.jpg' }]
218
+ }
219
+ })
250
220
  })
251
- })
252
- it('should succeed on no args with ! no media', async function () {
253
- await this.mediaCountAsserter.assertNotConvoStep({
254
- convoStep: { stepTag: 'test' },
255
- args: [],
256
- botMsg: {
257
- media: []
221
+ it('should fail on >1 with one media', async function () {
222
+ try {
223
+ await this.mediaCountAsserter.assertConvoStep({
224
+ convoStep: { stepTag: 'test' },
225
+ args: ['>1'],
226
+ botMsg: {
227
+ media: [{ mediaUri: 'test.jpg' }]
228
+ }
229
+ })
230
+ assert.fail('should have failed')
231
+ } catch (err) {
232
+ assert.isTrue(err.message.indexOf('Expected Media count 1 to be >1') >= 0)
258
233
  }
259
234
  })
260
- })
261
- it('should fail on one args with ! one media', async function () {
262
- try {
235
+ it('should succeed on <=1 with one media', async function () {
236
+ await this.mediaCountAsserter.assertConvoStep({
237
+ convoStep: { stepTag: 'test' },
238
+ args: ['<=1'],
239
+ botMsg: {
240
+ media: [{ mediaUri: 'test.jpg' }]
241
+ }
242
+ })
243
+ })
244
+ it('should succeed on <2 with one media', async function () {
245
+ await this.mediaCountAsserter.assertConvoStep({
246
+ convoStep: { stepTag: 'test' },
247
+ args: ['<2'],
248
+ botMsg: {
249
+ media: [{ mediaUri: 'test.jpg' }]
250
+ }
251
+ })
252
+ })
253
+ it('should succeed on no args with ! no media', async function () {
263
254
  await this.mediaCountAsserter.assertNotConvoStep({
264
255
  convoStep: { stepTag: 'test' },
265
256
  args: [],
266
257
  botMsg: {
267
- media: [{ mediaUri: 'test.jpg' }]
258
+ media: []
268
259
  }
269
260
  })
270
- assert.fail('should have failed')
271
- } catch (err) {
272
- assert.isTrue(err.message.indexOf('Not expected Media count 1 to be >0') >= 0)
273
- }
274
- })
275
- it('should succeed on >1 with ! no media', async function () {
276
- await this.mediaCountAsserter.assertNotConvoStep({
277
- convoStep: { stepTag: 'test' },
278
- args: ['>1'],
279
- botMsg: {
280
- media: []
261
+ })
262
+ it('should fail on one args with ! one media', async function () {
263
+ try {
264
+ await this.mediaCountAsserter.assertNotConvoStep({
265
+ convoStep: { stepTag: 'test' },
266
+ args: [],
267
+ botMsg: {
268
+ media: [{ mediaUri: 'test.jpg' }]
269
+ }
270
+ })
271
+ assert.fail('should have failed')
272
+ } catch (err) {
273
+ assert.isTrue(err.message.indexOf('Not expected Media count 1 to be >0') >= 0)
281
274
  }
282
275
  })
283
- })
284
- it('should fail on >1 with ! two media', async function () {
285
- try {
276
+ it('should succeed on >1 with ! no media', async function () {
286
277
  await this.mediaCountAsserter.assertNotConvoStep({
287
278
  convoStep: { stepTag: 'test' },
288
279
  args: ['>1'],
289
280
  botMsg: {
290
- media: [{ mediaUri: 'test.jpg' }, { mediaUri: 'test.jpg' }]
281
+ media: []
291
282
  }
292
283
  })
293
- assert.fail('should have failed')
294
- } catch (err) {
295
- assert.isTrue(err.message.indexOf('Not expected Media count 2 to be >1') >= 0)
296
- }
297
- })
298
- it('should succeed on >3 with rec media', async function () {
299
- await this.mediaCountRecAsserter.assertConvoStep({
300
- convoStep: { stepTag: 'test' },
301
- args: ['>3'],
302
- botMsg: {
303
- media: [{ mediaUri: 'test.jpg' }],
304
- cards: [
305
- { image: { mediaUri: 'test.jpg ' } },
306
- { media: [{ mediaUri: 'test.jpg' }, { mediaUri: 'test.jpg' }] }
307
- ]
284
+ })
285
+ it('should fail on >1 with ! two media', async function () {
286
+ try {
287
+ await this.mediaCountAsserter.assertNotConvoStep({
288
+ convoStep: { stepTag: 'test' },
289
+ args: ['>1'],
290
+ botMsg: {
291
+ media: [{ mediaUri: 'test.jpg' }, { mediaUri: 'test.jpg' }]
292
+ }
293
+ })
294
+ assert.fail('should have failed')
295
+ } catch (err) {
296
+ assert.isTrue(err.message.indexOf('Not expected Media count 2 to be >1') >= 0)
308
297
  }
309
298
  })
299
+ it('should succeed on >3 with rec media', async function () {
300
+ await this.mediaCountRecAsserter.assertConvoStep({
301
+ convoStep: { stepTag: 'test' },
302
+ args: ['>3'],
303
+ botMsg: {
304
+ media: [{ mediaUri: 'test.jpg' }],
305
+ cards: [
306
+ { image: { mediaUri: 'test.jpg ' } },
307
+ { media: [{ mediaUri: 'test.jpg' }, { mediaUri: 'test.jpg' }] }
308
+ ]
309
+ }
310
+ })
311
+ })
310
312
  })
311
313
  })
@@ -0,0 +1,51 @@
1
+ const assert = require('chai').assert
2
+ const path = require('path')
3
+
4
+ const BotDriver = require('../../..').BotDriver
5
+ const Capabilities = require('../../..').Capabilities
6
+
7
+ const echoConnector = ({ queueBotSays }) => {
8
+ return {
9
+ UserSays (msg) {
10
+ const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
11
+ queueBotSays(botMsg)
12
+ }
13
+ }
14
+ }
15
+
16
+ describe('scripting.asserters.werAsserter', function () {
17
+ beforeEach(async function () {
18
+ const myCaps = {
19
+ [Capabilities.PROJECTNAME]: 'scripting.asserters.werAsserter',
20
+ [Capabilities.CONTAINERMODE]: echoConnector
21
+ }
22
+ const driver = new BotDriver(myCaps)
23
+ this.compiler = driver.BuildCompiler()
24
+ this.container = await driver.Build()
25
+ })
26
+ afterEach(async function () {
27
+ this.container && await this.container.Clean()
28
+ })
29
+
30
+ it('ok', async function () {
31
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_ok.yml'))
32
+
33
+ this.compiler.ExpandScriptingMemoryToConvos()
34
+ assert.equal(this.compiler.convos.length, 1)
35
+ await this.compiler.convos[0].Run(this.container)
36
+ })
37
+
38
+ it('nok', async function () {
39
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_nok.yml'))
40
+
41
+ this.compiler.ExpandScriptingMemoryToConvos()
42
+ assert.equal(this.compiler.convos.length, 1)
43
+
44
+ try {
45
+ await this.compiler.convos[0].Run(this.container)
46
+ assert.fail('expected error')
47
+ } catch (err) {
48
+ assert.equal(err.message, 'wer_threshold_nok/Line 2: assertion error - Line 2: Word error rate 0.5 > 0.1 for tast 123')
49
+ }
50
+ })
51
+ })