botium-core 1.13.18 → 1.14.0

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 (60) hide show
  1. package/dist/botium-cjs.js +326 -387
  2. package/dist/botium-cjs.js.map +1 -1
  3. package/dist/botium-es.js +326 -385
  4. package/dist/botium-es.js.map +1 -1
  5. package/package.json +21 -25
  6. package/samples/extensions/asserterHooks/botium.json +1 -0
  7. package/samples/extensions/logichooks/botium.json +1 -0
  8. package/samples/extensions/logichooks/custom/MyAsserter.js +3 -3
  9. package/src/Capabilities.js +2 -1
  10. package/src/containers/PluginConnectorContainer.js +8 -0
  11. package/src/containers/plugins/SimpleRestContainer.js +17 -9
  12. package/src/containers/plugins/index.js +29 -41
  13. package/src/helpers/HookUtils.js +32 -68
  14. package/src/scripting/Convo.js +17 -5
  15. package/src/scripting/ScriptingMemory.js +0 -24
  16. package/src/scripting/logichook/LogicHookConsts.js +5 -1
  17. package/src/scripting/logichook/LogicHookUtils.js +27 -47
  18. package/src/scripting/logichook/asserter/ButtonsAsserter.js +5 -5
  19. package/src/scripting/logichook/logichooks/ConditionalBusinessHoursLogicHook.js +56 -0
  20. package/src/scripting/logichook/logichooks/ConditionalCapabilityValueBasedLogicHook.js +37 -0
  21. package/src/scripting/logichook/logichooks/ConditionalJsonPathBasedLogicHook.js +31 -0
  22. package/src/scripting/logichook/logichooks/ConditionalTimeBasedLogicHook.js +46 -0
  23. package/test/compiler/precompilerscript.spec.js +24 -26
  24. package/test/connectors/pluginconnectorcontainer.spec.js +60 -0
  25. package/test/connectors/simplerest.spec.js +24 -27
  26. package/test/convo/fillAndApplyScriptingMemory.spec.js +1 -47
  27. package/test/hooks/customhooks.spec.js +3 -25
  28. package/test/logichooks/hookfromsrc.spec.js +13 -3
  29. package/test/plugins/plugins.spec.js +29 -2
  30. package/test/scripting/logichooks/CustomConditionalLogicHook.js +21 -0
  31. package/test/scripting/logichooks/conditionalStepBusinessHoursLogicHook.spec.js +130 -0
  32. package/test/scripting/logichooks/conditionalStepCapabilityValueBasedLogicHook.spec.js +35 -0
  33. package/test/scripting/logichooks/conditionalStepJsonPathBasedLogicHook.spec.js +35 -0
  34. package/test/scripting/logichooks/conditionalStepTimeBasedLogicHook.spec.js +91 -0
  35. package/test/scripting/logichooks/convos/conditional_steps.convo.txt +12 -0
  36. package/test/scripting/logichooks/convos/conditional_steps_business_hours.convo.txt +16 -0
  37. package/test/scripting/logichooks/convos/conditional_steps_cap_value_based.convo.txt +12 -0
  38. package/test/scripting/logichooks/convos/conditional_steps_followed_by_bot_msg.convo.txt +15 -0
  39. package/test/scripting/logichooks/convos/conditional_steps_followed_by_me.convo.txt +18 -0
  40. package/test/scripting/logichooks/convos/conditional_steps_json_path_based.convo.txt.convo.txt +12 -0
  41. package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups.convo.txt +20 -0
  42. package/test/scripting/logichooks/convos/conditional_steps_multiple_condition_groups_no_assertion.convo.txt +20 -0
  43. package/test/scripting/logichooks/convos/conditional_steps_time_based.convo.txt +12 -0
  44. package/test/scripting/logichooks/customConditionalStepLogicHook.spec.js +105 -0
  45. package/test/scripting/scriptingProvider.spec.js +1 -1
  46. package/test/security/allowUnsafe.spec.js +20 -129
  47. package/LICENSES-3RDPARTY.txt +0 -6450
  48. package/test/scripting/asserters/convos/customembeddedasserterwithhugo.convo.txt +0 -7
  49. package/test/scripting/asserters/convos/customembeddedasserterwithouthugo.convo.txt +0 -7
  50. package/test/scripting/asserters/customEmbeddedAsserter.json +0 -14
  51. package/test/scripting/asserters/customEmbeddedAsserter.spec.js +0 -55
  52. package/test/scripting/logichooks/convos/custom_embedded.convo.txt +0 -8
  53. package/test/scripting/logichooks/convos/custom_embedded_skip.convo.txt +0 -11
  54. package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_me.convo.txt +0 -11
  55. package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_nothing.convo.txt +0 -8
  56. package/test/scripting/logichooks/customEmbedded.json +0 -14
  57. package/test/scripting/logichooks/customEmbedded.spec.js +0 -44
  58. package/test/scripting/logichooks/customEmbeddedSkip.json +0 -14
  59. package/test/scripting/logichooks/customEmbeddedSkip.spec.js +0 -58
  60. package/test/security/convos/withscriptingmemoryfunction.convo.txt +0 -5
@@ -1,7 +0,0 @@
1
- 1 step
2
-
3
- #me
4
- Hello hugo
5
-
6
- #bot
7
- MY-ASSERTER-NAME
@@ -1,7 +0,0 @@
1
- 1 step
2
-
3
- #me
4
- Hello
5
-
6
- #bot
7
- MY-ASSERTER-NAME
@@ -1,14 +0,0 @@
1
- {
2
- "ASSERTERS": [
3
- {
4
- "ref": "MY-ASSERTER-NAME",
5
- "src": {
6
- "assertConvoStep": "if (botMsg.messageText !== 'Hello hugo') throw `expected hugo, got ${JSON.stringify(botMsg)}`"
7
- },
8
- "global": false,
9
- "args": {
10
- "my-arg-1": "something"
11
- }
12
- }
13
- ]
14
- }
@@ -1,55 +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('./customEmbeddedAsserter')
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.customasserters',
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', 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 fail', async function () {
42
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'customembeddedasserterwithouthugo.convo.txt')
43
- try {
44
- await this.compiler.convos[0].Run(this.container)
45
- } catch (err) {
46
- assert.isTrue(err.message.indexOf('expected hugo') >= 0)
47
- return
48
- }
49
- assert.fail('should have failed without retry')
50
- })
51
- it('should succeed', async function () {
52
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'customembeddedasserterwithhugo.convo.txt')
53
- await this.compiler.convos[0].Run(this.container)
54
- })
55
- })
@@ -1,8 +0,0 @@
1
- custom embedded
2
-
3
- #me
4
- hello
5
- MY-LOGICHOOK-NAME
6
-
7
- #bot
8
- hello from logichook
@@ -1,11 +0,0 @@
1
- custom embedded
2
-
3
- #me
4
- hello
5
-
6
- #bot
7
- hello fail
8
- MY-LOGICHOOK-SKIP
9
-
10
- #bot
11
- hello
@@ -1,11 +0,0 @@
1
- custom embedded
2
-
3
- #me
4
- hello
5
-
6
- #bot
7
- hello fail
8
- MY-LOGICHOOK-SKIP
9
-
10
- #me
11
- hello
@@ -1,8 +0,0 @@
1
- custom embedded
2
-
3
- #me
4
- hello
5
-
6
- #bot
7
- hello fail
8
- MY-LOGICHOOK-SKIP
@@ -1,14 +0,0 @@
1
- {
2
- "LOGIC_HOOKS": [
3
- {
4
- "ref": "MY-LOGICHOOK-NAME",
5
- "src": {
6
- "onMeStart": "meMsg.messageText += ' from logichook'"
7
- },
8
- "global": false,
9
- "args": {
10
- "my-arg-1": "something"
11
- }
12
- }
13
- ]
14
- }
@@ -1,44 +0,0 @@
1
- const path = require('path')
2
- const BotDriver = require('../../..').BotDriver
3
- const Capabilities = require('../../..').Capabilities
4
- const myCaps = require('./customEmbedded')
5
-
6
- const echoConnector = () => ({ queueBotSays }) => {
7
- return {
8
- UserSays (msg) {
9
- const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
10
- queueBotSays(botMsg)
11
- }
12
- }
13
- }
14
-
15
- const buildDriver = async (mergeCaps) => {
16
- const myCaps = Object.assign({
17
- [Capabilities.PROJECTNAME]: 'convo.customasserters',
18
- [Capabilities.CONTAINERMODE]: echoConnector()
19
- }, mergeCaps)
20
-
21
- const result = {}
22
- result.driver = new BotDriver(myCaps)
23
- result.compiler = result.driver.BuildCompiler()
24
- result.container = await result.driver.Build()
25
- return result
26
- }
27
-
28
- describe('convo.customasserters', function () {
29
- beforeEach(async function () {
30
- const { compiler, container } = await buildDriver(myCaps)
31
- this.compiler = compiler
32
- this.container = container
33
- await this.container.Start()
34
- })
35
- afterEach(async function () {
36
- await this.container.Stop()
37
- await this.container.Clean()
38
- })
39
-
40
- it('should success', async function () {
41
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'custom_embedded.convo.txt')
42
- await this.compiler.convos[0].Run(this.container)
43
- })
44
- })
@@ -1,14 +0,0 @@
1
- {
2
- "LOGIC_HOOKS": [
3
- {
4
- "ref": "MY-LOGICHOOK-SKIP",
5
- "src": {
6
- "onBotPrepare": "convoStep.skip = true"
7
- },
8
- "global": false,
9
- "args": {
10
- "my-arg-1": "something"
11
- }
12
- }
13
- ]
14
- }
@@ -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
- })
@@ -1,5 +0,0 @@
1
- #me
2
- result: $func(1+1)
3
-
4
- #bot
5
- you said: "result: 2"