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.
- package/.eslintrc.js +6 -3
- package/dist/botium-cjs.js +214 -61
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +213 -61
- package/dist/botium-es.js.map +1 -1
- package/package.json +3 -1
- package/src/Capabilities.js +2 -1
- package/src/containers/plugins/SimpleRestContainer.js +20 -16
- package/src/grid/inbound/proxy.js +2 -1
- package/src/scripting/Convo.js +16 -10
- package/src/scripting/MatchFunctions.js +10 -0
- package/src/scripting/ScriptingProvider.js +106 -37
- package/src/scripting/logichook/LogicHookConsts.js +1 -1
- package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
- package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
- package/test/compiler/compilercsv.spec.js +104 -3
- package/test/compiler/compilerjson.spec.js +0 -2
- package/test/compiler/compilerxlsx.spec.js +1 -1
- package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
- package/test/connectors/simplerest.spec.js +1012 -969
- package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
- package/test/convo/partialconvo.spec.js +345 -339
- package/test/driver/capabilities.spec.js +156 -151
- package/test/logichooks/hookfromsrc.spec.js +79 -73
- package/test/plugins/plugins.spec.js +44 -42
- package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
- package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
- package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
- package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
- package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
- package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
- package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
- package/test/scripting/asserters/werAsserter.spec.js +51 -0
- package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
- package/test/scripting/matching/matchingmode.spec.js +306 -258
- package/test/scripting/scriptingProvider.spec.js +666 -633
- package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
- package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
- package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
- package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
- package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
- package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
- package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
- package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
- package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
- package/test/security/allowUnsafe.spec.js +274 -268
- package/test/utils.spec.js +40 -38
|
@@ -7,7 +7,11 @@ const echoAssertConnector = ({ queueBotSays }) => {
|
|
|
7
7
|
return {
|
|
8
8
|
UserSays (msg) {
|
|
9
9
|
const response = `${msg.messageText.replace('forcereplace1', 'OUTPUT1').replace('forcereplace2', 'OUTPUT2')}`
|
|
10
|
-
const botMsg = {
|
|
10
|
+
const botMsg = {
|
|
11
|
+
sender: 'bot',
|
|
12
|
+
sourceData: msg.sourceData,
|
|
13
|
+
messageText: response
|
|
14
|
+
}
|
|
11
15
|
queueBotSays(botMsg)
|
|
12
16
|
}
|
|
13
17
|
}
|
|
@@ -21,7 +25,11 @@ const echoShopConnector = ({ queueBotSays }) => {
|
|
|
21
25
|
} else if (msg.messageText.startsWith('Ok, then send me some')) {
|
|
22
26
|
response = `Added ${msg.messageText.substr(21).trim()} to the shopping cart`
|
|
23
27
|
}
|
|
24
|
-
const botMsg = {
|
|
28
|
+
const botMsg = {
|
|
29
|
+
sender: 'bot',
|
|
30
|
+
sourceData: msg.sourceData,
|
|
31
|
+
messageText: response
|
|
32
|
+
}
|
|
25
33
|
queueBotSays(botMsg)
|
|
26
34
|
}
|
|
27
35
|
}
|
|
@@ -31,99 +39,105 @@ const multipleVariableEntriesConnector = ({ queueBotSays }) => {
|
|
|
31
39
|
return {
|
|
32
40
|
UserSays (msg) {
|
|
33
41
|
const response = 'I\'d like to have Schnitzel and one more Schnitzel'
|
|
34
|
-
const botMsg = {
|
|
42
|
+
const botMsg = {
|
|
43
|
+
sender: 'bot',
|
|
44
|
+
sourceData: msg.sourceData,
|
|
45
|
+
messageText: response
|
|
46
|
+
}
|
|
35
47
|
queueBotSays(botMsg)
|
|
36
48
|
}
|
|
37
49
|
}
|
|
38
50
|
}
|
|
39
51
|
|
|
40
|
-
describe('scripting.useScriptingMemoryForAssertion
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
describe('scripting.scriptingmemory.useScriptingMemoryForAssertion', function () {
|
|
53
|
+
describe('simpleassertion', function () {
|
|
54
|
+
beforeEach(async function () {
|
|
55
|
+
const myCaps = {
|
|
56
|
+
[Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
|
|
57
|
+
[Capabilities.CONTAINERMODE]: echoAssertConnector,
|
|
58
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true
|
|
59
|
+
}
|
|
60
|
+
const driver = new BotDriver(myCaps)
|
|
61
|
+
this.compiler = driver.BuildCompiler()
|
|
62
|
+
this.container = await driver.Build()
|
|
63
|
+
})
|
|
64
|
+
afterEach(async function () {
|
|
65
|
+
this.container && await this.container.Clean()
|
|
66
|
+
})
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
it('should use scripting memory for assertion', async function () {
|
|
69
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosAssertion'))
|
|
70
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
72
|
+
try {
|
|
73
|
+
await this.compiler.convos[0].Run(this.container)
|
|
74
|
+
assert.fail('should have failed')
|
|
75
|
+
} catch (err) {
|
|
76
|
+
assert.isTrue(err.message.indexOf('Bot response (on Line 3: #me - $productName $customer) "OUTPUT1 OUTPUT2" expected to match "forcereplace1 forcereplace2"') >= 0)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
65
79
|
})
|
|
66
|
-
})
|
|
67
80
|
|
|
68
|
-
describe('
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
describe('multiplefiles', function () {
|
|
82
|
+
beforeEach(async function () {
|
|
83
|
+
const myCaps = {
|
|
84
|
+
[Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
|
|
85
|
+
[Capabilities.CONTAINERMODE]: echoShopConnector,
|
|
86
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
|
|
87
|
+
[Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]: 'joker'
|
|
88
|
+
}
|
|
89
|
+
const driver = new BotDriver(myCaps)
|
|
90
|
+
this.compiler = driver.BuildCompiler()
|
|
91
|
+
this.container = await driver.Build()
|
|
92
|
+
})
|
|
93
|
+
afterEach(async function () {
|
|
94
|
+
this.container && await this.container.Clean()
|
|
95
|
+
})
|
|
83
96
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
it('should use scripting memory for assertion', async function () {
|
|
98
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemory', 'convos'))
|
|
99
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemory', 'memory1'))
|
|
100
|
+
this.compiler.ExpandScriptingMemoryToConvos()
|
|
101
|
+
assert.lengthOf(this.compiler.convos, 2)
|
|
89
102
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
const transcript0 = await this.compiler.convos[0].Run(this.container)
|
|
104
|
+
assert.lengthOf(transcript0.steps, 4)
|
|
105
|
+
assert.equal(transcript0.steps[0].scriptingMemory.$available_products, 'Bread, Beer, Eggs')
|
|
106
|
+
assert.equal(transcript0.steps[0].scriptingMemory.$productName, 'Bread')
|
|
94
107
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
const transcript1 = await this.compiler.convos[1].Run(this.container)
|
|
109
|
+
assert.lengthOf(transcript1.steps, 4)
|
|
110
|
+
assert.equal(transcript1.steps[0].scriptingMemory.$available_products, 'Bread, Beer, Eggs')
|
|
111
|
+
assert.equal(transcript1.steps[0].scriptingMemory.$productName, 'Beer')
|
|
112
|
+
})
|
|
99
113
|
})
|
|
100
|
-
})
|
|
101
114
|
|
|
102
|
-
describe('
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
describe('multipleVariableEntries', function () {
|
|
116
|
+
beforeEach(async function () {
|
|
117
|
+
const myCaps = {
|
|
118
|
+
[Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
|
|
119
|
+
[Capabilities.CONTAINERMODE]: multipleVariableEntriesConnector,
|
|
120
|
+
[Capabilities.SCRIPTING_ENABLE_MEMORY]: true
|
|
121
|
+
}
|
|
122
|
+
const driver = new BotDriver(myCaps)
|
|
123
|
+
this.compiler = driver.BuildCompiler()
|
|
124
|
+
this.container = await driver.Build()
|
|
125
|
+
})
|
|
126
|
+
afterEach(async function () {
|
|
127
|
+
this.container && await this.container.Clean()
|
|
128
|
+
})
|
|
116
129
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
it('should use scripting memory for assertion several variables entries', async function () {
|
|
131
|
+
// scripting variables replaced in every entry
|
|
132
|
+
this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'scriptingVariablesSeveralEntries'))
|
|
133
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
121
134
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
try {
|
|
136
|
+
await this.compiler.convos[0].Run(this.container)
|
|
137
|
+
assert.fail('should have failed')
|
|
138
|
+
} catch (err) {
|
|
139
|
+
assert.isTrue(err.message.indexOf('Bot response (on Line 6: #me - What would you like to eat?) "I\'d like to have Schnitzel and one more Schnitzel" expected to match "I\'d like to have a Schnitzel and one more Schnitzel"') >= 0)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
128
142
|
})
|
|
129
143
|
})
|
|
@@ -7,147 +7,253 @@ const convoStep = {
|
|
|
7
7
|
stepTag: 'MYSTEPTAG'
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
describe('
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} catch (err) {
|
|
31
|
-
assert.isDefined(err)
|
|
32
|
-
assert.instanceOf(err, Error)
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
it('should set button in message as payload', async function () {
|
|
36
|
-
const bi = new ButtonInput()
|
|
37
|
-
|
|
38
|
-
const meMsg = {}
|
|
39
|
-
await bi.setUserInput({ convoStep, args: ['Test1'], meMsg })
|
|
40
|
-
assert.isArray(meMsg.buttons)
|
|
41
|
-
assert.lengthOf(meMsg.buttons, 1)
|
|
42
|
-
assert.equal(meMsg.buttons[0].payload, 'Test1')
|
|
43
|
-
})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
describe('UserInputs.defaults.mediaInput', function () {
|
|
47
|
-
it('correct number of args', async function () {
|
|
48
|
-
const mi = new MediaInput({}, { SECURITY_ALLOW_UNSAFE: true })
|
|
49
|
-
await mi.setUserInput({ convoStep, args: ['Test1'], meMsg: {}, convo: { sourceTag: { filename: '' } } })
|
|
50
|
-
})
|
|
51
|
-
it('correct number of args with buffer', async function () {
|
|
52
|
-
const mi = new MediaInput()
|
|
53
|
-
await mi.setUserInput({ convoStep, args: ['Test1', Buffer.from('hello')], meMsg: {}, convo: { sourceTag: { filename: '' } } })
|
|
54
|
-
})
|
|
55
|
-
it('wrong number of args', async function () {
|
|
56
|
-
const mi = new MediaInput()
|
|
57
|
-
return mi.setUserInput({ convoStep, args: ['Test1', 'Test2'], meMsg: {} })
|
|
58
|
-
.then(() => assert.fail('expected error'))
|
|
59
|
-
.catch((err) => {
|
|
10
|
+
describe('scripting.userinputs.defaultUserInputs', function () {
|
|
11
|
+
describe('buttonInput', function () {
|
|
12
|
+
it('correct number of args', async function () {
|
|
13
|
+
const bi = new ButtonInput()
|
|
14
|
+
await bi.setUserInput({
|
|
15
|
+
convoStep,
|
|
16
|
+
args: ['Test1'],
|
|
17
|
+
meMsg: {}
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
it('wrong number of args', async function () {
|
|
21
|
+
const bi = new ButtonInput()
|
|
22
|
+
try {
|
|
23
|
+
await bi.setUserInput({
|
|
24
|
+
convoStep,
|
|
25
|
+
args: ['Test1', 'Test2'],
|
|
26
|
+
meMsg: {}
|
|
27
|
+
})
|
|
28
|
+
assert.fail('expected error')
|
|
29
|
+
} catch (err) {
|
|
60
30
|
assert.isDefined(err)
|
|
61
31
|
assert.instanceOf(err, Error)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
it('empty argument list', async function () {
|
|
35
|
+
const bi = new ButtonInput()
|
|
36
|
+
try {
|
|
37
|
+
await bi.setUserInput({
|
|
38
|
+
convoStep,
|
|
39
|
+
meMsg: {}
|
|
40
|
+
})
|
|
41
|
+
assert.fail('expected error')
|
|
42
|
+
} catch (err) {
|
|
69
43
|
assert.isDefined(err)
|
|
70
44
|
assert.instanceOf(err, Error)
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
it('should set button in message as payload', async function () {
|
|
48
|
+
const bi = new ButtonInput()
|
|
49
|
+
|
|
50
|
+
const meMsg = {}
|
|
51
|
+
await bi.setUserInput({
|
|
52
|
+
convoStep,
|
|
53
|
+
args: ['Test1'],
|
|
54
|
+
meMsg
|
|
71
55
|
})
|
|
56
|
+
assert.isArray(meMsg.buttons)
|
|
57
|
+
assert.lengthOf(meMsg.buttons, 1)
|
|
58
|
+
assert.equal(meMsg.buttons[0].payload, 'Test1')
|
|
59
|
+
})
|
|
72
60
|
})
|
|
73
|
-
it('should set media in message', async function () {
|
|
74
|
-
const mi = new MediaInput({}, { SECURITY_ALLOW_UNSAFE: true })
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
62
|
+
describe('mediaInput', function () {
|
|
63
|
+
it('correct number of args', async function () {
|
|
64
|
+
const mi = new MediaInput({}, { SECURITY_ALLOW_UNSAFE: true })
|
|
65
|
+
await mi.setUserInput({
|
|
66
|
+
convoStep,
|
|
67
|
+
args: ['Test1'],
|
|
68
|
+
meMsg: {},
|
|
69
|
+
convo: { sourceTag: { filename: '' } }
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
it('correct number of args with buffer', async function () {
|
|
73
|
+
const mi = new MediaInput()
|
|
74
|
+
await mi.setUserInput({
|
|
75
|
+
convoStep,
|
|
76
|
+
args: ['Test1', Buffer.from('hello')],
|
|
77
|
+
meMsg: {},
|
|
78
|
+
convo: { sourceTag: { filename: '' } }
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
it('wrong number of args', async function () {
|
|
82
|
+
const mi = new MediaInput()
|
|
83
|
+
return mi.setUserInput({
|
|
84
|
+
convoStep,
|
|
85
|
+
args: ['Test1', 'Test2'],
|
|
86
|
+
meMsg: {}
|
|
87
|
+
})
|
|
88
|
+
.then(() => assert.fail('expected error'))
|
|
89
|
+
.catch((err) => {
|
|
90
|
+
assert.isDefined(err)
|
|
91
|
+
assert.instanceOf(err, Error)
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
it('empty argument list', async function () {
|
|
95
|
+
const mi = new MediaInput()
|
|
96
|
+
return mi.setUserInput({
|
|
97
|
+
convoStep,
|
|
98
|
+
meMsg: {}
|
|
99
|
+
})
|
|
100
|
+
.then(() => assert.fail('expected error'))
|
|
101
|
+
.catch((err) => {
|
|
102
|
+
assert.isDefined(err)
|
|
103
|
+
assert.instanceOf(err, Error)
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
it('should set media in message', async function () {
|
|
107
|
+
const mi = new MediaInput({}, { SECURITY_ALLOW_UNSAFE: true })
|
|
83
108
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
assert.instanceOf(err, Error)
|
|
109
|
+
const meMsg = {}
|
|
110
|
+
await mi.setUserInput({
|
|
111
|
+
convoStep,
|
|
112
|
+
args: ['Test1'],
|
|
113
|
+
meMsg,
|
|
114
|
+
convo: {
|
|
115
|
+
sourceTag: {
|
|
116
|
+
convoDir: 'mydir',
|
|
117
|
+
filename: 'myfile.convo.txt'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
96
120
|
})
|
|
121
|
+
assert.isArray(meMsg.media)
|
|
122
|
+
assert.lengthOf(meMsg.media, 1)
|
|
123
|
+
assert.isTrue(meMsg.media[0].downloadUri.endsWith('mydir/Test1'))
|
|
124
|
+
})
|
|
97
125
|
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.
|
|
103
|
-
|
|
104
|
-
|
|
126
|
+
|
|
127
|
+
describe('formInput', function () {
|
|
128
|
+
it('correct number of args', async function () {
|
|
129
|
+
const mi = new FormInput()
|
|
130
|
+
await mi.setUserInput({
|
|
131
|
+
convoStep,
|
|
132
|
+
args: ['NAME1', 'VALUE1'],
|
|
133
|
+
meMsg: {},
|
|
134
|
+
convo: { sourceTag: { filename: '' } }
|
|
105
135
|
})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
136
|
+
})
|
|
137
|
+
it('wrong number of args', async function () {
|
|
138
|
+
const mi = new FormInput()
|
|
139
|
+
return mi.setUserInput({
|
|
140
|
+
convoStep,
|
|
141
|
+
args: [],
|
|
142
|
+
meMsg: {}
|
|
143
|
+
})
|
|
144
|
+
.then(() => assert.fail('expected error'))
|
|
145
|
+
.catch((err) => {
|
|
146
|
+
assert.isDefined(err)
|
|
147
|
+
assert.instanceOf(err, Error)
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
it('empty argument list', async function () {
|
|
151
|
+
const mi = new FormInput()
|
|
152
|
+
return mi.setUserInput({
|
|
153
|
+
convoStep,
|
|
154
|
+
meMsg: {}
|
|
155
|
+
})
|
|
156
|
+
.then(() => assert.fail('expected error'))
|
|
157
|
+
.catch((err) => {
|
|
158
|
+
assert.isDefined(err)
|
|
159
|
+
assert.instanceOf(err, Error)
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
it('should set form boolean in message', async function () {
|
|
163
|
+
const mi = new FormInput()
|
|
109
164
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
165
|
+
const meMsg = {}
|
|
166
|
+
await mi.setUserInput({
|
|
167
|
+
convoStep,
|
|
168
|
+
args: ['NAME1'],
|
|
169
|
+
meMsg,
|
|
170
|
+
convo: {
|
|
171
|
+
sourceTag: {
|
|
172
|
+
convoDir: 'mydir',
|
|
173
|
+
filename: 'myfile.convo.txt'
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
assert.isArray(meMsg.forms)
|
|
178
|
+
assert.lengthOf(meMsg.forms, 1)
|
|
179
|
+
assert.equal(meMsg.forms[0].name, 'NAME1')
|
|
180
|
+
assert.isTrue(meMsg.forms[0].value)
|
|
181
|
+
})
|
|
182
|
+
it('should set form value in message', async function () {
|
|
183
|
+
const mi = new FormInput()
|
|
119
184
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
185
|
+
const meMsg = {}
|
|
186
|
+
await mi.setUserInput({
|
|
187
|
+
convoStep,
|
|
188
|
+
args: ['NAME1', 'VALUE1'],
|
|
189
|
+
meMsg,
|
|
190
|
+
convo: {
|
|
191
|
+
sourceTag: {
|
|
192
|
+
convoDir: 'mydir',
|
|
193
|
+
filename: 'myfile.convo.txt'
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
assert.isArray(meMsg.forms)
|
|
198
|
+
assert.lengthOf(meMsg.forms, 1)
|
|
199
|
+
assert.equal(meMsg.forms[0].name, 'NAME1')
|
|
200
|
+
assert.equal(meMsg.forms[0].value, 'VALUE1')
|
|
201
|
+
})
|
|
202
|
+
it('should set form values in message', async function () {
|
|
203
|
+
const mi = new FormInput()
|
|
129
204
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
205
|
+
const meMsg = {}
|
|
206
|
+
await mi.setUserInput({
|
|
207
|
+
convoStep,
|
|
208
|
+
args: ['NAME1', 'VALUE1', 'VALUE2'],
|
|
209
|
+
meMsg,
|
|
210
|
+
convo: {
|
|
211
|
+
sourceTag: {
|
|
212
|
+
convoDir: 'mydir',
|
|
213
|
+
filename: 'myfile.convo.txt'
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
assert.isArray(meMsg.forms)
|
|
218
|
+
assert.lengthOf(meMsg.forms, 1)
|
|
219
|
+
assert.equal(meMsg.forms[0].name, 'NAME1')
|
|
220
|
+
assert.isArray(meMsg.forms[0].value)
|
|
221
|
+
assert.lengthOf(meMsg.forms[0].value, 2)
|
|
222
|
+
assert.equal(meMsg.forms[0].value[0], 'VALUE1')
|
|
223
|
+
assert.equal(meMsg.forms[0].value[1], 'VALUE2')
|
|
224
|
+
})
|
|
225
|
+
it('should set multiple form value in message', async function () {
|
|
226
|
+
const mi = new FormInput()
|
|
142
227
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
228
|
+
const meMsg = {}
|
|
229
|
+
await mi.setUserInput({
|
|
230
|
+
convoStep,
|
|
231
|
+
args: ['NAME1', 'VALUE1'],
|
|
232
|
+
meMsg,
|
|
233
|
+
convo: {
|
|
234
|
+
sourceTag: {
|
|
235
|
+
convoDir: 'mydir',
|
|
236
|
+
filename: 'myfile.convo.txt'
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
})
|
|
240
|
+
await mi.setUserInput({
|
|
241
|
+
convoStep,
|
|
242
|
+
args: ['NAME2', 'VALUE2'],
|
|
243
|
+
meMsg,
|
|
244
|
+
convo: {
|
|
245
|
+
sourceTag: {
|
|
246
|
+
convoDir: 'mydir',
|
|
247
|
+
filename: 'myfile.convo.txt'
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
assert.isArray(meMsg.forms)
|
|
252
|
+
assert.lengthOf(meMsg.forms, 2)
|
|
253
|
+
assert.equal(meMsg.forms[0].name, 'NAME1')
|
|
254
|
+
assert.equal(meMsg.forms[0].value, 'VALUE1')
|
|
255
|
+
assert.equal(meMsg.forms[1].name, 'NAME2')
|
|
256
|
+
assert.equal(meMsg.forms[1].value, 'VALUE2')
|
|
257
|
+
})
|
|
152
258
|
})
|
|
153
259
|
})
|