botium-core 1.15.10 → 1.15.13

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 (84) hide show
  1. package/dist/botium-cjs.js +91 -51
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +91 -50
  4. package/dist/botium-es.js.map +1 -1
  5. package/package.json +35 -40
  6. package/src/BotDriver.js +1 -1
  7. package/src/Events.js +1 -3
  8. package/src/containers/GridContainer.js +0 -4
  9. package/src/mocks/BotiumMockScripting.js +3 -0
  10. package/src/scripting/Convo.js +10 -0
  11. package/src/utils/boolean.js +39 -0
  12. package/test/compiler/compilercsv.spec.js +34 -0
  13. package/test/compiler/compilermarkdown.spec.js +11 -0
  14. package/test/compiler/compilertxt.spec.js +21 -0
  15. package/test/compiler/compilerxlsx.spec.js +27 -0
  16. package/test/compiler/precompilerjson.spec.js +1 -0
  17. package/test/compiler/precompilermarkdownrasa.spec.js +1 -0
  18. package/test/connectors/pluginconnectorcontainer.spec.js +1 -0
  19. package/test/connectors/simplerest.spec.js +3 -1
  20. package/test/convo/failure.spec.js +1 -0
  21. package/test/convo/fillAndApplyScriptingMemory.spec.js +56 -0
  22. package/test/convo/partialconvo.spec.js +3 -0
  23. package/test/convo/retry.spec.js +9 -0
  24. package/test/convo/retryasserter.spec.js +9 -0
  25. package/test/convo/transcript.spec.js +33 -0
  26. package/test/convo/tree.spec.js +5 -0
  27. package/test/driver/capabilities.spec.js +16 -0
  28. package/test/helpers/capabilitiesutils.spec.js +8 -0
  29. package/test/helpers/transcriptutils.spec.js +1 -0
  30. package/test/hooks/customhooks.spec.js +3 -0
  31. package/test/logichooks/hookfromsrc.spec.js +3 -0
  32. package/test/logichooks/textfromhook.spec.js +1 -0
  33. package/test/plugins/plugins.spec.js +3 -0
  34. package/test/scripting/asserters/buttonsAsserter.spec.js +15 -0
  35. package/test/scripting/asserters/cardsAsserter.spec.js +12 -0
  36. package/test/scripting/asserters/convoStepParameters.spec.js +11 -0
  37. package/test/scripting/asserters/entitiesAsserter.spec.js +1 -0
  38. package/test/scripting/asserters/entityValuesAsserter.spec.js +7 -0
  39. package/test/scripting/asserters/formsAsserter.spec.js +10 -0
  40. package/test/scripting/asserters/intentAsserter.spec.js +4 -0
  41. package/test/scripting/asserters/intentUniqueAsserter.spec.js +2 -0
  42. package/test/scripting/asserters/jsonpathAsserter.spec.js +25 -0
  43. package/test/scripting/asserters/mediaAsserter.spec.js +20 -0
  44. package/test/scripting/asserters/responseLengthAsserter.spec.js +4 -0
  45. package/test/scripting/asserters/textAsserter.spec.js +1 -0
  46. package/test/scripting/asserters/textContainsAllAsserter.spec.js +1 -0
  47. package/test/scripting/asserters/textContainsAnyAsserter.spec.js +1 -0
  48. package/test/scripting/asserters/textEqualsAsserter.spec.js +1 -0
  49. package/test/scripting/asserters/textRegexpAllAsserter.spec.js +1 -0
  50. package/test/scripting/asserters/textRegexpAnyAsserter.spec.js +1 -0
  51. package/test/scripting/asserters/textWildcardAllAsserter.spec.js +1 -0
  52. package/test/scripting/asserters/textWildcardAnyAsserter.spec.js +1 -0
  53. package/test/scripting/asserters/textWildcardExactAllAsserter.spec.js +1 -0
  54. package/test/scripting/asserters/textWildcardExactAnyAsserter.spec.js +1 -0
  55. package/test/scripting/asserters/werAsserter.spec.js +6 -0
  56. package/test/scripting/logichooks/convos/scripting_memory_resolved_args.convo.txt +11 -0
  57. package/test/scripting/logichooks/customConditionalStepLogicHook.spec.js +2 -0
  58. package/test/scripting/logichooks/localvsglobal.spec.js +1 -0
  59. package/test/scripting/logichooks/pauseLogic.spec.js +4 -0
  60. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +17 -0
  61. package/test/scripting/logichooks/updateCustom.spec.js +2 -0
  62. package/test/scripting/matching/matchingmode.spec.js +48 -0
  63. package/test/scripting/scriptingModificator.spec.js +1 -0
  64. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +4 -0
  65. package/test/scripting/scriptingmemory/regexp.spec.js +1 -0
  66. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +3 -0
  67. package/test/scripting/txt/decompile.spec.js +20 -0
  68. package/test/scripting/userinputs/buttonInputConvos.spec.js +1 -0
  69. package/test/scripting/userinputs/defaultUserInputs.spec.js +13 -0
  70. package/test/scripting/userinputs/mediaInputConvos.spec.js +10 -0
  71. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +2 -0
  72. package/test/security/allowUnsafe.spec.js +5 -0
  73. package/test/utils.spec.js +2 -0
  74. package/samples/postman/Botium Agent Sample.postman_collection.json +0 -834
  75. package/samples/postman/README.md +0 -5
  76. package/samples/postman/botiumFluent.js +0 -37
  77. package/src/grid/agent/AgentWorker.js +0 -204
  78. package/src/grid/agent/agent.js +0 -96
  79. package/src/grid/agent/agentworkerpool.js +0 -58
  80. package/src/grid/agent/routes.js +0 -353
  81. package/src/grid/agent/swagger.json +0 -327
  82. package/src/grid/agent/swaggerDef.json +0 -8
  83. package/src/grid/agent/views/index.html +0 -39
  84. package/test/grid/agent/client.js +0 -65
@@ -164,6 +164,7 @@ describe('convo.transcript', function () {
164
164
  this.containerMultipleBotmessagesAssertionFailOnOptional = await this.driverMultipleBotmessagesAssertionFailOnOptional.Build()
165
165
  await this.containerMultipleBotmessagesAssertionFailOnOptional.Start()
166
166
  })
167
+
167
168
  afterEach(async function () {
168
169
  await this.container.Stop()
169
170
  await this.container.Clean()
@@ -172,6 +173,7 @@ describe('convo.transcript', function () {
172
173
  await this.containerSkipAssertErrors.Stop()
173
174
  await this.containerSkipAssertErrors.Clean()
174
175
  })
176
+
175
177
  it('should provide transcript steps on success', async function () {
176
178
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2steps.convo.txt')
177
179
  assert.equal(this.compiler.convos.length, 1)
@@ -188,6 +190,7 @@ describe('convo.transcript', function () {
188
190
  assert.isTrue(moment(step.stepBegin).isSameOrBefore(step.stepEnd), 'begin should be same or before end')
189
191
  })
190
192
  })
193
+
191
194
  it('should provide transcript negated steps on success', async function () {
192
195
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsneg.convo.txt')
193
196
  assert.equal(this.compiler.convos.length, 1)
@@ -197,6 +200,7 @@ describe('convo.transcript', function () {
197
200
  assert.equal(transcript.steps.length, 2)
198
201
  assert.isTrue(transcript.steps[1].not)
199
202
  })
203
+
200
204
  it('should provide transcript optional steps on success', async function () {
201
205
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsopt.convo.txt')
202
206
  assert.equal(this.compiler.convos.length, 1)
@@ -205,6 +209,7 @@ describe('convo.transcript', function () {
205
209
  assert.isDefined(transcript)
206
210
  assert.equal(transcript.steps.length, 2)
207
211
  })
212
+
208
213
  it('should provide transcript optional negated steps on success', async function () {
209
214
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsoptneg.convo.txt')
210
215
  assert.equal(this.compiler.convos.length, 1)
@@ -213,6 +218,7 @@ describe('convo.transcript', function () {
213
218
  assert.isDefined(transcript)
214
219
  assert.equal(transcript.steps.length, 2)
215
220
  })
221
+
216
222
  it('should provide transcript optional steps on success skipping step', async function () {
217
223
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsoptskip.convo.txt')
218
224
  assert.equal(this.compiler.convos.length, 1)
@@ -221,6 +227,7 @@ describe('convo.transcript', function () {
221
227
  assert.isDefined(transcript)
222
228
  assert.equal(transcript.steps.length, 2)
223
229
  })
230
+
224
231
  it('should provide transcript optional steps on failing', async function () {
225
232
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsoptfollowme.convo.txt')
226
233
  assert.equal(this.compiler.convos.length, 1)
@@ -236,6 +243,7 @@ describe('convo.transcript', function () {
236
243
  assert.isDefined(err.transcript.steps[1].err)
237
244
  }
238
245
  })
246
+
239
247
  it('should provide transcript optional steps on success with asserters', async function () {
240
248
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'assertersopt.convo.txt')
241
249
  assert.equal(this.compiler.convos.length, 1)
@@ -244,6 +252,7 @@ describe('convo.transcript', function () {
244
252
  assert.isDefined(transcript)
245
253
  assert.equal(transcript.steps.length, 2)
246
254
  })
255
+
247
256
  it('should provide transcript optional steps on success skipping steps with asserters', async function () {
248
257
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'assertersoptskip.convo.txt')
249
258
  assert.equal(this.compiler.convos.length, 1)
@@ -252,6 +261,7 @@ describe('convo.transcript', function () {
252
261
  assert.isDefined(transcript)
253
262
  assert.equal(transcript.steps.length, 2)
254
263
  })
264
+
255
265
  it('should provide transcript optional multiple bot steps on getting all bot messages', async function () {
256
266
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'welcome_multiple_botsteps_opt.convo.txt')
257
267
  assert.equal(this.compiler.convos.length, 1)
@@ -260,6 +270,7 @@ describe('convo.transcript', function () {
260
270
  assert.isDefined(transcript)
261
271
  assert.equal(transcript.steps.length, 6)
262
272
  })
273
+
263
274
  it('should provide transcript optional multiple bot steps on skip an optional bot messages', async function () {
264
275
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'welcome_multiple_botsteps_opt.convo.txt')
265
276
  assert.equal(this.compiler.convos.length, 1)
@@ -268,6 +279,7 @@ describe('convo.transcript', function () {
268
279
  assert.isDefined(transcript)
269
280
  assert.equal(transcript.steps.length, 5)
270
281
  })
282
+
271
283
  it('should provide transcript optional multiple bot steps assertion fail on optional bot messages', async function () {
272
284
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'welcome_multiple_botsteps_opt.convo.txt')
273
285
  assert.equal(this.compiler.convos.length, 1)
@@ -281,6 +293,7 @@ describe('convo.transcript', function () {
281
293
  assert.isTrue(err.message.includes('Unexpected message'))
282
294
  }
283
295
  })
296
+
284
297
  it('should provide transcript optional multiple bot steps on not getting all bot messages', async function () {
285
298
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'welcome_multiple_botsteps_opt.convo.txt')
286
299
  assert.equal(this.compiler.convos.length, 1)
@@ -289,6 +302,7 @@ describe('convo.transcript', function () {
289
302
  assert.isDefined(transcript)
290
303
  assert.equal(transcript.steps.length, 5)
291
304
  })
305
+
292
306
  it('should include pause in transcript steps', async function () {
293
307
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsWithPause.convo.txt')
294
308
  assert.equal(this.compiler.convos.length, 1)
@@ -301,6 +315,7 @@ describe('convo.transcript', function () {
301
315
  assert.equal(transcript.steps.length, 4)
302
316
  assert.isTrue(moment(transcript.steps[2].stepEnd).diff(transcript.steps[2].stepBegin) >= 1000, 'begin should be at least 1000 ms before end')
303
317
  })
318
+
304
319
  it('should provide transcript steps on failing', async function () {
305
320
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsfailing.convo.txt')
306
321
  assert.equal(this.compiler.convos.length, 1)
@@ -319,10 +334,12 @@ describe('convo.transcript', function () {
319
334
  assert.isDefined(err.transcript.steps[3].err)
320
335
  }
321
336
  })
337
+
322
338
  it('should not fail on invalid sender', async function () {
323
339
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'invalidsender.convo.txt')
324
340
  assert.equal(this.compiler.convos.length, 1)
325
341
  })
342
+
326
343
  it('should emit transcript event on success', async function () {
327
344
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2steps.convo.txt')
328
345
  assert.equal(this.compiler.convos.length, 1)
@@ -333,6 +350,7 @@ describe('convo.transcript', function () {
333
350
  await this.compiler.convos[0].Run(this.container)
334
351
  assert.isDefined(transcript)
335
352
  })
353
+
336
354
  it('should emit transcript event on failure', async function () {
337
355
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsfailing.convo.txt')
338
356
  assert.equal(this.compiler.convos.length, 1)
@@ -347,6 +365,7 @@ describe('convo.transcript', function () {
347
365
  assert.isDefined(transcript)
348
366
  }
349
367
  })
368
+
350
369
  it('should handle expected JSON response', async function () {
351
370
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'json-matching-key-and-value.convo.txt')
352
371
  assert.equal(this.compiler.convos.length, 1)
@@ -362,6 +381,7 @@ describe('convo.transcript', function () {
362
381
  assert.fail('unexpected error: ' + error)
363
382
  })
364
383
  })
384
+
365
385
  it('should handle fail with mismatching key in JSON response', async function () {
366
386
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'json-mismatching-key.convo.txt')
367
387
  assert.equal(this.compiler.convos.length, 1)
@@ -375,6 +395,7 @@ describe('convo.transcript', function () {
375
395
  assert.isNotNull(transcript)
376
396
  })
377
397
  })
398
+
378
399
  it('should handle fail with mismatching value in JSON response', async function () {
379
400
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'json-mismatching-value.convo.txt')
380
401
  assert.equal(this.compiler.convos.length, 1)
@@ -388,6 +409,7 @@ describe('convo.transcript', function () {
388
409
  assert.isDefined(transcript)
389
410
  })
390
411
  })
412
+
391
413
  it('should emit transcript with asserters', async function () {
392
414
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'asserters.convo.txt')
393
415
 
@@ -406,6 +428,7 @@ describe('convo.transcript', function () {
406
428
  assert.lengthOf(transcript.steps[1].expected.asserters[0].args, 2)
407
429
  }
408
430
  })
431
+
409
432
  it('should throw simple error with multiple asserting errors if its disabled', async function () {
410
433
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'multiple_asserting_errors.convo.txt')
411
434
 
@@ -418,6 +441,7 @@ describe('convo.transcript', function () {
418
441
  'asserters/Line 6: Bot response (on Line 3: #me - Hello) "Hello" expected to match "Goodbye!"')
419
442
  }
420
443
  })
444
+
421
445
  it('should throw simple error with multiple asserting errors if its enabled', async function () {
422
446
  this.compilerMultipleAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'multiple_asserting_errors.convo.txt')
423
447
 
@@ -440,6 +464,7 @@ describe('convo.transcript', function () {
440
464
  assert.equal(err.transcript.err.context.errors[2].source, 'Buttons Asserter')
441
465
  }
442
466
  })
467
+
443
468
  it('should throw simple error with multiple asserting errors if its enabled and assertConvoEnd fail', async function () {
444
469
  this.compilerMultipleAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'multiple_asserting_errors.convo.txt')
445
470
  this.compilerMultipleAssertErrors.convos[0].scriptingEvents.assertConvoEnd = () => {
@@ -472,6 +497,7 @@ describe('convo.transcript', function () {
472
497
  assert.equal(err.transcript.err.context.errors[3].source, 'assertConvoEnd')
473
498
  }
474
499
  })
500
+
475
501
  it('should fail on unconsumed bot reply on #me', async function () {
476
502
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'botreply_not_consumed_me.convo.txt')
477
503
  assert.equal(this.compiler.convos.length, 1)
@@ -482,6 +508,7 @@ describe('convo.transcript', function () {
482
508
  assert.isTrue(err.message.indexOf('There is an unread bot reply in queue') >= 0)
483
509
  }
484
510
  })
511
+
485
512
  it('should fail on unconsumed bot reply on #end', async function () {
486
513
  this.compilerMultipleAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'botreply_not_consumed_end.convo.txt')
487
514
  assert.equal(this.compilerMultipleAssertErrors.convos.length, 1)
@@ -492,21 +519,25 @@ describe('convo.transcript', function () {
492
519
  assert.isTrue(err.message.indexOf('There is an unread bot reply in queue') >= 0)
493
520
  }
494
521
  })
522
+
495
523
  it('should succeed on not unconsumed bot reply on #end', async function () {
496
524
  this.compilerMultipleAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'botreply_not_consumed_end_not.convo.txt')
497
525
  assert.equal(this.compilerMultipleAssertErrors.convos.length, 1)
498
526
  await this.compilerMultipleAssertErrors.convos[0].Run(this.containerMultipleAssertErrors)
499
527
  })
528
+
500
529
  it('should succeed on unconsumed bot reply count', async function () {
501
530
  this.compilerMultipleAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'botreply_unconsumed_count.convo.txt')
502
531
  assert.equal(this.compilerMultipleAssertErrors.convos.length, 1)
503
532
  await this.compilerMultipleAssertErrors.convos[0].Run(this.containerMultipleAssertErrors)
504
533
  })
534
+
505
535
  it('should succeed on clearing unconsumed bot reply', async function () {
506
536
  this.compilerMultipleAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'botreply_skip_unconsumed.convo.txt')
507
537
  assert.equal(this.compilerMultipleAssertErrors.convos.length, 1)
508
538
  await this.compilerMultipleAssertErrors.convos[0].Run(this.containerMultipleAssertErrors)
509
539
  })
540
+
510
541
  it('should continue on failing assertion', async function () {
511
542
  this.compilerSkipAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'continuefailing.convo.txt')
512
543
  assert.equal(this.compilerSkipAssertErrors.convos.length, 1)
@@ -528,6 +559,7 @@ describe('convo.transcript', function () {
528
559
  assert.isNull(err.transcript.steps[5].err)
529
560
  }
530
561
  })
562
+
531
563
  it('should continue on failing assertion with timeout', async function () {
532
564
  this.compilerSkipAssertErrors.ReadScript(path.resolve(__dirname, 'convos'), 'continuefailing_timeout.convo.txt')
533
565
  assert.equal(this.compilerSkipAssertErrors.convos.length, 1)
@@ -544,6 +576,7 @@ describe('convo.transcript', function () {
544
576
  assert.equal(err.transcript.steps.length, 5)
545
577
  }
546
578
  })
579
+
547
580
  it('should calculate assertion count', async function () {
548
581
  this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2steps.convo.txt')
549
582
  assert.equal(this.compiler.convos.length, 1)
@@ -18,6 +18,7 @@ describe('tree.buildconversationtreeview', function () {
18
18
  assert.equal(tree[0].childNodes.length, 1)
19
19
  assert.equal(tree[0].childNodes[0].childNodes.length, 2)
20
20
  })
21
+
21
22
  it('should build from excel', async function () {
22
23
  const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
23
24
  await scriptingProvider.Build()
@@ -25,6 +26,7 @@ describe('tree.buildconversationtreeview', function () {
25
26
  const tree = scriptingProvider.GetConversationFlowView({ detectLoops: true, summarizeMultiSteps: false })
26
27
  assert.equal(tree.length, 3)
27
28
  })
29
+
28
30
  it('should build shared convo node on userInput buttons', async function () {
29
31
  const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
30
32
  await scriptingProvider.Build()
@@ -36,6 +38,7 @@ describe('tree.buildconversationtreeview', function () {
36
38
  assert.equal(tree[0].childNodes.length, 1)
37
39
  assert.equal(tree[0].childNodes[0].childNodes.length, 2)
38
40
  })
41
+
39
42
  it('should provide utterance samples', async function () {
40
43
  const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
41
44
  await scriptingProvider.Build()
@@ -54,6 +57,7 @@ describe('tree.buildconversationtreeview', function () {
54
57
  assert.equal(tree[1].childNodes[0].convoNodes[0].utteranceCount, 5)
55
58
  assert.equal(tree[1].childNodes[0].convoNodes[0].utteranceSamples.length, 3)
56
59
  })
60
+
57
61
  it('should detect loops', async function () {
58
62
  const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
59
63
  await scriptingProvider.Build()
@@ -68,6 +72,7 @@ describe('tree.buildconversationtreeview', function () {
68
72
  assert.deepEqual(tree[0].convos[1].convoStepIndices, [0, 3])
69
73
  assert.equal(tree[0].childNodes[0].childNodes[0].childNodes[0].ref, tree[0].key)
70
74
  })
75
+
71
76
  it('should build dot file', async function () {
72
77
  const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
73
78
  await scriptingProvider.Build()
@@ -11,18 +11,21 @@ describe('driver.capabilities', function () {
11
11
  assert.isArray(result)
12
12
  assert.lengthOf(result, 1)
13
13
  })
14
+
14
15
  it('fetch capabilities from non existing files', function () {
15
16
  const driver = new BotDriver()
16
17
  const result = driver._fetchConfigFromFiles(['test/driver/configFiles/configNotExists.json'])
17
18
  assert.isArray(result)
18
19
  assert.lengthOf(result, 0)
19
20
  })
21
+
20
22
  it('fetch capabilities from multiple files', function () {
21
23
  const driver = new BotDriver()
22
24
  const result = driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
23
25
  assert.isArray(result)
24
26
  assert.lengthOf(result, 2)
25
27
  })
28
+
26
29
  it('fetch capabilities from multiple files and check if overwritten', function () {
27
30
  const driver = new BotDriver()
28
31
  driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
@@ -38,16 +41,19 @@ describe('driver.capabilities', function () {
38
41
  const result = driver._loadConfigFile('test/driver/configFiles/config1.json')
39
42
  assert.isTrue(result)
40
43
  })
44
+
41
45
  it('load Config from non existing file', function () {
42
46
  const driver = new BotDriver()
43
47
  assert.throws(() => driver._loadConfigFile('test/driver/configFiles/configNonExisting.json'))
44
48
  })
49
+
45
50
  it('load Config from file only once', function () {
46
51
  const driver = new BotDriver()
47
52
  driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config1.json', 'test/driver/configFiles/config1.json'])
48
53
  assert.lengthOf(driver._fetchedConfigFiles, 1)
49
54
  assert.lengthOf(driver.caps.ARR_CAP, 2)
50
55
  })
56
+
51
57
  it('should make unique array', function () {
52
58
  const driver = new BotDriver()
53
59
  driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
@@ -66,6 +72,7 @@ describe('driver.capabilities', function () {
66
72
  assert.isBoolean(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
67
73
  assert.isTrue(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
68
74
  })
75
+
69
76
  it('should merge string caps', function () {
70
77
  const myCaps = {
71
78
  CAP_STRING_1: 'Test',
@@ -75,6 +82,7 @@ describe('driver.capabilities', function () {
75
82
  assert.isString(driver.caps.CAP_STRING_1)
76
83
  assert.isString(driver.caps.CAP_STRING_2)
77
84
  })
85
+
78
86
  it('should merge string caps when there are numbers', function () {
79
87
  const myCaps = {
80
88
  CAP_STRING_1: 'Test',
@@ -84,6 +92,7 @@ describe('driver.capabilities', function () {
84
92
  assert.strictEqual(driver.caps.CAP_STRING_1, myCaps.CAP_STRING_1)
85
93
  assert.strictEqual(driver.caps.CAP_STRING_2, myCaps.CAP_STRING_2)
86
94
  })
95
+
87
96
  it('should merge boolean envs', function () {
88
97
  process.env.BOTIUM_SIMPLEREST_PING_PROCESS_RESPONSE = 'NO'
89
98
  const driver = new BotDriver()
@@ -91,6 +100,7 @@ describe('driver.capabilities', function () {
91
100
  assert.isBoolean(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
92
101
  assert.isFalse(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
93
102
  })
103
+
94
104
  it('should parse array caps', function () {
95
105
  DefaultCapabilities.MYCAP = []
96
106
  const myCaps = {
@@ -100,6 +110,7 @@ describe('driver.capabilities', function () {
100
110
  assert.isArray(driver.caps.MYCAP)
101
111
  assert.lengthOf(driver.caps.MYCAP, 2)
102
112
  })
113
+
103
114
  it('should merge array caps', function () {
104
115
  DefaultCapabilities.MYCAP = [{
105
116
  id: 'id1',
@@ -116,6 +127,7 @@ describe('driver.capabilities', function () {
116
127
  assert.isUndefined(driver.caps.MYCAP[1].id)
117
128
  assert.equal(driver.caps.MYCAP[1].key, 'VALUE1')
118
129
  })
130
+
119
131
  it('should parse object caps', function () {
120
132
  DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
121
133
  const myCaps = {
@@ -125,6 +137,7 @@ describe('driver.capabilities', function () {
125
137
  assert.isObject(driver.caps.MYCAP)
126
138
  assert.equal(driver.caps.MYCAP.KEY, 'VALUE1')
127
139
  })
140
+
128
141
  it('should merge object caps', function () {
129
142
  DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
130
143
  const myCaps = {
@@ -135,6 +148,7 @@ describe('driver.capabilities', function () {
135
148
  assert.equal(driver.caps.MYCAP.KEY, 'VALUE')
136
149
  assert.equal(driver.caps.MYCAP.KEY1, 'VALUE1')
137
150
  })
151
+
138
152
  it('should not parse JSON caps', function () {
139
153
  const myCaps = {
140
154
  MYJSONCAP: '{"KEY":"VALUE1"}'
@@ -143,6 +157,7 @@ describe('driver.capabilities', function () {
143
157
  assert.isObject(driver.caps.MYJSONCAP)
144
158
  assert.equal(driver.caps.MYJSONCAP.KEY, 'VALUE1')
145
159
  })
160
+
146
161
  it('should override not matching object caps', function () {
147
162
  DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
148
163
  const myCaps = {
@@ -152,6 +167,7 @@ describe('driver.capabilities', function () {
152
167
  assert.isString(driver.caps.MYCAP)
153
168
  assert.equal(driver.caps.MYCAP, 'SIMPLESTRING')
154
169
  })
170
+
155
171
  it('should override not matching array caps', function () {
156
172
  DefaultCapabilities.MYCAP = ['VAL1', 'VAL2']
157
173
  const myCaps = {
@@ -31,18 +31,21 @@ describe('scripting.asserters.textAsserter', function () {
31
31
  assert.deepEqual(actual, EXPECTED_SINGLE)
32
32
  })
33
33
  })
34
+
34
35
  it('global and json', async function () {
35
36
  const actual = flatCababilities({
36
37
  PRECOMP: ACTUAL_SINGLE
37
38
  }, 'PRECOMP')
38
39
  assert.deepEqual(actual, EXPECTED_SINGLE)
39
40
  })
41
+
40
42
  it('global and jsonstring', async function () {
41
43
  const actual = flatCababilities({
42
44
  PRECOMP: JSON.stringify(ACTUAL_SINGLE)
43
45
  }, 'PRECOMP')
44
46
  assert.deepEqual(actual, EXPECTED_SINGLE)
45
47
  })
48
+
46
49
  describe('multiple precompilers', function () {
47
50
  it('suffix', async function () {
48
51
  const actual = flatCababilities({
@@ -53,6 +56,7 @@ describe('scripting.asserters.textAsserter', function () {
53
56
  }, 'PRECOMP')
54
57
  assert.deepEqual(actual, EXPECTED)
55
58
  })
59
+
56
60
  it('suffix and json', async function () {
57
61
  const actual = flatCababilities({
58
62
  'PRECOMP.0': {
@@ -66,12 +70,14 @@ describe('scripting.asserters.textAsserter', function () {
66
70
  }, 'PRECOMP')
67
71
  assert.deepEqual(actual, EXPECTED)
68
72
  })
73
+
69
74
  it('global and array', async function () {
70
75
  const actual = flatCababilities({
71
76
  PRECOMP: ACTUAL
72
77
  }, 'PRECOMP')
73
78
  assert.deepEqual(actual, EXPECTED)
74
79
  })
80
+
75
81
  it('global and arraystring', async function () {
76
82
  const actual = flatCababilities({
77
83
  PRECOMP: JSON.stringify(ACTUAL)
@@ -80,6 +86,7 @@ describe('scripting.asserters.textAsserter', function () {
80
86
  })
81
87
  })
82
88
  })
89
+
83
90
  describe('key types', function () {
84
91
  it('prefix is shorter', async function () {
85
92
  const actual = flatCababilities({
@@ -87,6 +94,7 @@ describe('scripting.asserters.textAsserter', function () {
87
94
  }, 'PRECOMP')
88
95
  assert.deepEqual(actual, [])
89
96
  })
97
+
90
98
  it('global is not unique', async function () {
91
99
  try {
92
100
  flatCababilities({
@@ -50,6 +50,7 @@ describe('helpers.transcriptutils', function () {
50
50
  }
51
51
  await container.Clean()
52
52
  })
53
+
53
54
  it('should return false if there is no timeout', async function () {
54
55
  const myCaps = {
55
56
  [Capabilities.PROJECTNAME]: 'helpers.transcriptutils.hasTimeout should return false if there is no timeout',
@@ -65,6 +65,7 @@ describe('customhooks.hookfromsrc', function () {
65
65
  assert.isTrue(onStopCalled)
66
66
  assert.isTrue(onCleanCalled)
67
67
  })
68
+
68
69
  it('should change meMsg from hook', async function () {
69
70
  const { container } = await buildDriver({
70
71
  [Capabilities.CUSTOMHOOK_ONUSERSAYS]: ({ meMsg }) => {
@@ -79,6 +80,7 @@ describe('customhooks.hookfromsrc', function () {
79
80
 
80
81
  assert.equal(botMsg.testInput, 1)
81
82
  })
83
+
82
84
  it('should change botMsg from hook', async function () {
83
85
  const { container } = await buildDriver({
84
86
  [Capabilities.CUSTOMHOOK_ONBOTRESPONSE]: ({ botMsg }) => {
@@ -93,6 +95,7 @@ describe('customhooks.hookfromsrc', function () {
93
95
 
94
96
  assert.equal(botMsg.fromHook, 1)
95
97
  })
98
+
96
99
  it('should call http api from function', async function () {
97
100
  const scope = nock('https://gettoken.com')
98
101
  .get('/get')
@@ -49,6 +49,7 @@ describe('logichooks.hookfromsrc', function () {
49
49
  compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
50
50
  await compiler.convos[0].Run(container)
51
51
  })
52
+
52
53
  it('should fail with asserter from code', async function () {
53
54
  const { compiler, container } = await buildDriver({
54
55
  [Capabilities.ASSERTERS]: [{
@@ -69,6 +70,7 @@ describe('logichooks.hookfromsrc', function () {
69
70
  assert.isTrue(err.message.includes('Line 6: assertion error - expected Hello1'))
70
71
  }
71
72
  })
73
+
72
74
  it('should fail with asserter with invalid script', async function () {
73
75
  const { compiler, container } = await buildDriver({
74
76
  [Capabilities.ASSERTERS]: [{
@@ -113,6 +115,7 @@ describe('logichooks.hookfromsrc', function () {
113
115
  compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
114
116
  await compiler.convos[0].Run(container)
115
117
  })
118
+
116
119
  it('should succeed with asserter from asserter module file', async function () {
117
120
  const { compiler, container } = await buildDriverFromFile({
118
121
  [Capabilities.ASSERTERS]: [{
@@ -43,6 +43,7 @@ describe('logichooks.textfromhook', function () {
43
43
  assert.lengthOf(transcript.steps, 2)
44
44
  assert.equal(transcript.steps[0].actual.testAttribute, 'val1')
45
45
  })
46
+
46
47
  it('should use text from onBotPrepare logic hook', async function () {
47
48
  const { compiler, container } = await buildDriver({
48
49
  [Capabilities.LOGIC_HOOKS]: [{
@@ -39,6 +39,7 @@ describe('plugins.plugins', function () {
39
39
  const response = await container.WaitBotSays()
40
40
  assert.equal(response.messageText, 'TEST')
41
41
  })
42
+
42
43
  it('should map simple function from file to class', async function () {
43
44
  const myCaps = {
44
45
  [Capabilities.PROJECTNAME]: 'plugins.load',
@@ -52,6 +53,7 @@ describe('plugins.plugins', function () {
52
53
  const response = await container.WaitBotSays()
53
54
  assert.equal(response.messageText, 'TEST')
54
55
  })
56
+
55
57
  it('should use UserSays function from module as class', async function () {
56
58
  const myCaps = {
57
59
  [Capabilities.PROJECTNAME]: 'plugins.load',
@@ -65,6 +67,7 @@ describe('plugins.plugins', function () {
65
67
  const response = await container.WaitBotSays()
66
68
  assert.equal(response.messageText, 'MYPREFIX:TEST')
67
69
  })
70
+
68
71
  it('should use UserSays function from file as class', async function () {
69
72
  const myCaps = {
70
73
  [Capabilities.PROJECTNAME]: 'plugins.load',
@@ -28,6 +28,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
28
28
  }
29
29
  })
30
30
  })
31
+
31
32
  it('should succeed on existing card button', async function () {
32
33
  const payload = {
33
34
  value: 'test'
@@ -49,6 +50,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
49
50
  }
50
51
  })
51
52
  })
53
+
52
54
  it('should succeed on existing card buttons', async function () {
53
55
  const payload = {
54
56
  value: 'test'
@@ -79,6 +81,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
79
81
  }
80
82
  })
81
83
  })
84
+
82
85
  it('should succeed on not existing button', async function () {
83
86
  const notPayload = {
84
87
  value: 'test1'
@@ -98,6 +101,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
98
101
  }
99
102
  })
100
103
  })
104
+
101
105
  it('should fail on unexpected button', async function () {
102
106
  const buttons = [
103
107
  {
@@ -124,6 +128,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
124
128
  assert.deepEqual(err.context.cause.diff, ['test'])
125
129
  }
126
130
  })
131
+
127
132
  it('should fail on unexpected button payload', async function () {
128
133
  const payload = {
129
134
  value: 'test'
@@ -154,6 +159,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
154
159
  assert.deepEqual(err.context.cause.diff, [JSON.stringify(payload)])
155
160
  }
156
161
  })
162
+
157
163
  it('should succeed on existing button if has no arg', async function () {
158
164
  await this.buttonsAsserter.assertConvoStep({
159
165
  convoStep: { stepTag: 'test' },
@@ -167,6 +173,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
167
173
  }
168
174
  })
169
175
  })
176
+
170
177
  it('should fail on no button if has no arg', async function () {
171
178
  try {
172
179
  await this.buttonsAsserter.assertConvoStep({ convoStep: { stepTag: 'test' } })
@@ -181,9 +188,11 @@ describe('scripting.asserters.buttonsAsserter', function () {
181
188
  assert.deepEqual(err.context.cause.actual, '[]')
182
189
  }
183
190
  })
191
+
184
192
  it('should succeed on not existing button if has no arg and negated', async function () {
185
193
  await this.buttonsAsserter.assertNotConvoStep({ convoStep: { stepTag: 'test' } })
186
194
  })
195
+
187
196
  it('should fail on button if has no arg and negated', async function () {
188
197
  const buttons = [
189
198
  {
@@ -210,6 +219,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
210
219
  }
211
220
  })
212
221
  })
222
+
213
223
  describe('buttonsCountAsserter', function () {
214
224
  beforeEach(async function () {
215
225
  this.buttonsCountAsserter = new ButtonsCountAsserter({}, {})
@@ -225,6 +235,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
225
235
  }
226
236
  })
227
237
  })
238
+
228
239
  it('should succeed on 3 with 3 buttons', async function () {
229
240
  await this.buttonsCountAsserter.assertConvoStep({
230
241
  convoStep: { stepTag: 'test' },
@@ -240,6 +251,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
240
251
  }
241
252
  })
242
253
  })
254
+
243
255
  it('should fail on 3 with 4 buttons', async function () {
244
256
  try {
245
257
  await this.buttonsCountAsserter.assertConvoStep({
@@ -260,6 +272,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
260
272
  assert.isTrue(err.message.indexOf('Expected Buttons count 4 to be 3') >= 0)
261
273
  }
262
274
  })
275
+
263
276
  it('should fail on >3 with 3 buttons', async function () {
264
277
  try {
265
278
  await this.buttonsCountAsserter.assertConvoStep({
@@ -280,6 +293,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
280
293
  assert.isTrue(err.message.indexOf('Expected Buttons count 3 to be >3') >= 0)
281
294
  }
282
295
  })
296
+
283
297
  it('should succeed on >=3 with rec buttons', async function () {
284
298
  await this.buttonsCountRecAsserter.assertConvoStep({
285
299
  convoStep: { stepTag: 'test' },
@@ -295,6 +309,7 @@ describe('scripting.asserters.buttonsAsserter', function () {
295
309
  }
296
310
  })
297
311
  })
312
+
298
313
  it('should succeed on 3 with rec buttons', async function () {
299
314
  await this.buttonsCountRecAsserter.assertConvoStep({
300
315
  convoStep: { stepTag: 'test' },