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
|
@@ -6,730 +6,763 @@ const ScriptingProvider = require('../../src/scripting/ScriptingProvider')
|
|
|
6
6
|
const DefaultCapabilities = require('../../src/Defaults').Capabilities
|
|
7
7
|
const Capabilities = require('../../src/Capabilities')
|
|
8
8
|
|
|
9
|
-
describe('scriptingProvider
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
assert.isArray(convos)
|
|
16
|
-
assert.equal(convos.length, 2)
|
|
17
|
-
})
|
|
18
|
-
it('should read multiple files from dir with globFilter', async function () {
|
|
19
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
20
|
-
await scriptingProvider.Build()
|
|
21
|
-
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos'), '**/*.convo.txt')
|
|
22
|
-
|
|
23
|
-
assert.isArray(convos)
|
|
24
|
-
assert.equal(convos.length, 2)
|
|
25
|
-
})
|
|
26
|
-
it('should ignore files from dir with globFilter', async function () {
|
|
27
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
28
|
-
await scriptingProvider.Build()
|
|
29
|
-
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos'), 'sepp.txt')
|
|
9
|
+
describe('scripting.scriptingProvider', function () {
|
|
10
|
+
describe('ReadScriptsFromDirectory', function () {
|
|
11
|
+
it('should read multiple files from dir', async function () {
|
|
12
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
13
|
+
await scriptingProvider.Build()
|
|
14
|
+
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos'))
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
assert.isArray(convos)
|
|
17
|
+
assert.equal(convos.length, 2)
|
|
18
|
+
})
|
|
19
|
+
it('should read multiple files from dir with globFilter', async function () {
|
|
20
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
21
|
+
await scriptingProvider.Build()
|
|
22
|
+
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos'), '**/*.convo.txt')
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
24
|
+
assert.isArray(convos)
|
|
25
|
+
assert.equal(convos.length, 2)
|
|
26
|
+
})
|
|
27
|
+
it('should ignore files from dir with globFilter', async function () {
|
|
28
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
29
|
+
await scriptingProvider.Build()
|
|
30
|
+
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos'), 'sepp.txt')
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
assert.isArray(convos)
|
|
33
|
+
assert.equal(convos.length, 0)
|
|
34
|
+
})
|
|
35
|
+
it('should read single file from file path', async function () {
|
|
36
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
37
|
+
await scriptingProvider.Build()
|
|
38
|
+
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'convo1.convo.txt'))
|
|
51
39
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
55
|
-
await scriptingProvider.Build()
|
|
56
|
-
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
57
|
-
scriptingProvider.AddUtterances({
|
|
58
|
-
name: 'utt1',
|
|
59
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
63
|
-
assert.isArray(tomatch)
|
|
64
|
-
assert.equal(tomatch.length, 2)
|
|
65
|
-
assert.equal(tomatch[0], 'TEXT1')
|
|
66
|
-
assert.equal(tomatch[1], 'TEXT2')
|
|
67
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1')
|
|
68
|
-
})
|
|
69
|
-
it('should resolve null on invalid utterance', async function () {
|
|
70
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
71
|
-
await scriptingProvider.Build()
|
|
72
|
-
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
73
|
-
scriptingProvider.AddUtterances({
|
|
74
|
-
name: 'utt1',
|
|
75
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
40
|
+
assert.isArray(convos)
|
|
41
|
+
assert.equal(convos.length, 1)
|
|
76
42
|
})
|
|
43
|
+
it('should skip convos', async function () {
|
|
44
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
45
|
+
await scriptingProvider.Build()
|
|
46
|
+
const { convos } = await scriptingProvider.ReadScriptsFromDirectory(path.resolve(__dirname, 'skipconvos'))
|
|
77
47
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
it('should fail on invalid utterance', async function () {
|
|
82
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
83
|
-
await scriptingProvider.Build()
|
|
84
|
-
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
85
|
-
scriptingProvider.AddUtterances({
|
|
86
|
-
name: 'utt1',
|
|
87
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt2' })
|
|
91
|
-
assert.isArray(tomatch)
|
|
92
|
-
assert.equal(tomatch.length, 1)
|
|
93
|
-
assert.equal(tomatch[0], 'utt2')
|
|
94
|
-
try {
|
|
95
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1')
|
|
96
|
-
assert.fail('expected error')
|
|
97
|
-
} catch (err) {
|
|
98
|
-
assert.isTrue(err.message.indexOf('Bot response') > 0)
|
|
99
|
-
assert.isNotNull(err.context)
|
|
100
|
-
assert.isNotNull(err.context.cause)
|
|
101
|
-
assert.isArray(err.context.cause.expected)
|
|
102
|
-
assert.deepEqual(err.context.cause.expected, tomatch)
|
|
103
|
-
assert.equal(err.context.cause.actual, 'TEXT1')
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
it('should fail on unresolved utterance', async function () {
|
|
107
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
108
|
-
await scriptingProvider.Build()
|
|
109
|
-
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
110
|
-
scriptingProvider.AddUtterances({
|
|
111
|
-
name: 'utt1',
|
|
112
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
113
|
-
})
|
|
114
|
-
try {
|
|
115
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', 'utt1', 'test1')
|
|
116
|
-
assert.fail('expected error')
|
|
117
|
-
} catch (err) {
|
|
118
|
-
assert.isTrue(err.message.indexOf('Bot response') > 0)
|
|
119
|
-
assert.isNotNull(err.context)
|
|
120
|
-
assert.isNotNull(err.context.cause)
|
|
121
|
-
assert.isArray(err.context.cause.expected)
|
|
122
|
-
assert.deepEqual(err.context.cause.expected, ['utt1'])
|
|
123
|
-
assert.equal(err.context.cause.actual, 'TEXT1')
|
|
124
|
-
}
|
|
125
|
-
})
|
|
126
|
-
it('should resolve and format utterance args', async function () {
|
|
127
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
128
|
-
await scriptingProvider.Build()
|
|
129
|
-
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
130
|
-
scriptingProvider.AddUtterances({
|
|
131
|
-
name: 'utt1',
|
|
132
|
-
utterances: ['TEXT1 %s', 'TEXT2 %s']
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1 hello' })
|
|
136
|
-
assert.isArray(tomatch)
|
|
137
|
-
assert.equal(tomatch.length, 2)
|
|
138
|
-
assert.equal(tomatch[0], 'TEXT1 hello')
|
|
139
|
-
assert.equal(tomatch[1], 'TEXT2 hello')
|
|
140
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1')
|
|
141
|
-
})
|
|
142
|
-
it('should resolve and append utterance args', async function () {
|
|
143
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
144
|
-
await scriptingProvider.Build()
|
|
145
|
-
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
146
|
-
scriptingProvider.AddUtterances({
|
|
147
|
-
name: 'utt1',
|
|
148
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1 hello' })
|
|
152
|
-
assert.isArray(tomatch)
|
|
153
|
-
assert.equal(tomatch.length, 2)
|
|
154
|
-
assert.equal(tomatch[0], 'TEXT1 hello')
|
|
155
|
-
assert.equal(tomatch[1], 'TEXT2 hello')
|
|
156
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1')
|
|
48
|
+
assert.isArray(convos)
|
|
49
|
+
assert.equal(convos.length, 1)
|
|
50
|
+
})
|
|
157
51
|
})
|
|
158
52
|
|
|
159
|
-
describe('
|
|
160
|
-
it('
|
|
53
|
+
describe('_resolveUtterances', function () {
|
|
54
|
+
it('should resolve utterance', async function () {
|
|
161
55
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
162
56
|
await scriptingProvider.Build()
|
|
163
57
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
164
58
|
scriptingProvider.AddUtterances({
|
|
165
59
|
name: 'utt1',
|
|
166
|
-
utterances: ['
|
|
60
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
167
61
|
})
|
|
168
62
|
|
|
169
63
|
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
170
64
|
assert.isArray(tomatch)
|
|
171
65
|
assert.equal(tomatch.length, 2)
|
|
172
|
-
assert.equal(tomatch[0], '
|
|
173
|
-
assert.equal(tomatch[1], '
|
|
66
|
+
assert.equal(tomatch[0], 'TEXT1')
|
|
67
|
+
assert.equal(tomatch[1], 'TEXT2')
|
|
68
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1')
|
|
69
|
+
})
|
|
70
|
+
it('should resolve multiple utterance', async function () {
|
|
71
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
72
|
+
await scriptingProvider.Build()
|
|
73
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
74
|
+
scriptingProvider.AddUtterances([{
|
|
75
|
+
name: 'utt1',
|
|
76
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'utt2',
|
|
80
|
+
utterances: ['TEXT3', 'TEXT4']
|
|
81
|
+
}])
|
|
82
|
+
|
|
83
|
+
const tomatchUtt1 = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
84
|
+
assert.isArray(tomatchUtt1)
|
|
85
|
+
assert.equal(tomatchUtt1.length, 2)
|
|
86
|
+
assert.equal(tomatchUtt1[0], 'TEXT1')
|
|
87
|
+
assert.equal(tomatchUtt1[1], 'TEXT2')
|
|
88
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatchUtt1, 'test1')
|
|
89
|
+
const tomatchUtt2 = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt2' })
|
|
90
|
+
assert.isArray(tomatchUtt2)
|
|
91
|
+
assert.equal(tomatchUtt2.length, 2)
|
|
92
|
+
assert.equal(tomatchUtt2[0], 'TEXT3')
|
|
93
|
+
assert.equal(tomatchUtt2[1], 'TEXT4')
|
|
174
94
|
})
|
|
95
|
+
it('should resolve null on invalid utterance', async function () {
|
|
96
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
97
|
+
await scriptingProvider.Build()
|
|
98
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
99
|
+
scriptingProvider.AddUtterances({
|
|
100
|
+
name: 'utt1',
|
|
101
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
102
|
+
})
|
|
175
103
|
|
|
176
|
-
|
|
104
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({
|
|
105
|
+
utterance: 'utt2',
|
|
106
|
+
resolveEmptyIfUnknown: true
|
|
107
|
+
})
|
|
108
|
+
assert.isNull(tomatch)
|
|
109
|
+
})
|
|
110
|
+
it('should fail on invalid utterance', async function () {
|
|
177
111
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
178
112
|
await scriptingProvider.Build()
|
|
179
113
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
180
114
|
scriptingProvider.AddUtterances({
|
|
181
115
|
name: 'utt1',
|
|
182
|
-
utterances: ['
|
|
116
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
183
117
|
})
|
|
118
|
+
|
|
119
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt2' })
|
|
120
|
+
assert.isArray(tomatch)
|
|
121
|
+
assert.equal(tomatch.length, 1)
|
|
122
|
+
assert.equal(tomatch[0], 'utt2')
|
|
123
|
+
try {
|
|
124
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1')
|
|
125
|
+
assert.fail('expected error')
|
|
126
|
+
} catch (err) {
|
|
127
|
+
assert.isTrue(err.message.indexOf('Bot response') > 0)
|
|
128
|
+
assert.isNotNull(err.context)
|
|
129
|
+
assert.isNotNull(err.context.cause)
|
|
130
|
+
assert.isArray(err.context.cause.expected)
|
|
131
|
+
assert.deepEqual(err.context.cause.expected, tomatch)
|
|
132
|
+
assert.equal(err.context.cause.actual, 'TEXT1')
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
it('should fail on unresolved utterance', async function () {
|
|
136
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
137
|
+
await scriptingProvider.Build()
|
|
138
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
139
|
+
scriptingProvider.AddUtterances({
|
|
140
|
+
name: 'utt1',
|
|
141
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
142
|
+
})
|
|
143
|
+
try {
|
|
144
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', 'utt1', 'test1')
|
|
145
|
+
assert.fail('expected error')
|
|
146
|
+
} catch (err) {
|
|
147
|
+
assert.isTrue(err.message.indexOf('Bot response') > 0)
|
|
148
|
+
assert.isNotNull(err.context)
|
|
149
|
+
assert.isNotNull(err.context.cause)
|
|
150
|
+
assert.isArray(err.context.cause.expected)
|
|
151
|
+
assert.deepEqual(err.context.cause.expected, ['utt1'])
|
|
152
|
+
assert.equal(err.context.cause.actual, 'TEXT1')
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
it('should resolve and format utterance args', async function () {
|
|
156
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
157
|
+
await scriptingProvider.Build()
|
|
158
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
184
159
|
scriptingProvider.AddUtterances({
|
|
185
160
|
name: 'utt1',
|
|
186
|
-
utterances: ['
|
|
161
|
+
utterances: ['TEXT1 %s', 'TEXT2 %s']
|
|
187
162
|
})
|
|
188
163
|
|
|
189
|
-
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
164
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1 hello' })
|
|
190
165
|
assert.isArray(tomatch)
|
|
191
166
|
assert.equal(tomatch.length, 2)
|
|
192
|
-
assert.equal(tomatch[0], '
|
|
193
|
-
assert.equal(tomatch[1], '
|
|
167
|
+
assert.equal(tomatch[0], 'TEXT1 hello')
|
|
168
|
+
assert.equal(tomatch[1], 'TEXT2 hello')
|
|
169
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1')
|
|
194
170
|
})
|
|
195
|
-
|
|
196
|
-
it('expected $name, found none', async function () {
|
|
171
|
+
it('should resolve and append utterance args', async function () {
|
|
197
172
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
198
173
|
await scriptingProvider.Build()
|
|
199
174
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
200
175
|
scriptingProvider.AddUtterances({
|
|
201
176
|
name: 'utt1',
|
|
202
|
-
utterances: ['
|
|
177
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
203
178
|
})
|
|
204
179
|
|
|
205
|
-
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
180
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1 hello' })
|
|
206
181
|
assert.isArray(tomatch)
|
|
207
182
|
assert.equal(tomatch.length, 2)
|
|
208
|
-
assert.equal(tomatch[0], '
|
|
209
|
-
assert.equal(tomatch[1], '
|
|
183
|
+
assert.equal(tomatch[0], 'TEXT1 hello')
|
|
184
|
+
assert.equal(tomatch[1], 'TEXT2 hello')
|
|
185
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1')
|
|
210
186
|
})
|
|
211
|
-
})
|
|
212
|
-
})
|
|
213
187
|
|
|
214
|
-
describe('
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
188
|
+
describe('should resolve utterance with ambiguous scripting memory variable (with a debug message)', function () {
|
|
189
|
+
it('expected none, found $name', async function () {
|
|
190
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
191
|
+
await scriptingProvider.Build()
|
|
192
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
193
|
+
scriptingProvider.AddUtterances({
|
|
194
|
+
name: 'utt1',
|
|
195
|
+
utterances: ['Hi!', 'Hi $name']
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
199
|
+
assert.isArray(tomatch)
|
|
200
|
+
assert.equal(tomatch.length, 2)
|
|
201
|
+
assert.equal(tomatch[0], 'Hi!')
|
|
202
|
+
assert.equal(tomatch[1], 'Hi $name')
|
|
203
|
+
})
|
|
224
204
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
205
|
+
it('expected none, found $name in different Utterance', async function () {
|
|
206
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
207
|
+
await scriptingProvider.Build()
|
|
208
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
209
|
+
scriptingProvider.AddUtterances({
|
|
210
|
+
name: 'utt1',
|
|
211
|
+
utterances: ['Hi!']
|
|
212
|
+
})
|
|
213
|
+
scriptingProvider.AddUtterances({
|
|
214
|
+
name: 'utt1',
|
|
215
|
+
utterances: ['Hi $name']
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
219
|
+
assert.isArray(tomatch)
|
|
220
|
+
assert.equal(tomatch.length, 2)
|
|
221
|
+
assert.equal(tomatch[0], 'Hi!')
|
|
222
|
+
assert.equal(tomatch[1], 'Hi $name')
|
|
223
|
+
})
|
|
234
224
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
]
|
|
253
|
-
}))
|
|
254
|
-
|
|
255
|
-
scriptingProvider.ExpandConvos()
|
|
256
|
-
assert.equal(scriptingProvider.convos.length, 2)
|
|
257
|
-
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
258
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/utt1-L1')
|
|
259
|
-
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
260
|
-
assert.equal(scriptingProvider.convos[1].conversation.length, 1)
|
|
261
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt1-L2')
|
|
262
|
-
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
263
|
-
})
|
|
264
|
-
it('should build convos for utterance with parameters', async function () {
|
|
265
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
266
|
-
await scriptingProvider.Build()
|
|
267
|
-
scriptingProvider.AddUtterances({
|
|
268
|
-
name: 'utt1',
|
|
269
|
-
utterances: ['TEXT1 %s-%d', 'TEXT2']
|
|
270
|
-
})
|
|
271
|
-
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
272
|
-
header: {
|
|
273
|
-
name: 'test convo'
|
|
274
|
-
},
|
|
275
|
-
conversation: [
|
|
276
|
-
{
|
|
277
|
-
sender: 'me',
|
|
278
|
-
messageText: 'utt1 arg0 1'
|
|
279
|
-
}
|
|
280
|
-
]
|
|
281
|
-
}))
|
|
282
|
-
|
|
283
|
-
scriptingProvider.ExpandConvos()
|
|
284
|
-
assert.equal(scriptingProvider.convos.length, 2)
|
|
285
|
-
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
286
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/utt1-L1')
|
|
287
|
-
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1 arg0-1')
|
|
288
|
-
assert.equal(scriptingProvider.convos[1].conversation.length, 1)
|
|
289
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt1-L2')
|
|
290
|
-
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2 arg0 1')
|
|
291
|
-
})
|
|
292
|
-
it('should build convos for utterance with whitespace', async function () {
|
|
293
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
294
|
-
await scriptingProvider.Build()
|
|
295
|
-
scriptingProvider.AddUtterances({
|
|
296
|
-
name: 'utt with some whitespace',
|
|
297
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
298
|
-
})
|
|
299
|
-
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
300
|
-
header: {
|
|
301
|
-
name: 'test convo'
|
|
302
|
-
},
|
|
303
|
-
conversation: [
|
|
304
|
-
{
|
|
305
|
-
sender: 'me',
|
|
306
|
-
messageText: 'utt with some whitespace'
|
|
307
|
-
}
|
|
308
|
-
]
|
|
309
|
-
}))
|
|
310
|
-
|
|
311
|
-
scriptingProvider.ExpandConvos()
|
|
312
|
-
assert.equal(scriptingProvider.convos.length, 2)
|
|
313
|
-
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
314
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/utt with some whitespace-L1')
|
|
315
|
-
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
316
|
-
assert.equal(scriptingProvider.convos[1].conversation.length, 1)
|
|
317
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt with some whitespace-L2')
|
|
318
|
-
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
225
|
+
it('expected $name, found none', async function () {
|
|
226
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
227
|
+
await scriptingProvider.Build()
|
|
228
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
229
|
+
scriptingProvider.AddUtterances({
|
|
230
|
+
name: 'utt1',
|
|
231
|
+
utterances: ['Hi $name', 'Hi!']
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
const tomatch = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt1' })
|
|
235
|
+
assert.isArray(tomatch)
|
|
236
|
+
assert.equal(tomatch.length, 2)
|
|
237
|
+
assert.equal(tomatch[0], 'Hi $name')
|
|
238
|
+
assert.equal(tomatch[1], 'Hi!')
|
|
239
|
+
})
|
|
240
|
+
})
|
|
319
241
|
})
|
|
320
|
-
describe('should build convos for SCRIPTING_UTTEXPANSION_NAMING_MODE', function () {
|
|
321
|
-
const utterances = {
|
|
322
|
-
name: 'uttText',
|
|
323
|
-
utterances: ['TEXT1 01234567890123456789', 'TEXT2 01234567890123456789']
|
|
324
|
-
}
|
|
325
|
-
const convoUtterances = {
|
|
326
|
-
header: {
|
|
327
|
-
name: 'test convo'
|
|
328
|
-
},
|
|
329
|
-
conversation: [
|
|
330
|
-
{
|
|
331
|
-
sender: 'me',
|
|
332
|
-
messageText: 'uttText'
|
|
333
|
-
}
|
|
334
|
-
]
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=justLineNumber', async function () {
|
|
338
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
339
|
-
await scriptingProvider.Build()
|
|
340
|
-
scriptingProvider.AddUtterances(utterances)
|
|
341
|
-
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
342
242
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
assert.equal(scriptingProvider.
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
DefaultCapabilities,
|
|
354
|
-
{
|
|
355
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
356
|
-
}
|
|
357
|
-
))
|
|
358
|
-
await scriptingProvider.Build()
|
|
359
|
-
scriptingProvider.AddUtterances(utterances)
|
|
360
|
-
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
243
|
+
describe('_isValidAsserterType', function () {
|
|
244
|
+
it('valid asserterType', async function () {
|
|
245
|
+
const scriptingProvider = new ScriptingProvider()
|
|
246
|
+
assert.equal(scriptingProvider._isValidAsserterType('assertConvoStep'), true)
|
|
247
|
+
})
|
|
248
|
+
it('invalid asserterType', async function () {
|
|
249
|
+
const scriptingProvider = new ScriptingProvider()
|
|
250
|
+
assert.equal(scriptingProvider._isValidAsserterType('assertStep'), false)
|
|
251
|
+
})
|
|
252
|
+
})
|
|
361
253
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance',
|
|
375
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: null
|
|
376
|
-
}
|
|
377
|
-
))
|
|
378
|
-
await scriptingProvider.Build()
|
|
379
|
-
scriptingProvider.AddUtterances(utterances)
|
|
380
|
-
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
254
|
+
describe('_tagAndCleanupUtterances', function () {
|
|
255
|
+
it('positive case remove empty String from utterances', async function () {
|
|
256
|
+
const scriptingProvider = new ScriptingProvider()
|
|
257
|
+
const utterances = ['don\'t understand', 'sorry', '']
|
|
258
|
+
const fileUtterances = [{
|
|
259
|
+
name: 'INCOMPREHENSION',
|
|
260
|
+
utterances
|
|
261
|
+
}]
|
|
262
|
+
const actualResult = scriptingProvider._tagAndCleanupUtterances(fileUtterances, 'mydir', 'incomprehension.utterances.txt')
|
|
263
|
+
expect(actualResult[0].utterances).to.eql(utterances.slice(0, 2))
|
|
264
|
+
})
|
|
265
|
+
})
|
|
381
266
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1-TEXT1 01234567890123456789')
|
|
386
|
-
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2-TEXT2 01234567890123456789')
|
|
387
|
-
})
|
|
388
|
-
|
|
389
|
-
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance len=10', async function () {
|
|
390
|
-
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
391
|
-
{},
|
|
392
|
-
DefaultCapabilities,
|
|
393
|
-
{
|
|
394
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance',
|
|
395
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: 10
|
|
396
|
-
}
|
|
397
|
-
))
|
|
267
|
+
describe('ExpandConvos', function () {
|
|
268
|
+
it('should build convos for utterance', async function () {
|
|
269
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
398
270
|
await scriptingProvider.Build()
|
|
399
|
-
scriptingProvider.AddUtterances(
|
|
400
|
-
|
|
271
|
+
scriptingProvider.AddUtterances({
|
|
272
|
+
name: 'utt1',
|
|
273
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
274
|
+
})
|
|
275
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
276
|
+
header: {
|
|
277
|
+
name: 'test convo'
|
|
278
|
+
},
|
|
279
|
+
conversation: [
|
|
280
|
+
{
|
|
281
|
+
sender: 'me',
|
|
282
|
+
messageText: 'utt1'
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
}))
|
|
401
286
|
|
|
402
287
|
scriptingProvider.ExpandConvos()
|
|
403
288
|
assert.equal(scriptingProvider.convos.length, 2)
|
|
404
289
|
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
405
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/
|
|
406
|
-
assert.equal(scriptingProvider.convos[
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
414
|
-
}
|
|
415
|
-
))
|
|
290
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/utt1-L1')
|
|
291
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
292
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 1)
|
|
293
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt1-L2')
|
|
294
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
295
|
+
})
|
|
296
|
+
it('should build convos for utterance with parameters', async function () {
|
|
297
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
416
298
|
await scriptingProvider.Build()
|
|
299
|
+
scriptingProvider.AddUtterances({
|
|
300
|
+
name: 'utt1',
|
|
301
|
+
utterances: ['TEXT1 %s-%d', 'TEXT2']
|
|
302
|
+
})
|
|
417
303
|
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
418
304
|
header: {
|
|
419
305
|
name: 'test convo'
|
|
420
306
|
},
|
|
421
|
-
sourceTag: {},
|
|
422
307
|
conversation: [
|
|
423
308
|
{
|
|
424
309
|
sender: 'me',
|
|
425
|
-
|
|
426
|
-
{
|
|
427
|
-
name: 'BUTTON',
|
|
428
|
-
args: ['button1']
|
|
429
|
-
},
|
|
430
|
-
{
|
|
431
|
-
name: 'MEDIA',
|
|
432
|
-
args: ['test1.jpg', 'test2 01234567890123456789.jpg', 'test3.jpg']
|
|
433
|
-
}
|
|
434
|
-
]
|
|
310
|
+
messageText: 'utt1 arg0 1'
|
|
435
311
|
}
|
|
436
312
|
]
|
|
437
313
|
}))
|
|
438
314
|
|
|
439
315
|
scriptingProvider.ExpandConvos()
|
|
440
|
-
assert.equal(scriptingProvider.convos.length,
|
|
316
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
441
317
|
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
442
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/
|
|
443
|
-
assert.equal(scriptingProvider.convos[
|
|
444
|
-
assert.equal(scriptingProvider.convos[
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
{
|
|
451
|
-
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
452
|
-
}
|
|
453
|
-
))
|
|
318
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/utt1-L1')
|
|
319
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1 arg0-1')
|
|
320
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 1)
|
|
321
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt1-L2')
|
|
322
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2 arg0 1')
|
|
323
|
+
})
|
|
324
|
+
it('should build convos for utterance with whitespace', async function () {
|
|
325
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
454
326
|
await scriptingProvider.Build()
|
|
455
|
-
scriptingProvider.AddUtterances(
|
|
327
|
+
scriptingProvider.AddUtterances({
|
|
328
|
+
name: 'utt with some whitespace',
|
|
329
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
330
|
+
})
|
|
456
331
|
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
457
332
|
header: {
|
|
458
333
|
name: 'test convo'
|
|
459
334
|
},
|
|
460
|
-
sourceTag: {},
|
|
461
335
|
conversation: [
|
|
462
336
|
{
|
|
463
337
|
sender: 'me',
|
|
464
|
-
messageText: '
|
|
465
|
-
userInputs: [
|
|
466
|
-
{
|
|
467
|
-
name: 'BUTTON',
|
|
468
|
-
args: ['button1']
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
name: 'MEDIA',
|
|
472
|
-
args: ['test1.jpg', 'test2 01234567890123456789.jpg', 'test3.jpg']
|
|
473
|
-
}
|
|
474
|
-
]
|
|
338
|
+
messageText: 'utt with some whitespace'
|
|
475
339
|
}
|
|
476
340
|
]
|
|
477
341
|
}))
|
|
478
342
|
|
|
479
343
|
scriptingProvider.ExpandConvos()
|
|
480
|
-
assert.equal(scriptingProvider.convos.length,
|
|
344
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
481
345
|
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
482
|
-
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/
|
|
483
|
-
assert.equal(scriptingProvider.convos[
|
|
484
|
-
assert.equal(scriptingProvider.convos[
|
|
485
|
-
assert.equal(scriptingProvider.convos[
|
|
486
|
-
assert.equal(scriptingProvider.convos[
|
|
346
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/utt with some whitespace-L1')
|
|
347
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
348
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 1)
|
|
349
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt with some whitespace-L2')
|
|
350
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
487
351
|
})
|
|
488
|
-
|
|
489
|
-
|
|
352
|
+
describe('should build convos for SCRIPTING_UTTEXPANSION_NAMING_MODE', function () {
|
|
353
|
+
const utterances = {
|
|
354
|
+
name: 'uttText',
|
|
355
|
+
utterances: ['TEXT1 01234567890123456789', 'TEXT2 01234567890123456789']
|
|
356
|
+
}
|
|
357
|
+
const convoUtterances = {
|
|
358
|
+
header: {
|
|
359
|
+
name: 'test convo'
|
|
360
|
+
},
|
|
361
|
+
conversation: [
|
|
362
|
+
{
|
|
363
|
+
sender: 'me',
|
|
364
|
+
messageText: 'uttText'
|
|
365
|
+
}
|
|
366
|
+
]
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=justLineNumber', async function () {
|
|
370
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
371
|
+
await scriptingProvider.Build()
|
|
372
|
+
scriptingProvider.AddUtterances(utterances)
|
|
373
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
374
|
+
|
|
375
|
+
scriptingProvider.ExpandConvos()
|
|
376
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
377
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
378
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1')
|
|
379
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2')
|
|
380
|
+
})
|
|
490
381
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
name: 'utt1',
|
|
631
|
-
utterances: ['TEXT1', 'TEXT2']
|
|
632
|
-
})
|
|
633
|
-
|
|
634
|
-
scriptingProvider.ExpandUtterancesToConvos()
|
|
635
|
-
assert.lengthOf(scriptingProvider.convos, 1)
|
|
636
|
-
assert.lengthOf(scriptingProvider.convos[0].conversation, 2)
|
|
637
|
-
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
638
|
-
assert.equal(scriptingProvider.convos[0].conversation[1].messageText, '')
|
|
639
|
-
assert.isFalse(scriptingProvider.convos[0].conversation[1].not)
|
|
640
|
-
|
|
641
|
-
scriptingProvider.ExpandConvos()
|
|
642
|
-
assert.lengthOf(scriptingProvider.convos, 2)
|
|
643
|
-
assert.lengthOf(scriptingProvider.convos[0].conversation, 2)
|
|
644
|
-
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
645
|
-
assert.equal(scriptingProvider.convos[0].conversation[1].messageText, '')
|
|
646
|
-
assert.isFalse(scriptingProvider.convos[0].conversation[1].not)
|
|
647
|
-
assert.lengthOf(scriptingProvider.convos[1].conversation, 2)
|
|
648
|
-
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
649
|
-
assert.equal(scriptingProvider.convos[1].conversation[1].messageText, '')
|
|
650
|
-
assert.isFalse(scriptingProvider.convos[1].conversation[1].not)
|
|
382
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance', async function () {
|
|
383
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
384
|
+
{},
|
|
385
|
+
DefaultCapabilities,
|
|
386
|
+
{
|
|
387
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
388
|
+
}
|
|
389
|
+
))
|
|
390
|
+
await scriptingProvider.Build()
|
|
391
|
+
scriptingProvider.AddUtterances(utterances)
|
|
392
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
393
|
+
|
|
394
|
+
scriptingProvider.ExpandConvos()
|
|
395
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
396
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
397
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1-TEXT1 0123456...')
|
|
398
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2-TEXT2 0123456...')
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance, turn length off', async function () {
|
|
402
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
403
|
+
{},
|
|
404
|
+
DefaultCapabilities,
|
|
405
|
+
{
|
|
406
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance',
|
|
407
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: null
|
|
408
|
+
}
|
|
409
|
+
))
|
|
410
|
+
await scriptingProvider.Build()
|
|
411
|
+
scriptingProvider.AddUtterances(utterances)
|
|
412
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
413
|
+
|
|
414
|
+
scriptingProvider.ExpandConvos()
|
|
415
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
416
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
417
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1-TEXT1 01234567890123456789')
|
|
418
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2-TEXT2 01234567890123456789')
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance len=10', async function () {
|
|
422
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
423
|
+
{},
|
|
424
|
+
DefaultCapabilities,
|
|
425
|
+
{
|
|
426
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance',
|
|
427
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_UTTERANCE_MAX]: 10
|
|
428
|
+
}
|
|
429
|
+
))
|
|
430
|
+
await scriptingProvider.Build()
|
|
431
|
+
scriptingProvider.AddUtterances(utterances)
|
|
432
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), convoUtterances))
|
|
433
|
+
|
|
434
|
+
scriptingProvider.ExpandConvos()
|
|
435
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
436
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
437
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1-TEXT1 0...')
|
|
438
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2-TEXT2 0...')
|
|
439
|
+
})
|
|
440
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance userinputs', async function () {
|
|
441
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
442
|
+
{},
|
|
443
|
+
DefaultCapabilities,
|
|
444
|
+
{
|
|
445
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
446
|
+
}
|
|
447
|
+
))
|
|
448
|
+
await scriptingProvider.Build()
|
|
449
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
450
|
+
header: {
|
|
451
|
+
name: 'test convo'
|
|
452
|
+
},
|
|
453
|
+
sourceTag: {},
|
|
454
|
+
conversation: [
|
|
455
|
+
{
|
|
456
|
+
sender: 'me',
|
|
457
|
+
userInputs: [
|
|
458
|
+
{
|
|
459
|
+
name: 'BUTTON',
|
|
460
|
+
args: ['button1']
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
name: 'MEDIA',
|
|
464
|
+
args: ['test1.jpg', 'test2 01234567890123456789.jpg', 'test3.jpg']
|
|
465
|
+
}
|
|
466
|
+
]
|
|
467
|
+
}
|
|
468
|
+
]
|
|
469
|
+
}))
|
|
470
|
+
|
|
471
|
+
scriptingProvider.ExpandConvos()
|
|
472
|
+
assert.equal(scriptingProvider.convos.length, 3)
|
|
473
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
474
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-L1-test1.jpg')
|
|
475
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-L2-test2 0123456...')
|
|
476
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-L3-test3.jpg')
|
|
477
|
+
})
|
|
478
|
+
it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance userinputs and utterances', async function () {
|
|
479
|
+
const scriptingProvider = new ScriptingProvider(Object.assign(
|
|
480
|
+
{},
|
|
481
|
+
DefaultCapabilities,
|
|
482
|
+
{
|
|
483
|
+
[Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
|
|
484
|
+
}
|
|
485
|
+
))
|
|
486
|
+
await scriptingProvider.Build()
|
|
487
|
+
scriptingProvider.AddUtterances(utterances)
|
|
488
|
+
scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
|
|
489
|
+
header: {
|
|
490
|
+
name: 'test convo'
|
|
491
|
+
},
|
|
492
|
+
sourceTag: {},
|
|
493
|
+
conversation: [
|
|
494
|
+
{
|
|
495
|
+
sender: 'me',
|
|
496
|
+
messageText: 'uttText',
|
|
497
|
+
userInputs: [
|
|
498
|
+
{
|
|
499
|
+
name: 'BUTTON',
|
|
500
|
+
args: ['button1']
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
name: 'MEDIA',
|
|
504
|
+
args: ['test1.jpg', 'test2 01234567890123456789.jpg', 'test3.jpg']
|
|
505
|
+
}
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
]
|
|
509
|
+
}))
|
|
510
|
+
|
|
511
|
+
scriptingProvider.ExpandConvos()
|
|
512
|
+
assert.equal(scriptingProvider.convos.length, 5)
|
|
513
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 1)
|
|
514
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-L1-test1.jpg')
|
|
515
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-L2-test2 0123456...')
|
|
516
|
+
assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-L3-test3.jpg')
|
|
517
|
+
assert.equal(scriptingProvider.convos[3].header.name, 'test convo/uttText-L1-TEXT1 0123456...')
|
|
518
|
+
assert.equal(scriptingProvider.convos[4].header.name, 'test convo/uttText-L2-TEXT2 0123456...')
|
|
519
|
+
})
|
|
520
|
+
})
|
|
651
521
|
})
|
|
652
|
-
it('should fail incomprehension convos for utterance without incomprehension utt', async function () {
|
|
653
|
-
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities, { SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION' }))
|
|
654
|
-
await scriptingProvider.Build()
|
|
655
522
|
|
|
656
|
-
|
|
523
|
+
describe('ExpandUtterancesToConvos', function () {
|
|
524
|
+
it('should build plain convos for utterance', async function () {
|
|
525
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
526
|
+
await scriptingProvider.Build()
|
|
527
|
+
scriptingProvider.AddUtterances({
|
|
528
|
+
name: 'utt1',
|
|
529
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
530
|
+
})
|
|
531
|
+
|
|
657
532
|
scriptingProvider.ExpandUtterancesToConvos()
|
|
658
|
-
assert.
|
|
659
|
-
|
|
660
|
-
assert.
|
|
661
|
-
|
|
662
|
-
})
|
|
663
|
-
})
|
|
533
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
534
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
535
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'utt1')
|
|
536
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
664
537
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
assert.
|
|
673
|
-
|
|
674
|
-
assert.equal(
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
assert.
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
538
|
+
scriptingProvider.ExpandConvos()
|
|
539
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
540
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
541
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'utt1/utt1-L1')
|
|
542
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
543
|
+
assert.equal(scriptingProvider.convos[0].toString(), '1 utt1/utt1-L1 (Expanded Utterances - utt1) ({ origUttName: \'utt1\', origConvoName: \'utt1\' }): Step 1 - tell utterance: #me - TEXT1 SKIP_BOT_UNCONSUMED(no args) | Step 2 - check bot response: #bot - ')
|
|
544
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 2)
|
|
545
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'utt1/utt1-L2')
|
|
546
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
547
|
+
assert.equal(scriptingProvider.convos[1].toString(), '2 utt1/utt1-L2 (Expanded Utterances - utt1) ({ origUttName: \'utt1\', origConvoName: \'utt1\' }): Step 1 - tell utterance: #me - TEXT2 SKIP_BOT_UNCONSUMED(no args) | Step 2 - check bot response: #bot - ')
|
|
548
|
+
})
|
|
549
|
+
it('should add leading zeros for utterance tags', async function () {
|
|
550
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
551
|
+
await scriptingProvider.Build()
|
|
552
|
+
scriptingProvider.AddUtterances({
|
|
553
|
+
name: 'utt1',
|
|
554
|
+
utterances: Array.from(Array(10000).keys()).map(i => `TEXT${i + 1}`)
|
|
555
|
+
})
|
|
556
|
+
|
|
557
|
+
scriptingProvider.ExpandUtterancesToConvos()
|
|
558
|
+
scriptingProvider.ExpandConvos()
|
|
559
|
+
|
|
560
|
+
assert.equal(scriptingProvider.convos.length, 10000)
|
|
561
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
562
|
+
assert.equal(scriptingProvider.convos[0].header.name, 'utt1/utt1-L00001')
|
|
563
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
564
|
+
assert.equal(scriptingProvider.convos[0].toString(), '1 utt1/utt1-L00001 (Expanded Utterances - utt1) ({ origUttName: \'utt1\', origConvoName: \'utt1\' }): Step 1 - tell utterance: #me - TEXT1 SKIP_BOT_UNCONSUMED(no args) | Step 2 - check bot response: #bot - ')
|
|
565
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 2)
|
|
566
|
+
assert.equal(scriptingProvider.convos[1].header.name, 'utt1/utt1-L00002')
|
|
567
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
568
|
+
assert.equal(scriptingProvider.convos[1].toString(), '2 utt1/utt1-L00002 (Expanded Utterances - utt1) ({ origUttName: \'utt1\', origConvoName: \'utt1\' }): Step 1 - tell utterance: #me - TEXT2 SKIP_BOT_UNCONSUMED(no args) | Step 2 - check bot response: #bot - ')
|
|
569
|
+
})
|
|
570
|
+
it('should build incomprehension convos for utterance', async function () {
|
|
571
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities, { SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION' }))
|
|
572
|
+
await scriptingProvider.Build()
|
|
573
|
+
scriptingProvider.AddUtterances({
|
|
574
|
+
name: 'utt1',
|
|
575
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
576
|
+
})
|
|
577
|
+
scriptingProvider.AddUtterances({
|
|
578
|
+
name: 'INCOMPREHENSION',
|
|
579
|
+
utterances: ['INCOMPREHENSION1', 'INCOMPREHENSION2']
|
|
580
|
+
})
|
|
581
|
+
|
|
582
|
+
scriptingProvider.ExpandUtterancesToConvos()
|
|
583
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
584
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
585
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
586
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].messageText, 'INCOMPREHENSION')
|
|
587
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].not, true)
|
|
588
|
+
|
|
589
|
+
scriptingProvider.ExpandConvos()
|
|
590
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
591
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
592
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
593
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].messageText, 'INCOMPREHENSION')
|
|
594
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].not, true)
|
|
595
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 2)
|
|
596
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
597
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].messageText, 'INCOMPREHENSION')
|
|
598
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].not, true)
|
|
599
|
+
})
|
|
600
|
+
it('should build intent check convos for utterance', async function () {
|
|
601
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities, { SCRIPTING_UTTEXPANSION_USENAMEASINTENT: true }))
|
|
602
|
+
await scriptingProvider.Build()
|
|
603
|
+
scriptingProvider.AddUtterances({
|
|
604
|
+
name: 'utt1',
|
|
605
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
606
|
+
})
|
|
607
|
+
|
|
608
|
+
scriptingProvider.ExpandUtterancesToConvos()
|
|
609
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
610
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
611
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
612
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters.length, 1)
|
|
613
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].name, 'INTENT')
|
|
614
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].args[0], 'utt1')
|
|
700
615
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
assert.
|
|
709
|
-
|
|
710
|
-
assert.equal(
|
|
711
|
-
|
|
616
|
+
scriptingProvider.ExpandConvos()
|
|
617
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
618
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
619
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
620
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters.length, 1)
|
|
621
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].name, 'INTENT')
|
|
622
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].args[0], 'utt1')
|
|
623
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 2)
|
|
624
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
625
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].asserters.length, 1)
|
|
626
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].asserters[0].name, 'INTENT')
|
|
627
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].asserters[0].args[0], 'utt1')
|
|
628
|
+
})
|
|
629
|
+
it('should build intent check convos for utterance (with arg)', async function () {
|
|
630
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities))
|
|
631
|
+
await scriptingProvider.Build()
|
|
632
|
+
scriptingProvider.AddUtterances({
|
|
633
|
+
name: 'utt1',
|
|
634
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
635
|
+
})
|
|
636
|
+
|
|
637
|
+
scriptingProvider.ExpandUtterancesToConvos({ useNameAsIntent: true })
|
|
638
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
639
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
640
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
641
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters.length, 1)
|
|
642
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].name, 'INTENT')
|
|
643
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].args[0], 'utt1')
|
|
644
|
+
|
|
645
|
+
scriptingProvider.ExpandConvos()
|
|
646
|
+
assert.equal(scriptingProvider.convos.length, 2)
|
|
647
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
648
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
649
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters.length, 1)
|
|
650
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].name, 'INTENT')
|
|
651
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].args[0], 'utt1')
|
|
652
|
+
assert.equal(scriptingProvider.convos[1].conversation.length, 2)
|
|
653
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
654
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].asserters.length, 1)
|
|
655
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].asserters[0].name, 'INTENT')
|
|
656
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].asserters[0].args[0], 'utt1')
|
|
657
|
+
})
|
|
658
|
+
it('should build check-only convos for utterance', async function () {
|
|
659
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities))
|
|
660
|
+
await scriptingProvider.Build()
|
|
661
|
+
scriptingProvider.AddUtterances({
|
|
662
|
+
name: 'utt1',
|
|
663
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
664
|
+
})
|
|
665
|
+
|
|
666
|
+
scriptingProvider.ExpandUtterancesToConvos()
|
|
667
|
+
assert.lengthOf(scriptingProvider.convos, 1)
|
|
668
|
+
assert.lengthOf(scriptingProvider.convos[0].conversation, 2)
|
|
669
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
670
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].messageText, '')
|
|
671
|
+
assert.isFalse(scriptingProvider.convos[0].conversation[1].not)
|
|
672
|
+
|
|
673
|
+
scriptingProvider.ExpandConvos()
|
|
674
|
+
assert.lengthOf(scriptingProvider.convos, 2)
|
|
675
|
+
assert.lengthOf(scriptingProvider.convos[0].conversation, 2)
|
|
676
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'TEXT1')
|
|
677
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].messageText, '')
|
|
678
|
+
assert.isFalse(scriptingProvider.convos[0].conversation[1].not)
|
|
679
|
+
assert.lengthOf(scriptingProvider.convos[1].conversation, 2)
|
|
680
|
+
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
681
|
+
assert.equal(scriptingProvider.convos[1].conversation[1].messageText, '')
|
|
682
|
+
assert.isFalse(scriptingProvider.convos[1].conversation[1].not)
|
|
683
|
+
})
|
|
684
|
+
it('should fail incomprehension convos for utterance without incomprehension utt', async function () {
|
|
685
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities, { SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION' }))
|
|
686
|
+
await scriptingProvider.Build()
|
|
687
|
+
|
|
688
|
+
try {
|
|
689
|
+
scriptingProvider.ExpandUtterancesToConvos()
|
|
690
|
+
assert.fail('should have failed')
|
|
691
|
+
} catch (err) {
|
|
692
|
+
assert.isTrue(err.message.indexOf('incomprehension utterance \'INCOMPREHENSION\' undefined') > 0)
|
|
693
|
+
}
|
|
694
|
+
})
|
|
712
695
|
})
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
scriptingContext.
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
696
|
+
|
|
697
|
+
describe('assertBotResponse', function () {
|
|
698
|
+
it('should fail with correct error message on single tomatch', async function () {
|
|
699
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
700
|
+
await scriptingProvider.Build()
|
|
701
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
702
|
+
try {
|
|
703
|
+
scriptingContext.scriptingEvents.assertBotResponse('actual', 'expected', 'test1')
|
|
704
|
+
assert.fail('expected error')
|
|
705
|
+
} catch (err) {
|
|
706
|
+
assert.equal(err.message, 'test1: Bot response "actual" expected to match "expected"')
|
|
707
|
+
}
|
|
708
|
+
})
|
|
709
|
+
it('should fail with correct error message on empty bot message', async function () {
|
|
710
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
711
|
+
await scriptingProvider.Build()
|
|
712
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
713
|
+
try {
|
|
714
|
+
scriptingContext.scriptingEvents.assertBotResponse(null, 'expected', 'test1')
|
|
715
|
+
assert.fail('expected error')
|
|
716
|
+
} catch (err) {
|
|
717
|
+
assert.equal(err.message, 'test1: Bot response <no response> expected to match "expected"')
|
|
718
|
+
}
|
|
719
|
+
})
|
|
720
|
+
it('should fail with correct error message on multiple tomatch', async function () {
|
|
721
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
722
|
+
await scriptingProvider.Build()
|
|
723
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
724
|
+
try {
|
|
725
|
+
scriptingContext.scriptingEvents.assertBotResponse('actual', ['expected1', 'expected2'], 'test1')
|
|
726
|
+
assert.fail('expected error')
|
|
727
|
+
} catch (err) {
|
|
728
|
+
assert.equal(err.message, 'test1: Bot response "actual" expected to match one of "expected1", "expected2"')
|
|
729
|
+
}
|
|
730
|
+
})
|
|
723
731
|
})
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
scriptingContext.
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
732
|
+
|
|
733
|
+
describe('assertBotNotResponse', function () {
|
|
734
|
+
it('should fail with correct error message on match', async function () {
|
|
735
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
736
|
+
await scriptingProvider.Build()
|
|
737
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
738
|
+
try {
|
|
739
|
+
scriptingContext.scriptingEvents.assertBotNotResponse('Keine Antwort gefunden!', ['Keine Antwort gefunden'], 'test1')
|
|
740
|
+
assert.fail('expected error')
|
|
741
|
+
} catch (err) {
|
|
742
|
+
assert.equal(err.message, 'test1: Bot response "Keine Antwort gefunden!" expected NOT to match "Keine Antwort gefunden"')
|
|
743
|
+
}
|
|
744
|
+
})
|
|
745
|
+
it('should fail with correct error message on by empty asserter', async function () {
|
|
746
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
747
|
+
await scriptingProvider.Build()
|
|
748
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
749
|
+
try {
|
|
750
|
+
scriptingContext.scriptingEvents.assertBotNotResponse('Keine Antwort gefunden!', [''], 'test1')
|
|
751
|
+
assert.fail('expected error')
|
|
752
|
+
} catch (err) {
|
|
753
|
+
assert.equal(err.message, 'test1: Bot response "Keine Antwort gefunden!" expected NOT to match <any response>')
|
|
754
|
+
}
|
|
755
|
+
})
|
|
756
|
+
it('should fail with correct error message on by empty asserter, and empty bot response', async function () {
|
|
757
|
+
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
758
|
+
await scriptingProvider.Build()
|
|
759
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
760
|
+
try {
|
|
761
|
+
scriptingContext.scriptingEvents.assertBotNotResponse('', [''], 'test1')
|
|
762
|
+
assert.fail('expected error')
|
|
763
|
+
} catch (err) {
|
|
764
|
+
assert.equal(err.message, 'test1: Bot response <no response> expected NOT to match <any response>')
|
|
765
|
+
}
|
|
766
|
+
})
|
|
734
767
|
})
|
|
735
768
|
})
|