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,94 +4,60 @@ const CardsCountAsserter = require('../../../src/scripting/logichook/asserter/Ca
|
|
|
4
4
|
const CardsCountRecAsserter = require('../../../src/scripting/logichook/asserter/CardsCountRecAsserter')
|
|
5
5
|
|
|
6
6
|
describe('scripting.asserters.cardsAsserter', function () {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
it('should succeed on existing card text', async function () {
|
|
14
|
-
await this.cardsAsserter.assertConvoStep({
|
|
15
|
-
convoStep: { stepTag: 'test' },
|
|
16
|
-
args: ['cardtext'],
|
|
17
|
-
botMsg: {
|
|
18
|
-
cards: [
|
|
19
|
-
{
|
|
20
|
-
text: 'cardtext'
|
|
21
|
-
}
|
|
22
|
-
]
|
|
23
|
-
}
|
|
7
|
+
describe('cardsAsserter', function () {
|
|
8
|
+
beforeEach(async function () {
|
|
9
|
+
this.cardsAsserter = new CardsAsserter({
|
|
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
|
-
it('should succeed on existing card content', async function () {
|
|
40
|
-
await this.cardsAsserter.assertConvoStep({
|
|
41
|
-
convoStep: { stepTag: 'test' },
|
|
42
|
-
args: ['cardtext'],
|
|
43
|
-
botMsg: {
|
|
44
|
-
cards: [
|
|
45
|
-
{
|
|
46
|
-
content: 'cardtext'
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
}
|
|
13
|
+
|
|
14
|
+
it('should succeed on existing card text', async function () {
|
|
15
|
+
await this.cardsAsserter.assertConvoStep({
|
|
16
|
+
convoStep: { stepTag: 'test' },
|
|
17
|
+
args: ['cardtext'],
|
|
18
|
+
botMsg: {
|
|
19
|
+
cards: [
|
|
20
|
+
{
|
|
21
|
+
text: 'cardtext'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
})
|
|
50
26
|
})
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
}
|
|
27
|
+
it('should succeed on existing card subtext', async function () {
|
|
28
|
+
await this.cardsAsserter.assertConvoStep({
|
|
29
|
+
convoStep: { stepTag: 'test' },
|
|
30
|
+
args: ['cardtext'],
|
|
31
|
+
botMsg: {
|
|
32
|
+
cards: [
|
|
33
|
+
{
|
|
34
|
+
subtext: 'cardtext'
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
})
|
|
66
39
|
})
|
|
67
|
-
|
|
68
|
-
it('should fail on missing card', async function () {
|
|
69
|
-
try {
|
|
40
|
+
it('should succeed on existing card content', async function () {
|
|
70
41
|
await this.cardsAsserter.assertConvoStep({
|
|
71
42
|
convoStep: { stepTag: 'test' },
|
|
72
|
-
args: ['
|
|
73
|
-
botMsg: {
|
|
43
|
+
args: ['cardtext'],
|
|
44
|
+
botMsg: {
|
|
45
|
+
cards: [
|
|
46
|
+
{
|
|
47
|
+
content: 'cardtext'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
74
51
|
})
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
assert.isTrue(err.message.indexOf('Expected card(s) with text "missingcard"') > 0)
|
|
78
|
-
assert.isNotNull(err.context)
|
|
79
|
-
assert.isNotNull(err.context.cause)
|
|
80
|
-
assert.isArray(err.context.cause.expected)
|
|
81
|
-
assert.deepEqual(err.context.cause.expected, ['missingcard'])
|
|
82
|
-
assert.deepEqual(err.context.cause.actual, [])
|
|
83
|
-
assert.deepEqual(err.context.cause.diff, ['missingcard'])
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
it('should fail on one missing card', async function () {
|
|
87
|
-
try {
|
|
52
|
+
})
|
|
53
|
+
it('should succeed on multiple existing cards', async function () {
|
|
88
54
|
await this.cardsAsserter.assertConvoStep({
|
|
89
55
|
convoStep: { stepTag: 'test' },
|
|
90
|
-
args: ['
|
|
56
|
+
args: ['cardtext1', 'cardtext2'],
|
|
91
57
|
botMsg: {
|
|
92
58
|
cards: [
|
|
93
59
|
{
|
|
94
|
-
text: '
|
|
60
|
+
text: 'cardtext1'
|
|
95
61
|
},
|
|
96
62
|
{
|
|
97
63
|
text: 'cardtext2'
|
|
@@ -99,92 +65,96 @@ describe('scripting.asserters.cardsAsserter', function () {
|
|
|
99
65
|
]
|
|
100
66
|
}
|
|
101
67
|
})
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
68
|
+
})
|
|
69
|
+
it('should fail on missing card', async function () {
|
|
70
|
+
try {
|
|
71
|
+
await this.cardsAsserter.assertConvoStep({
|
|
72
|
+
convoStep: { stepTag: 'test' },
|
|
73
|
+
args: ['missingcard'],
|
|
74
|
+
botMsg: {}
|
|
75
|
+
})
|
|
76
|
+
assert.fail('should have failed')
|
|
77
|
+
} catch (err) {
|
|
78
|
+
assert.isTrue(err.message.indexOf('Expected card(s) with text "missingcard"') > 0)
|
|
79
|
+
assert.isNotNull(err.context)
|
|
80
|
+
assert.isNotNull(err.context.cause)
|
|
81
|
+
assert.isArray(err.context.cause.expected)
|
|
82
|
+
assert.deepEqual(err.context.cause.expected, ['missingcard'])
|
|
83
|
+
assert.deepEqual(err.context.cause.actual, [])
|
|
84
|
+
assert.deepEqual(err.context.cause.diff, ['missingcard'])
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
it('should fail on one missing card', async function () {
|
|
88
|
+
try {
|
|
89
|
+
await this.cardsAsserter.assertConvoStep({
|
|
90
|
+
convoStep: { stepTag: 'test' },
|
|
91
|
+
args: ['existingcard', 'missingcard'],
|
|
92
|
+
botMsg: {
|
|
93
|
+
cards: [
|
|
94
|
+
{
|
|
95
|
+
text: 'existingcard'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
text: 'cardtext2'
|
|
99
|
+
}
|
|
100
|
+
]
|
|
122
101
|
}
|
|
123
|
-
|
|
102
|
+
})
|
|
103
|
+
assert.fail('should have failed')
|
|
104
|
+
} catch (err) {
|
|
105
|
+
assert.isTrue(err.message.indexOf('Expected card(s) with text "missingcard"') > 0)
|
|
106
|
+
assert.isNotNull(err.context)
|
|
107
|
+
assert.isNotNull(err.context.cause)
|
|
108
|
+
assert.isArray(err.context.cause.expected)
|
|
109
|
+
assert.isNotTrue(err.context.cause.not)
|
|
110
|
+
assert.deepEqual(err.context.cause.expected, ['existingcard', 'missingcard'])
|
|
111
|
+
assert.deepEqual(err.context.cause.actual, ['existingcard', 'cardtext2'])
|
|
112
|
+
assert.deepEqual(err.context.cause.diff, ['missingcard'])
|
|
124
113
|
}
|
|
125
114
|
})
|
|
126
|
-
|
|
127
|
-
it('should fail on one unexpected card', async function () {
|
|
128
|
-
try {
|
|
115
|
+
it('should succeed on unexpected card text', async function () {
|
|
129
116
|
await this.cardsAsserter.assertNotConvoStep({
|
|
130
117
|
convoStep: { stepTag: 'test' },
|
|
131
|
-
args: ['
|
|
118
|
+
args: ['cardtext1'],
|
|
132
119
|
botMsg: {
|
|
133
120
|
cards: [
|
|
134
121
|
{
|
|
135
|
-
text: '
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
text: 'cardtext2'
|
|
122
|
+
text: 'cardtext'
|
|
139
123
|
}
|
|
140
124
|
]
|
|
141
125
|
}
|
|
142
126
|
})
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
args: [],
|
|
159
|
-
botMsg: {
|
|
160
|
-
cards: [
|
|
161
|
-
{
|
|
162
|
-
text: 'test'
|
|
127
|
+
})
|
|
128
|
+
it('should fail on one unexpected card', async function () {
|
|
129
|
+
try {
|
|
130
|
+
await this.cardsAsserter.assertNotConvoStep({
|
|
131
|
+
convoStep: { stepTag: 'test' },
|
|
132
|
+
args: ['existingcard', 'missingcard'],
|
|
133
|
+
botMsg: {
|
|
134
|
+
cards: [
|
|
135
|
+
{
|
|
136
|
+
text: 'existingcard'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
text: 'cardtext2'
|
|
140
|
+
}
|
|
141
|
+
]
|
|
163
142
|
}
|
|
164
|
-
|
|
143
|
+
})
|
|
144
|
+
assert.fail('should have failed')
|
|
145
|
+
} catch (err) {
|
|
146
|
+
assert.isTrue(err.message.indexOf('Not expected card(s) with text "existingcard"') > 0)
|
|
147
|
+
assert.isNotNull(err.context)
|
|
148
|
+
assert.isNotNull(err.context.cause)
|
|
149
|
+
assert.isArray(err.context.cause.expected)
|
|
150
|
+
assert.isTrue(err.context.cause.not)
|
|
151
|
+
assert.deepEqual(err.context.cause.expected, ['existingcard', 'missingcard'])
|
|
152
|
+
assert.deepEqual(err.context.cause.actual, ['existingcard', 'cardtext2'])
|
|
153
|
+
assert.deepEqual(err.context.cause.diff, ['existingcard'])
|
|
165
154
|
}
|
|
166
155
|
})
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
try {
|
|
170
|
-
await this.cardsAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
|
|
171
|
-
assert.fail('should have failed')
|
|
172
|
-
} catch (err) {
|
|
173
|
-
assert.isTrue(err.message.indexOf('Expected some card(s)') > 0)
|
|
174
|
-
assert.isNotNull(err.context)
|
|
175
|
-
assert.isNotNull(err.context.cause)
|
|
176
|
-
assert.isArray(err.context.cause.expected)
|
|
177
|
-
assert.isNotTrue(err.context.cause.not)
|
|
178
|
-
assert.deepEqual(err.context.cause.expected, [])
|
|
179
|
-
assert.deepEqual(err.context.cause.actual, [])
|
|
180
|
-
}
|
|
181
|
-
})
|
|
182
|
-
it('should succeed on not existing card if has no arg and negated', async function () {
|
|
183
|
-
await this.cardsAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
|
|
184
|
-
})
|
|
185
|
-
it('should fail on card if has no arg and negated', async function () {
|
|
186
|
-
try {
|
|
187
|
-
await this.cardsAsserter.assertNotConvoStep({
|
|
156
|
+
it('should succeed on existing card if has no arg', async function () {
|
|
157
|
+
await this.cardsAsserter.assertConvoStep({
|
|
188
158
|
convoStep: { stepTag: 'test' },
|
|
189
159
|
args: [],
|
|
190
160
|
botMsg: {
|
|
@@ -195,90 +165,122 @@ describe('scripting.asserters.cardsAsserter', function () {
|
|
|
195
165
|
]
|
|
196
166
|
}
|
|
197
167
|
})
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
beforeEach(async function () {
|
|
212
|
-
this.cardsCountAsserter = new CardsCountAsserter({}, {})
|
|
213
|
-
this.cardsCountRecAsserter = new CardsCountRecAsserter({}, {})
|
|
214
|
-
})
|
|
215
|
-
|
|
216
|
-
it('should succeed on no args with one card', async function () {
|
|
217
|
-
await this.cardsCountAsserter.assertConvoStep({
|
|
218
|
-
convoStep: { stepTag: 'test' },
|
|
219
|
-
args: [],
|
|
220
|
-
botMsg: {
|
|
221
|
-
cards: [{ text: 'test.jpg' }]
|
|
168
|
+
})
|
|
169
|
+
it('should fail on no card if has no arg', async function () {
|
|
170
|
+
try {
|
|
171
|
+
await this.cardsAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
|
|
172
|
+
assert.fail('should have failed')
|
|
173
|
+
} catch (err) {
|
|
174
|
+
assert.isTrue(err.message.indexOf('Expected some card(s)') > 0)
|
|
175
|
+
assert.isNotNull(err.context)
|
|
176
|
+
assert.isNotNull(err.context.cause)
|
|
177
|
+
assert.isArray(err.context.cause.expected)
|
|
178
|
+
assert.isNotTrue(err.context.cause.not)
|
|
179
|
+
assert.deepEqual(err.context.cause.expected, [])
|
|
180
|
+
assert.deepEqual(err.context.cause.actual, [])
|
|
222
181
|
}
|
|
223
182
|
})
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
{
|
|
233
|
-
text: 'card1',
|
|
183
|
+
it('should succeed on not existing card if has no arg and negated', async function () {
|
|
184
|
+
await this.cardsAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
|
|
185
|
+
})
|
|
186
|
+
it('should fail on card if has no arg and negated', async function () {
|
|
187
|
+
try {
|
|
188
|
+
await this.cardsAsserter.assertNotConvoStep({
|
|
189
|
+
convoStep: { stepTag: 'test' },
|
|
190
|
+
args: [],
|
|
191
|
+
botMsg: {
|
|
234
192
|
cards: [
|
|
235
193
|
{
|
|
236
|
-
text: '
|
|
237
|
-
cards: [{ text: 'card3' }]
|
|
194
|
+
text: 'test'
|
|
238
195
|
}
|
|
239
196
|
]
|
|
240
197
|
}
|
|
241
|
-
|
|
198
|
+
})
|
|
199
|
+
assert.fail('should have failed')
|
|
200
|
+
} catch (err) {
|
|
201
|
+
assert.isTrue(err.message.indexOf('Not expected card(s) with text "test"') > 0)
|
|
202
|
+
assert.isNotNull(err.context)
|
|
203
|
+
assert.isNotNull(err.context.cause)
|
|
204
|
+
assert.isArray(err.context.cause.expected)
|
|
205
|
+
assert.isTrue(err.context.cause.not)
|
|
206
|
+
assert.deepEqual(err.context.cause.expected, [])
|
|
207
|
+
assert.deepEqual(err.context.cause.actual, ['test'])
|
|
242
208
|
}
|
|
243
209
|
})
|
|
244
210
|
})
|
|
245
|
-
|
|
211
|
+
describe('cardsCountAsserter', function () {
|
|
212
|
+
beforeEach(async function () {
|
|
213
|
+
this.cardsCountAsserter = new CardsCountAsserter({}, {})
|
|
214
|
+
this.cardsCountRecAsserter = new CardsCountRecAsserter({}, {})
|
|
215
|
+
})
|
|
246
216
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
217
|
+
it('should succeed on no args with one card', async function () {
|
|
218
|
+
await this.cardsCountAsserter.assertConvoStep({
|
|
219
|
+
convoStep: { stepTag: 'test' },
|
|
220
|
+
args: [],
|
|
221
|
+
botMsg: {
|
|
222
|
+
cards: [{ text: 'test.jpg' }]
|
|
223
|
+
}
|
|
224
|
+
})
|
|
225
|
+
})
|
|
253
226
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
227
|
+
it('should succeed on >=3 with rec cards', async function () {
|
|
228
|
+
await this.cardsCountRecAsserter.assertConvoStep({
|
|
229
|
+
convoStep: { stepTag: 'test' },
|
|
230
|
+
args: ['>=3'],
|
|
231
|
+
botMsg: {
|
|
232
|
+
cards: [
|
|
233
|
+
{
|
|
234
|
+
text: 'card1',
|
|
235
|
+
cards: [
|
|
236
|
+
{
|
|
237
|
+
text: 'card2',
|
|
238
|
+
cards: [{ text: 'card3' }]
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
}
|
|
244
|
+
})
|
|
261
245
|
})
|
|
262
246
|
})
|
|
263
247
|
|
|
264
|
-
|
|
265
|
-
|
|
248
|
+
describe('cardsNormalizeAsserter', function () {
|
|
249
|
+
beforeEach(async function () {
|
|
250
|
+
this.cardsAsserter = new CardsAsserter({
|
|
251
|
+
Match: (botresponse, utterance) => botresponse.toLowerCase().indexOf(utterance.toLowerCase()) >= 0
|
|
252
|
+
}, { SCRIPTING_NORMALIZE_TEXT: true })
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
it('should succeed with normalized text', async function () {
|
|
266
256
|
await this.cardsAsserter.assertConvoStep({
|
|
267
257
|
convoStep: { stepTag: 'test' },
|
|
268
|
-
args: ['Test Html
|
|
258
|
+
args: ['Test Html header test html text'],
|
|
269
259
|
botMsg: {
|
|
270
260
|
cards: [{ text: '<html><h1>test html header</h1><p>test html text</p>' }]
|
|
271
261
|
}
|
|
272
262
|
})
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('should fail with normalized text', async function () {
|
|
266
|
+
try {
|
|
267
|
+
await this.cardsAsserter.assertConvoStep({
|
|
268
|
+
convoStep: { stepTag: 'test' },
|
|
269
|
+
args: ['Test Html header1 test html text'],
|
|
270
|
+
botMsg: {
|
|
271
|
+
cards: [{ text: '<html><h1>test html header</h1><p>test html text</p>' }]
|
|
272
|
+
}
|
|
273
|
+
})
|
|
274
|
+
assert.fail('should have failed')
|
|
275
|
+
} catch (err) {
|
|
276
|
+
assert.isTrue(err.message.indexOf('Expected card(s) with text "Test Html header1 test html text"') > 0)
|
|
277
|
+
assert.isNotNull(err.context)
|
|
278
|
+
assert.isNotNull(err.context.cause)
|
|
279
|
+
assert.isArray(err.context.cause.expected)
|
|
280
|
+
assert.deepEqual(err.context.cause.expected, ['Test Html header1 test html text'])
|
|
281
|
+
assert.deepEqual(err.context.cause.actual, ['test html header test html text'])
|
|
282
|
+
assert.deepEqual(err.context.cause.diff, ['Test Html header1 test html text'])
|
|
283
|
+
}
|
|
284
|
+
})
|
|
283
285
|
})
|
|
284
286
|
})
|
|
@@ -8,6 +8,40 @@ const asserterWithGlobal = new IntentConfidenceAsserter(null, null, { expectedMi
|
|
|
8
8
|
const asserterWithoutGlobal = new IntentConfidenceAsserter(null)
|
|
9
9
|
|
|
10
10
|
describe('scripting.asserters.intentConfidenceAsserter', function () {
|
|
11
|
+
const _assert = (useWithGlobal, expected, found, negative) => {
|
|
12
|
+
const steptag = `UseWithGlobal: ${useWithGlobal}, expected: ${util.inspect(expected)}, found: ${util.inspect(found)}`
|
|
13
|
+
const promise = (useWithGlobal ? asserterWithGlobal : asserterWithoutGlobal).assertConvoStep(_params(
|
|
14
|
+
expected,
|
|
15
|
+
found,
|
|
16
|
+
steptag
|
|
17
|
+
))
|
|
18
|
+
|
|
19
|
+
if (negative) {
|
|
20
|
+
return assert.isRejected(promise)
|
|
21
|
+
} else {
|
|
22
|
+
return assert.isFulfilled(promise)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const _params = (expected, found, steptag) => {
|
|
27
|
+
found = found / 100
|
|
28
|
+
return {
|
|
29
|
+
convoStep: {
|
|
30
|
+
stepTag: steptag
|
|
31
|
+
},
|
|
32
|
+
args: expected ? [expected] : [],
|
|
33
|
+
botMsg: {
|
|
34
|
+
nlp: found
|
|
35
|
+
? {
|
|
36
|
+
intent: {
|
|
37
|
+
name: 'not_important',
|
|
38
|
+
confidence: found
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
: null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
11
45
|
// useWithGlobal, expected (minimum), found, negative (expect reject)
|
|
12
46
|
const cases = [
|
|
13
47
|
[true, null, null, true],
|
|
@@ -40,38 +74,3 @@ describe('scripting.asserters.intentConfidenceAsserter', function () {
|
|
|
40
74
|
)
|
|
41
75
|
})
|
|
42
76
|
})
|
|
43
|
-
|
|
44
|
-
const _assert = (useWithGlobal, expected, found, negative) => {
|
|
45
|
-
const steptag = `UseWithGlobal: ${useWithGlobal}, expected: ${util.inspect(expected)}, found: ${util.inspect(found)}`
|
|
46
|
-
const promise = (useWithGlobal ? asserterWithGlobal : asserterWithoutGlobal).assertConvoStep(_params(
|
|
47
|
-
expected,
|
|
48
|
-
found,
|
|
49
|
-
steptag
|
|
50
|
-
))
|
|
51
|
-
|
|
52
|
-
if (negative) {
|
|
53
|
-
return assert.isRejected(promise)
|
|
54
|
-
} else {
|
|
55
|
-
return assert.isFulfilled(promise)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const _params = (expected, found, steptag) => {
|
|
60
|
-
found = found / 100
|
|
61
|
-
return {
|
|
62
|
-
convoStep: {
|
|
63
|
-
stepTag: steptag
|
|
64
|
-
},
|
|
65
|
-
args: expected ? [expected] : [],
|
|
66
|
-
botMsg: {
|
|
67
|
-
nlp: found
|
|
68
|
-
? {
|
|
69
|
-
intent: {
|
|
70
|
-
name: 'not_important',
|
|
71
|
-
confidence: found
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
: null
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|