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
|
@@ -7,358 +7,376 @@ const echoConnector = ({ queueBotSays }) => {
|
|
|
7
7
|
return {
|
|
8
8
|
UserSays (msg) {
|
|
9
9
|
const response = `You said: ${msg.messageText.replace('forcereplace1', 'OUTPUT1').replace('forcereplace2', 'OUTPUT2')}`
|
|
10
|
-
const botMsg = {
|
|
10
|
+
const botMsg = {
|
|
11
|
+
sender: 'bot',
|
|
12
|
+
sourceData: msg.sourceData,
|
|
13
|
+
messageText: response
|
|
14
|
+
}
|
|
11
15
|
queueBotSays(botMsg)
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
describe('scripting.fillingScriptingMemoryFromFile
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
it('Set Scripting memory by convo vs by scripting memory file', async function () {
|
|
35
|
-
// scripting memory file wins, log on console
|
|
36
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosLogicHookCollision'))
|
|
37
|
-
this.compiler.ExpandScriptingMemoryToConvos()
|
|
38
|
-
assert.equal(this.compiler.convos.length, 1)
|
|
39
|
-
|
|
40
|
-
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
41
|
-
assert.isObject(transcript.scriptingMemory)
|
|
42
|
-
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
43
|
-
assert.equal(transcript.scriptingMemory.$productName, 'Wiener Schnitzel')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('one scripting memory file, two colums', async function () {
|
|
47
|
-
// variations are hardcoded into table
|
|
48
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosOneTable'))
|
|
49
|
-
this.compiler.ExpandScriptingMemoryToConvos()
|
|
50
|
-
assert.equal(this.compiler.convos.length, 4)
|
|
51
|
-
|
|
52
|
-
for (const convo of this.compiler.convos) {
|
|
53
|
-
await this.container.Start()
|
|
54
|
-
const transcript = await convo.Run(this.container)
|
|
55
|
-
assert.isObject(transcript.scriptingMemory)
|
|
56
|
-
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
57
|
-
await this.container.Stop()
|
|
58
|
-
}
|
|
59
|
-
})
|
|
20
|
+
describe('scripting.scriptingmemory.fillingScriptingMemoryFromFile', function () {
|
|
21
|
+
describe('memoryenabled.originaldeleted', function () {
|
|
22
|
+
beforeEach(async function () {
|
|
23
|
+
const myCaps = {
|
|
24
|
+
[Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
|
|
25
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
26
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
27
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
28
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
|
|
29
|
+
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false
|
|
30
|
+
}
|
|
31
|
+
const driver = new BotDriver(myCaps)
|
|
32
|
+
this.compiler = driver.BuildCompiler()
|
|
33
|
+
this.container = await driver.Build()
|
|
34
|
+
})
|
|
35
|
+
afterEach(async function () {
|
|
36
|
+
this.container && await this.container.Clean()
|
|
37
|
+
})
|
|
60
38
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
39
|
+
it('Set Scripting memory by convo vs by scripting memory file', async function () {
|
|
40
|
+
// scripting memory file wins, log on console
|
|
41
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosLogicHookCollision'))
|
|
42
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
43
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
66
44
|
|
|
67
|
-
|
|
68
|
-
const transcript = await convo.Run(this.container)
|
|
45
|
+
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
69
46
|
assert.isObject(transcript.scriptingMemory)
|
|
70
47
|
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
it('two scripting memory file, one colum each, column mode testcasenames', async function () {
|
|
75
|
-
// all variations are generated
|
|
76
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosTwoTablesCols'))
|
|
77
|
-
this.compiler.ExpandScriptingMemoryToConvos()
|
|
78
|
-
assert.equal(this.compiler.convos.length, 4)
|
|
79
|
-
|
|
80
|
-
const assertScriptingMemory = [
|
|
81
|
-
{ $productName: 'Wiener Schnitzel', $customerName: 'GoodCustomer' },
|
|
82
|
-
{ $productName: 'Pfannkuchen', $customerName: 'GoodCustomer' },
|
|
83
|
-
{ $productName: 'Wiener Schnitzel', $customerName: 'BadCustomer' },
|
|
84
|
-
{ $productName: 'Pfannkuchen', $customerName: 'BadCustomer' }
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
for (const [i, convo] of this.compiler.convos.entries()) {
|
|
88
|
-
const transcript = await convo.Run(this.container)
|
|
89
|
-
assert.isObject(transcript.scriptingMemory)
|
|
90
|
-
assert.equal(transcript.scriptingMemory.$productName, assertScriptingMemory[i].$productName)
|
|
91
|
-
assert.equal(transcript.scriptingMemory.$customerName, assertScriptingMemory[i].$customerName)
|
|
92
|
-
}
|
|
93
|
-
})
|
|
48
|
+
assert.equal(transcript.scriptingMemory.$productName, 'Wiener Schnitzel')
|
|
49
|
+
})
|
|
94
50
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
51
|
+
it('one scripting memory file, two colums', async function () {
|
|
52
|
+
// variations are hardcoded into table
|
|
53
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosOneTable'))
|
|
54
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
55
|
+
assert.equal(this.compiler.convos.length, 4)
|
|
100
56
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
57
|
+
for (const convo of this.compiler.convos) {
|
|
58
|
+
await this.container.Start()
|
|
59
|
+
const transcript = await convo.Run(this.container)
|
|
60
|
+
assert.isObject(transcript.scriptingMemory)
|
|
61
|
+
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
62
|
+
await this.container.Stop()
|
|
63
|
+
}
|
|
64
|
+
})
|
|
106
65
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
113
|
-
assert.isObject(transcript.scriptingMemory)
|
|
114
|
-
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
115
|
-
assert.equal(transcript.scriptingMemory.$productName, 'Wiener Schnitzel')
|
|
116
|
-
assert.isDefined(transcript.scriptingMemory.$customer)
|
|
117
|
-
assert.equal(transcript.scriptingMemory.$customer, 'Joe')
|
|
118
|
-
})
|
|
66
|
+
it('two scripting memory file, one colum each', async function () {
|
|
67
|
+
// all variations are generated
|
|
68
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosTwoTables'))
|
|
69
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
70
|
+
assert.equal(this.compiler.convos.length, 4)
|
|
119
71
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
assert.isObject(transcript.scriptingMemory)
|
|
127
|
-
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
128
|
-
assert.equal(transcript.scriptingMemory.$productName, 'Wiener Schnitzel')
|
|
129
|
-
assert.isDefined(transcript.scriptingMemory.$customer)
|
|
130
|
-
assert.equal(transcript.scriptingMemory.$customer, 'Joe')
|
|
131
|
-
})
|
|
72
|
+
for (const convo of this.compiler.convos) {
|
|
73
|
+
const transcript = await convo.Run(this.container)
|
|
74
|
+
assert.isObject(transcript.scriptingMemory)
|
|
75
|
+
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
132
78
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, '
|
|
79
|
+
it('two scripting memory file, one colum each, column mode testcasenames', async function () {
|
|
80
|
+
// all variations are generated
|
|
81
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosTwoTablesCols'))
|
|
136
82
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
137
|
-
|
|
138
|
-
assert.equal(err.toString(), 'BotiumError: ReadScript - an error occurred at \'products.scriptingmemory.txt\' file: Scripting Memory Definition has no name')
|
|
139
|
-
assert.isNotNull(err.context)
|
|
140
|
-
assert.equal(err.context.type, 'Compiler')
|
|
141
|
-
assert.equal(err.context.subtype, 'Scripting memory without name')
|
|
142
|
-
assert.equal(err.context.source, 'ScriptingProvider')
|
|
143
|
-
|
|
144
|
-
return
|
|
145
|
-
}
|
|
146
|
-
throw (new Error('Exception not thrown'))
|
|
147
|
-
})
|
|
83
|
+
assert.equal(this.compiler.convos.length, 4)
|
|
148
84
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
85
|
+
const assertScriptingMemory = [
|
|
86
|
+
{
|
|
87
|
+
$productName: 'Wiener Schnitzel',
|
|
88
|
+
$customerName: 'GoodCustomer'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
$productName: 'Pfannkuchen',
|
|
92
|
+
$customerName: 'GoodCustomer'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
$productName: 'Wiener Schnitzel',
|
|
96
|
+
$customerName: 'BadCustomer'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
$productName: 'Pfannkuchen',
|
|
100
|
+
$customerName: 'BadCustomer'
|
|
101
|
+
}
|
|
102
|
+
]
|
|
164
103
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
assert.equal(err.context.type, 'Compiler')
|
|
173
|
-
assert.equal(err.context.subtype, 'Scripting memory without variable')
|
|
174
|
-
assert.equal(err.context.source, 'ScriptingProvider')
|
|
175
|
-
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
throw (new Error('Exception not thrown'))
|
|
179
|
-
})
|
|
104
|
+
for (const [i, convo] of this.compiler.convos.entries()) {
|
|
105
|
+
const transcript = await convo.Run(this.container)
|
|
106
|
+
assert.isObject(transcript.scriptingMemory)
|
|
107
|
+
assert.equal(transcript.scriptingMemory.$productName, assertScriptingMemory[i].$productName)
|
|
108
|
+
assert.equal(transcript.scriptingMemory.$customerName, assertScriptingMemory[i].$customerName)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
180
111
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, '
|
|
112
|
+
it('Value is optional in the scripting memory file', async function () {
|
|
113
|
+
// all variations are generated
|
|
114
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosValueOptional'))
|
|
184
115
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
185
|
-
assert.equal(this.compiler.convos.length,
|
|
116
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
186
117
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
assert.isObject(err.transcript.scriptingMemory)
|
|
192
|
-
assert.isDefined(err.transcript.scriptingMemory.$productName)
|
|
193
|
-
assert.equal(err.transcript.scriptingMemory.$productName, 'Bread')
|
|
194
|
-
assert.isDefined(err.transcript.scriptingMemory.$available_products)
|
|
195
|
-
assert.equal(err.transcript.scriptingMemory.$available_products, 'Bread, Beer, Eggs')
|
|
196
|
-
return
|
|
197
|
-
} else {
|
|
198
|
-
throw err
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
throw (new Error('Exception not thrown'))
|
|
118
|
+
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
119
|
+
assert.isObject(transcript.scriptingMemory)
|
|
120
|
+
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
121
|
+
assert.notExists(transcript.scriptingMemory.$customerName)
|
|
202
122
|
})
|
|
203
123
|
|
|
204
|
-
it('
|
|
205
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, '
|
|
124
|
+
it('Using text file', async function () {
|
|
125
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimpleText'))
|
|
206
126
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
207
|
-
assert.equal(this.compiler.convos.length,
|
|
127
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
208
128
|
|
|
209
|
-
const transcript = await this.compiler.convos[
|
|
129
|
+
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
210
130
|
assert.isObject(transcript.scriptingMemory)
|
|
211
131
|
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
212
|
-
assert.equal(transcript.scriptingMemory.$productName, '
|
|
132
|
+
assert.equal(transcript.scriptingMemory.$productName, 'Wiener Schnitzel')
|
|
133
|
+
assert.isDefined(transcript.scriptingMemory.$customer)
|
|
134
|
+
assert.equal(transcript.scriptingMemory.$customer, 'Joe')
|
|
213
135
|
})
|
|
214
136
|
|
|
215
|
-
it('
|
|
216
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, '
|
|
137
|
+
it('Using text file in column mode testcasenames', async function () {
|
|
138
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimpleCols'))
|
|
217
139
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
218
|
-
assert.equal(this.compiler.convos.length,
|
|
140
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
219
141
|
|
|
220
|
-
const transcript = await this.compiler.convos[
|
|
142
|
+
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
221
143
|
assert.isObject(transcript.scriptingMemory)
|
|
222
144
|
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
223
|
-
assert.equal(transcript.scriptingMemory.$productName, '
|
|
145
|
+
assert.equal(transcript.scriptingMemory.$productName, 'Wiener Schnitzel')
|
|
146
|
+
assert.isDefined(transcript.scriptingMemory.$customer)
|
|
147
|
+
assert.equal(transcript.scriptingMemory.$customer, 'Joe')
|
|
224
148
|
})
|
|
225
149
|
|
|
226
|
-
it('should throw exception if
|
|
150
|
+
it('should throw exception if name is not set', async function () {
|
|
227
151
|
try {
|
|
228
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, '
|
|
152
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoName'))
|
|
229
153
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
230
154
|
} catch (err) {
|
|
231
|
-
assert.equal(err.toString(), 'BotiumError:
|
|
155
|
+
assert.equal(err.toString(), 'BotiumError: ReadScript - an error occurred at \'products.scriptingmemory.txt\' file: Scripting Memory Definition has no name')
|
|
232
156
|
assert.isNotNull(err.context)
|
|
233
|
-
assert.equal(err.context.type, '
|
|
157
|
+
assert.equal(err.context.type, 'Compiler')
|
|
158
|
+
assert.equal(err.context.subtype, 'Scripting memory without name')
|
|
234
159
|
assert.equal(err.context.source, 'ScriptingProvider')
|
|
235
160
|
|
|
236
|
-
assert.isObject(err.context.cause)
|
|
237
|
-
assert.isArray(err.context.cause.aggregatedIntersections)
|
|
238
|
-
assert.equal(err.context.cause.aggregatedIntersections.length, 3)
|
|
239
|
-
|
|
240
161
|
return
|
|
241
162
|
}
|
|
242
163
|
throw (new Error('Exception not thrown'))
|
|
243
164
|
})
|
|
244
165
|
|
|
245
|
-
it('should throw exception if
|
|
166
|
+
it('should throw exception if variable name is not set', async function () {
|
|
246
167
|
try {
|
|
247
|
-
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, '
|
|
168
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoVariableName'))
|
|
248
169
|
this.compiler.ExpandScriptingMemoryToConvos()
|
|
249
170
|
} catch (err) {
|
|
250
|
-
assert.equal(err.toString(), 'BotiumError: Scripting Memory Definition
|
|
171
|
+
assert.equal(err.toString(), 'BotiumError: ReadScript - an error occurred at \'products.scriptingmemory.txt\' file: Scripting Memory Definition variable has no name')
|
|
251
172
|
assert.isNotNull(err.context)
|
|
252
|
-
assert.equal(err.context.type, '
|
|
173
|
+
assert.equal(err.context.type, 'Compiler')
|
|
174
|
+
assert.equal(err.context.subtype, 'Scripting memory without variable name')
|
|
253
175
|
assert.equal(err.context.source, 'ScriptingProvider')
|
|
254
176
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
throw (new Error('Exception not thrown'))
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
it('should throw exception variable is not set', async function () {
|
|
183
|
+
try {
|
|
184
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoVariable'))
|
|
185
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
186
|
+
} catch (err) {
|
|
187
|
+
assert.equal(err.toString(), 'BotiumError: ReadScript - an error occurred at \'products.scriptingmemory.txt\' file: Scripting Memory Definition has no variables')
|
|
188
|
+
assert.isNotNull(err.context)
|
|
189
|
+
assert.equal(err.context.type, 'Compiler')
|
|
190
|
+
assert.equal(err.context.subtype, 'Scripting memory without variable')
|
|
191
|
+
assert.equal(err.context.source, 'ScriptingProvider')
|
|
258
192
|
|
|
259
193
|
return
|
|
260
194
|
}
|
|
261
195
|
throw (new Error('Exception not thrown'))
|
|
262
196
|
})
|
|
263
|
-
})
|
|
264
197
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
198
|
+
describe('Using multiple scripting memory file', function () {
|
|
199
|
+
it('should work with different variable names', async function () {
|
|
200
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryDifferent'))
|
|
201
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
202
|
+
assert.equal(this.compiler.convos.length, 6)
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
await this.compiler.convos[0].Run(this.container)
|
|
206
|
+
} catch (err) {
|
|
207
|
+
if (err.transcript) {
|
|
208
|
+
assert.isObject(err.transcript.scriptingMemory)
|
|
209
|
+
assert.isDefined(err.transcript.scriptingMemory.$productName)
|
|
210
|
+
assert.equal(err.transcript.scriptingMemory.$productName, 'Bread')
|
|
211
|
+
assert.isDefined(err.transcript.scriptingMemory.$available_products)
|
|
212
|
+
assert.equal(err.transcript.scriptingMemory.$available_products, 'Bread, Beer, Eggs')
|
|
213
|
+
return
|
|
214
|
+
} else {
|
|
215
|
+
throw err
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
throw (new Error('Exception not thrown'))
|
|
219
|
+
})
|
|
269
220
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
})
|
|
275
|
-
})
|
|
221
|
+
it('should work with same variable names', async function () {
|
|
222
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemorySame'))
|
|
223
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
224
|
+
assert.equal(this.compiler.convos.length, 4)
|
|
276
225
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
283
|
-
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
284
|
-
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
|
|
285
|
-
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: true
|
|
226
|
+
const transcript = await this.compiler.convos[3].Run(this.container)
|
|
227
|
+
assert.isObject(transcript.scriptingMemory)
|
|
228
|
+
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
229
|
+
assert.equal(transcript.scriptingMemory.$productName, 'Hamburger')
|
|
230
|
+
})
|
|
286
231
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
232
|
+
it('should work with same variable names in column mode testcasenames', async function () {
|
|
233
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemorySameCols'))
|
|
234
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
235
|
+
assert.equal(this.compiler.convos.length, 4)
|
|
236
|
+
|
|
237
|
+
const transcript = await this.compiler.convos[3].Run(this.container)
|
|
238
|
+
assert.isObject(transcript.scriptingMemory)
|
|
239
|
+
assert.isDefined(transcript.scriptingMemory.$productName)
|
|
240
|
+
assert.equal(transcript.scriptingMemory.$productName, 'Hamburger')
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
it('should throw exception if there is intersection in convosMultiMemoryCaseNameCollisionvariable names', async function () {
|
|
244
|
+
try {
|
|
245
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryIntersection'))
|
|
246
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
247
|
+
} catch (err) {
|
|
248
|
+
assert.equal(err.toString(), 'BotiumError: Scripting Memory Definitions "available1, available2, product1" are invalid because variable name collision"')
|
|
249
|
+
assert.isNotNull(err.context)
|
|
250
|
+
assert.equal(err.context.type, 'Scripting Memory')
|
|
251
|
+
assert.equal(err.context.source, 'ScriptingProvider')
|
|
252
|
+
|
|
253
|
+
assert.isObject(err.context.cause)
|
|
254
|
+
assert.isArray(err.context.cause.aggregatedIntersections)
|
|
255
|
+
assert.equal(err.context.cause.aggregatedIntersections.length, 3)
|
|
295
256
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
throw (new Error('Exception not thrown'))
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
it('should throw exception if case name is not unique', async function () {
|
|
263
|
+
try {
|
|
264
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryCaseNameCollision'))
|
|
265
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
266
|
+
} catch (err) {
|
|
267
|
+
assert.equal(err.toString(), 'BotiumError: Scripting Memory Definition name(s) "product1" are not unique')
|
|
268
|
+
assert.isNotNull(err.context)
|
|
269
|
+
assert.equal(err.context.type, 'Scripting Memory')
|
|
270
|
+
assert.equal(err.context.source, 'ScriptingProvider')
|
|
271
|
+
|
|
272
|
+
assert.isObject(err.context.cause)
|
|
273
|
+
assert.isArray(err.context.cause.aggregatedDuplicates)
|
|
274
|
+
assert.equal(err.context.cause.aggregatedDuplicates.length, 2)
|
|
302
275
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
309
|
-
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
310
|
-
[Capabilities.SCRIPTING_ENABLE_MEMORY]: false
|
|
276
|
+
return
|
|
277
|
+
}
|
|
278
|
+
throw (new Error('Exception not thrown'))
|
|
279
|
+
})
|
|
280
|
+
})
|
|
311
281
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
282
|
+
// nothing to test here, this case is just a debug log.
|
|
283
|
+
it('Reserved word', async function () {
|
|
284
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosReservedWord'))
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
it('No intersecion, no multiply', async function () {
|
|
288
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosNoIntersection'))
|
|
289
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
290
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
291
|
+
})
|
|
319
292
|
})
|
|
320
293
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
294
|
+
describe('memoryenabled.originalkept', function () {
|
|
295
|
+
beforeEach(async function () {
|
|
296
|
+
const myCaps = {
|
|
297
|
+
[Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
|
|
298
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
299
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
300
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
301
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
|
|
302
|
+
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: true
|
|
325
303
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
})
|
|
304
|
+
}
|
|
305
|
+
const driver = new BotDriver(myCaps)
|
|
306
|
+
this.compiler = driver.BuildCompiler()
|
|
307
|
+
this.container = await driver.Build()
|
|
308
|
+
})
|
|
309
|
+
afterEach(async function () {
|
|
310
|
+
this.container && await this.container.Clean()
|
|
311
|
+
})
|
|
331
312
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
338
|
-
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
339
|
-
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
|
|
340
|
-
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false
|
|
341
|
-
}
|
|
342
|
-
const driver = new BotDriver(myCaps)
|
|
343
|
-
this.compiler = driver.BuildCompiler()
|
|
344
|
-
this.container = await driver.Build()
|
|
313
|
+
it('Original convo kept', async function () {
|
|
314
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimple'))
|
|
315
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
316
|
+
assert.equal(this.compiler.convos.length, 2)
|
|
317
|
+
})
|
|
345
318
|
})
|
|
346
|
-
|
|
347
|
-
|
|
319
|
+
|
|
320
|
+
describe('memorydisabled', function () {
|
|
321
|
+
beforeEach(async function () {
|
|
322
|
+
const myCaps = {
|
|
323
|
+
[Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
|
|
324
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
325
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
326
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
327
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: false
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
const driver = new BotDriver(myCaps)
|
|
331
|
+
this.compiler = driver.BuildCompiler()
|
|
332
|
+
this.container = await driver.Build()
|
|
333
|
+
})
|
|
334
|
+
afterEach(async function () {
|
|
335
|
+
this.container && await this.container.Clean()
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
it('scripting disabled, variable not replaced', async function () {
|
|
339
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimple'))
|
|
340
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
341
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
342
|
+
|
|
343
|
+
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
344
|
+
assert.isObject(transcript.scriptingMemory)
|
|
345
|
+
assert.notExists(transcript.scriptingMemory.$productName)
|
|
346
|
+
})
|
|
348
347
|
})
|
|
349
348
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
349
|
+
describe('coverage', function () {
|
|
350
|
+
beforeEach(async function () {
|
|
351
|
+
const myCaps = {
|
|
352
|
+
[Capabilities.PROJECTNAME]: 'scripting.fillingScriptingMemoryFromFile.coverage',
|
|
353
|
+
[Capabilities.CONTAINERMODE]: echoConnector,
|
|
354
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
|
|
355
|
+
[Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
|
|
356
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
|
|
357
|
+
[Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false
|
|
358
|
+
}
|
|
359
|
+
const driver = new BotDriver(myCaps)
|
|
360
|
+
this.compiler = driver.BuildCompiler()
|
|
361
|
+
this.container = await driver.Build()
|
|
362
|
+
})
|
|
363
|
+
afterEach(async function () {
|
|
364
|
+
this.container && await this.container.Clean()
|
|
365
|
+
})
|
|
354
366
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
assert.equal(
|
|
367
|
+
it('should replace scripting memory in asserter arguments', async function () {
|
|
368
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosCoverageAsserters'))
|
|
369
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
370
|
+
assert.equal(this.compiler.convos.length, 3)
|
|
359
371
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
372
|
+
try {
|
|
373
|
+
await this.compiler.convos[0].Run(this.container)
|
|
374
|
+
} catch (err) {
|
|
375
|
+
assert.equal(err.toString(), 'TranscriptError: asserters.product1/Line 9: assertion error - Line 9: Expected button(s) with text "Wiener Schnitzel"')
|
|
376
|
+
|
|
377
|
+
return
|
|
378
|
+
}
|
|
379
|
+
throw (new Error('Exception not thrown'))
|
|
380
|
+
})
|
|
363
381
|
})
|
|
364
382
|
})
|