botium-core 1.13.2 → 1.13.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.
Files changed (54) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +214 -61
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +213 -61
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +3 -1
  7. package/src/Capabilities.js +2 -1
  8. package/src/containers/plugins/SimpleRestContainer.js +20 -16
  9. package/src/grid/inbound/proxy.js +2 -1
  10. package/src/scripting/Convo.js +16 -10
  11. package/src/scripting/MatchFunctions.js +10 -0
  12. package/src/scripting/ScriptingProvider.js +106 -37
  13. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  14. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  15. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  16. package/test/compiler/compilercsv.spec.js +104 -3
  17. package/test/compiler/compilerjson.spec.js +0 -2
  18. package/test/compiler/compilerxlsx.spec.js +1 -1
  19. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  20. package/test/connectors/simplerest.spec.js +1012 -969
  21. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  22. package/test/convo/partialconvo.spec.js +345 -339
  23. package/test/driver/capabilities.spec.js +156 -151
  24. package/test/logichooks/hookfromsrc.spec.js +79 -73
  25. package/test/plugins/plugins.spec.js +44 -42
  26. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  27. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  28. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  29. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  30. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  31. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  32. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  33. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  34. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  35. package/test/scripting/matching/matchingmode.spec.js +306 -258
  36. package/test/scripting/scriptingProvider.spec.js +666 -633
  37. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  38. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  39. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  40. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  41. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  42. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  43. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  44. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  45. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  46. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  47. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  53. package/test/security/allowUnsafe.spec.js +274 -268
  54. package/test/utils.spec.js +40 -38
@@ -3,162 +3,167 @@ const BotDriver = require('../../').BotDriver
3
3
  const Capabilities = require('../../').Capabilities
4
4
  const DefaultCapabilities = require('../../src/Defaults').Capabilities
5
5
 
6
- describe('driver.fetchConfigFromFiles', function () {
7
- it('fetch capabilities from files', function () {
8
- const driver = new BotDriver()
9
- const result = driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json'])
10
- assert.isArray(result)
11
- assert.lengthOf(result, 1)
12
- })
13
- it('fetch capabilities from non existing files', function () {
14
- const driver = new BotDriver()
15
- const result = driver._fetchConfigFromFiles(['test/driver/configFiles/configNotExists.json'])
16
- assert.isArray(result)
17
- assert.lengthOf(result, 0)
18
- })
19
- it('fetch capabilities from multiple files', function () {
20
- const driver = new BotDriver()
21
- const result = driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
22
- assert.isArray(result)
23
- assert.lengthOf(result, 2)
24
- })
25
- it('fetch capabilities from multiple files and check if overwritten', function () {
26
- const driver = new BotDriver()
27
- driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
28
- assert.equal(driver.caps.PROJECTNAME, 'Botium Example 2')
29
- assert.equal(driver.sources.GITURL, 'https://github.com/codeforequity-at/botium-bindings')
30
- assert.equal(driver.envs.IS_BOTIUM_CONTAINER, true)
6
+ describe('driver.capabilities', function () {
7
+ describe('fetchConfigFromFiles', function () {
8
+ it('fetch capabilities from files', function () {
9
+ const driver = new BotDriver()
10
+ const result = driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json'])
11
+ assert.isArray(result)
12
+ assert.lengthOf(result, 1)
13
+ })
14
+ it('fetch capabilities from non existing files', function () {
15
+ const driver = new BotDriver()
16
+ const result = driver._fetchConfigFromFiles(['test/driver/configFiles/configNotExists.json'])
17
+ assert.isArray(result)
18
+ assert.lengthOf(result, 0)
19
+ })
20
+ it('fetch capabilities from multiple files', function () {
21
+ const driver = new BotDriver()
22
+ const result = driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
23
+ assert.isArray(result)
24
+ assert.lengthOf(result, 2)
25
+ })
26
+ it('fetch capabilities from multiple files and check if overwritten', function () {
27
+ const driver = new BotDriver()
28
+ driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
29
+ assert.equal(driver.caps.PROJECTNAME, 'Botium Example 2')
30
+ assert.equal(driver.sources.GITURL, 'https://github.com/codeforequity-at/botium-bindings')
31
+ assert.equal(driver.envs.IS_BOTIUM_CONTAINER, true)
32
+ })
31
33
  })
32
- })
33
34
 
34
- describe('driver.loadConfigFile', function () {
35
- it('load Config from file', function () {
36
- const driver = new BotDriver()
37
- const result = driver._loadConfigFile('test/driver/configFiles/config1.json')
38
- assert.isTrue(result)
35
+ describe('loadConfigFile', function () {
36
+ it('load Config from file', function () {
37
+ const driver = new BotDriver()
38
+ const result = driver._loadConfigFile('test/driver/configFiles/config1.json')
39
+ assert.isTrue(result)
40
+ })
41
+ it('load Config from non existing file', function () {
42
+ const driver = new BotDriver()
43
+ assert.throws(() => driver._loadConfigFile('test/driver/configFiles/configNonExisting.json'))
44
+ })
45
+ it('load Config from file only once', function () {
46
+ const driver = new BotDriver()
47
+ driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config1.json', 'test/driver/configFiles/config1.json'])
48
+ assert.lengthOf(driver._fetchedConfigFiles, 1)
49
+ assert.lengthOf(driver.caps.ARR_CAP, 2)
50
+ })
51
+ it('should make unique array', function () {
52
+ const driver = new BotDriver()
53
+ driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
54
+ assert.lengthOf(driver._fetchedConfigFiles, 2)
55
+ assert.lengthOf(driver.caps.ARR_CAP, 3)
56
+ assert.deepEqual(driver.caps.ARR_CAP, ['val1', 'val2', 'val3'])
57
+ })
39
58
  })
40
- it('load Config from non existing file', function () {
41
- const driver = new BotDriver()
42
- assert.throws(() => driver._loadConfigFile('test/driver/configFiles/configNonExisting.json'))
43
- })
44
- it('load Config from file only once', function () {
45
- const driver = new BotDriver()
46
- driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config1.json', 'test/driver/configFiles/config1.json'])
47
- assert.lengthOf(driver._fetchedConfigFiles, 1)
48
- assert.lengthOf(driver.caps.ARR_CAP, 2)
49
- })
50
- it('should make unique array', function () {
51
- const driver = new BotDriver()
52
- driver._fetchConfigFromFiles(['test/driver/configFiles/config1.json', 'test/driver/configFiles/config2.json'])
53
- assert.lengthOf(driver._fetchedConfigFiles, 2)
54
- assert.lengthOf(driver.caps.ARR_CAP, 3)
55
- assert.deepEqual(driver.caps.ARR_CAP, ['val1', 'val2', 'val3'])
56
- })
57
- })
58
59
 
59
- describe('driver.capabilities', function () {
60
- it('should merge boolean caps', function () {
61
- const myCaps = {
62
- [Capabilities.SIMULATE_WRITING_SPEED]: 'YES'
63
- }
64
- const driver = new BotDriver(myCaps)
65
- assert.isBoolean(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
66
- assert.isTrue(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
60
+ describe('capabilities', function () {
61
+ it('should merge boolean caps', function () {
62
+ const myCaps = {
63
+ [Capabilities.SIMULATE_WRITING_SPEED]: 'YES'
64
+ }
65
+ const driver = new BotDriver(myCaps)
66
+ assert.isBoolean(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
67
+ assert.isTrue(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
68
+ })
69
+ it('should merge string caps', function () {
70
+ const myCaps = {
71
+ CAP_STRING_1: 'Test',
72
+ CAP_STRING_2: '12345'
73
+ }
74
+ const driver = new BotDriver(myCaps)
75
+ assert.isString(driver.caps.CAP_STRING_1)
76
+ assert.isString(driver.caps.CAP_STRING_2)
77
+ })
78
+ it('should merge boolean envs', function () {
79
+ process.env.BOTIUM_SIMULATE_WRITING_SPEED = 'NO'
80
+ const driver = new BotDriver()
81
+ delete process.env.BOTIUM_SIMULATE_WRITING_SPEED
82
+ assert.isBoolean(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
83
+ assert.isFalse(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
84
+ })
85
+ it('should parse array caps', function () {
86
+ DefaultCapabilities.MYCAP = []
87
+ const myCaps = {
88
+ MYCAP: '[{"KEY":"VALUE"},{"KEY":"VALUE1"}]'
89
+ }
90
+ const driver = new BotDriver(myCaps)
91
+ assert.isArray(driver.caps.MYCAP)
92
+ assert.lengthOf(driver.caps.MYCAP, 2)
93
+ })
94
+ it('should merge array caps', function () {
95
+ DefaultCapabilities.MYCAP = [{
96
+ id: 'id1',
97
+ key: 'VALUE'
98
+ }]
99
+ const myCaps = {
100
+ MYCAP: '[{"id":"id1", "key1": "VALUE1"},{"key":"VALUE1"}]'
101
+ }
102
+ const driver = new BotDriver(myCaps)
103
+ assert.isArray(driver.caps.MYCAP)
104
+ assert.lengthOf(driver.caps.MYCAP, 2)
105
+ assert.equal(driver.caps.MYCAP[0].key, 'VALUE')
106
+ assert.equal(driver.caps.MYCAP[0].key1, 'VALUE1')
107
+ assert.isUndefined(driver.caps.MYCAP[1].id)
108
+ assert.equal(driver.caps.MYCAP[1].key, 'VALUE1')
109
+ })
110
+ it('should parse object caps', function () {
111
+ DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
112
+ const myCaps = {
113
+ MYCAP: '{"KEY":"VALUE1"}'
114
+ }
115
+ const driver = new BotDriver(myCaps)
116
+ assert.isObject(driver.caps.MYCAP)
117
+ assert.equal(driver.caps.MYCAP.KEY, 'VALUE1')
118
+ })
119
+ it('should merge object caps', function () {
120
+ DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
121
+ const myCaps = {
122
+ MYCAP: '{"KEY1":"VALUE1"}'
123
+ }
124
+ const driver = new BotDriver(myCaps)
125
+ assert.isObject(driver.caps.MYCAP)
126
+ assert.equal(driver.caps.MYCAP.KEY, 'VALUE')
127
+ assert.equal(driver.caps.MYCAP.KEY1, 'VALUE1')
128
+ })
129
+ it('should not parse JSON caps', function () {
130
+ const myCaps = {
131
+ MYJSONCAP: '{"KEY":"VALUE1"}'
132
+ }
133
+ const driver = new BotDriver(myCaps)
134
+ assert.isObject(driver.caps.MYJSONCAP)
135
+ assert.equal(driver.caps.MYJSONCAP.KEY, 'VALUE1')
136
+ })
137
+ it('should override not matching object caps', function () {
138
+ DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
139
+ const myCaps = {
140
+ MYCAP: 'SIMPLESTRING'
141
+ }
142
+ const driver = new BotDriver(myCaps)
143
+ assert.isString(driver.caps.MYCAP)
144
+ assert.equal(driver.caps.MYCAP, 'SIMPLESTRING')
145
+ })
146
+ it('should override not matching array caps', function () {
147
+ DefaultCapabilities.MYCAP = ['VAL1', 'VAL2']
148
+ const myCaps = {
149
+ MYCAP: { VAL1: 'VALUE1' }
150
+ }
151
+ const driver = new BotDriver(myCaps)
152
+ assert.isObject(driver.caps.MYCAP)
153
+ assert.equal(driver.caps.MYCAP.VAL1, 'VALUE1')
154
+ })
67
155
  })
68
- it('should merge string caps', function () {
69
- const myCaps = {
70
- CAP_STRING_1: 'Test',
71
- CAP_STRING_2: '12345'
72
- }
73
- const driver = new BotDriver(myCaps)
74
- assert.isString(driver.caps.CAP_STRING_1)
75
- assert.isString(driver.caps.CAP_STRING_2)
76
- })
77
- it('should merge boolean envs', function () {
78
- process.env.BOTIUM_SIMULATE_WRITING_SPEED = 'NO'
79
- const driver = new BotDriver()
80
- delete process.env.BOTIUM_SIMULATE_WRITING_SPEED
81
- assert.isBoolean(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
82
- assert.isFalse(driver.caps[Capabilities.SIMULATE_WRITING_SPEED])
83
- })
84
- it('should parse array caps', function () {
85
- DefaultCapabilities.MYCAP = []
86
- const myCaps = {
87
- MYCAP: '[{"KEY":"VALUE"},{"KEY":"VALUE1"}]'
88
- }
89
- const driver = new BotDriver(myCaps)
90
- assert.isArray(driver.caps.MYCAP)
91
- assert.lengthOf(driver.caps.MYCAP, 2)
92
- })
93
- it('should merge array caps', function () {
94
- DefaultCapabilities.MYCAP = [{ id: 'id1', key: 'VALUE' }]
95
- const myCaps = {
96
- MYCAP: '[{"id":"id1", "key1": "VALUE1"},{"key":"VALUE1"}]'
97
- }
98
- const driver = new BotDriver(myCaps)
99
- assert.isArray(driver.caps.MYCAP)
100
- assert.lengthOf(driver.caps.MYCAP, 2)
101
- assert.equal(driver.caps.MYCAP[0].key, 'VALUE')
102
- assert.equal(driver.caps.MYCAP[0].key1, 'VALUE1')
103
- assert.isUndefined(driver.caps.MYCAP[1].id)
104
- assert.equal(driver.caps.MYCAP[1].key, 'VALUE1')
105
- })
106
- it('should parse object caps', function () {
107
- DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
108
- const myCaps = {
109
- MYCAP: '{"KEY":"VALUE1"}'
110
- }
111
- const driver = new BotDriver(myCaps)
112
- assert.isObject(driver.caps.MYCAP)
113
- assert.equal(driver.caps.MYCAP.KEY, 'VALUE1')
114
- })
115
- it('should merge object caps', function () {
116
- DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
117
- const myCaps = {
118
- MYCAP: '{"KEY1":"VALUE1"}'
119
- }
120
- const driver = new BotDriver(myCaps)
121
- assert.isObject(driver.caps.MYCAP)
122
- assert.equal(driver.caps.MYCAP.KEY, 'VALUE')
123
- assert.equal(driver.caps.MYCAP.KEY1, 'VALUE1')
124
- })
125
- it('should not parse JSON caps', function () {
126
- const myCaps = {
127
- MYJSONCAP: '{"KEY":"VALUE1"}'
128
- }
129
- const driver = new BotDriver(myCaps)
130
- assert.isObject(driver.caps.MYJSONCAP)
131
- assert.equal(driver.caps.MYJSONCAP.KEY, 'VALUE1')
132
- })
133
- it('should override not matching object caps', function () {
134
- DefaultCapabilities.MYCAP = { KEY: 'VALUE' }
135
- const myCaps = {
136
- MYCAP: 'SIMPLESTRING'
137
- }
138
- const driver = new BotDriver(myCaps)
139
- assert.isString(driver.caps.MYCAP)
140
- assert.equal(driver.caps.MYCAP, 'SIMPLESTRING')
141
- })
142
- it('should override not matching array caps', function () {
143
- DefaultCapabilities.MYCAP = ['VAL1', 'VAL2']
144
- const myCaps = {
145
- MYCAP: { VAL1: 'VALUE1' }
146
- }
147
- const driver = new BotDriver(myCaps)
148
- assert.isObject(driver.caps.MYCAP)
149
- assert.equal(driver.caps.MYCAP.VAL1, 'VALUE1')
150
- })
151
- })
152
156
 
153
- describe('driver.constructor', function () {
154
- it('should deep copy caps', function () {
155
- const myCaps = {
156
- ASSERTERS: [{ name: 'ASSERTER1' }]
157
- }
158
- const driver = new BotDriver(myCaps)
159
- assert.isArray(driver.caps.ASSERTERS)
160
- assert.lengthOf(driver.caps.ASSERTERS, 1)
161
- assert.isArray(DefaultCapabilities.ASSERTERS)
162
- assert.lengthOf(DefaultCapabilities.ASSERTERS, 0)
157
+ describe('constructor', function () {
158
+ it('should deep copy caps', function () {
159
+ const myCaps = {
160
+ ASSERTERS: [{ name: 'ASSERTER1' }]
161
+ }
162
+ const driver = new BotDriver(myCaps)
163
+ assert.isArray(driver.caps.ASSERTERS)
164
+ assert.lengthOf(driver.caps.ASSERTERS, 1)
165
+ assert.isArray(DefaultCapabilities.ASSERTERS)
166
+ assert.lengthOf(DefaultCapabilities.ASSERTERS, 0)
167
+ })
163
168
  })
164
169
  })
@@ -6,7 +6,11 @@ const Capabilities = require('../../').Capabilities
6
6
  const echoConnector = ({ queueBotSays }) => {
7
7
  return {
8
8
  UserSays (msg) {
9
- const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
9
+ const botMsg = {
10
+ sender: 'bot',
11
+ sourceData: msg.sourceData,
12
+ messageText: msg.messageText
13
+ }
10
14
  queueBotSays(botMsg)
11
15
  }
12
16
  }
@@ -26,86 +30,88 @@ const buildDriver = async (mergeCaps) => {
26
30
  }
27
31
 
28
32
  describe('logichooks.hookfromsrc', function () {
29
- it('should succeed with asserter from code', async function () {
30
- const { compiler, container } = await buildDriver({
31
- [Capabilities.ASSERTERS]: [{
32
- ref: 'CUSTOMASSERTER',
33
- src: {
34
- assertConvoStep: 'if (botMsg.messageText === "Hello") result=Promise.resolve(); else result=Promise.reject(new Error("expected Hello"))'
35
- }
36
- }]
33
+ describe('hookfromsrc', function () {
34
+ it('should succeed with asserter from code', async function () {
35
+ const { compiler, container } = await buildDriver({
36
+ [Capabilities.ASSERTERS]: [{
37
+ ref: 'CUSTOMASSERTER',
38
+ src: {
39
+ assertConvoStep: 'if (botMsg.messageText === "Hello") result=Promise.resolve(); else result=Promise.reject(new Error("expected Hello"))'
40
+ }
41
+ }]
42
+ })
43
+ compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
44
+ await compiler.convos[0].Run(container)
37
45
  })
38
- compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
39
- await compiler.convos[0].Run(container)
40
- })
41
- it('should fail with asserter from code', async function () {
42
- const { compiler, container } = await buildDriver({
43
- [Capabilities.ASSERTERS]: [{
44
- ref: 'CUSTOMASSERTER',
45
- src: {
46
- assertConvoStep: 'if (botMsg.messageText === "Hello1") module.exports=Promise.resolve(); else module.exports=Promise.reject(new Error("expected Hello1"))'
47
- }
48
- }]
46
+ it('should fail with asserter from code', async function () {
47
+ const { compiler, container } = await buildDriver({
48
+ [Capabilities.ASSERTERS]: [{
49
+ ref: 'CUSTOMASSERTER',
50
+ src: {
51
+ assertConvoStep: 'if (botMsg.messageText === "Hello1") module.exports=Promise.resolve(); else module.exports=Promise.reject(new Error("expected Hello1"))'
52
+ }
53
+ }]
54
+ })
55
+ compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
56
+ try {
57
+ await compiler.convos[0].Run(container)
58
+ assert.fail('it should have failed')
59
+ } catch (err) {
60
+ assert.isTrue(err.message.includes('Line 6: assertion error - expected Hello1'))
61
+ }
49
62
  })
50
- compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
51
- try {
52
- await compiler.convos[0].Run(container)
53
- assert.fail('it should have failed')
54
- } catch (err) {
55
- assert.isTrue(err.message.includes('Line 6: assertion error - expected Hello1'))
56
- }
57
- })
58
- it('should fail with asserter with invalid script', async function () {
59
- const { compiler, container } = await buildDriver({
60
- [Capabilities.ASSERTERS]: [{
61
- ref: 'CUSTOMASSERTER',
62
- src: {
63
- assertConvoStep: '!'
64
- }
65
- }]
63
+ it('should fail with asserter with invalid script', async function () {
64
+ const { compiler, container } = await buildDriver({
65
+ [Capabilities.ASSERTERS]: [{
66
+ ref: 'CUSTOMASSERTER',
67
+ src: {
68
+ assertConvoStep: '!'
69
+ }
70
+ }]
71
+ })
72
+ compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
73
+ try {
74
+ await compiler.convos[0].Run(container)
75
+ assert.fail('it should have failed')
76
+ } catch (err) {
77
+ assert.isTrue(err.message.includes('Line 6: assertion error - Script assertConvoStep is not valid'))
78
+ }
66
79
  })
67
- compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
68
- try {
69
- await compiler.convos[0].Run(container)
70
- assert.fail('it should have failed')
71
- } catch (err) {
72
- assert.isTrue(err.message.includes('Line 6: assertion error - Script assertConvoStep is not valid'))
73
- }
74
80
  })
75
- })
76
81
 
77
- const buildDriverFromFile = async (mergeCaps) => {
78
- const myCaps = Object.assign({
79
- [Capabilities.PROJECTNAME]: 'logichooks.hookfromsrc',
80
- [Capabilities.CONTAINERMODE]: path.join(__dirname, 'botium-connector-fromfile')
81
- }, mergeCaps)
82
+ const buildDriverFromFile = async (mergeCaps) => {
83
+ const myCaps = Object.assign({
84
+ [Capabilities.PROJECTNAME]: 'logichooks.hookfromsrc',
85
+ [Capabilities.CONTAINERMODE]: path.join(__dirname, 'botium-connector-fromfile')
86
+ }, mergeCaps)
82
87
 
83
- const result = {}
84
- result.driver = new BotDriver(myCaps)
85
- result.compiler = result.driver.BuildCompiler()
86
- result.container = await result.driver.Build()
87
- return result
88
- }
88
+ const result = {}
89
+ result.driver = new BotDriver(myCaps)
90
+ result.compiler = result.driver.BuildCompiler()
91
+ result.container = await result.driver.Build()
92
+ return result
93
+ }
89
94
 
90
- describe('logichooks.hookfromconnector', function () {
91
- it('should succeed with asserter from connector', async function () {
92
- const { compiler, container } = await buildDriverFromFile({
93
- [Capabilities.ASSERTERS]: [{
94
- ref: 'CUSTOMASSERTER',
95
- src: path.join(__dirname, 'botium-connector-fromfile.js/MyCustomAsserter')
96
- }]
95
+ describe('hookfromconnector', function () {
96
+ it('should succeed with asserter from connector', async function () {
97
+ const { compiler, container } = await buildDriverFromFile({
98
+ [Capabilities.ASSERTERS]: [{
99
+ ref: 'CUSTOMASSERTER',
100
+ src: path.join(__dirname, 'botium-connector-fromfile.js/MyCustomAsserter')
101
+ }]
102
+ })
103
+ compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
104
+ await compiler.convos[0].Run(container)
97
105
  })
98
- compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
99
- await compiler.convos[0].Run(container)
100
- })
101
- it('should succeed with asserter from asserter module file', async function () {
102
- const { compiler, container } = await buildDriverFromFile({
103
- [Capabilities.ASSERTERS]: [{
104
- ref: 'CUSTOMASSERTER',
105
- src: path.join(__dirname, 'botium-asserter-fromfile.js')
106
- }]
106
+ it('should succeed with asserter from asserter module file', async function () {
107
+ const { compiler, container } = await buildDriverFromFile({
108
+ [Capabilities.ASSERTERS]: [{
109
+ ref: 'CUSTOMASSERTER',
110
+ src: path.join(__dirname, 'botium-asserter-fromfile.js')
111
+ }]
112
+ })
113
+ compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
114
+ await compiler.convos[0].Run(container)
107
115
  })
108
- compiler.ReadScript(path.resolve(__dirname, 'convos'), 'HOOKFROMSRC.convo.txt')
109
- await compiler.convos[0].Run(container)
110
116
  })
111
117
  })
@@ -2,53 +2,55 @@ const path = require('path')
2
2
  const assert = require('chai').assert
3
3
  const { BotDriver, Capabilities, Plugins } = require('../../')
4
4
 
5
- describe('plugins.find', function () {
6
- it('should return empty list on invalid folder', async () => {
7
- const plugins = await Plugins.getPlugins(Plugins.PLUGIN_TYPE_ASSERTER, 'abcd')
8
- assert.isEmpty(plugins)
9
- })
5
+ describe('plugins.plugins', function () {
6
+ describe('find', function () {
7
+ it('should return empty list on invalid folder', async function () {
8
+ const plugins = await Plugins.getPlugins(Plugins.PLUGIN_TYPE_ASSERTER, 'abcd')
9
+ assert.isEmpty(plugins)
10
+ })
10
11
 
11
- it('should load connector from folder', async () => {
12
- const plugins = await Plugins.getPlugins(Plugins.PLUGIN_TYPE_CONNECTOR, path.join(__dirname, 'plugindir', 'fromfolder'))
13
- assert.lengthOf(plugins, 1)
14
- assert.equal(plugins[0].PluginDesc.name, 'Test Connector FromDir')
15
- assert.equal(plugins[0].PluginDesc.src, 'fromdir1')
16
- })
12
+ it('should load connector from folder', async function () {
13
+ const plugins = await Plugins.getPlugins(Plugins.PLUGIN_TYPE_CONNECTOR, path.join(__dirname, 'plugindir', 'fromfolder'))
14
+ assert.lengthOf(plugins, 1)
15
+ assert.equal(plugins[0].PluginDesc.name, 'Test Connector FromDir')
16
+ assert.equal(plugins[0].PluginDesc.src, 'fromdir1')
17
+ })
17
18
 
18
- it('should load connector from file', async () => {
19
- const plugins = await Plugins.getPlugins(Plugins.PLUGIN_TYPE_CONNECTOR, path.join(__dirname, 'plugindir', 'fromfile'))
20
- assert.lengthOf(plugins, 2)
21
- assert.equal(plugins[0].PluginDesc.name, 'Test Connector FromFile 1')
22
- assert.equal(plugins[0].PluginDesc.src, 'fromfile1')
23
- assert.equal(plugins[1].PluginDesc.name, 'Test Connector FromFile 2')
24
- assert.equal(plugins[1].PluginDesc.src, 'fromfile2')
19
+ it('should load connector from file', async function () {
20
+ const plugins = await Plugins.getPlugins(Plugins.PLUGIN_TYPE_CONNECTOR, path.join(__dirname, 'plugindir', 'fromfile'))
21
+ assert.lengthOf(plugins, 2)
22
+ assert.equal(plugins[0].PluginDesc.name, 'Test Connector FromFile 1')
23
+ assert.equal(plugins[0].PluginDesc.src, 'fromfile1')
24
+ assert.equal(plugins[1].PluginDesc.name, 'Test Connector FromFile 2')
25
+ assert.equal(plugins[1].PluginDesc.src, 'fromfile2')
26
+ })
25
27
  })
26
- })
27
28
 
28
- describe('plugins.load', function () {
29
- it('should map simple function to class', async () => {
30
- const myCaps = {
31
- [Capabilities.PROJECTNAME]: 'plugins.load',
32
- [Capabilities.CONTAINERMODE]: 'fromfile1'
33
- }
34
- const driver = new BotDriver(myCaps)
35
- const container = await driver.Build()
29
+ describe('load', function () {
30
+ it('should map simple function to class', async function () {
31
+ const myCaps = {
32
+ [Capabilities.PROJECTNAME]: 'plugins.load',
33
+ [Capabilities.CONTAINERMODE]: 'fromfile1'
34
+ }
35
+ const driver = new BotDriver(myCaps)
36
+ const container = await driver.Build()
36
37
 
37
- await container.UserSays({ messageText: 'TEST' })
38
- const response = await container.WaitBotSays()
39
- assert.equal(response.messageText, 'TEST')
40
- })
41
- it('should use UserSays function as class', async () => {
42
- const myCaps = {
43
- [Capabilities.PROJECTNAME]: 'plugins.load',
44
- [Capabilities.CONTAINERMODE]: 'fromfile2',
45
- cap1: 'MYPREFIX'
46
- }
47
- const driver = new BotDriver(myCaps)
48
- const container = await driver.Build()
38
+ await container.UserSays({ messageText: 'TEST' })
39
+ const response = await container.WaitBotSays()
40
+ assert.equal(response.messageText, 'TEST')
41
+ })
42
+ it('should use UserSays function as class', async function () {
43
+ const myCaps = {
44
+ [Capabilities.PROJECTNAME]: 'plugins.load',
45
+ [Capabilities.CONTAINERMODE]: 'fromfile2',
46
+ cap1: 'MYPREFIX'
47
+ }
48
+ const driver = new BotDriver(myCaps)
49
+ const container = await driver.Build()
49
50
 
50
- await container.UserSays({ messageText: 'TEST' })
51
- const response = await container.WaitBotSays()
52
- assert.equal(response.messageText, 'MYPREFIX:TEST')
51
+ await container.UserSays({ messageText: 'TEST' })
52
+ const response = await container.WaitBotSays()
53
+ assert.equal(response.messageText, 'MYPREFIX:TEST')
54
+ })
53
55
  })
54
56
  })