botium-core 1.13.16 → 1.13.18
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/README.md +0 -1
- package/dist/botium-cjs.js +283 -172
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +282 -171
- package/dist/botium-es.js.map +1 -1
- package/package.json +23 -23
- package/src/BotDriver.js +2 -4
- package/src/Capabilities.js +7 -3
- package/src/Events.js +1 -0
- package/src/containers/BaseContainer.js +5 -3
- package/src/containers/PluginConnectorContainer.js +0 -4
- package/src/containers/plugins/SimpleRestContainer.js +49 -0
- package/src/scripting/Convo.js +10 -27
- package/src/scripting/ScriptingProvider.js +121 -53
- package/src/scripting/helper.js +9 -2
- package/src/scripting/logichook/asserter/ButtonsAsserter.js +21 -8
- package/src/scripting/logichook/asserter/WerAsserter.js +53 -6
- package/src/scripting/logichook/logichooks/ClearQueueLogicHook.js +0 -1
- package/test/connectors/logicHook.js +0 -1
- package/test/connectors/simplerest.spec.js +79 -4
- package/test/scripting/asserters/buttonsAsserter.spec.js +84 -50
- package/test/scripting/logichooks/convos/custom_embedded_skip.convo.txt +11 -0
- package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_me.convo.txt +11 -0
- package/test/scripting/logichooks/convos/custom_embedded_skip_followed_by_nothing.convo.txt +8 -0
- package/test/scripting/logichooks/customEmbeddedSkip.json +14 -0
- package/test/scripting/logichooks/customEmbeddedSkip.spec.js +58 -0
- package/test/security/allowUnsafe.spec.js +20 -10
- package/test/security/convos/withscriptingmemoryfunction.convo.txt +1 -0
- package/test/convo/retryconvo.spec.js +0 -134
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const assert = require('chai').assert
|
|
3
|
-
const BotDriver = require('../../').BotDriver
|
|
4
|
-
const Capabilities = require('../../').Capabilities
|
|
5
|
-
|
|
6
|
-
const echoConnector = (numErrors, errorText) => ({ queueBotSays }) => {
|
|
7
|
-
let errors = 0
|
|
8
|
-
return {
|
|
9
|
-
UserSays (msg) {
|
|
10
|
-
if (errors >= numErrors) {
|
|
11
|
-
const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
|
|
12
|
-
queueBotSays(botMsg)
|
|
13
|
-
} else {
|
|
14
|
-
errors++
|
|
15
|
-
return Promise.reject(errorText)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('convo.retries', function () {
|
|
22
|
-
beforeEach(async function () {
|
|
23
|
-
this.init = async (numErrors, errorText, errorPatterns, numRetries) => {
|
|
24
|
-
const myCaps = {
|
|
25
|
-
[Capabilities.PROJECTNAME]: 'convo.retry',
|
|
26
|
-
[Capabilities.CONTAINERMODE]: echoConnector(numErrors, errorText),
|
|
27
|
-
RETRY_CONVO_MINTIMEOUT: 10,
|
|
28
|
-
RETRY_CONVO_ONERROR_REGEXP: errorPatterns
|
|
29
|
-
}
|
|
30
|
-
if (!isNaN(numRetries)) {
|
|
31
|
-
myCaps.RETRY_CONVO_NUMRETRIES = numRetries
|
|
32
|
-
}
|
|
33
|
-
this.driver = new BotDriver(myCaps)
|
|
34
|
-
this.compiler = this.driver.BuildCompiler()
|
|
35
|
-
this.container = await this.driver.Build()
|
|
36
|
-
await this.container.Start()
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
afterEach(async function () {
|
|
40
|
-
await this.container.Stop()
|
|
41
|
-
await this.container.Clean()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('should fail without retry', async function () {
|
|
45
|
-
await this.init(1, 'myerror')
|
|
46
|
-
|
|
47
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
48
|
-
try {
|
|
49
|
-
await this.compiler.convos[0].Run(this.container)
|
|
50
|
-
} catch (err) {
|
|
51
|
-
assert.isTrue(err.message.indexOf('myerror') >= 0)
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
assert.fail('should have failed without retry')
|
|
55
|
-
})
|
|
56
|
-
it('should succeed after one retry with default numRetries', async function () {
|
|
57
|
-
await this.init(1, 'myerror', 'myerror')
|
|
58
|
-
|
|
59
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
60
|
-
await this.compiler.convos[0].Run(this.container)
|
|
61
|
-
})
|
|
62
|
-
it('should succeed after one retry with joker regex', async function () {
|
|
63
|
-
await this.init(1, 'myerror', null, 1)
|
|
64
|
-
|
|
65
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
66
|
-
await this.compiler.convos[0].Run(this.container)
|
|
67
|
-
})
|
|
68
|
-
it('should fail after one retry with default settings', async function () {
|
|
69
|
-
await this.init(2, 'myerror', 'myerror')
|
|
70
|
-
|
|
71
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
72
|
-
try {
|
|
73
|
-
await this.compiler.convos[0].Run(this.container)
|
|
74
|
-
} catch (err) {
|
|
75
|
-
assert.isTrue(err.message.indexOf('myerror') >= 0)
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
assert.fail('should have failed after first retry')
|
|
79
|
-
})
|
|
80
|
-
it('should succeed after many retries', async function () {
|
|
81
|
-
await this.init(5, 'myerror', 'myerror', 5)
|
|
82
|
-
|
|
83
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
84
|
-
await this.compiler.convos[0].Run(this.container)
|
|
85
|
-
})
|
|
86
|
-
it('should succeed after too less retries', async function () {
|
|
87
|
-
await this.init(5, 'myerror', 'myerror', 4)
|
|
88
|
-
|
|
89
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
90
|
-
try {
|
|
91
|
-
await this.compiler.convos[0].Run(this.container)
|
|
92
|
-
} catch (err) {
|
|
93
|
-
assert.isTrue(err.message.indexOf('myerror') >= 0)
|
|
94
|
-
return
|
|
95
|
-
}
|
|
96
|
-
assert.fail('should have failed after four retries')
|
|
97
|
-
})
|
|
98
|
-
it('should succeed after one retry with regexp pattern', async function () {
|
|
99
|
-
await this.init(1, 'myerror', /myeRRor/i)
|
|
100
|
-
|
|
101
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
102
|
-
await this.compiler.convos[0].Run(this.container)
|
|
103
|
-
})
|
|
104
|
-
it('should fail after one retry with unmatched regexp pattern', async function () {
|
|
105
|
-
await this.init(1, 'myerror', /myeRRor1/i)
|
|
106
|
-
|
|
107
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
108
|
-
try {
|
|
109
|
-
await this.compiler.convos[0].Run(this.container)
|
|
110
|
-
} catch (err) {
|
|
111
|
-
assert.isTrue(err.message.indexOf('myerror') >= 0)
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
assert.fail('should have failed with unmatched retry pattern')
|
|
115
|
-
})
|
|
116
|
-
it('should succeed after one retry with regexp pattern array', async function () {
|
|
117
|
-
await this.init(1, 'myerror', [/myeRRor/i, /myeRRor1/i])
|
|
118
|
-
|
|
119
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
120
|
-
await this.compiler.convos[0].Run(this.container)
|
|
121
|
-
})
|
|
122
|
-
it('should fail after one retry with unmatched regexp pattern array', async function () {
|
|
123
|
-
await this.init(1, 'myerror', [/myeRRor1/i, /myeRRor2/i])
|
|
124
|
-
|
|
125
|
-
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '1step.convo.txt')
|
|
126
|
-
try {
|
|
127
|
-
await this.compiler.convos[0].Run(this.container)
|
|
128
|
-
} catch (err) {
|
|
129
|
-
assert.isTrue(err.message.indexOf('myerror') >= 0)
|
|
130
|
-
return
|
|
131
|
-
}
|
|
132
|
-
assert.fail('should have failed with unmatched retry pattern')
|
|
133
|
-
})
|
|
134
|
-
})
|