botium-core 1.13.2 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +214 -61
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +213 -61
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +3 -1
  7. package/src/Capabilities.js +2 -1
  8. package/src/containers/plugins/SimpleRestContainer.js +20 -16
  9. package/src/grid/inbound/proxy.js +2 -1
  10. package/src/scripting/Convo.js +16 -10
  11. package/src/scripting/MatchFunctions.js +10 -0
  12. package/src/scripting/ScriptingProvider.js +106 -37
  13. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  14. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  15. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  16. package/test/compiler/compilercsv.spec.js +104 -3
  17. package/test/compiler/compilerjson.spec.js +0 -2
  18. package/test/compiler/compilerxlsx.spec.js +1 -1
  19. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  20. package/test/connectors/simplerest.spec.js +1012 -969
  21. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  22. package/test/convo/partialconvo.spec.js +345 -339
  23. package/test/driver/capabilities.spec.js +156 -151
  24. package/test/logichooks/hookfromsrc.spec.js +79 -73
  25. package/test/plugins/plugins.spec.js +44 -42
  26. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  27. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  28. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  29. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  30. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  31. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  32. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  33. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  34. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  35. package/test/scripting/matching/matchingmode.spec.js +306 -258
  36. package/test/scripting/scriptingProvider.spec.js +666 -633
  37. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  38. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  39. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  40. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  41. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  42. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  43. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  44. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  45. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  46. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  47. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  53. package/test/security/allowUnsafe.spec.js +274 -268
  54. 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 = { sender: 'bot', sourceData: msg.sourceData, messageText: response }
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.memoryenabled.originaldeleted', function () {
17
- beforeEach(async function () {
18
- const myCaps = {
19
- [Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
20
- [Capabilities.CONTAINERMODE]: echoConnector,
21
- [Capabilities.SCRIPTING_XLSX_SHEETNAMES_SCRIPTING_MEMORY]: 'ScriptingMemory',
22
- [Capabilities.SCRIPTING_XLSX_SHEETNAMES]: 'Convos',
23
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
24
- [Capabilities.SCRIPTING_MEMORYEXPANSION_KEEP_ORIG]: false
25
- }
26
- const driver = new BotDriver(myCaps)
27
- this.compiler = driver.BuildCompiler()
28
- this.container = await driver.Build()
29
- })
30
- afterEach(async function () {
31
- this.container && await this.container.Clean()
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
- it('two scripting memory file, one colum each', async function () {
62
- // all variations are generated
63
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosTwoTables'))
64
- this.compiler.ExpandScriptingMemoryToConvos()
65
- assert.equal(this.compiler.convos.length, 4)
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
- for (const convo of this.compiler.convos) {
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
- it('Value is optional in the scripting memory file', async function () {
96
- // all variations are generated
97
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosValueOptional'))
98
- this.compiler.ExpandScriptingMemoryToConvos()
99
- assert.equal(this.compiler.convos.length, 1)
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
- const transcript = await this.compiler.convos[0].Run(this.container)
102
- assert.isObject(transcript.scriptingMemory)
103
- assert.isDefined(transcript.scriptingMemory.$productName)
104
- assert.notExists(transcript.scriptingMemory.$customerName)
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
- it('Using text file', async function () {
108
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimpleText'))
109
- this.compiler.ExpandScriptingMemoryToConvos()
110
- assert.equal(this.compiler.convos.length, 1)
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
- it('Using text file in column mode testcasenames', async function () {
121
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimpleCols'))
122
- this.compiler.ExpandScriptingMemoryToConvos()
123
- assert.equal(this.compiler.convos.length, 1)
124
-
125
- const transcript = await this.compiler.convos[0].Run(this.container)
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
- it('should throw exception if name is not set', async function () {
134
- try {
135
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoName'))
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
- } catch (err) {
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
- it('should throw exception if variable name is not set', async function () {
150
- try {
151
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoVariableName'))
152
- this.compiler.ExpandScriptingMemoryToConvos()
153
- } catch (err) {
154
- assert.equal(err.toString(), 'BotiumError: ReadScript - an error occurred at \'products.scriptingmemory.txt\' file: Scripting Memory Definition variable has no name')
155
- assert.isNotNull(err.context)
156
- assert.equal(err.context.type, 'Compiler')
157
- assert.equal(err.context.subtype, 'Scripting memory without variable name')
158
- assert.equal(err.context.source, 'ScriptingProvider')
159
-
160
- return
161
- }
162
- throw (new Error('Exception not thrown'))
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
- it('should throw exception variable is not set', async function () {
166
- try {
167
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoVariable'))
168
- this.compiler.ExpandScriptingMemoryToConvos()
169
- } catch (err) {
170
- assert.equal(err.toString(), 'BotiumError: ReadScript - an error occurred at \'products.scriptingmemory.txt\' file: Scripting Memory Definition has no variables')
171
- assert.isNotNull(err.context)
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
- describe('Using multiple scripting memory file', function () {
182
- it('should work with different variable names', async function () {
183
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryDifferent'))
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, 6)
116
+ assert.equal(this.compiler.convos.length, 1)
186
117
 
187
- try {
188
- await this.compiler.convos[0].Run(this.container)
189
- } catch (err) {
190
- if (err.transcript) {
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('should work with same variable names', async function () {
205
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemorySame'))
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, 4)
127
+ assert.equal(this.compiler.convos.length, 1)
208
128
 
209
- const transcript = await this.compiler.convos[3].Run(this.container)
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, 'Hamburger')
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('should work with same variable names in column mode testcasenames', async function () {
216
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemorySameCols'))
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, 4)
140
+ assert.equal(this.compiler.convos.length, 1)
219
141
 
220
- const transcript = await this.compiler.convos[3].Run(this.container)
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, 'Hamburger')
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 there is intersection in convosMultiMemoryCaseNameCollisionvariable names', async function () {
150
+ it('should throw exception if name is not set', async function () {
227
151
  try {
228
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryIntersection'))
152
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryNoName'))
229
153
  this.compiler.ExpandScriptingMemoryToConvos()
230
154
  } catch (err) {
231
- assert.equal(err.toString(), 'BotiumError: Scripting Memory Definitions "available1, available2, product1" are invalid because variable name collision"')
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, 'Scripting Memory')
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 case name is not unique', async function () {
166
+ it('should throw exception if variable name is not set', async function () {
246
167
  try {
247
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemoryCaseNameCollision'))
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 name(s) "product1" are not unique')
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, 'Scripting Memory')
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
- assert.isObject(err.context.cause)
256
- assert.isArray(err.context.cause.aggregatedDuplicates)
257
- assert.equal(err.context.cause.aggregatedDuplicates.length, 2)
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
- // nothing to test here, this case is just a debug log.
266
- it('Reserved word', async function () {
267
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosReservedWord'))
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
- it('No intersecion, no multiply', async function () {
271
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosNoIntersection'))
272
- this.compiler.ExpandScriptingMemoryToConvos()
273
- assert.equal(this.compiler.convos.length, 1)
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
- describe('scripting.fillingScriptingMemoryFromFile.memoryenabled.originalkept', function () {
278
- beforeEach(async function () {
279
- const myCaps = {
280
- [Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
281
- [Capabilities.CONTAINERMODE]: echoConnector,
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
- const driver = new BotDriver(myCaps)
289
- this.compiler = driver.BuildCompiler()
290
- this.container = await driver.Build()
291
- })
292
- afterEach(async function () {
293
- this.container && await this.container.Clean()
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
- it('Original convo kept', async function () {
297
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimple'))
298
- this.compiler.ExpandScriptingMemoryToConvos()
299
- assert.equal(this.compiler.convos.length, 2)
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
- describe('scripting.fillingScriptingMemoryFromFile.memorydisabled', function () {
304
- beforeEach(async function () {
305
- const myCaps = {
306
- [Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
307
- [Capabilities.CONTAINERMODE]: echoConnector,
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
- const driver = new BotDriver(myCaps)
314
- this.compiler = driver.BuildCompiler()
315
- this.container = await driver.Build()
316
- })
317
- afterEach(async function () {
318
- this.container && await this.container.Clean()
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
- it('scripting disabled, variable not replaced', async function () {
322
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosSimple'))
323
- this.compiler.ExpandScriptingMemoryToConvos()
324
- assert.equal(this.compiler.convos.length, 1)
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
- const transcript = await this.compiler.convos[0].Run(this.container)
327
- assert.isObject(transcript.scriptingMemory)
328
- assert.notExists(transcript.scriptingMemory.$productName)
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
- describe('scripting.fillingScriptingMemoryFromFile.coverage', function () {
333
- beforeEach(async function () {
334
- const myCaps = {
335
- [Capabilities.PROJECTNAME]: 'scripting.fillingScriptingMemoryFromFile.coverage',
336
- [Capabilities.CONTAINERMODE]: echoConnector,
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
- afterEach(async function () {
347
- this.container && await this.container.Clean()
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
- it('should replace scripting memory in asserter arguments', async function () {
351
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosCoverageAsserters'))
352
- this.compiler.ExpandScriptingMemoryToConvos()
353
- assert.equal(this.compiler.convos.length, 3)
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
- try {
356
- await this.compiler.convos[0].Run(this.container)
357
- } catch (err) {
358
- assert.equal(err.toString(), 'TranscriptError: asserters.product1/Line 9: assertion error - Line 9: Expected button(s) with text "Wiener Schnitzel"')
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
- return
361
- }
362
- throw (new Error('Exception not thrown'))
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
  })