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.
Files changed (57) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +305 -123
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +323 -142
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +17 -15
  7. package/src/Capabilities.js +2 -1
  8. package/src/containers/plugins/SimpleRestContainer.js +23 -16
  9. package/src/grid/inbound/proxy.js +2 -1
  10. package/src/helpers/RetryHelper.js +13 -7
  11. package/src/scripting/Convo.js +36 -10
  12. package/src/scripting/MatchFunctions.js +10 -0
  13. package/src/scripting/ScriptingProvider.js +106 -37
  14. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  15. package/src/scripting/logichook/LogicHookUtils.js +1 -1
  16. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  17. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  18. package/test/compiler/compilercsv.spec.js +104 -3
  19. package/test/compiler/compilerjson.spec.js +0 -2
  20. package/test/compiler/compilerxlsx.spec.js +1 -1
  21. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  22. package/test/connectors/simplerest.spec.js +1012 -969
  23. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  24. package/test/convo/partialconvo.spec.js +345 -339
  25. package/test/convo/retryconvo.spec.js +134 -0
  26. package/test/driver/capabilities.spec.js +156 -151
  27. package/test/logichooks/hookfromsrc.spec.js +79 -73
  28. package/test/plugins/plugins.spec.js +44 -42
  29. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  30. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  31. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  32. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  33. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  34. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  35. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  36. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  37. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  38. package/test/scripting/matching/matchingmode.spec.js +306 -258
  39. package/test/scripting/scriptingProvider.spec.js +666 -633
  40. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  41. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  42. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  43. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  44. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  45. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  46. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  47. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  53. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  54. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  55. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  56. package/test/security/allowUnsafe.spec.js +274 -268
  57. package/test/utils.spec.js +40 -38
@@ -10,7 +10,11 @@ const scriptedConnector = (script) => ({ queueBotSays }) => {
10
10
  return {
11
11
  UserSays (msg) {
12
12
  this.counter = this.counter >= 0 ? this.counter + 1 : 0
13
- const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: script[this.counter] }
13
+ const botMsg = {
14
+ sender: 'bot',
15
+ sourceData: msg.sourceData,
16
+ messageText: script[this.counter]
17
+ }
14
18
  queueBotSays(botMsg)
15
19
  }
16
20
  }
@@ -30,338 +34,339 @@ const _initIt = async (script, dir, _this) => {
30
34
  _this.container = await driver.Build()
31
35
  }
32
36
 
33
- describe('convo.partialconvo.usecases', function () {
34
- it('Depth1 txt, everything ok', async function () {
35
- await _initIt([
36
- 'Password please!',
37
- 'You are logged in!',
38
- 'Are you sure?',
39
- 'You are logged out!'
40
- ], 'convos/partialconvo/depth1', this)
41
-
42
- assert.equal(this.compiler.convos.length, 1)
43
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
44
-
45
- const transcript = await this.compiler.convos[0].Run(this.container)
46
- assert.lengthOf(transcript.steps, 8)
47
- assert.equal(transcript.steps[0].actual.sender, 'me')
48
- assert.equal(transcript.steps[0].actual.messageText, 'Login please')
49
- assert.equal(transcript.steps[1].actual.sender, 'bot')
50
- assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
51
- assert.equal(transcript.steps[2].actual.sender, 'me')
52
- assert.equal(transcript.steps[2].actual.messageText, '123456')
53
- assert.equal(transcript.steps[3].actual.sender, 'bot')
54
- assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
55
- assert.equal(transcript.steps[4].actual.sender, 'me')
56
- assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
57
- assert.equal(transcript.steps[5].actual.sender, 'bot')
58
- assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
59
- assert.equal(transcript.steps[6].actual.sender, 'me')
60
- assert.equal(transcript.steps[6].actual.messageText, 'Yes')
61
- assert.equal(transcript.steps[7].actual.sender, 'bot')
62
- assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
37
+ describe('convo.partialconvo', function () {
38
+ describe('usecases', function () {
39
+ it('Depth1 txt, everything ok', async function () {
40
+ await _initIt([
41
+ 'Password please!',
42
+ 'You are logged in!',
43
+ 'Are you sure?',
44
+ 'You are logged out!'
45
+ ], 'convos/partialconvo/depth1', this)
46
+
47
+ assert.equal(this.compiler.convos.length, 1)
48
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
49
+
50
+ const transcript = await this.compiler.convos[0].Run(this.container)
51
+ assert.lengthOf(transcript.steps, 8)
52
+ assert.equal(transcript.steps[0].actual.sender, 'me')
53
+ assert.equal(transcript.steps[0].actual.messageText, 'Login please')
54
+ assert.equal(transcript.steps[1].actual.sender, 'bot')
55
+ assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
56
+ assert.equal(transcript.steps[2].actual.sender, 'me')
57
+ assert.equal(transcript.steps[2].actual.messageText, '123456')
58
+ assert.equal(transcript.steps[3].actual.sender, 'bot')
59
+ assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
60
+ assert.equal(transcript.steps[4].actual.sender, 'me')
61
+ assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
62
+ assert.equal(transcript.steps[5].actual.sender, 'bot')
63
+ assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
64
+ assert.equal(transcript.steps[6].actual.sender, 'me')
65
+ assert.equal(transcript.steps[6].actual.messageText, 'Yes')
66
+ assert.equal(transcript.steps[7].actual.sender, 'bot')
67
+ assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
68
+ })
69
+ it('Depth1 xls, everything ok', async function () {
70
+ await _initIt([
71
+ 'Password please!',
72
+ 'You are logged in!',
73
+ 'Are you sure?',
74
+ 'You are logged out!'
75
+ ], 'convos/partialconvo/excel/convo', this)
76
+
77
+ assert.equal(this.compiler.convos.length, 1)
78
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
79
+
80
+ const transcript = await this.compiler.convos[0].Run(this.container)
81
+ assert.lengthOf(transcript.steps, 8)
82
+ assert.equal(transcript.steps[0].actual.sender, 'me')
83
+ assert.equal(transcript.steps[0].actual.messageText, 'Login please')
84
+ assert.equal(transcript.steps[1].actual.sender, 'bot')
85
+ assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
86
+ assert.equal(transcript.steps[2].actual.sender, 'me')
87
+ assert.equal(transcript.steps[2].actual.messageText, '123456')
88
+ assert.equal(transcript.steps[3].actual.sender, 'bot')
89
+ assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
90
+ assert.equal(transcript.steps[4].actual.sender, 'me')
91
+ assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
92
+ assert.equal(transcript.steps[5].actual.sender, 'bot')
93
+ assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
94
+ assert.equal(transcript.steps[6].actual.sender, 'me')
95
+ assert.equal(transcript.steps[6].actual.messageText, 'Yes')
96
+ assert.equal(transcript.steps[7].actual.sender, 'bot')
97
+ assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
98
+ })
99
+ it('Depth1 csv, everything ok', async function () {
100
+ await _initIt([
101
+ 'Password please!',
102
+ 'You are logged in!',
103
+ 'Are you sure?',
104
+ 'You are logged out!'
105
+ ], 'convos/partialconvo/csv', this)
106
+
107
+ assert.equal(this.compiler.convos.length, 1)
108
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
109
+
110
+ const transcript = await this.compiler.convos[0].Run(this.container)
111
+ assert.lengthOf(transcript.steps, 8)
112
+ assert.equal(transcript.steps[0].actual.sender, 'me')
113
+ assert.equal(transcript.steps[0].actual.messageText, 'Login please')
114
+ assert.equal(transcript.steps[1].actual.sender, 'bot')
115
+ assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
116
+ assert.equal(transcript.steps[2].actual.sender, 'me')
117
+ assert.equal(transcript.steps[2].actual.messageText, '123456')
118
+ assert.equal(transcript.steps[3].actual.sender, 'bot')
119
+ assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
120
+ assert.equal(transcript.steps[4].actual.sender, 'me')
121
+ assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
122
+ assert.equal(transcript.steps[5].actual.sender, 'bot')
123
+ assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
124
+ assert.equal(transcript.steps[6].actual.sender, 'me')
125
+ assert.equal(transcript.steps[6].actual.messageText, 'Yes')
126
+ assert.equal(transcript.steps[7].actual.sender, 'bot')
127
+ assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
128
+ })
129
+ it('Wrong botsays in main convo', async function () {
130
+ await _initIt([
131
+ 'Password please!',
132
+ 'You are logged in ERROR!',
133
+ 'Are you sure?',
134
+ 'You are logged out!'
135
+ ], 'convos/partialconvo/depth1', this)
136
+ return assert.isRejected(this.compiler.convos[0].Run(this.container), 'Main/Line 10: Bot response (on Login/Line 8: #me - 123456) "You are logged in ERROR!" expected to match "You are logged in!"')
137
+ })
138
+
139
+ it('Wrong botsays in partial convo', async function () {
140
+ await _initIt([
141
+ 'Password please!',
142
+ 'You are logged in!',
143
+ 'Are you sure ERROR?',
144
+ 'You are logged out!'
145
+ ], 'convos/partialconvo/depth1', this)
146
+ return assert.isRejected(this.compiler.convos[0].Run(this.container), 'Main/Logout/Line 5: Bot response (on Line 13: #me - Logout please! INCLUDE(Logout)) "Are you sure ERROR?" expected to match "Are you sure?"')
147
+ })
148
+
149
+ it('Depth is 2', async function () {
150
+ await _initIt([
151
+ 'in depth1',
152
+ 'in depth2',
153
+ 'main end'
154
+ ], 'convos/partialconvo/depth2', this)
155
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
156
+ })
157
+
158
+ it('Included after bot', async function () {
159
+ await _initIt([
160
+ 'ok',
161
+ 'included afterbot!'
162
+ ], 'convos/partialconvo/includeafterbot', this)
163
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
164
+ })
165
+
166
+ it('Included more times', async function () {
167
+ await _initIt([
168
+ 'in sub!',
169
+ 'in sub!'
170
+ ], 'convos/partialconvo/includedmoretimes', this)
171
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
172
+ })
173
+
174
+ it('It is possible to include a partial convo first', async function () {
175
+ await _initIt([
176
+ 'in depth2',
177
+ 'in depth1',
178
+ 'main end'
179
+ ], 'convos/partialconvo/includefirst', this)
180
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
181
+ })
182
+
183
+ it('It is possible to use #include in convo', async function () {
184
+ await _initIt([
185
+ 'in depth2',
186
+ 'in depth1',
187
+ 'main end'
188
+ ], 'convos/partialconvo/usesender', this)
189
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
190
+ })
191
+
192
+ it('It is possible to use multiple #include in convo', async function () {
193
+ await _initIt([
194
+ 'in sub!',
195
+ 'in sub!',
196
+ 'in sub!',
197
+ 'in sub!'
198
+ ], 'convos/partialconvo/usesendermultiinclude', this)
199
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
200
+ })
201
+
202
+ it('It is possible to use multiple #include in JSON convo', async function () {
203
+ await _initIt([
204
+ 'in sub!',
205
+ 'in sub!'
206
+ ], 'convos/partialconvo/usesendermultiincludejson', this)
207
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
208
+ })
209
+
210
+ it('It is possible to use multiple #include in YAML convo', async function () {
211
+ await _initIt([
212
+ 'in sub!',
213
+ 'in sub!'
214
+ ], 'convos/partialconvo/usesendermultiincludeyaml', this)
215
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
216
+ })
217
+
218
+ it('It is possible to use multiple #include in MD convo', async function () {
219
+ await _initIt([
220
+ 'in sub!',
221
+ 'in sub!'
222
+ ], 'convos/partialconvo/usesendermultiincludemd', this)
223
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
224
+ })
225
+
226
+ it('It is possible to include more partial convos in one convostep', async function () {
227
+ await _initIt([
228
+ 'in sub!',
229
+ 'in sub!'
230
+ ], 'convos/partialconvo/includedmoretimes', this)
231
+ return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
232
+ })
233
+
234
+ it('has empty #me convo step in Excel', async function () {
235
+ await _initIt([
236
+ 'Password please!',
237
+ 'You are logged in!',
238
+ 'Are you sure?',
239
+ 'You are logged out!'
240
+ ], 'convos/partialconvo/excel/emptystep', this)
241
+
242
+ assert.equal(this.compiler.convos.length, 2)
243
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
244
+
245
+ const transcript = await this.compiler.convos[0].Run(this.container)
246
+ assert.lengthOf(transcript.steps, 8)
247
+ assert.equal(transcript.steps[0].actual.sender, 'me')
248
+ assert.equal(transcript.steps[0].actual.messageText, 'Login please')
249
+ assert.equal(transcript.steps[1].actual.sender, 'bot')
250
+ assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
251
+ assert.equal(transcript.steps[2].actual.sender, 'me')
252
+ assert.equal(transcript.steps[2].actual.messageText, '123456')
253
+ assert.equal(transcript.steps[3].actual.sender, 'bot')
254
+ assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
255
+ assert.equal(transcript.steps[4].actual.sender, 'me')
256
+ assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
257
+ assert.equal(transcript.steps[5].actual.sender, 'bot')
258
+ assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
259
+ assert.equal(transcript.steps[6].actual.sender, 'me')
260
+ assert.equal(transcript.steps[6].actual.messageText, 'Yes')
261
+ assert.equal(transcript.steps[7].actual.sender, 'bot')
262
+ assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
263
+ })
264
+
265
+ it('has empty #bot convo step in Excel', async function () {
266
+ await _initIt([
267
+ 'Password please!',
268
+ 'You are logged in!',
269
+ 'Are you sure?',
270
+ 'You are logged out!'
271
+ ], 'convos/partialconvo/excel/emptystep', this)
272
+
273
+ assert.equal(this.compiler.convos.length, 2)
274
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
275
+
276
+ const transcript = await this.compiler.convos[1].Run(this.container)
277
+ assert.lengthOf(transcript.steps, 8)
278
+ })
279
+
280
+ it('has bot text in convo step in Excel', async function () {
281
+ await _initIt([
282
+ 'Password please!',
283
+ 'You are logged in!'
284
+ ], 'convos/partialconvo/excel/bottext', this)
285
+
286
+ assert.equal(this.compiler.convos.length, 1)
287
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 1)
288
+
289
+ const transcript = await this.compiler.convos[0].Run(this.container)
290
+ assert.lengthOf(transcript.steps, 4)
291
+ })
292
+
293
+ it('expands utterances in partial convos', async function () {
294
+ await _initIt([], 'convos/partialconvo/withutterances', this)
295
+
296
+ assert.equal(this.compiler.convos.length, 3)
297
+ assert.equal(Object.keys(this.compiler.utterances).length, 1)
298
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
299
+ assert.equal(this.compiler.convos[0].conversation[7].messageText, 'yes')
300
+ assert.equal(this.compiler.convos[1].conversation[7].messageText, 'sure')
301
+ assert.equal(this.compiler.convos[2].conversation[7].messageText, 'do it')
302
+ })
303
+
304
+ it('uses scripting memory in partial convos', async function () {
305
+ await _initIt([
306
+ 'Password please!',
307
+ 'You are logged in!',
308
+ 'Are you sure?',
309
+ 'You are logged out!'
310
+ ], 'convos/partialconvo/withscriptingmemory', this)
311
+
312
+ assert.equal(this.compiler.convos.length, 1)
313
+ const transcript = await this.compiler.convos[0].Run(this.container)
314
+ assert.equal(transcript.steps[2].actual.messageText, '123456')
315
+ })
316
+
317
+ afterEach(async function () {
318
+ this.container && await this.container.Clean()
319
+ })
63
320
  })
64
- it('Depth1 xls, everything ok', async function () {
65
- await _initIt([
66
- 'Password please!',
67
- 'You are logged in!',
68
- 'Are you sure?',
69
- 'You are logged out!'
70
- ], 'convos/partialconvo/excel/convo', this)
71
-
72
- assert.equal(this.compiler.convos.length, 1)
73
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
74
-
75
- const transcript = await this.compiler.convos[0].Run(this.container)
76
- assert.lengthOf(transcript.steps, 8)
77
- assert.equal(transcript.steps[0].actual.sender, 'me')
78
- assert.equal(transcript.steps[0].actual.messageText, 'Login please')
79
- assert.equal(transcript.steps[1].actual.sender, 'bot')
80
- assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
81
- assert.equal(transcript.steps[2].actual.sender, 'me')
82
- assert.equal(transcript.steps[2].actual.messageText, '123456')
83
- assert.equal(transcript.steps[3].actual.sender, 'bot')
84
- assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
85
- assert.equal(transcript.steps[4].actual.sender, 'me')
86
- assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
87
- assert.equal(transcript.steps[5].actual.sender, 'bot')
88
- assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
89
- assert.equal(transcript.steps[6].actual.sender, 'me')
90
- assert.equal(transcript.steps[6].actual.messageText, 'Yes')
91
- assert.equal(transcript.steps[7].actual.sender, 'bot')
92
- assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
93
- })
94
- it('Depth1 csv, everything ok', async function () {
95
- await _initIt([
96
- 'Password please!',
97
- 'You are logged in!',
98
- 'Are you sure?',
99
- 'You are logged out!'
100
- ], 'convos/partialconvo/csv', this)
101
-
102
- assert.equal(this.compiler.convos.length, 1)
103
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
104
-
105
- const transcript = await this.compiler.convos[0].Run(this.container)
106
- assert.lengthOf(transcript.steps, 8)
107
- assert.equal(transcript.steps[0].actual.sender, 'me')
108
- assert.equal(transcript.steps[0].actual.messageText, 'Login please')
109
- assert.equal(transcript.steps[1].actual.sender, 'bot')
110
- assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
111
- assert.equal(transcript.steps[2].actual.sender, 'me')
112
- assert.equal(transcript.steps[2].actual.messageText, '123456')
113
- assert.equal(transcript.steps[3].actual.sender, 'bot')
114
- assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
115
- assert.equal(transcript.steps[4].actual.sender, 'me')
116
- assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
117
- assert.equal(transcript.steps[5].actual.sender, 'bot')
118
- assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
119
- assert.equal(transcript.steps[6].actual.sender, 'me')
120
- assert.equal(transcript.steps[6].actual.messageText, 'Yes')
121
- assert.equal(transcript.steps[7].actual.sender, 'bot')
122
- assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
123
- })
124
- it('Wrong botsays in main convo', async function () {
125
- await _initIt([
126
- 'Password please!',
127
- 'You are logged in ERROR!',
128
- 'Are you sure?',
129
- 'You are logged out!'
130
- ], 'convos/partialconvo/depth1', this)
131
- return assert.isRejected(this.compiler.convos[0].Run(this.container), 'Main/Line 10: Bot response (on Login/Line 8: #me - 123456) "You are logged in ERROR!" expected to match "You are logged in!"')
132
- })
133
-
134
- it('Wrong botsays in partial convo', async function () {
135
- await _initIt([
136
- 'Password please!',
137
- 'You are logged in!',
138
- 'Are you sure ERROR?',
139
- 'You are logged out!'
140
- ], 'convos/partialconvo/depth1', this)
141
- return assert.isRejected(this.compiler.convos[0].Run(this.container), 'Main/Logout/Line 5: Bot response (on Line 13: #me - Logout please! INCLUDE(Logout)) "Are you sure ERROR?" expected to match "Are you sure?"')
142
- })
143
-
144
- it('Depth is 2', async function () {
145
- await _initIt([
146
- 'in depth1',
147
- 'in depth2',
148
- 'main end'
149
- ], 'convos/partialconvo/depth2', this)
150
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
151
- })
152
-
153
- it('Included after bot', async function () {
154
- await _initIt([
155
- 'ok',
156
- 'included afterbot!'
157
- ], 'convos/partialconvo/includeafterbot', this)
158
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
159
- })
160
-
161
- it('Included more times', async function () {
162
- await _initIt([
163
- 'in sub!',
164
- 'in sub!'
165
- ], 'convos/partialconvo/includedmoretimes', this)
166
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
167
- })
168
-
169
- it('It is possible to include a partial convo first', async function () {
170
- await _initIt([
171
- 'in depth2',
172
- 'in depth1',
173
- 'main end'
174
- ], 'convos/partialconvo/includefirst', this)
175
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
176
- })
177
-
178
- it('It is possible to use #include in convo', async function () {
179
- await _initIt([
180
- 'in depth2',
181
- 'in depth1',
182
- 'main end'
183
- ], 'convos/partialconvo/usesender', this)
184
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
185
- })
186
-
187
- it('It is possible to use multiple #include in convo', async function () {
188
- await _initIt([
189
- 'in sub!',
190
- 'in sub!',
191
- 'in sub!',
192
- 'in sub!'
193
- ], 'convos/partialconvo/usesendermultiinclude', this)
194
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
195
- })
196
-
197
- it('It is possible to use multiple #include in JSON convo', async function () {
198
- await _initIt([
199
- 'in sub!',
200
- 'in sub!'
201
- ], 'convos/partialconvo/usesendermultiincludejson', this)
202
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
203
- })
204
-
205
- it('It is possible to use multiple #include in YAML convo', async function () {
206
- await _initIt([
207
- 'in sub!',
208
- 'in sub!'
209
- ], 'convos/partialconvo/usesendermultiincludeyaml', this)
210
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
211
- })
212
-
213
- it('It is possible to use multiple #include in MD convo', async function () {
214
- await _initIt([
215
- 'in sub!',
216
- 'in sub!'
217
- ], 'convos/partialconvo/usesendermultiincludemd', this)
218
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
219
- })
220
-
221
- it('It is possible to include more partial convos in one convostep', async function () {
222
- await _initIt([
223
- 'in sub!',
224
- 'in sub!'
225
- ], 'convos/partialconvo/includedmoretimes', this)
226
- return assert.isFulfilled(this.compiler.convos[0].Run(this.container))
227
- })
228
-
229
- it('has empty #me convo step in Excel', async function () {
230
- await _initIt([
231
- 'Password please!',
232
- 'You are logged in!',
233
- 'Are you sure?',
234
- 'You are logged out!'
235
- ], 'convos/partialconvo/excel/emptystep', this)
236
-
237
- assert.equal(this.compiler.convos.length, 2)
238
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
239
-
240
- const transcript = await this.compiler.convos[0].Run(this.container)
241
- assert.lengthOf(transcript.steps, 8)
242
- assert.equal(transcript.steps[0].actual.sender, 'me')
243
- assert.equal(transcript.steps[0].actual.messageText, 'Login please')
244
- assert.equal(transcript.steps[1].actual.sender, 'bot')
245
- assert.equal(transcript.steps[1].actual.messageText, 'Password please!')
246
- assert.equal(transcript.steps[2].actual.sender, 'me')
247
- assert.equal(transcript.steps[2].actual.messageText, '123456')
248
- assert.equal(transcript.steps[3].actual.sender, 'bot')
249
- assert.equal(transcript.steps[3].actual.messageText, 'You are logged in!')
250
- assert.equal(transcript.steps[4].actual.sender, 'me')
251
- assert.equal(transcript.steps[4].actual.messageText, 'Logout please!')
252
- assert.equal(transcript.steps[5].actual.sender, 'bot')
253
- assert.equal(transcript.steps[5].actual.messageText, 'Are you sure?')
254
- assert.equal(transcript.steps[6].actual.sender, 'me')
255
- assert.equal(transcript.steps[6].actual.messageText, 'Yes')
256
- assert.equal(transcript.steps[7].actual.sender, 'bot')
257
- assert.equal(transcript.steps[7].actual.messageText, 'You are logged out!')
258
- })
259
-
260
- it('has empty #bot convo step in Excel', async function () {
261
- await _initIt([
262
- 'Password please!',
263
- 'You are logged in!',
264
- 'Are you sure?',
265
- 'You are logged out!'
266
- ], 'convos/partialconvo/excel/emptystep', this)
267
321
 
268
- assert.equal(this.compiler.convos.length, 2)
269
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
322
+ describe('wrongconvos', function () {
323
+ it('Circular', async function () {
324
+ return assert.isRejected(_initIt([], 'convos/partialconvo/circular', this), 'Partial convos are included circular. "first" is referenced by "/" and by "/first/second"')
325
+ })
270
326
 
271
- const transcript = await this.compiler.convos[1].Run(this.container)
272
- assert.lengthOf(transcript.steps, 8)
273
- })
274
-
275
- it('has bot text in convo step in Excel', async function () {
276
- await _initIt([
277
- 'Password please!',
278
- 'You are logged in!'
279
- ], 'convos/partialconvo/excel/bottext', this)
280
-
281
- assert.equal(this.compiler.convos.length, 1)
282
- assert.equal(Object.keys(this.compiler.partialConvos).length, 1)
283
-
284
- const transcript = await this.compiler.convos[0].Run(this.container)
285
- assert.lengthOf(transcript.steps, 4)
286
- })
287
-
288
- it('expands utterances in partial convos', async function () {
289
- await _initIt([], 'convos/partialconvo/withutterances', this)
290
-
291
- assert.equal(this.compiler.convos.length, 3)
292
- assert.equal(Object.keys(this.compiler.utterances).length, 1)
293
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
294
- assert.equal(this.compiler.convos[0].conversation[7].messageText, 'yes')
295
- assert.equal(this.compiler.convos[1].conversation[7].messageText, 'sure')
296
- assert.equal(this.compiler.convos[2].conversation[7].messageText, 'do it')
297
- })
298
-
299
- it('uses scripting memory in partial convos', async function () {
300
- await _initIt([
301
- 'Password please!',
302
- 'You are logged in!',
303
- 'Are you sure?',
304
- 'You are logged out!'
305
- ], 'convos/partialconvo/withscriptingmemory', this)
306
-
307
- assert.equal(this.compiler.convos.length, 1)
308
- const transcript = await this.compiler.convos[0].Run(this.container)
309
- assert.equal(transcript.steps[2].actual.messageText, '123456')
310
- })
311
-
312
- afterEach(async function () {
313
- this.container && await this.container.Clean()
314
- })
315
- })
316
-
317
- describe('convo.partialconvo.wrongconvos', function () {
318
- it('Circular', async function () {
319
- return assert.isRejected(_initIt([], 'convos/partialconvo/circular', this), 'Partial convos are included circular. "first" is referenced by "/" and by "/first/second"')
320
- })
327
+ it('Partial convo without name', async function () {
328
+ return assert.isRejected(_initIt([], 'convos/partialconvo/noname', this), 'Header name is mandatory: {"name":""}')
329
+ })
321
330
 
322
- it('Partial convo without name', async function () {
323
- return assert.isRejected(_initIt([], 'convos/partialconvo/noname', this), 'Header name is mandatory: {"name":""}')
324
- })
331
+ it('Partial convo not found', async function () {
332
+ return assert.isRejected(_initIt([], 'convos/partialconvo/notfound', this), 'Cant find partial convo with name notexists (There are no partial convos)')
333
+ })
325
334
 
326
- it('Partial convo not found', async function () {
327
- return assert.isRejected(_initIt([], 'convos/partialconvo/notfound', this), 'Cant find partial convo with name notexists (There are no partial convos)')
328
- })
335
+ it('Partial convo wrong ref', async function () {
336
+ return assert.isRejected(_initIt([], 'convos/partialconvo/wrongref', this), 'Cant find partial convo with name wrongref (available partial convos: exists)')
337
+ })
329
338
 
330
- it('Partial convo wrong ref', async function () {
331
- return assert.isRejected(_initIt([], 'convos/partialconvo/wrongref', this), 'Cant find partial convo with name wrongref (available partial convos: exists)')
332
- })
339
+ it('Partial convo name duplicated', async function () {
340
+ return assert.isRejected(_initIt([], 'convos/partialconvo/duplicatepconvo', this), 'Duplicate partial convo: pconvo')
341
+ })
333
342
 
334
- it('Partial convo name duplicated', async function () {
335
- return assert.isRejected(_initIt([], 'convos/partialconvo/duplicatepconvo', this), 'Duplicate partial convo: pconvo')
336
- })
337
-
338
- it('Wrong arguments', async function () {
339
- return assert.isRejected(_initIt([], 'convos/partialconvo/wrongarg', this), 'Wrong argument for include logic hook!')
340
- })
343
+ it('Wrong arguments', async function () {
344
+ return assert.isRejected(_initIt([], 'convos/partialconvo/wrongarg', this), 'Wrong argument for include logic hook!')
345
+ })
341
346
 
342
- it('Illegal partial convo name', async function () {
343
- return assert.isRejected(_initIt([], 'convos/partialconvo/illegalname', this), 'Invalid partial convo name: illegal|name')
344
- })
347
+ it('Illegal partial convo name', async function () {
348
+ return assert.isRejected(_initIt([], 'convos/partialconvo/illegalname', this), 'Invalid partial convo name: illegal|name')
349
+ })
345
350
 
346
- afterEach(async function () {
347
- this.container && await this.container.Clean()
351
+ afterEach(async function () {
352
+ this.container && await this.container.Clean()
353
+ })
348
354
  })
349
- })
350
355
 
351
- describe('convo.partialconvo.decompile', function () {
352
- it('Depth1 txt, everything ok', async function () {
353
- await _initIt([
354
- 'Password please!',
355
- 'You are logged in!',
356
- 'Are you sure?',
357
- 'You are logged out!'
358
- ], 'convos/partialconvo/depth1', this)
356
+ describe('decompile', function () {
357
+ it('Depth1 txt, everything ok', async function () {
358
+ await _initIt([
359
+ 'Password please!',
360
+ 'You are logged in!',
361
+ 'Are you sure?',
362
+ 'You are logged out!'
363
+ ], 'convos/partialconvo/depth1', this)
359
364
 
360
- assert.equal(this.compiler.convos.length, 1)
361
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
365
+ assert.equal(this.compiler.convos.length, 1)
366
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
362
367
 
363
- const convoTxt = this.compiler.Decompile(this.compiler.convos, 'SCRIPTING_FORMAT_TXT')
364
- assert.equal(convoTxt, `Main
368
+ const convoTxt = this.compiler.Decompile(this.compiler.convos, 'SCRIPTING_FORMAT_TXT')
369
+ assert.equal(convoTxt, `Main
365
370
 
366
371
  #begin
367
372
 
@@ -393,24 +398,25 @@ You are logged out!
393
398
 
394
399
  #end
395
400
  `)
396
- })
397
-
398
- it('Depth1 excel, everything ok', async function () {
399
- await _initIt([
400
- 'Password please!',
401
- 'You are logged in!',
402
- 'Are you sure?',
403
- 'You are logged out!'
404
- ], 'convos/partialconvo/excel/convo', this)
405
-
406
- assert.equal(this.compiler.convos.length, 1)
407
- assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
408
-
409
- const convoXslx = this.compiler.Decompile(this.compiler.convos, 'SCRIPTING_FORMAT_XSLX')
410
-
411
- this.compiler.convos = []
412
- this.compiler.partialConvos = {}
413
- this.compiler.Compile(convoXslx, 'SCRIPTING_FORMAT_XSLX', 'SCRIPTING_TYPE_CONVO')
414
- assert.equal(this.compiler.convos.length, 1)
401
+ })
402
+
403
+ it('Depth1 excel, everything ok', async function () {
404
+ await _initIt([
405
+ 'Password please!',
406
+ 'You are logged in!',
407
+ 'Are you sure?',
408
+ 'You are logged out!'
409
+ ], 'convos/partialconvo/excel/convo', this)
410
+
411
+ assert.equal(this.compiler.convos.length, 1)
412
+ assert.equal(Object.keys(this.compiler.partialConvos).length, 2)
413
+
414
+ const convoXslx = this.compiler.Decompile(this.compiler.convos, 'SCRIPTING_FORMAT_XSLX')
415
+
416
+ this.compiler.convos = []
417
+ this.compiler.partialConvos = {}
418
+ this.compiler.Compile(convoXslx, 'SCRIPTING_FORMAT_XSLX', 'SCRIPTING_TYPE_CONVO')
419
+ assert.equal(this.compiler.convos.length, 1)
420
+ })
415
421
  })
416
422
  })