botium-core 1.13.11 → 1.13.14
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 +109 -58
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +95 -45
- package/dist/botium-es.js.map +1 -1
- package/index.js +15 -9
- package/package.json +1 -1
- package/src/Capabilities.js +4 -0
- package/src/Defaults.js +0 -1
- package/src/containers/plugins/SimpleRestContainer.js +50 -22
- package/src/helpers/TranscriptUtils.js +12 -0
- package/test/compiler/compilermarkdown.spec.js +11 -11
- package/test/compiler/compilertxt.spec.js +11 -11
- package/test/compiler/compilerxlsx.spec.js +10 -10
- package/test/compiler/convos/md/{convos_with!.md → convos_with_exclamation.md} +0 -0
- package/test/compiler/convos/md/{convos_with!_secline.md → convos_with_exclamation_secline.md} +0 -0
- package/test/compiler/convos/md/{convos_with!!!!.md → convos_with_four_exclamation.md} +0 -0
- package/test/compiler/convos/md/{convos_with????.md → convos_with_four_question.md} +0 -0
- package/test/compiler/convos/md/{convos_with?.md → convos_with_question.md} +0 -0
- package/test/compiler/convos/md/{convos_with?!.md → convos_with_question_exclamation.md} +0 -0
- package/test/compiler/convos/md/{convos_with?_invalid.md → convos_with_question_invalid.md} +0 -0
- package/test/compiler/convos/md/{convos_with?_secline.md → convos_with_question_secline.md} +0 -0
- package/test/compiler/convos/md/{convos_with!!.md → convos_with_two_exclamation.md} +0 -0
- package/test/compiler/convos/md/{convos_with??.md → convos_with_two_question.md} +0 -0
- package/test/compiler/convos/md/{convos_with??!.md → convos_with_two_question_exclamation.md} +0 -0
- package/test/compiler/convos/txt/{convos_with!.convo.txt → convos_with_exclamation.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with!_secline.convo.txt → convos_with_exclamation_secline.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with!!!!.convo.txt → convos_with_four_exclamation.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with????.convo.txt → convos_with_four_question.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with_#.convo.txt → convos_with_hashmark.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with?.convo.txt → convos_with_question.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with?!.convo.txt → convos_with_question_exclamation.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with?_secline.convo.txt → convos_with_question_secline.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with!!.convo.txt → convos_with_two_exclamation.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with??.convo.txt → convos_with_two_question.convo.txt} +0 -0
- package/test/compiler/convos/txt/{convos_with??!.convo.txt → convos_with_two_question_exclamation.convo.txt} +0 -0
- package/test/compiler/convos/xlsx/{convos_with!.xlsx → convos_with_exclamation.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with!_secline.xlsx → convos_with_exclamation_secline.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with!!!!.xlsx → convos_with_four_exclamation.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with????.xlsx → convos_with_four_question.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with?.xlsx → convos_with_question.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with?!.xlsx → convos_with_question_exclamation.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with?_secline.xlsx → convos_with_question_secline.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with!!.xlsx → convos_with_two_exclamation.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with??.xlsx → convos_with_two_question.xlsx} +0 -0
- package/test/compiler/convos/xlsx/{convos_with??!.xlsx → convos_with_two_question_exclamation.xlsx} +0 -0
- package/test/connectors/simplerest.spec.js +53 -4
- package/test/driver/capabilities.spec.js +7 -7
- package/test/helpers/convos/hello.convo.txt +6 -0
- package/test/helpers/transcriptutils.spec.js +71 -0
|
@@ -852,7 +852,9 @@ describe('connectors.simplerest', function () {
|
|
|
852
852
|
[Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH]: '$.title',
|
|
853
853
|
[Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH]: '$.subTitle',
|
|
854
854
|
[Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH]: '$.media',
|
|
855
|
-
[Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH]: '$.buttons[*]
|
|
855
|
+
[Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH]: '$.buttons[*]',
|
|
856
|
+
[Capabilities.SIMPLEREST_CARD_BUTTONS_TEXT_SUBJSONPATH]: '$.text',
|
|
857
|
+
[Capabilities.SIMPLEREST_CARD_BUTTONS_PAYLOAD_SUBJSONPATH]: ['$.postback', '$.value']
|
|
856
858
|
})
|
|
857
859
|
const driver = new BotDriver(myCaps)
|
|
858
860
|
const container = await driver.Build()
|
|
@@ -867,10 +869,12 @@ describe('connectors.simplerest', function () {
|
|
|
867
869
|
media: 'http://botium.at/1.jpg',
|
|
868
870
|
buttons: [
|
|
869
871
|
{
|
|
870
|
-
text: 'c1b1'
|
|
872
|
+
text: 'c1b1',
|
|
873
|
+
postback: 'c1b1'
|
|
871
874
|
},
|
|
872
875
|
{
|
|
873
|
-
text: 'c1b2'
|
|
876
|
+
text: 'c1b2',
|
|
877
|
+
postback: 'c1b2'
|
|
874
878
|
}
|
|
875
879
|
]
|
|
876
880
|
},
|
|
@@ -880,7 +884,8 @@ describe('connectors.simplerest', function () {
|
|
|
880
884
|
media: 'http://botium.at/2.jpg',
|
|
881
885
|
buttons: [
|
|
882
886
|
{
|
|
883
|
-
text: 'c2b1'
|
|
887
|
+
text: 'c2b1',
|
|
888
|
+
value: 'c2b1'
|
|
884
889
|
}
|
|
885
890
|
]
|
|
886
891
|
}
|
|
@@ -897,7 +902,9 @@ describe('connectors.simplerest', function () {
|
|
|
897
902
|
assert.equal(msgs[0].cards[0].media[0].mimeType, 'image/jpeg')
|
|
898
903
|
assert.equal(msgs[0].cards[0].buttons.length, 2)
|
|
899
904
|
assert.equal(msgs[0].cards[0].buttons[0].text, 'c1b1')
|
|
905
|
+
assert.equal(msgs[0].cards[0].buttons[0].payload, 'c1b1')
|
|
900
906
|
assert.equal(msgs[0].cards[0].buttons[1].text, 'c1b2')
|
|
907
|
+
assert.equal(msgs[0].cards[0].buttons[1].payload, 'c1b2')
|
|
901
908
|
|
|
902
909
|
assert.equal(msgs[0].cards[1].text, 'card2')
|
|
903
910
|
assert.equal(msgs[0].cards[1].subtext, 'card2 sub')
|
|
@@ -906,6 +913,48 @@ describe('connectors.simplerest', function () {
|
|
|
906
913
|
assert.equal(msgs[0].cards[1].media[0].mimeType, 'image/jpeg')
|
|
907
914
|
assert.equal(msgs[0].cards[1].buttons.length, 1)
|
|
908
915
|
assert.equal(msgs[0].cards[1].buttons[0].text, 'c2b1')
|
|
916
|
+
assert.equal(msgs[0].cards[1].buttons[0].payload, 'c2b1')
|
|
917
|
+
|
|
918
|
+
await container.Clean()
|
|
919
|
+
})
|
|
920
|
+
it('should process button responses', async function () {
|
|
921
|
+
const myCaps = Object.assign({}, myCapsGet, {
|
|
922
|
+
[Capabilities.SIMPLEREST_RESPONSE_JSONPATH]: '$.text',
|
|
923
|
+
[Capabilities.SIMPLEREST_BUTTONS_JSONPATH]: '$.buttons[*]',
|
|
924
|
+
[Capabilities.SIMPLEREST_BUTTONS_TEXT_SUBJSONPATH]: '$.text',
|
|
925
|
+
[Capabilities.SIMPLEREST_BUTTONS_PAYLOAD_SUBJSONPATH]: ['$.postback', '$.value']
|
|
926
|
+
})
|
|
927
|
+
const driver = new BotDriver(myCaps)
|
|
928
|
+
const container = await driver.Build()
|
|
929
|
+
assert.equal(container.pluginInstance.constructor.name, 'SimpleRestContainer')
|
|
930
|
+
|
|
931
|
+
await container.Start()
|
|
932
|
+
const msgs = await container.pluginInstance._processBodyAsyncImpl({
|
|
933
|
+
buttons: [
|
|
934
|
+
{
|
|
935
|
+
text: 'b1',
|
|
936
|
+
postback: 'b1'
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
text: 'b2',
|
|
940
|
+
postback: 'b2'
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
text: 'b3',
|
|
944
|
+
value: 'b3'
|
|
945
|
+
}
|
|
946
|
+
]
|
|
947
|
+
}, {}, true)
|
|
948
|
+
|
|
949
|
+
assert.exists(msgs)
|
|
950
|
+
assert.equal(msgs.length, 1)
|
|
951
|
+
assert.equal(msgs[0].buttons.length, 3)
|
|
952
|
+
assert.equal(msgs[0].buttons[0].text, 'b1')
|
|
953
|
+
assert.equal(msgs[0].buttons[0].payload, 'b1')
|
|
954
|
+
assert.equal(msgs[0].buttons[1].text, 'b2')
|
|
955
|
+
assert.equal(msgs[0].buttons[1].payload, 'b2')
|
|
956
|
+
assert.equal(msgs[0].buttons[2].text, 'b3')
|
|
957
|
+
assert.equal(msgs[0].buttons[2].payload, 'b3')
|
|
909
958
|
|
|
910
959
|
await container.Clean()
|
|
911
960
|
})
|
|
@@ -60,11 +60,11 @@ describe('driver.capabilities', function () {
|
|
|
60
60
|
describe('capabilities', function () {
|
|
61
61
|
it('should merge boolean caps', function () {
|
|
62
62
|
const myCaps = {
|
|
63
|
-
[Capabilities.
|
|
63
|
+
[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE]: 'YES'
|
|
64
64
|
}
|
|
65
65
|
const driver = new BotDriver(myCaps)
|
|
66
|
-
assert.isBoolean(driver.caps[Capabilities.
|
|
67
|
-
assert.isTrue(driver.caps[Capabilities.
|
|
66
|
+
assert.isBoolean(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
|
|
67
|
+
assert.isTrue(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
|
|
68
68
|
})
|
|
69
69
|
it('should merge string caps', function () {
|
|
70
70
|
const myCaps = {
|
|
@@ -76,11 +76,11 @@ describe('driver.capabilities', function () {
|
|
|
76
76
|
assert.isString(driver.caps.CAP_STRING_2)
|
|
77
77
|
})
|
|
78
78
|
it('should merge boolean envs', function () {
|
|
79
|
-
process.env.
|
|
79
|
+
process.env.BOTIUM_SIMPLEREST_PING_PROCESS_RESPONSE = 'NO'
|
|
80
80
|
const driver = new BotDriver()
|
|
81
|
-
delete process.env.
|
|
82
|
-
assert.isBoolean(driver.caps[Capabilities.
|
|
83
|
-
assert.isFalse(driver.caps[Capabilities.
|
|
81
|
+
delete process.env.BOTIUM_SIMPLEREST_PING_PROCESS_RESPONSE
|
|
82
|
+
assert.isBoolean(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
|
|
83
|
+
assert.isFalse(driver.caps[Capabilities.SIMPLEREST_PING_PROCESS_RESPONSE])
|
|
84
84
|
})
|
|
85
85
|
it('should parse array caps', function () {
|
|
86
86
|
DefaultCapabilities.MYCAP = []
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const assert = require('chai').assert
|
|
3
|
+
const BotDriver = require('../../').BotDriver
|
|
4
|
+
const Capabilities = require('../../').Capabilities
|
|
5
|
+
const TranscriptUtils = require('../../').TranscriptUtils
|
|
6
|
+
const debug = require('debug')('botium-test-transcriptutils')
|
|
7
|
+
const util = require('util')
|
|
8
|
+
|
|
9
|
+
const createEchoConnector = () => ({ queueBotSays, caps }) => {
|
|
10
|
+
return {
|
|
11
|
+
UserSays (msg) {
|
|
12
|
+
const prefix = `Testcase "${caps[Capabilities.PROJECTNAME]}"`
|
|
13
|
+
debug(`${prefix} Connector got message ${util.inspect(msg)}`)
|
|
14
|
+
const botMsg = {
|
|
15
|
+
sender: 'bot',
|
|
16
|
+
sourceData: msg.sourceData,
|
|
17
|
+
messageText: msg.messageText
|
|
18
|
+
}
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
debug(`${prefix} Connector send message ${util.inspect(botMsg)}`)
|
|
21
|
+
return queueBotSays(botMsg)
|
|
22
|
+
}, caps.WAITECHO)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('helpers.transcriptutils', function () {
|
|
28
|
+
describe('hasTimeout', function () {
|
|
29
|
+
it('should return true ontimeout', async function () {
|
|
30
|
+
const myCaps = {
|
|
31
|
+
[Capabilities.PROJECTNAME]: 'helpers.transcriptutils.hasTimeout should should return true ontimeout',
|
|
32
|
+
[Capabilities.CONTAINERMODE]: createEchoConnector(),
|
|
33
|
+
[Capabilities.WAITFORBOTTIMEOUT]: 0,
|
|
34
|
+
WAITECHO: 20
|
|
35
|
+
}
|
|
36
|
+
const driver = new BotDriver(myCaps)
|
|
37
|
+
const compiler = driver.BuildCompiler()
|
|
38
|
+
const container = await driver.Build()
|
|
39
|
+
|
|
40
|
+
compiler.ReadScript(path.resolve(__dirname, 'convos'), 'hello.convo.txt')
|
|
41
|
+
assert.equal(compiler.convos.length, 1)
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await compiler.convos[0].Run(container)
|
|
45
|
+
assert.fail('should have failed with timeout')
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (!TranscriptUtils.hasWaitForBotTimeout(err)) {
|
|
48
|
+
throw err
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
await container.Clean()
|
|
52
|
+
})
|
|
53
|
+
it('should return false if there is no timeout', async function () {
|
|
54
|
+
const myCaps = {
|
|
55
|
+
[Capabilities.PROJECTNAME]: 'helpers.transcriptutils.hasTimeout should return false if there is no timeout',
|
|
56
|
+
[Capabilities.CONTAINERMODE]: createEchoConnector(),
|
|
57
|
+
[Capabilities.WAITFORBOTTIMEOUT]: 50,
|
|
58
|
+
WAITECHO: 20
|
|
59
|
+
}
|
|
60
|
+
const driver = new BotDriver(myCaps)
|
|
61
|
+
const compiler = driver.BuildCompiler()
|
|
62
|
+
const container = await driver.Build()
|
|
63
|
+
|
|
64
|
+
compiler.ReadScript(path.resolve(__dirname, 'convos'), 'hello.convo.txt')
|
|
65
|
+
assert.equal(compiler.convos.length, 1)
|
|
66
|
+
|
|
67
|
+
await compiler.convos[0].Run(container)
|
|
68
|
+
await container.Clean()
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
})
|