botium-core 1.13.3 → 1.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +315 -107
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +315 -107
- package/dist/botium-es.js.map +1 -1
- package/package.json +19 -19
- package/src/Capabilities.js +2 -0
- package/src/Defaults.js +4 -0
- package/src/mocks/BotiumMockScripting.js +1 -0
- package/src/scripting/CompilerXlsx.js +1 -0
- package/src/scripting/ScriptingMemory.js +41 -2
- package/src/scripting/ScriptingProvider.js +206 -84
- package/src/scripting/helper.js +2 -0
- package/src/scripting/logichook/userinput/MediaInput.js +2 -1
- package/test/compiler/compilercsv.spec.js +9 -2
- package/test/compiler/convos/csv/utterances_variable_row_len.csv +1 -1
- package/test/convo/fillAndApplyScriptingMemory.spec.js +64 -4
- package/test/convo/transcript.spec.js +9 -0
- package/test/scripting/asserters/intentConfidenceAsserter.spec.js +3 -7
- package/test/scripting/scriptingProvider.spec.js +213 -4
- package/test/scripting/utteranceexpansion/associateByIndex.spec.js +15 -15
|
@@ -15,8 +15,15 @@ const buildContext = () => {
|
|
|
15
15
|
AddConvos: (c) => {
|
|
16
16
|
result.convos = result.convos.concat(c)
|
|
17
17
|
},
|
|
18
|
-
AddUtterances: (
|
|
19
|
-
|
|
18
|
+
AddUtterances: (utteranceStructsToAdd) => {
|
|
19
|
+
for (const utteranceStructToAdd of utteranceStructsToAdd) {
|
|
20
|
+
const existing = result.utterances.find(entry => entry.name === utteranceStructToAdd.name)
|
|
21
|
+
if (existing) {
|
|
22
|
+
existing.utterances = existing.utterances.concat(utteranceStructToAdd.utterances)
|
|
23
|
+
} else {
|
|
24
|
+
result.utterances.push(utteranceStructToAdd)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
20
27
|
},
|
|
21
28
|
convos: [],
|
|
22
29
|
utterances: []
|
|
@@ -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
|
|
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(
|
|
@@ -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
|
})
|
|
@@ -61,16 +61,12 @@ describe('scripting.asserters.intentConfidenceAsserter', function () {
|
|
|
61
61
|
[false, 80, 85, false]
|
|
62
62
|
]
|
|
63
63
|
|
|
64
|
-
cases
|
|
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(
|
|
68
|
+
return _assert(useWithGlobal, expected, found, negative)
|
|
73
69
|
}
|
|
74
70
|
)
|
|
75
|
-
}
|
|
71
|
+
}
|
|
76
72
|
})
|
|
@@ -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
|
-
|
|
355
|
-
|
|
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 () {
|
|
@@ -692,6 +844,63 @@ describe('scripting.scriptingProvider', function () {
|
|
|
692
844
|
assert.isTrue(err.message.indexOf('incomprehension utterance \'INCOMPREHENSION\' undefined') > 0)
|
|
693
845
|
}
|
|
694
846
|
})
|
|
847
|
+
it('should add incomprehension utterances to new utterance list', async function () {
|
|
848
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities))
|
|
849
|
+
await scriptingProvider.Build()
|
|
850
|
+
scriptingProvider.AddUtterances({
|
|
851
|
+
name: 'utt1',
|
|
852
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
853
|
+
})
|
|
854
|
+
|
|
855
|
+
scriptingProvider.ExpandUtterancesToConvos({ incomprehensionUtt: 'INCOMPREHENSION', incomprehensionUtts: ['INCOMPREHENSION3', 'INCOMPREHENSION4'] })
|
|
856
|
+
assert.lengthOf(scriptingProvider.utterances.INCOMPREHENSION.utterances, 2)
|
|
857
|
+
})
|
|
858
|
+
it('should add incomprehension utterances to new default utterance list', async function () {
|
|
859
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities))
|
|
860
|
+
await scriptingProvider.Build()
|
|
861
|
+
scriptingProvider.AddUtterances({
|
|
862
|
+
name: 'utt1',
|
|
863
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
864
|
+
})
|
|
865
|
+
|
|
866
|
+
scriptingProvider.ExpandUtterancesToConvos({ incomprehensionUtts: ['INCOMPREHENSION3', 'INCOMPREHENSION4'] })
|
|
867
|
+
assert.lengthOf(scriptingProvider.utterances.UTT_INCOMPREHENSION.utterances, 2)
|
|
868
|
+
})
|
|
869
|
+
it('should add incomprehension utterances to existing utterance list', async function () {
|
|
870
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities))
|
|
871
|
+
await scriptingProvider.Build()
|
|
872
|
+
scriptingProvider.AddUtterances({
|
|
873
|
+
name: 'utt1',
|
|
874
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
875
|
+
})
|
|
876
|
+
scriptingProvider.AddUtterances({
|
|
877
|
+
name: 'INCOMPREHENSION',
|
|
878
|
+
utterances: ['INCOMPREHENSION1', 'INCOMPREHENSION2']
|
|
879
|
+
})
|
|
880
|
+
|
|
881
|
+
scriptingProvider.ExpandUtterancesToConvos({ incomprehensionUtt: 'INCOMPREHENSION', incomprehensionUtts: ['INCOMPREHENSION3', 'INCOMPREHENSION4'] })
|
|
882
|
+
assert.lengthOf(scriptingProvider.utterances.INCOMPREHENSION.utterances, 4)
|
|
883
|
+
})
|
|
884
|
+
it('should add incomprehension intent to asserter list', async function () {
|
|
885
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities))
|
|
886
|
+
await scriptingProvider.Build()
|
|
887
|
+
scriptingProvider.AddUtterances({
|
|
888
|
+
name: 'utt1',
|
|
889
|
+
utterances: ['TEXT1', 'TEXT2']
|
|
890
|
+
})
|
|
891
|
+
|
|
892
|
+
scriptingProvider.ExpandUtterancesToConvos({ incomprehensionIntents: ['FALLBACK1', 'FALLBACK2'] })
|
|
893
|
+
assert.equal(scriptingProvider.convos.length, 1)
|
|
894
|
+
assert.equal(scriptingProvider.convos[0].conversation.length, 2)
|
|
895
|
+
assert.equal(scriptingProvider.convos[0].conversation[0].messageText, 'utt1')
|
|
896
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters.length, 2)
|
|
897
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].name, 'INTENT')
|
|
898
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].args[0], 'FALLBACK1')
|
|
899
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[0].not, true)
|
|
900
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[1].name, 'INTENT')
|
|
901
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[1].args[0], 'FALLBACK2')
|
|
902
|
+
assert.equal(scriptingProvider.convos[0].conversation[1].asserters[1].not, true)
|
|
903
|
+
})
|
|
695
904
|
})
|
|
696
905
|
|
|
697
906
|
describe('assertBotResponse', 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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
})
|