botium-core 1.13.18 → 1.13.19
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 +29 -6
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +29 -6
- package/dist/botium-es.js.map +1 -1
- package/package.json +2 -1
- package/src/scripting/Convo.js +17 -5
- package/src/scripting/logichook/LogicHookConsts.js +5 -1
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +5 -5
- package/src/scripting/logichook/logichooks/ConditionalBusinessHoursLogicHook.js +56 -0
- package/src/scripting/logichook/logichooks/ConditionalCapabilityValueBasedLogicHook.js +37 -0
- package/src/scripting/logichook/logichooks/ConditionalJsonPathBasedLogicHook.js +31 -0
- package/src/scripting/logichook/logichooks/ConditionalTimeBasedLogicHook.js +46 -0
- package/test/scripting/logichooks/CustomConditionalLogicHook.js +21 -0
- package/test/scripting/logichooks/conditionalStepBusinessHoursLogicHook.spec.js +130 -0
- package/test/scripting/logichooks/conditionalStepCapabilityValueBasedLogicHook.spec.js +35 -0
- package/test/scripting/logichooks/conditionalStepJsonPathBasedLogicHook.spec.js +35 -0
- package/test/scripting/logichooks/conditionalStepTimeBasedLogicHook.spec.js +91 -0
- package/test/scripting/logichooks/convos/conditional_steps.convo.txt +12 -0
- package/test/scripting/logichooks/convos/conditional_steps_business_hours.convo.txt +16 -0
- package/test/scripting/logichooks/convos/conditional_steps_cap_value_based.convo.txt +12 -0
- package/test/scripting/logichooks/convos/conditional_steps_followed_by_bot_msg.convo.txt +15 -0
- package/test/scripting/logichooks/convos/conditional_steps_followed_by_me.convo.txt +18 -0
- package/test/scripting/logichooks/convos/conditional_steps_json_path_based.convo.txt.convo.txt +12 -0
- package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups.convo.txt +20 -0
- package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups_no_assertion.convo.txt +20 -0
- package/test/scripting/logichooks/convos/conditional_steps_time_based.convo.txt +12 -0
- package/test/scripting/logichooks/customConditionalStepLogicHook.spec.js +105 -0
- package/test/scripting/scriptingProvider.spec.js +1 -1
- package/test/scripting/logichooks/convos/custom_embedded_skip.convo.txt +0 -11
- package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_me.convo.txt +0 -11
- package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_nothing.convo.txt +0 -8
- package/test/scripting/logichooks/customEmbeddedSkip.json +0 -14
- package/test/scripting/logichooks/customEmbeddedSkip.spec.js +0 -58
package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups.convo.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
custom embedded
|
|
2
|
+
|
|
3
|
+
#me
|
|
4
|
+
hello
|
|
5
|
+
|
|
6
|
+
#bot
|
|
7
|
+
hello should not assert
|
|
8
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G1
|
|
9
|
+
|
|
10
|
+
#bot
|
|
11
|
+
hello
|
|
12
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G1
|
|
13
|
+
|
|
14
|
+
#bot
|
|
15
|
+
hello Duplicate
|
|
16
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":false }|G2
|
|
17
|
+
|
|
18
|
+
#bot
|
|
19
|
+
hello should not assert
|
|
20
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
custom embedded
|
|
2
|
+
|
|
3
|
+
#me
|
|
4
|
+
hello
|
|
5
|
+
|
|
6
|
+
#bot
|
|
7
|
+
hello should not assert
|
|
8
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G1
|
|
9
|
+
|
|
10
|
+
#bot
|
|
11
|
+
hello should not assert
|
|
12
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G1
|
|
13
|
+
|
|
14
|
+
#bot
|
|
15
|
+
hello should not assert
|
|
16
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
|
|
17
|
+
|
|
18
|
+
#bot
|
|
19
|
+
hello should not assert
|
|
20
|
+
CONDITIONAL_STEP_LOGIC_HOOK { "skip":true }|G2
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const assert = require('chai').assert
|
|
3
|
+
const BotDriver = require('../../..').BotDriver
|
|
4
|
+
const Capabilities = require('../../..').Capabilities
|
|
5
|
+
const CustomConditionalLogicHook = require('./CustomConditionalLogicHook')
|
|
6
|
+
const myCaps = {
|
|
7
|
+
LOGIC_HOOKS: [
|
|
8
|
+
{
|
|
9
|
+
ref: 'CONDITIONAL_STEP_LOGIC_HOOK',
|
|
10
|
+
src: CustomConditionalLogicHook,
|
|
11
|
+
global: false
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
const echoConnector = () => ({ queueBotSays }) => {
|
|
16
|
+
return {
|
|
17
|
+
UserSays (msg) {
|
|
18
|
+
const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
|
|
19
|
+
queueBotSays(botMsg)
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const echoConnectorDuplicatedBotMsg = () => ({ queueBotSays }) => {
|
|
25
|
+
return {
|
|
26
|
+
UserSays (msg) {
|
|
27
|
+
const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
|
|
28
|
+
queueBotSays(botMsg)
|
|
29
|
+
|
|
30
|
+
const botMsgDuplicate = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText + ' Duplicate' }
|
|
31
|
+
queueBotSays(botMsgDuplicate)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const buildDriver = async (mergeCaps, duplicateBotMsg) => {
|
|
37
|
+
const myCaps = Object.assign({
|
|
38
|
+
[Capabilities.PROJECTNAME]: 'convo.customassertersskip',
|
|
39
|
+
[Capabilities.CONTAINERMODE]: duplicateBotMsg ? echoConnectorDuplicatedBotMsg() : echoConnector()
|
|
40
|
+
}, mergeCaps)
|
|
41
|
+
|
|
42
|
+
const result = {}
|
|
43
|
+
result.driver = new BotDriver(myCaps)
|
|
44
|
+
result.compiler = result.driver.BuildCompiler()
|
|
45
|
+
result.container = await result.driver.Build()
|
|
46
|
+
return result
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('convo with custom conditional logichook', function () {
|
|
50
|
+
describe('simple bot messages', function () {
|
|
51
|
+
beforeEach(async function () {
|
|
52
|
+
const { compiler, container } = await buildDriver(myCaps)
|
|
53
|
+
this.compiler = compiler
|
|
54
|
+
this.container = container
|
|
55
|
+
await this.container.Start()
|
|
56
|
+
})
|
|
57
|
+
afterEach(async function () {
|
|
58
|
+
await this.container.Stop()
|
|
59
|
+
await this.container.Clean()
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('should success', async function () {
|
|
63
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps.convo.txt')
|
|
64
|
+
const transript = await this.compiler.convos[0].Run(this.container)
|
|
65
|
+
assert.equal(transript.steps.length, 2)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it('should success followed by me message', async function () {
|
|
69
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_followed_by_me.convo.txt')
|
|
70
|
+
const transript = await this.compiler.convos[0].Run(this.container)
|
|
71
|
+
assert.equal(transript.steps.length, 4)
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
describe('multiple bot messages', function () {
|
|
76
|
+
beforeEach(async function () {
|
|
77
|
+
const { compiler, container } = await buildDriver(myCaps, true)
|
|
78
|
+
this.compiler = compiler
|
|
79
|
+
this.container = container
|
|
80
|
+
await this.container.Start()
|
|
81
|
+
})
|
|
82
|
+
afterEach(async function () {
|
|
83
|
+
await this.container.Stop()
|
|
84
|
+
await this.container.Clean()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('should success followed by bot message', async function () {
|
|
88
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_followed_by_bot_msg.convo.txt')
|
|
89
|
+
const transript = await this.compiler.convos[0].Run(this.container)
|
|
90
|
+
assert.equal(transript.steps.length, 3)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('should success with multiple condition groups', async function () {
|
|
94
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_multiple_condition_groups.convo.txt')
|
|
95
|
+
const transript = await this.compiler.convos[0].Run(this.container)
|
|
96
|
+
assert.equal(transript.steps.length, 3)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should success with multiple condition groups no assertion', async function () {
|
|
100
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'conditional_steps_multiple_condition_groups_no_assertion.convo.txt')
|
|
101
|
+
const transript = await this.compiler.convos[0].Run(this.container)
|
|
102
|
+
assert.equal(transript.steps.length, 3)
|
|
103
|
+
})
|
|
104
|
+
})
|
|
105
|
+
})
|
|
@@ -718,7 +718,7 @@ describe('scripting.scriptingProvider', function () {
|
|
|
718
718
|
assert.equal(scriptingProvider.convos[1].header.name, 'utt1/utt1-L00002')
|
|
719
719
|
assert.equal(scriptingProvider.convos[1].conversation[0].messageText, 'TEXT2')
|
|
720
720
|
assert.equal(scriptingProvider.convos[1].toString(), '2 utt1/utt1-L00002 (Expanded Utterances - utt1) ({ origUttName: \'utt1\', origConvoName: \'utt1\' }): Step 1 - tell utterance: #me - TEXT2 SKIP_BOT_UNCONSUMED(no args) | Step 2 - check bot response: #bot - ')
|
|
721
|
-
})
|
|
721
|
+
}).timeout(5000)
|
|
722
722
|
it('should build incomprehension convos for utterance', async function () {
|
|
723
723
|
const scriptingProvider = new ScriptingProvider(Object.assign({}, DefaultCapabilities, { SCRIPTING_UTTEXPANSION_INCOMPREHENSION: 'INCOMPREHENSION' }))
|
|
724
724
|
await scriptingProvider.Build()
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const assert = require('chai').assert
|
|
3
|
-
const BotDriver = require('../../..').BotDriver
|
|
4
|
-
const Capabilities = require('../../..').Capabilities
|
|
5
|
-
const myCaps = require('./customEmbeddedSkip')
|
|
6
|
-
|
|
7
|
-
const echoConnector = () => ({ queueBotSays }) => {
|
|
8
|
-
return {
|
|
9
|
-
UserSays (msg) {
|
|
10
|
-
const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
|
|
11
|
-
queueBotSays(botMsg)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const buildDriver = async (mergeCaps) => {
|
|
17
|
-
const myCaps = Object.assign({
|
|
18
|
-
[Capabilities.PROJECTNAME]: 'convo.customassertersskip',
|
|
19
|
-
[Capabilities.CONTAINERMODE]: echoConnector()
|
|
20
|
-
}, mergeCaps)
|
|
21
|
-
|
|
22
|
-
const result = {}
|
|
23
|
-
result.driver = new BotDriver(myCaps)
|
|
24
|
-
result.compiler = result.driver.BuildCompiler()
|
|
25
|
-
result.container = await result.driver.Build()
|
|
26
|
-
return result
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
describe('convo.customasserters skip', function () {
|
|
30
|
-
beforeEach(async function () {
|
|
31
|
-
const { compiler, container } = await buildDriver(myCaps)
|
|
32
|
-
this.compiler = compiler
|
|
33
|
-
this.container = container
|
|
34
|
-
await this.container.Start()
|
|
35
|
-
})
|
|
36
|
-
afterEach(async function () {
|
|
37
|
-
await this.container.Stop()
|
|
38
|
-
await this.container.Clean()
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it('should success followed by another bot message', async function () {
|
|
42
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'custom_embedded_skip.convo.txt')
|
|
43
|
-
const transript = await this.compiler.convos[0].Run(this.container)
|
|
44
|
-
assert.equal(transript.steps.length, 2)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it('should success followed by me message', async function () {
|
|
48
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'custom_embedded_skip_followed_by_me.convo.txt')
|
|
49
|
-
const transript = await this.compiler.convos[0].Run(this.container)
|
|
50
|
-
assert.equal(transript.steps.length, 2)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('should success followed by nothing', async function () {
|
|
54
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'custom_embedded_skip_followed_by_nothing.convo.txt')
|
|
55
|
-
const transript = await this.compiler.convos[0].Run(this.container)
|
|
56
|
-
assert.equal(transript.steps.length, 1)
|
|
57
|
-
})
|
|
58
|
-
})
|