botium-core 1.13.0 → 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 +305 -123
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +323 -142
- package/dist/botium-es.js.map +1 -1
- package/package.json +17 -15
- package/src/Capabilities.js +2 -1
- package/src/containers/plugins/SimpleRestContainer.js +23 -16
- package/src/grid/inbound/proxy.js +2 -1
- package/src/helpers/RetryHelper.js +13 -7
- package/src/scripting/Convo.js +36 -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/LogicHookUtils.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/convo/retryconvo.spec.js +134 -0
- 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
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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: '
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
mediaUri: 'test2.jpg'
|
|
84
|
+
mediaUri: 'test.jpg'
|
|
101
85
|
}
|
|
102
86
|
]
|
|
103
87
|
}
|
|
104
88
|
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
189
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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: ['
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
262
|
-
|
|
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: [
|
|
258
|
+
media: []
|
|
268
259
|
}
|
|
269
260
|
})
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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: [
|
|
281
|
+
media: []
|
|
291
282
|
}
|
|
292
283
|
})
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
+
})
|