botium-core 1.13.4 → 1.13.6

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 (70) hide show
  1. package/dist/botium-cjs.js +262 -88
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +262 -88
  4. package/dist/botium-es.js.map +1 -1
  5. package/package.json +19 -19
  6. package/src/helpers/RetryHelper.js +3 -2
  7. package/src/scripting/CompilerXlsx.js +1 -0
  8. package/src/scripting/MatchFunctions.js +3 -1
  9. package/src/scripting/ScriptingMemory.js +41 -2
  10. package/src/scripting/ScriptingProvider.js +164 -56
  11. package/src/scripting/helper.js +2 -0
  12. package/src/scripting/logichook/asserter/BotRepliesConsumedAsserter.js +1 -1
  13. package/src/scripting/logichook/asserter/BotRepliesUnconsumedCountAsserter.js +1 -1
  14. package/src/scripting/logichook/asserter/ButtonsAsserter.js +1 -1
  15. package/src/scripting/logichook/asserter/ButtonsCountAsserter.js +1 -1
  16. package/src/scripting/logichook/asserter/ButtonsCountRecAsserter.js +1 -1
  17. package/src/scripting/logichook/asserter/CardsAsserter.js +1 -1
  18. package/src/scripting/logichook/asserter/CardsCountAsserter.js +1 -1
  19. package/src/scripting/logichook/asserter/CardsCountRecAsserter.js +1 -1
  20. package/src/scripting/logichook/asserter/EntitiesAsserter.js +1 -1
  21. package/src/scripting/logichook/asserter/EntityContentAsserter.js +2 -2
  22. package/src/scripting/logichook/asserter/EntityValuesAsserter.js +1 -1
  23. package/src/scripting/logichook/asserter/FormsAsserter.js +1 -1
  24. package/src/scripting/logichook/asserter/IntentAsserter.js +3 -3
  25. package/src/scripting/logichook/asserter/IntentConfidenceAsserter.js +4 -4
  26. package/src/scripting/logichook/asserter/IntentUniqueAsserter.js +2 -2
  27. package/src/scripting/logichook/asserter/JsonPathAsserter.js +5 -5
  28. package/src/scripting/logichook/asserter/JsonPathCountAsserter.js +2 -2
  29. package/src/scripting/logichook/asserter/MediaAsserter.js +1 -1
  30. package/src/scripting/logichook/asserter/MediaCountAsserter.js +1 -1
  31. package/src/scripting/logichook/asserter/MediaCountRecAsserter.js +1 -1
  32. package/src/scripting/logichook/asserter/PauseAsserter.js +1 -1
  33. package/src/scripting/logichook/asserter/ResponseLengthAsserter.js +3 -2
  34. package/src/scripting/logichook/asserter/TextContainsAllAsserter.js +2 -1
  35. package/src/scripting/logichook/asserter/TextContainsAllICAsserter.js +2 -1
  36. package/src/scripting/logichook/asserter/TextContainsAnyAsserter.js +1 -0
  37. package/src/scripting/logichook/asserter/TextContainsAnyICAsserter.js +2 -1
  38. package/src/scripting/logichook/asserter/TextEqualsAnyAsserter.js +2 -1
  39. package/src/scripting/logichook/asserter/TextEqualsAnyICAsserter.js +2 -1
  40. package/src/scripting/logichook/asserter/TextRegexpAllAsserter.js +2 -1
  41. package/src/scripting/logichook/asserter/TextRegexpAllICAsserter.js +2 -1
  42. package/src/scripting/logichook/asserter/TextRegexpAnyAsserter.js +1 -0
  43. package/src/scripting/logichook/asserter/TextRegexpAnyICAsserter.js +2 -1
  44. package/src/scripting/logichook/asserter/TextWildcardAllAsserter.js +2 -1
  45. package/src/scripting/logichook/asserter/TextWildcardAllICAsserter.js +2 -1
  46. package/src/scripting/logichook/asserter/TextWildcardAnyAsserter.js +1 -0
  47. package/src/scripting/logichook/asserter/TextWildcardAnyICAsserter.js +2 -1
  48. package/src/scripting/logichook/asserter/TextWildcardExactAllAsserter.js +2 -1
  49. package/src/scripting/logichook/asserter/TextWildcardExactAllICAsserter.js +2 -1
  50. package/src/scripting/logichook/asserter/TextWildcardExactAnyAsserter.js +1 -0
  51. package/src/scripting/logichook/asserter/TextWildcardExactAnyICAsserter.js +2 -1
  52. package/src/scripting/logichook/asserter/WerAsserter.js +10 -8
  53. package/src/scripting/logichook/userinput/MediaInput.js +2 -1
  54. package/test/compiler/compilercsv.spec.js +9 -2
  55. package/test/compiler/convos/csv/utterances_variable_row_len.csv +1 -1
  56. package/test/convo/fillAndApplyScriptingMemory.spec.js +64 -4
  57. package/test/convo/transcript.spec.js +15 -6
  58. package/test/scripting/asserters/convos/{wer_threshold_nok.yml → wer_threshold_nok_float.yml} +0 -0
  59. package/test/scripting/asserters/convos/wer_threshold_nok_percentage.yml +7 -0
  60. package/test/scripting/asserters/convos/{wer_threshold_ok.yml → wer_threshold_ok_float.yml} +0 -0
  61. package/test/scripting/asserters/convos/wer_threshold_ok_percentage.yml +7 -0
  62. package/test/scripting/asserters/entityContentAsserter.spec.js +2 -7
  63. package/test/scripting/asserters/intentAsserter.spec.js +1 -1
  64. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +3 -7
  65. package/test/scripting/asserters/jsonpathAsserter.spec.js +1 -1
  66. package/test/scripting/asserters/werAsserter.spec.js +25 -5
  67. package/test/scripting/matching/matchingmode.spec.js +42 -2
  68. package/test/scripting/scriptingModificator.spec.js +1 -2
  69. package/test/scripting/scriptingProvider.spec.js +156 -4
  70. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +15 -15
@@ -1,4 +1,5 @@
1
1
  const path = require('path')
2
+ const moment = require('moment')
2
3
  const assert = require('chai').assert
3
4
  const BotDriver = require('../../').BotDriver
4
5
  const Capabilities = require('../../').Capabilities
@@ -695,6 +696,39 @@ describe('convo.fillAndApplyScriptingMemory', function () {
695
696
  assert(result.length === 13, '$timestap is invalid')
696
697
  })
697
698
 
699
+ it('tomorrow without format', async function () {
700
+ const result = ScriptingMemory.apply(
701
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
702
+ {},
703
+ '$tomorrow'
704
+ )
705
+ assert.equal(result, moment().add(1, 'day').toDate().toLocaleDateString())
706
+ })
707
+ it('tomorrow with format', async function () {
708
+ const result = ScriptingMemory.apply(
709
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
710
+ {},
711
+ '$tomorrow(YYYY.MM.DD)'
712
+ )
713
+ assert.equal(result, moment().add(1, 'day').format('YYYY.MM.DD'))
714
+ })
715
+ it('yesterday without format', async function () {
716
+ const result = ScriptingMemory.apply(
717
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
718
+ {},
719
+ '$yesterday'
720
+ )
721
+ assert.equal(result, moment().subtract(1, 'day').toDate().toLocaleDateString())
722
+ })
723
+ it('yesterday with format', async function () {
724
+ const result = ScriptingMemory.apply(
725
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
726
+ {},
727
+ '$yesterday(YYYY.MM.DD)'
728
+ )
729
+ assert.equal(result, moment().subtract(1, 'day').format('YYYY.MM.DD'))
730
+ })
731
+
698
732
  it('year', async function () {
699
733
  const result = ScriptingMemory.apply(
700
734
  { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
@@ -703,7 +737,7 @@ describe('convo.fillAndApplyScriptingMemory', function () {
703
737
  )
704
738
 
705
739
  const year = parseInt(result)
706
- assert(year >= 2019 && year <= 2219, '$year invalid')
740
+ assert.equal(year, new Date().getFullYear(), '$year invalid')
707
741
  })
708
742
 
709
743
  it('month', async function () {
@@ -712,8 +746,7 @@ describe('convo.fillAndApplyScriptingMemory', function () {
712
746
  {},
713
747
  '$month'
714
748
  )
715
-
716
- assert(result.length >= 2 && result.length <= 10, '$month invalid')
749
+ assert.equal(result, moment().format('MMMM'), '$month invalid')
717
750
  })
718
751
  it('month_MM', async function () {
719
752
  const result = ScriptingMemory.apply(
@@ -733,7 +766,7 @@ describe('convo.fillAndApplyScriptingMemory', function () {
733
766
  )
734
767
 
735
768
  const dayOfMonth = parseInt(result)
736
- assert(dayOfMonth >= 1 && dayOfMonth <= 35, 'day_of_month invalid')
769
+ assert(dayOfMonth >= 1 && dayOfMonth <= 35, '$day_of_month invalid')
737
770
  })
738
771
 
739
772
  it('day_of_week', async function () {
@@ -746,6 +779,25 @@ describe('convo.fillAndApplyScriptingMemory', function () {
746
779
  assert(result.length >= 2 && result.length <= 20, '$day_of_week invalid')
747
780
  })
748
781
 
782
+ it('date_add', async function () {
783
+ const result = ScriptingMemory.apply(
784
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
785
+ {},
786
+ '$date_add(1, "day", YYYY.MM.DD)'
787
+ )
788
+
789
+ assert.equal(result, moment().add(1, 'day').format('YYYY.MM.DD'))
790
+ })
791
+ it('date_subtract', async function () {
792
+ const result = ScriptingMemory.apply(
793
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
794
+ {},
795
+ '$date_subtract(1, "month", YYYY.MM.DD)'
796
+ )
797
+
798
+ assert.equal(result, moment().subtract(1, 'month').format('YYYY.MM.DD'))
799
+ })
800
+
749
801
  it('random', async function () {
750
802
  const result = ScriptingMemory.apply(
751
803
  { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
@@ -813,6 +865,14 @@ describe('convo.fillAndApplyScriptingMemory', function () {
813
865
  )
814
866
  assert.equal(result, 'botium')
815
867
  })
868
+ it('func with moment', async function () {
869
+ const result = ScriptingMemory.apply(
870
+ { caps: CAPS_ENABLE_SCRIPTING_MEMORY },
871
+ {},
872
+ '$func(moment(\\).subtract(1, "month"\\).startOf("month"\\).format("DD.MM.YYYY"\\))'
873
+ )
874
+ assert.equal(result, moment().subtract(1, 'month').startOf('month').format('DD.MM.YYYY'))
875
+ })
816
876
  it('environment variable', async function () {
817
877
  process.env.MY_VAR_VALUE = 'botium'
818
878
  const result = ScriptingMemory.apply(
@@ -287,11 +287,11 @@ describe('convo.transcript', function () {
287
287
 
288
288
  assert.equal(err.transcript.err.context.input.messageText, 'Hello')
289
289
  assert.equal(err.transcript.err.context.errors[0].type, 'asserter')
290
- assert.equal(err.transcript.err.context.errors[0].source, 'TextMatchAsserter')
290
+ assert.equal(err.transcript.err.context.errors[0].source, 'Text Match Asserter')
291
291
  assert.equal(err.transcript.err.context.errors[1].type, 'asserter')
292
- assert.equal(err.transcript.err.context.errors[1].source, 'ButtonsAsserter')
292
+ assert.equal(err.transcript.err.context.errors[1].source, 'Buttons Asserter')
293
293
  assert.equal(err.transcript.err.context.errors[2].type, 'asserter')
294
- assert.equal(err.transcript.err.context.errors[2].source, 'ButtonsAsserter')
294
+ assert.equal(err.transcript.err.context.errors[2].source, 'Buttons Asserter')
295
295
  }
296
296
  })
297
297
  it('should throw simple error with multiple asserting errors if its enabled and assertConvoEnd fail', async function () {
@@ -317,11 +317,11 @@ describe('convo.transcript', function () {
317
317
 
318
318
  assert.equal(err.transcript.err.context.input.messageText, 'Hello')
319
319
  assert.equal(err.transcript.err.context.errors[0].type, 'asserter')
320
- assert.equal(err.transcript.err.context.errors[0].source, 'TextMatchAsserter')
320
+ assert.equal(err.transcript.err.context.errors[0].source, 'Text Match Asserter')
321
321
  assert.equal(err.transcript.err.context.errors[1].type, 'asserter')
322
- assert.equal(err.transcript.err.context.errors[1].source, 'ButtonsAsserter')
322
+ assert.equal(err.transcript.err.context.errors[1].source, 'Buttons Asserter')
323
323
  assert.equal(err.transcript.err.context.errors[2].type, 'asserter')
324
- assert.equal(err.transcript.err.context.errors[2].source, 'ButtonsAsserter')
324
+ assert.equal(err.transcript.err.context.errors[2].source, 'Buttons Asserter')
325
325
  assert.equal(err.transcript.err.context.errors[3].type, 'asserter')
326
326
  assert.equal(err.transcript.err.context.errors[3].source, 'assertConvoEnd')
327
327
  }
@@ -398,4 +398,13 @@ describe('convo.transcript', function () {
398
398
  assert.equal(err.transcript.steps.length, 5)
399
399
  }
400
400
  })
401
+ it('should calculate assertion count', async function () {
402
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2steps.convo.txt')
403
+ assert.equal(this.compiler.convos.length, 1)
404
+ assert.equal(this.compiler.GetAssertionCount(this.compiler.convos[0]), 2)
405
+
406
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'asserters.convo.txt')
407
+ assert.equal(this.compiler.convos.length, 2)
408
+ assert.equal(this.compiler.GetAssertionCount(this.compiler.convos[1]), 1)
409
+ })
401
410
  })
@@ -0,0 +1,7 @@
1
+ convos:
2
+ - name: wer_threshold_nok
3
+ steps:
4
+ - me:
5
+ - test 123
6
+ - bot:
7
+ - TEXT_WER tast 123|10
@@ -0,0 +1,7 @@
1
+ convos:
2
+ - name: wer_threshold_ok
3
+ steps:
4
+ - me:
5
+ - test 123
6
+ - bot:
7
+ - TEXT_WER tast 123|60
@@ -20,10 +20,9 @@ describe('scripting.asserters.entityContentAsserter', function () {
20
20
  })
21
21
  assert.fail('should have failed')
22
22
  } catch (err) {
23
- assert.isTrue(err.message.indexOf('EntityContentAsserter Missing argument') > 0)
23
+ assert.isTrue(err.message.indexOf('Missing argument') > 0)
24
24
  assert.isNotNull(err.context)
25
25
  assert.equal(err.context.type, 'asserter')
26
- assert.equal(err.context.source, 'EntityContentAsserter')
27
26
  }
28
27
  })
29
28
 
@@ -36,10 +35,9 @@ describe('scripting.asserters.entityContentAsserter', function () {
36
35
  })
37
36
  assert.fail('should have failed')
38
37
  } catch (err) {
39
- assert.isTrue(err.message.indexOf('EntityContentAsserter Missing argument') > 0)
38
+ assert.isTrue(err.message.indexOf('Missing argument') > 0)
40
39
  assert.isNotNull(err.context)
41
40
  assert.equal(err.context.type, 'asserter')
42
- assert.equal(err.context.source, 'EntityContentAsserter')
43
41
  }
44
42
  })
45
43
 
@@ -55,7 +53,6 @@ describe('scripting.asserters.entityContentAsserter', function () {
55
53
  assert.isTrue(err.message.indexOf('Expected entity "something" but found nothing') > 0)
56
54
  assert.isNotNull(err.context)
57
55
  assert.equal(err.context.type, 'asserter')
58
- assert.equal(err.context.source, 'EntityContentAsserter')
59
56
  }
60
57
  })
61
58
 
@@ -88,7 +85,6 @@ describe('scripting.asserters.entityContentAsserter', function () {
88
85
  assert.isTrue(err.message.indexOf('test: Missing entity content: [ \'something_value\' ] of entity "something"') >= 0)
89
86
  assert.isNotNull(err.context)
90
87
  assert.equal(err.context.type, 'asserter')
91
- assert.equal(err.context.source, 'EntityContentAsserter')
92
88
  assert.isNotNull(err.context.cause)
93
89
  assert.equal(err.context.cause.entity, 'something')
94
90
  assert.deepEqual(err.context.cause.expected, ['something_value'])
@@ -126,7 +122,6 @@ describe('scripting.asserters.entityContentAsserter', function () {
126
122
  assert.isTrue(err.message.indexOf('test: Missing entity content: [ \'entity1_value1\', \'entity1_value3\' ] of entity "entity1"') >= 0)
127
123
  assert.isNotNull(err.context)
128
124
  assert.equal(err.context.type, 'asserter')
129
- assert.equal(err.context.source, 'EntityContentAsserter')
130
125
  assert.isNotNull(err.context.cause)
131
126
  assert.equal(err.context.cause.entity, 'entity1')
132
127
  assert.deepEqual(err.context.cause.expected, ['entity1_value1', 'entity1_value1', 'entity1_value3'])
@@ -62,7 +62,7 @@ const _assert = (expected, found) => {
62
62
  ))
63
63
 
64
64
  if (!expected) {
65
- return assert.isRejected(promise, `${steptag}: IntentAsserter Missing argument`)
65
+ return assert.isRejected(promise, `${steptag}: NLU Intent Asserter Missing argument`)
66
66
  } else if (!found) {
67
67
  return assert.isRejected(promise, `${steptag}: Expected intent "${expected}" but found nothing`)
68
68
  } else if (expected !== found) {
@@ -61,16 +61,12 @@ describe('scripting.asserters.intentConfidenceAsserter', function () {
61
61
  [false, 80, 85, false]
62
62
  ]
63
63
 
64
- cases.forEach((cse) => {
65
- const useWithGlobal = cse[0]
66
- const expected = cse[1]
67
- const found = cse[2]
68
- const negative = cse[3]
64
+ for (const [useWithGlobal, expected, found, negative] of cases) {
69
65
  const message = `${negative ? 'negative' : 'positive'} case for intent confidence asserter ${useWithGlobal ? 'with global args' : 'without global args'}, exp: ${expected}, found: ${found}`
70
66
  it(message,
71
67
  async function () {
72
- return _assert(...cse)
68
+ return _assert(useWithGlobal, expected, found, negative)
73
69
  }
74
70
  )
75
- })
71
+ }
76
72
  })
@@ -278,7 +278,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
278
278
  })
279
279
  assert.fail('should have failed')
280
280
  } catch (err) {
281
- assert.isTrue(err.message.indexOf('JsonPathAsserter 0 arguments expected') > 0)
281
+ assert.isTrue(err.message.indexOf('0 arguments expected') > 0)
282
282
  }
283
283
  })
284
284
  it('should succeed on existing jsonpath from pathPattern', async function () {
@@ -27,16 +27,36 @@ describe('scripting.asserters.werAsserter', function () {
27
27
  this.container && await this.container.Clean()
28
28
  })
29
29
 
30
- it('ok', async function () {
31
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_ok.yml'))
30
+ it('ok (float)', async function () {
31
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_ok_float.yml'))
32
32
 
33
33
  this.compiler.ExpandScriptingMemoryToConvos()
34
34
  assert.equal(this.compiler.convos.length, 1)
35
35
  await this.compiler.convos[0].Run(this.container)
36
36
  })
37
+ it('ok (percentage)', async function () {
38
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_ok_percentage.yml'))
37
39
 
38
- it('nok', async function () {
39
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_nok.yml'))
40
+ this.compiler.ExpandScriptingMemoryToConvos()
41
+ assert.equal(this.compiler.convos.length, 1)
42
+ await this.compiler.convos[0].Run(this.container)
43
+ })
44
+
45
+ it('nok (float)', async function () {
46
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_nok_float.yml'))
47
+
48
+ this.compiler.ExpandScriptingMemoryToConvos()
49
+ assert.equal(this.compiler.convos.length, 1)
50
+
51
+ try {
52
+ await this.compiler.convos[0].Run(this.container)
53
+ assert.fail('expected error')
54
+ } catch (err) {
55
+ assert.equal(err.message, 'wer_threshold_nok/Line 2: assertion error - Line 2: Word Error Rate (50%) higher than accepted (10%)')
56
+ }
57
+ })
58
+ it('nok (percentage)', async function () {
59
+ this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convos', 'wer_threshold_nok_percentage.yml'))
40
60
 
41
61
  this.compiler.ExpandScriptingMemoryToConvos()
42
62
  assert.equal(this.compiler.convos.length, 1)
@@ -45,7 +65,7 @@ describe('scripting.asserters.werAsserter', function () {
45
65
  await this.compiler.convos[0].Run(this.container)
46
66
  assert.fail('expected error')
47
67
  } catch (err) {
48
- assert.equal(err.message, 'wer_threshold_nok/Line 2: assertion error - Line 2: Word error rate 0.5 > 0.1 for tast 123')
68
+ assert.equal(err.message, 'wer_threshold_nok/Line 2: assertion error - Line 2: Word Error Rate (50%) higher than accepted (10%)')
49
69
  }
50
70
  })
51
71
  })
@@ -306,7 +306,7 @@ describe('scripting.matching.matchingmode', function () {
306
306
  })
307
307
  })
308
308
 
309
- describe('wer.lowthreshold', function () {
309
+ describe('wer.lowthreshold (float)', function () {
310
310
  beforeEach(async function () {
311
311
  const myCaps = {
312
312
  [Capabilities.PROJECTNAME]: 'matching.matchingmode',
@@ -326,8 +326,28 @@ describe('scripting.matching.matchingmode', function () {
326
326
  assert.isFalse(this.compiler.Match('test 123', 'tast 123'))
327
327
  })
328
328
  })
329
+ describe('wer.lowthreshold (percentage)', function () {
330
+ beforeEach(async function () {
331
+ const myCaps = {
332
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
333
+ [Capabilities.CONTAINERMODE]: echoConnector,
334
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
335
+ [Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [10]
336
+ }
337
+ const driver = new BotDriver(myCaps)
338
+ this.compiler = driver.BuildCompiler()
339
+ this.container = await driver.Build()
340
+ })
341
+ afterEach(async function () {
342
+ this.container && await this.container.Clean()
343
+ })
344
+
345
+ it('should not match because of low threshold', async function () {
346
+ assert.isFalse(this.compiler.Match('test 123', 'tast 123'))
347
+ })
348
+ })
329
349
 
330
- describe('wer.highthreshold', function () {
350
+ describe('wer.highthreshold (float)', function () {
331
351
  beforeEach(async function () {
332
352
  const myCaps = {
333
353
  [Capabilities.PROJECTNAME]: 'matching.matchingmode',
@@ -343,6 +363,26 @@ describe('scripting.matching.matchingmode', function () {
343
363
  this.container && await this.container.Clean()
344
364
  })
345
365
 
366
+ it('should match because of high threshold', async function () {
367
+ assert.isTrue(this.compiler.Match('test 123', 'tast 123'))
368
+ })
369
+ })
370
+ describe('wer.highthreshold (percentage)', function () {
371
+ beforeEach(async function () {
372
+ const myCaps = {
373
+ [Capabilities.PROJECTNAME]: 'matching.matchingmode',
374
+ [Capabilities.CONTAINERMODE]: echoConnector,
375
+ [Capabilities.SCRIPTING_MATCHING_MODE]: 'wer',
376
+ [Capabilities.SCRIPTING_MATCHING_MODE_ARGS]: [60]
377
+ }
378
+ const driver = new BotDriver(myCaps)
379
+ this.compiler = driver.BuildCompiler()
380
+ this.container = await driver.Build()
381
+ })
382
+ afterEach(async function () {
383
+ this.container && await this.container.Clean()
384
+ })
385
+
346
386
  it('should match because of high threshold', async function () {
347
387
  assert.isTrue(this.compiler.Match('test 123', 'tast 123'))
348
388
  })
@@ -55,9 +55,8 @@ describe('scriptingModificator.assertions', function () {
55
55
  })
56
56
  assert.fail('should have failed')
57
57
  } catch (err) {
58
- assert.isTrue(err.message.indexOf('Expected asserter IntentAsserter with args "test1" to fail') > 0)
58
+ assert.isTrue(err.message.indexOf('Expected asserter NLU Intent Asserter with args "test1" to fail') > 0)
59
59
  assert.isNotNull(err.context)
60
- assert.equal(err.context.source, 'IntentAsserter')
61
60
  }
62
61
  })
63
62
  })
@@ -293,6 +293,48 @@ describe('scripting.scriptingProvider', function () {
293
293
  assert.equal(scriptingProvider.convos[1].header.name, 'test convo/utt1-L2')
294
294
  assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
295
295
  })
296
+ it('should build convos for utterance using iterator', async function () {
297
+ const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
298
+ await scriptingProvider.Build()
299
+ scriptingProvider.AddUtterances({
300
+ name: 'utt1',
301
+ utterances: ['TEXT1', 'TEXT2']
302
+ })
303
+ scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
304
+ header: {
305
+ name: 'test convo'
306
+ },
307
+ conversation: [
308
+ {
309
+ sender: 'me',
310
+ messageText: 'utt1'
311
+ }
312
+ ]
313
+ }))
314
+
315
+ scriptingProvider.ExpandConvosIterable()
316
+ const expected = [
317
+ {
318
+ header: { name: 'test convo/utt1-L1' },
319
+ conversation: [{ messageText: 'TEXT1' }]
320
+ },
321
+ {
322
+ header: { name: 'test convo/utt1-L2' },
323
+ conversation: [{ messageText: 'TEXT2' }]
324
+ }
325
+ ]
326
+ let i = 0
327
+ for (const c of scriptingProvider.convosIterable) {
328
+ const exp = expected[i++]
329
+ assert.equal(c.header.name, exp.header.name)
330
+ assert.equal(c.conversation.length, exp.conversation.length)
331
+ assert.deepEqual(c.conversation.map(s => s.messageText), exp.conversation.map(s => s.messageText))
332
+ }
333
+ assert.equal(i, 2)
334
+ // scriptingProvider.convosIterable.forEach((iteratedConvo, index) => {
335
+ // assert.deepEqual(iteratedConvo, expected[index])
336
+ // })
337
+ })
296
338
  it('should build convos for utterance with parameters', async function () {
297
339
  const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
298
340
  await scriptingProvider.Build()
@@ -350,10 +392,12 @@ describe('scripting.scriptingProvider', function () {
350
392
  assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
351
393
  })
352
394
  describe('should build convos for SCRIPTING_UTTEXPANSION_NAMING_MODE', function () {
353
- const utterances = {
354
- name: 'uttText',
355
- utterances: ['TEXT1 01234567890123456789', 'TEXT2 01234567890123456789']
356
- }
395
+ const utterances = [
396
+ {
397
+ name: 'uttText',
398
+ utterances: ['TEXT1 01234567890123456789', 'TEXT2 01234567890123456789']
399
+ }
400
+ ]
357
401
  const convoUtterances = {
358
402
  header: {
359
403
  name: 'test convo'
@@ -397,7 +441,38 @@ describe('scripting.scriptingProvider', function () {
397
441
  assert.equal(scriptingProvider.convos[0].header.name, 'test convo/uttText-L1-TEXT1 0123456...')
398
442
  assert.equal(scriptingProvider.convos[1].header.name, 'test convo/uttText-L2-TEXT2 0123456...')
399
443
  })
444
+ it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance len=1', async function () {
445
+ const scriptingProvider = new ScriptingProvider(Object.assign(
446
+ {},
447
+ DefaultCapabilities,
448
+ {
449
+ [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
450
+ }
451
+ ))
452
+ await scriptingProvider.Build()
453
+ scriptingProvider.AddUtterances([
454
+ {
455
+ name: 'uttText1',
456
+ utterances: ['TEXT1 01234567890123456789']
457
+ }
458
+ ])
459
+ scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
460
+ header: {
461
+ name: 'test convo'
462
+ },
463
+ conversation: [
464
+ {
465
+ sender: 'me',
466
+ messageText: 'uttText1'
467
+ }
468
+ ]
469
+ }))
400
470
 
471
+ scriptingProvider.ExpandConvos()
472
+ assert.equal(scriptingProvider.convos.length, 1)
473
+ assert.equal(scriptingProvider.convos[0].conversation.length, 1)
474
+ assert.equal(scriptingProvider.convos[0].header.name, 'test convo')
475
+ })
401
476
  it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance, turn length off', async function () {
402
477
  const scriptingProvider = new ScriptingProvider(Object.assign(
403
478
  {},
@@ -475,6 +550,42 @@ describe('scripting.scriptingProvider', function () {
475
550
  assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-L2-test2 0123456...')
476
551
  assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-L3-test3.jpg')
477
552
  })
553
+ it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance userinputs len=1', async function () {
554
+ const scriptingProvider = new ScriptingProvider(Object.assign(
555
+ {},
556
+ DefaultCapabilities,
557
+ {
558
+ [Capabilities.SCRIPTING_UTTEXPANSION_NAMING_MODE]: 'utterance'
559
+ }
560
+ ))
561
+ await scriptingProvider.Build()
562
+ scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
563
+ header: {
564
+ name: 'test convo'
565
+ },
566
+ sourceTag: {},
567
+ conversation: [
568
+ {
569
+ sender: 'me',
570
+ userInputs: [
571
+ {
572
+ name: 'BUTTON',
573
+ args: ['button1']
574
+ },
575
+ {
576
+ name: 'MEDIA',
577
+ args: ['test1.jpg']
578
+ }
579
+ ]
580
+ }
581
+ ]
582
+ }))
583
+
584
+ scriptingProvider.ExpandConvos()
585
+ assert.equal(scriptingProvider.convos.length, 1)
586
+ assert.equal(scriptingProvider.convos[0].conversation.length, 1)
587
+ assert.equal(scriptingProvider.convos[0].header.name, 'test convo')
588
+ })
478
589
  it('SCRIPTING_UTTEXPANSION_NAMING_MODE=utterance userinputs and utterances', async function () {
479
590
  const scriptingProvider = new ScriptingProvider(Object.assign(
480
591
  {},
@@ -518,6 +629,47 @@ describe('scripting.scriptingProvider', function () {
518
629
  assert.equal(scriptingProvider.convos[4].header.name, 'test convo/uttText-L2-TEXT2 0123456...')
519
630
  })
520
631
  })
632
+ describe('should have be possible to generate / store convos partially', function () {
633
+ const _createConvos = async () => {
634
+ const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
635
+ await scriptingProvider.Build()
636
+ scriptingProvider.AddUtterances({
637
+ name: 'utt1',
638
+ utterances: ['TEXT1', 'TEXT2', 'TEXT3', 'TEXT4', 'TEXT5']
639
+ })
640
+ scriptingProvider.AddConvos(new Convo(scriptingProvider._buildScriptContext(), {
641
+ header: {
642
+ name: 'test convo'
643
+ },
644
+ conversation: [
645
+ {
646
+ sender: 'me',
647
+ messageText: 'utt1'
648
+ },
649
+ {
650
+ sender: 'bot',
651
+ messageText: 'some text'
652
+ },
653
+ {
654
+ sender: 'me',
655
+ messageText: 'utt1'
656
+ }
657
+ ]
658
+ }))
659
+ return scriptingProvider
660
+ }
661
+
662
+ it('should build convos with nulls (to detect convo count)', async function () {
663
+ const scriptingProvider = await _createConvos()
664
+ scriptingProvider.ExpandConvos({ justHeader: true })
665
+ assert.equal(scriptingProvider.convos.length, 25)
666
+ for (let i = 0; i < 25; i++) {
667
+ const keys = Object.keys(scriptingProvider.convos[i])
668
+ assert.equal(keys.length, 1)
669
+ assert.equal(keys[0], 'header')
670
+ }
671
+ })
672
+ })
521
673
  })
522
674
 
523
675
  describe('ExpandUtterancesToConvos', function () {
@@ -70,15 +70,15 @@ describe('scripting.utteranceexpansion.associateByIndex', function () {
70
70
  scriptingProvider.ExpandConvos()
71
71
 
72
72
  assert.equal(scriptingProvider.convos.length, 5)
73
- assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_BODY-L1/UTT_GOODBYE-L1')
73
+ assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_GOODBYE-L1')
74
74
  assert.deepEqual(scriptingProvider.convos[0].conversation.length, 6)
75
- assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_BODY-L1/UTT_GOODBYE-L2')
75
+ assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_GOODBYE-L2')
76
76
  assert.deepEqual(scriptingProvider.convos[1].conversation.length, 6)
77
- assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L3')
77
+ assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L3')
78
78
  assert.deepEqual(scriptingProvider.convos[2].conversation.length, 6)
79
- assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L4')
79
+ assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L4')
80
80
  assert.deepEqual(scriptingProvider.convos[3].conversation.length, 6)
81
- assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L5')
81
+ assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L5')
82
82
  assert.deepEqual(scriptingProvider.convos[4].conversation.length, 6)
83
83
  })
84
84
  it('should associate media by index', async function () {
@@ -140,15 +140,15 @@ describe('scripting.utteranceexpansion.associateByIndex', function () {
140
140
  scriptingProvider.ExpandConvos()
141
141
 
142
142
  assert.equal(scriptingProvider.convos.length, 5)
143
- assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-L1/MEDIA-L1/MEDIA-L1')
143
+ assert.equal(scriptingProvider.convos[0].header.name, 'test convo/MEDIA-step0voice0.wav/MEDIA-step2voice0.wav')
144
144
  assert.deepEqual(scriptingProvider.convos[0].conversation.length, 6)
145
- assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-L2/MEDIA-L1/MEDIA-L2')
145
+ assert.equal(scriptingProvider.convos[1].header.name, 'test convo/MEDIA-step0voice1.wav/MEDIA-step2voice1.wav')
146
146
  assert.deepEqual(scriptingProvider.convos[1].conversation.length, 6)
147
- assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-L3/MEDIA-L1/MEDIA-L3')
147
+ assert.equal(scriptingProvider.convos[2].header.name, 'test convo/MEDIA-step0voice2.wav/MEDIA-step2voice2.wav')
148
148
  assert.deepEqual(scriptingProvider.convos[2].conversation.length, 6)
149
- assert.equal(scriptingProvider.convos[3].header.name, 'test convo/MEDIA-L3/MEDIA-L1/MEDIA-L4')
149
+ assert.equal(scriptingProvider.convos[3].header.name, 'test convo/MEDIA-step0voice2.wav/MEDIA-step2voice4.wav')
150
150
  assert.deepEqual(scriptingProvider.convos[3].conversation.length, 6)
151
- assert.equal(scriptingProvider.convos[4].header.name, 'test convo/MEDIA-L3/MEDIA-L1/MEDIA-L5')
151
+ assert.equal(scriptingProvider.convos[4].header.name, 'test convo/MEDIA-step0voice2.wav/MEDIA-step2voice5.wav')
152
152
  assert.deepEqual(scriptingProvider.convos[4].conversation.length, 6)
153
153
  })
154
154
  it('should associate utterance and media by index', async function () {
@@ -245,15 +245,15 @@ describe('scripting.utteranceexpansion.associateByIndex', function () {
245
245
  scriptingProvider.ExpandConvos()
246
246
 
247
247
  assert.equal(scriptingProvider.convos.length, 5)
248
- assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_BODY-L1/UTT_GOODBYE-L1/MEDIA-L1/MEDIA-L1/MEDIA-L1')
248
+ assert.equal(scriptingProvider.convos[0].header.name, 'test convo/UTT_HELLO-L1/UTT_GOODBYE-L1/MEDIA-step0voice0.wav/MEDIA-step2voice0.wav')
249
249
  assert.deepEqual(scriptingProvider.convos[0].conversation.length, 12)
250
- assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_BODY-L1/UTT_GOODBYE-L2/MEDIA-L2/MEDIA-L1/MEDIA-L2')
250
+ assert.equal(scriptingProvider.convos[1].header.name, 'test convo/UTT_HELLO-L2/UTT_GOODBYE-L2/MEDIA-step0voice1.wav/MEDIA-step2voice1.wav')
251
251
  assert.deepEqual(scriptingProvider.convos[1].conversation.length, 12)
252
- assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L3/MEDIA-L3/MEDIA-L1/MEDIA-L3')
252
+ assert.equal(scriptingProvider.convos[2].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L3/MEDIA-step0voice2.wav/MEDIA-step2voice2.wav')
253
253
  assert.deepEqual(scriptingProvider.convos[2].conversation.length, 12)
254
- assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L4/MEDIA-L3/MEDIA-L1/MEDIA-L4')
254
+ assert.equal(scriptingProvider.convos[3].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L4/MEDIA-step0voice2.wav/MEDIA-step2voice4.wav')
255
255
  assert.deepEqual(scriptingProvider.convos[3].conversation.length, 12)
256
- assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_BODY-L1/UTT_GOODBYE-L5/MEDIA-L3/MEDIA-L1/MEDIA-L5')
256
+ assert.equal(scriptingProvider.convos[4].header.name, 'test convo/UTT_HELLO-L3/UTT_GOODBYE-L5/MEDIA-step0voice2.wav/MEDIA-step2voice5.wav')
257
257
  assert.deepEqual(scriptingProvider.convos[4].conversation.length, 12)
258
258
  })
259
259
  })