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
|
@@ -4,104 +4,91 @@ const ButtonsCountAsserter = require('../../../src/scripting/logichook/asserter/
|
|
|
4
4
|
const ButtonsCountRecAsserter = require('../../../src/scripting/logichook/asserter/ButtonsCountRecAsserter')
|
|
5
5
|
|
|
6
6
|
describe('scripting.asserters.buttonsAsserter', function () {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
it('should succeed on existing button', async function () {
|
|
14
|
-
await this.buttonsAsserter.assertConvoStep({
|
|
15
|
-
convoStep: { stepTag: 'test' },
|
|
16
|
-
args: ['test'],
|
|
17
|
-
botMsg: {
|
|
18
|
-
buttons: [
|
|
19
|
-
{
|
|
20
|
-
text: 'test'
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
7
|
+
describe('buttonsAsserter', function () {
|
|
8
|
+
beforeEach(async function () {
|
|
9
|
+
this.buttonsAsserter = new ButtonsAsserter({
|
|
10
|
+
Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
|
|
11
|
+
}, {})
|
|
24
12
|
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
}
|
|
13
|
+
|
|
14
|
+
it('should succeed on existing button', async function () {
|
|
15
|
+
await this.buttonsAsserter.assertConvoStep({
|
|
16
|
+
convoStep: { stepTag: 'test' },
|
|
17
|
+
args: ['test'],
|
|
18
|
+
botMsg: {
|
|
19
|
+
buttons: [
|
|
20
|
+
{
|
|
21
|
+
text: 'test'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
})
|
|
41
26
|
})
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
27
|
+
it('should succeed on existing card button', async function () {
|
|
28
|
+
await this.buttonsAsserter.assertConvoStep({
|
|
29
|
+
convoStep: { stepTag: 'test' },
|
|
30
|
+
args: ['test'],
|
|
31
|
+
botMsg: {
|
|
32
|
+
cards: [
|
|
33
|
+
{
|
|
34
|
+
buttons: [
|
|
35
|
+
{
|
|
36
|
+
text: 'test'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
})
|
|
63
43
|
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
44
|
+
it('should succeed on existing card buttons', async function () {
|
|
45
|
+
await this.buttonsAsserter.assertConvoStep({
|
|
46
|
+
convoStep: { stepTag: 'test' },
|
|
47
|
+
args: ['test', 'test1'],
|
|
48
|
+
botMsg: {
|
|
49
|
+
buttons: [
|
|
50
|
+
{
|
|
51
|
+
text: 'test'
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
cards: [
|
|
55
|
+
{
|
|
56
|
+
buttons: [
|
|
57
|
+
{
|
|
58
|
+
text: 'test1'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
})
|
|
85
65
|
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
66
|
+
it('should succeed on existing card buttons 2', async function () {
|
|
67
|
+
await this.buttonsAsserter.assertConvoStep({
|
|
68
|
+
convoStep: { stepTag: 'test' },
|
|
69
|
+
args: ['test', 'test1'],
|
|
70
|
+
botMsg: {
|
|
71
|
+
buttons: [
|
|
72
|
+
{
|
|
73
|
+
text: 'test'
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
cards: [
|
|
77
|
+
{
|
|
78
|
+
buttons: [
|
|
79
|
+
{
|
|
80
|
+
text: 'test1'
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
})
|
|
98
87
|
})
|
|
99
|
-
|
|
100
|
-
it('should fail on unexpected button', async function () {
|
|
101
|
-
try {
|
|
88
|
+
it('should succeed on not existing button', async function () {
|
|
102
89
|
await this.buttonsAsserter.assertNotConvoStep({
|
|
103
90
|
convoStep: { stepTag: 'test' },
|
|
104
|
-
args: ['
|
|
91
|
+
args: ['test1'],
|
|
105
92
|
botMsg: {
|
|
106
93
|
buttons: [
|
|
107
94
|
{
|
|
@@ -110,51 +97,34 @@ describe('scripting.asserters.buttonsAsserter', function () {
|
|
|
110
97
|
]
|
|
111
98
|
}
|
|
112
99
|
})
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
it('should succeed on existing button if has no arg', async function () {
|
|
126
|
-
await this.buttonsAsserter.assertConvoStep({
|
|
127
|
-
convoStep: { stepTag: 'test' },
|
|
128
|
-
args: [],
|
|
129
|
-
botMsg: {
|
|
130
|
-
buttons: [
|
|
131
|
-
{
|
|
132
|
-
text: 'test'
|
|
100
|
+
})
|
|
101
|
+
it('should fail on unexpected button', async function () {
|
|
102
|
+
try {
|
|
103
|
+
await this.buttonsAsserter.assertNotConvoStep({
|
|
104
|
+
convoStep: { stepTag: 'test' },
|
|
105
|
+
args: ['test', 'test1'],
|
|
106
|
+
botMsg: {
|
|
107
|
+
buttons: [
|
|
108
|
+
{
|
|
109
|
+
text: 'test'
|
|
110
|
+
}
|
|
111
|
+
]
|
|
133
112
|
}
|
|
134
|
-
|
|
113
|
+
})
|
|
114
|
+
assert.fail('should have failed')
|
|
115
|
+
} catch (err) {
|
|
116
|
+
assert.isTrue(err.message.indexOf('Not expected button(s) with text "test"') > 0)
|
|
117
|
+
assert.isNotNull(err.context)
|
|
118
|
+
assert.isNotNull(err.context.cause)
|
|
119
|
+
assert.isArray(err.context.cause.expected)
|
|
120
|
+
assert.isTrue(err.context.cause.not)
|
|
121
|
+
assert.deepEqual(err.context.cause.expected, ['test', 'test1'])
|
|
122
|
+
assert.deepEqual(err.context.cause.actual, ['test'])
|
|
123
|
+
assert.deepEqual(err.context.cause.diff, ['test'])
|
|
135
124
|
}
|
|
136
125
|
})
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
await this.buttonsAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
|
|
141
|
-
assert.fail('should have failed')
|
|
142
|
-
} catch (err) {
|
|
143
|
-
assert.isTrue(err.message.indexOf('Expected some button(s)') > 0)
|
|
144
|
-
assert.isNotNull(err.context)
|
|
145
|
-
assert.isNotNull(err.context.cause)
|
|
146
|
-
assert.isArray(err.context.cause.expected)
|
|
147
|
-
assert.isNotTrue(err.context.cause.not)
|
|
148
|
-
assert.deepEqual(err.context.cause.expected, [])
|
|
149
|
-
assert.deepEqual(err.context.cause.actual, [])
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
it('should succeed on not existing button if has no arg and negated', async function () {
|
|
153
|
-
await this.buttonsAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
|
|
154
|
-
})
|
|
155
|
-
it('should fail on button if has no arg and negated', async function () {
|
|
156
|
-
try {
|
|
157
|
-
await this.buttonsAsserter.assertNotConvoStep({
|
|
126
|
+
it('should succeed on existing button if has no arg', async function () {
|
|
127
|
+
await this.buttonsAsserter.assertConvoStep({
|
|
158
128
|
convoStep: { stepTag: 'test' },
|
|
159
129
|
args: [],
|
|
160
130
|
botMsg: {
|
|
@@ -165,131 +135,162 @@ describe('scripting.asserters.buttonsAsserter', function () {
|
|
|
165
135
|
]
|
|
166
136
|
}
|
|
167
137
|
})
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
beforeEach(async function () {
|
|
182
|
-
this.buttonsCountAsserter = new ButtonsCountAsserter({}, {})
|
|
183
|
-
this.buttonsCountRecAsserter = new ButtonsCountRecAsserter({}, {})
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
it('should succeed on no args with one button', async function () {
|
|
187
|
-
await this.buttonsCountAsserter.assertConvoStep({
|
|
188
|
-
convoStep: { stepTag: 'test' },
|
|
189
|
-
args: [],
|
|
190
|
-
botMsg: {
|
|
191
|
-
buttons: [{ text: 'test.jpg' }]
|
|
138
|
+
})
|
|
139
|
+
it('should fail on no button if has no arg', async function () {
|
|
140
|
+
try {
|
|
141
|
+
await this.buttonsAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
|
|
142
|
+
assert.fail('should have failed')
|
|
143
|
+
} catch (err) {
|
|
144
|
+
assert.isTrue(err.message.indexOf('Expected some button(s)') > 0)
|
|
145
|
+
assert.isNotNull(err.context)
|
|
146
|
+
assert.isNotNull(err.context.cause)
|
|
147
|
+
assert.isArray(err.context.cause.expected)
|
|
148
|
+
assert.isNotTrue(err.context.cause.not)
|
|
149
|
+
assert.deepEqual(err.context.cause.expected, [])
|
|
150
|
+
assert.deepEqual(err.context.cause.actual, [])
|
|
192
151
|
}
|
|
193
152
|
})
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
153
|
+
it('should succeed on not existing button if has no arg and negated', async function () {
|
|
154
|
+
await this.buttonsAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
|
|
155
|
+
})
|
|
156
|
+
it('should fail on button if has no arg and negated', async function () {
|
|
157
|
+
try {
|
|
158
|
+
await this.buttonsAsserter.assertNotConvoStep({
|
|
159
|
+
convoStep: { stepTag: 'test' },
|
|
160
|
+
args: [],
|
|
161
|
+
botMsg: {
|
|
162
|
+
buttons: [
|
|
163
|
+
{
|
|
164
|
+
text: 'test'
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
assert.fail('should have failed')
|
|
170
|
+
} catch (err) {
|
|
171
|
+
assert.isTrue(err.message.indexOf('Not expected button(s) with text "test"') > 0)
|
|
172
|
+
assert.isNotNull(err.context)
|
|
173
|
+
assert.isNotNull(err.context.cause)
|
|
174
|
+
assert.isArray(err.context.cause.expected)
|
|
175
|
+
assert.isTrue(err.context.cause.not)
|
|
176
|
+
assert.deepEqual(err.context.cause.expected, [])
|
|
177
|
+
assert.deepEqual(err.context.cause.actual, ['test'])
|
|
204
178
|
}
|
|
205
179
|
})
|
|
206
180
|
})
|
|
207
|
-
|
|
208
|
-
|
|
181
|
+
describe('buttonsCountAsserter', function () {
|
|
182
|
+
beforeEach(async function () {
|
|
183
|
+
this.buttonsCountAsserter = new ButtonsCountAsserter({}, {})
|
|
184
|
+
this.buttonsCountRecAsserter = new ButtonsCountRecAsserter({}, {})
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('should succeed on no args with one button', async function () {
|
|
209
188
|
await this.buttonsCountAsserter.assertConvoStep({
|
|
210
189
|
convoStep: { stepTag: 'test' },
|
|
211
|
-
args: [
|
|
190
|
+
args: [],
|
|
212
191
|
botMsg: {
|
|
213
|
-
buttons: [{ text: 'test.jpg' }
|
|
214
|
-
cards: [
|
|
215
|
-
{ buttons: [{ text: 'test.jpg' }], cards: [{ buttons: [{ text: 'test.jpg' }] }] }
|
|
216
|
-
]
|
|
192
|
+
buttons: [{ text: 'test.jpg' }]
|
|
217
193
|
}
|
|
218
194
|
})
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
assert.isTrue(err.message.indexOf('Expected Buttons count 4 to be 3') >= 0)
|
|
222
|
-
}
|
|
223
|
-
})
|
|
224
|
-
it('should fail on >3 with 3 buttons', async function () {
|
|
225
|
-
try {
|
|
195
|
+
})
|
|
196
|
+
it('should succeed on 3 with 3 buttons', async function () {
|
|
226
197
|
await this.buttonsCountAsserter.assertConvoStep({
|
|
227
198
|
convoStep: { stepTag: 'test' },
|
|
228
|
-
args: ['
|
|
199
|
+
args: ['3'],
|
|
229
200
|
botMsg: {
|
|
230
201
|
buttons: [{ text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }],
|
|
231
202
|
cards: [
|
|
232
|
-
{
|
|
203
|
+
{
|
|
204
|
+
buttons: [{ text: 'test.jpg' }],
|
|
205
|
+
cards: [{ buttons: [{ text: 'test.jpg' }] }]
|
|
206
|
+
}
|
|
233
207
|
]
|
|
234
208
|
}
|
|
235
209
|
})
|
|
236
|
-
assert.fail('should have failed')
|
|
237
|
-
} catch (err) {
|
|
238
|
-
assert.isTrue(err.message.indexOf('Expected Buttons count 3 to be >3') >= 0)
|
|
239
|
-
}
|
|
240
|
-
})
|
|
241
|
-
it('should succeed on >=3 with rec buttons', async function () {
|
|
242
|
-
await this.buttonsCountRecAsserter.assertConvoStep({
|
|
243
|
-
convoStep: { stepTag: 'test' },
|
|
244
|
-
args: ['>=3'],
|
|
245
|
-
botMsg: {
|
|
246
|
-
buttons: [{ text: 'test.jpg' }],
|
|
247
|
-
cards: [
|
|
248
|
-
{ buttons: [{ text: 'test.jpg' }], cards: [{ buttons: [{ text: 'test.jpg' }] }] }
|
|
249
|
-
]
|
|
250
|
-
}
|
|
251
210
|
})
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
211
|
+
it('should fail on 3 with 4 buttons', async function () {
|
|
212
|
+
try {
|
|
213
|
+
await this.buttonsCountAsserter.assertConvoStep({
|
|
214
|
+
convoStep: { stepTag: 'test' },
|
|
215
|
+
args: ['3'],
|
|
216
|
+
botMsg: {
|
|
217
|
+
buttons: [{ text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }],
|
|
218
|
+
cards: [
|
|
219
|
+
{
|
|
220
|
+
buttons: [{ text: 'test.jpg' }],
|
|
221
|
+
cards: [{ buttons: [{ text: 'test.jpg' }] }]
|
|
222
|
+
}
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
assert.fail('should have failed')
|
|
227
|
+
} catch (err) {
|
|
228
|
+
assert.isTrue(err.message.indexOf('Expected Buttons count 4 to be 3') >= 0)
|
|
262
229
|
}
|
|
263
230
|
})
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
args: ['Test Html header test html text'],
|
|
278
|
-
botMsg: {
|
|
279
|
-
buttons: [
|
|
280
|
-
{
|
|
281
|
-
text: '<html><h1>test html header</h1><p>test html text</p>'
|
|
231
|
+
it('should fail on >3 with 3 buttons', async function () {
|
|
232
|
+
try {
|
|
233
|
+
await this.buttonsCountAsserter.assertConvoStep({
|
|
234
|
+
convoStep: { stepTag: 'test' },
|
|
235
|
+
args: ['>3'],
|
|
236
|
+
botMsg: {
|
|
237
|
+
buttons: [{ text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }],
|
|
238
|
+
cards: [
|
|
239
|
+
{
|
|
240
|
+
buttons: [{ text: 'test.jpg' }],
|
|
241
|
+
cards: [{ buttons: [{ text: 'test.jpg' }] }]
|
|
242
|
+
}
|
|
243
|
+
]
|
|
282
244
|
}
|
|
283
|
-
|
|
245
|
+
})
|
|
246
|
+
assert.fail('should have failed')
|
|
247
|
+
} catch (err) {
|
|
248
|
+
assert.isTrue(err.message.indexOf('Expected Buttons count 3 to be >3') >= 0)
|
|
284
249
|
}
|
|
285
250
|
})
|
|
251
|
+
it('should succeed on >=3 with rec buttons', async function () {
|
|
252
|
+
await this.buttonsCountRecAsserter.assertConvoStep({
|
|
253
|
+
convoStep: { stepTag: 'test' },
|
|
254
|
+
args: ['>=3'],
|
|
255
|
+
botMsg: {
|
|
256
|
+
buttons: [{ text: 'test.jpg' }],
|
|
257
|
+
cards: [
|
|
258
|
+
{
|
|
259
|
+
buttons: [{ text: 'test.jpg' }],
|
|
260
|
+
cards: [{ buttons: [{ text: 'test.jpg' }] }]
|
|
261
|
+
}
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
})
|
|
266
|
+
it('should succeed on 3 with rec buttons', async function () {
|
|
267
|
+
await this.buttonsCountRecAsserter.assertConvoStep({
|
|
268
|
+
convoStep: { stepTag: 'test' },
|
|
269
|
+
args: ['3'],
|
|
270
|
+
botMsg: {
|
|
271
|
+
buttons: [{ text: 'test.jpg' }],
|
|
272
|
+
cards: [
|
|
273
|
+
{
|
|
274
|
+
buttons: [{ text: 'test.jpg' }],
|
|
275
|
+
cards: [{ buttons: [{ text: 'test.jpg' }] }]
|
|
276
|
+
}
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
})
|
|
280
|
+
})
|
|
286
281
|
})
|
|
287
282
|
|
|
288
|
-
|
|
289
|
-
|
|
283
|
+
describe('buttonsNormalizeAsserter', function () {
|
|
284
|
+
beforeEach(async function () {
|
|
285
|
+
this.cardsAsserter = new ButtonsAsserter({
|
|
286
|
+
Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
|
|
287
|
+
}, { SCRIPTING_NORMALIZE_TEXT: true })
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
it('should succeed with normalized text', async function () {
|
|
290
291
|
await this.cardsAsserter.assertConvoStep({
|
|
291
292
|
convoStep: { stepTag: 'test' },
|
|
292
|
-
args: ['Test Html
|
|
293
|
+
args: ['Test Html header test html text'],
|
|
293
294
|
botMsg: {
|
|
294
295
|
buttons: [
|
|
295
296
|
{
|
|
@@ -298,15 +299,31 @@ describe('scripting.asserters.buttonsNormalizeAsserter', function () {
|
|
|
298
299
|
]
|
|
299
300
|
}
|
|
300
301
|
})
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
it('should fail with normalized text', async function () {
|
|
305
|
+
try {
|
|
306
|
+
await this.cardsAsserter.assertConvoStep({
|
|
307
|
+
convoStep: { stepTag: 'test' },
|
|
308
|
+
args: ['Test Html header1 test html text'],
|
|
309
|
+
botMsg: {
|
|
310
|
+
buttons: [
|
|
311
|
+
{
|
|
312
|
+
text: '<html><h1>test html header</h1><p>test html text</p>'
|
|
313
|
+
}
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
assert.fail('should have failed')
|
|
318
|
+
} catch (err) {
|
|
319
|
+
assert.isTrue(err.message.indexOf('Expected button(s) with text "Test Html header1 test html text"') > 0)
|
|
320
|
+
assert.isNotNull(err.context)
|
|
321
|
+
assert.isNotNull(err.context.cause)
|
|
322
|
+
assert.isArray(err.context.cause.expected)
|
|
323
|
+
assert.deepEqual(err.context.cause.expected, ['Test Html header1 test html text'])
|
|
324
|
+
assert.deepEqual(err.context.cause.actual, ['test html header test html text'])
|
|
325
|
+
assert.deepEqual(err.context.cause.diff, ['Test Html header1 test html text'])
|
|
326
|
+
}
|
|
327
|
+
})
|
|
311
328
|
})
|
|
312
329
|
})
|