botium-core 1.14.0 → 1.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/botium-cjs.js +302 -94
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +302 -94
- package/dist/botium-es.js.map +1 -1
- package/package.json +19 -19
- package/src/Capabilities.js +2 -0
- package/src/scripting/BotiumError.js +40 -3
- package/src/scripting/Convo.js +139 -28
- package/src/scripting/ScriptingMemory.js +7 -0
- package/src/scripting/ScriptingProvider.js +79 -30
- package/src/scripting/logichook/LogicHookConsts.js +5 -2
- package/src/scripting/logichook/LogicHookUtils.js +8 -6
- package/src/scripting/logichook/logichooks/ConditionalBusinessHoursLogicHook.js +1 -1
- package/src/scripting/logichook/logichooks/ConditionalCapabilityValueBasedLogicHook.js +1 -1
- package/src/scripting/logichook/logichooks/ConditionalJsonPathBasedLogicHook.js +1 -1
- package/src/scripting/logichook/logichooks/ConditionalTimeBasedLogicHook.js +1 -1
- package/src/scripting/logichook/logichooks/ConvoStepParametersLogicHook.js +6 -0
- package/src/scripting/logichook/logichooks/OrderedListToButtonLogicHook.js +37 -0
- package/test/convo/fillAndApplyScriptingMemory.spec.js +11 -0
- package/test/logichooks/orderedListToButton.spec.js +35 -0
- package/test/scripting/asserters/convoStepParameters.spec.js +140 -0
- package/test/scripting/asserters/convos/TEXT_GOOD.convo.txt +6 -0
- package/test/scripting/asserters/convos/convo_step_parameter_matchmode_failed.convo.txt +8 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_asserters_all_good.convo.txt +9 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_asserters_botium_timeout.convo.txt +9 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_asserters_good.convo.txt +9 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_asserters_good_global.convo.txt +9 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_main_and_asserter.convo.txt +10 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_main_botium_timeout.convo.txt +9 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_main_but_no_button.convo.txt +10 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_main_good.convo.txt +9 -0
- package/test/scripting/asserters/convos/convo_step_parameter_retry_main_good_begin.convo.txt +11 -0
- package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups_no_assertion.convo.txt +6 -6
- package/test/scripting/logichooks/convos/conditional_steps_multiple_mandatory_condition_groups.convo.txt +20 -0
- package/test/scripting/logichooks/convos/conditional_steps_multiple_optional_condition_groups.convo.txt +20 -0
- package/test/scripting/logichooks/customConditionalStepLogicHook.spec.js +16 -0
- package/test/scripting/matching/matchingmode.spec.js +4 -1
- package/test/scripting/scriptingProvider.spec.js +38 -12
|
@@ -5,6 +5,7 @@ const { Convo } = require('../../src/scripting/Convo')
|
|
|
5
5
|
const ScriptingProvider = require('../../src/scripting/ScriptingProvider')
|
|
6
6
|
const DefaultCapabilities = require('../../src/Defaults').Capabilities
|
|
7
7
|
const Capabilities = require('../../src/Capabilities')
|
|
8
|
+
const { LOGIC_HOOK_EVENTS } = require('../../src/scripting/logichook/LogicHookConsts')
|
|
8
9
|
|
|
9
10
|
describe('scripting.scriptingProvider', function () {
|
|
10
11
|
describe('ReadScriptsFromDirectory', function () {
|
|
@@ -65,7 +66,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
65
66
|
assert.equal(tomatch.length, 2)
|
|
66
67
|
assert.equal(tomatch[0], 'TEXT1')
|
|
67
68
|
assert.equal(tomatch[1], 'TEXT2')
|
|
68
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1')
|
|
69
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1', null, {})
|
|
69
70
|
})
|
|
70
71
|
it('should resolve multiple utterance', async function () {
|
|
71
72
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
@@ -85,7 +86,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
85
86
|
assert.equal(tomatchUtt1.length, 2)
|
|
86
87
|
assert.equal(tomatchUtt1[0], 'TEXT1')
|
|
87
88
|
assert.equal(tomatchUtt1[1], 'TEXT2')
|
|
88
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatchUtt1, 'test1')
|
|
89
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatchUtt1, 'test1', null, {})
|
|
89
90
|
const tomatchUtt2 = scriptingContext.scriptingEvents.resolveUtterance({ utterance: 'utt2' })
|
|
90
91
|
assert.isArray(tomatchUtt2)
|
|
91
92
|
assert.equal(tomatchUtt2.length, 2)
|
|
@@ -121,7 +122,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
121
122
|
assert.equal(tomatch.length, 1)
|
|
122
123
|
assert.equal(tomatch[0], 'utt2')
|
|
123
124
|
try {
|
|
124
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1')
|
|
125
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', tomatch, 'test1', null, {})
|
|
125
126
|
assert.fail('expected error')
|
|
126
127
|
} catch (err) {
|
|
127
128
|
assert.isTrue(err.message.indexOf('Bot response') > 0)
|
|
@@ -141,7 +142,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
141
142
|
utterances: ['TEXT1', 'TEXT2']
|
|
142
143
|
})
|
|
143
144
|
try {
|
|
144
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', 'utt1', 'test1')
|
|
145
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1', 'utt1', 'test1', null, {})
|
|
145
146
|
assert.fail('expected error')
|
|
146
147
|
} catch (err) {
|
|
147
148
|
assert.isTrue(err.message.indexOf('Bot response') > 0)
|
|
@@ -166,7 +167,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
166
167
|
assert.equal(tomatch.length, 2)
|
|
167
168
|
assert.equal(tomatch[0], 'TEXT1 hello')
|
|
168
169
|
assert.equal(tomatch[1], 'TEXT2 hello')
|
|
169
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1')
|
|
170
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1', null, {})
|
|
170
171
|
})
|
|
171
172
|
it('should resolve and append utterance args', async function () {
|
|
172
173
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
@@ -182,7 +183,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
182
183
|
assert.equal(tomatch.length, 2)
|
|
183
184
|
assert.equal(tomatch[0], 'TEXT1 hello')
|
|
184
185
|
assert.equal(tomatch[1], 'TEXT2 hello')
|
|
185
|
-
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1')
|
|
186
|
+
scriptingContext.scriptingEvents.assertBotResponse('TEXT1 hello', tomatch, 'test1', null, {})
|
|
186
187
|
})
|
|
187
188
|
|
|
188
189
|
describe('should resolve utterance with ambiguous scripting memory variable (with a debug message)', function () {
|
|
@@ -909,7 +910,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
909
910
|
await scriptingProvider.Build()
|
|
910
911
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
911
912
|
try {
|
|
912
|
-
scriptingContext.scriptingEvents.assertBotResponse('actual', 'expected', 'test1')
|
|
913
|
+
scriptingContext.scriptingEvents.assertBotResponse('actual', 'expected', 'test1', null, {})
|
|
913
914
|
assert.fail('expected error')
|
|
914
915
|
} catch (err) {
|
|
915
916
|
assert.equal(err.message, 'test1: Bot response "actual" expected to match "expected"')
|
|
@@ -920,7 +921,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
920
921
|
await scriptingProvider.Build()
|
|
921
922
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
922
923
|
try {
|
|
923
|
-
scriptingContext.scriptingEvents.assertBotResponse(null, 'expected', 'test1')
|
|
924
|
+
scriptingContext.scriptingEvents.assertBotResponse(null, 'expected', 'test1', null, {})
|
|
924
925
|
assert.fail('expected error')
|
|
925
926
|
} catch (err) {
|
|
926
927
|
assert.equal(err.message, 'test1: Bot response <no response> expected to match "expected"')
|
|
@@ -931,7 +932,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
931
932
|
await scriptingProvider.Build()
|
|
932
933
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
933
934
|
try {
|
|
934
|
-
scriptingContext.scriptingEvents.assertBotResponse('actual', ['expected1', 'expected2'], 'test1')
|
|
935
|
+
scriptingContext.scriptingEvents.assertBotResponse('actual', ['expected1', 'expected2'], 'test1', null, {})
|
|
935
936
|
assert.fail('expected error')
|
|
936
937
|
} catch (err) {
|
|
937
938
|
assert.equal(err.message, 'test1: Bot response "actual" expected to match one of "expected1", "expected2"')
|
|
@@ -945,7 +946,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
945
946
|
await scriptingProvider.Build()
|
|
946
947
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
947
948
|
try {
|
|
948
|
-
scriptingContext.scriptingEvents.assertBotNotResponse('Keine Antwort gefunden!', ['Keine Antwort gefunden'], 'test1')
|
|
949
|
+
scriptingContext.scriptingEvents.assertBotNotResponse('Keine Antwort gefunden!', ['Keine Antwort gefunden'], 'test1', null, {})
|
|
949
950
|
assert.fail('expected error')
|
|
950
951
|
} catch (err) {
|
|
951
952
|
assert.equal(err.message, 'test1: Bot response "Keine Antwort gefunden!" expected NOT to match "Keine Antwort gefunden"')
|
|
@@ -956,7 +957,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
956
957
|
await scriptingProvider.Build()
|
|
957
958
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
958
959
|
try {
|
|
959
|
-
scriptingContext.scriptingEvents.assertBotNotResponse('Keine Antwort gefunden!', [''], 'test1')
|
|
960
|
+
scriptingContext.scriptingEvents.assertBotNotResponse('Keine Antwort gefunden!', [''], 'test1', null, {})
|
|
960
961
|
assert.fail('expected error')
|
|
961
962
|
} catch (err) {
|
|
962
963
|
assert.equal(err.message, 'test1: Bot response "Keine Antwort gefunden!" expected NOT to match <any response>')
|
|
@@ -967,11 +968,36 @@ describe('scripting.scriptingProvider', function () {
|
|
|
967
968
|
await scriptingProvider.Build()
|
|
968
969
|
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
969
970
|
try {
|
|
970
|
-
scriptingContext.scriptingEvents.assertBotNotResponse('', [''], 'test1')
|
|
971
|
+
scriptingContext.scriptingEvents.assertBotNotResponse('', [''], 'test1', null, {})
|
|
971
972
|
assert.fail('expected error')
|
|
972
973
|
} catch (err) {
|
|
973
974
|
assert.equal(err.message, 'test1: Bot response <no response> expected NOT to match <any response>')
|
|
974
975
|
}
|
|
975
976
|
})
|
|
976
977
|
})
|
|
978
|
+
|
|
979
|
+
describe('should call logichooks and userinputs even if there is no convo (logichook from livechat, and crawler)', function () {
|
|
980
|
+
LOGIC_HOOK_EVENTS.forEach(async (eventName) => {
|
|
981
|
+
it(`Logichook, event: ${eventName}`, async function () {
|
|
982
|
+
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities, {
|
|
983
|
+
[Capabilities.LOGIC_HOOKS]: [{
|
|
984
|
+
ref: 'SET_TEXT_FROM_HOOK',
|
|
985
|
+
src: {
|
|
986
|
+
[eventName]: ({ someobject, args }) => {
|
|
987
|
+
someobject.testAttribute = 'testAttributeValue'
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
global: true
|
|
991
|
+
}]
|
|
992
|
+
}))
|
|
993
|
+
await scriptingProvider.Build()
|
|
994
|
+
const scriptingContext = scriptingProvider._buildScriptContext()
|
|
995
|
+
const someobject = {}
|
|
996
|
+
await scriptingContext.scriptingEvents[eventName]({
|
|
997
|
+
someobject
|
|
998
|
+
})
|
|
999
|
+
assert.equal(someobject.testAttribute, 'testAttributeValue')
|
|
1000
|
+
})
|
|
1001
|
+
})
|
|
1002
|
+
})
|
|
977
1003
|
})
|