botium-core 1.13.0 → 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 (57) hide show
  1. package/.eslintrc.js +6 -3
  2. package/dist/botium-cjs.js +305 -123
  3. package/dist/botium-cjs.js.map +1 -1
  4. package/dist/botium-es.js +323 -142
  5. package/dist/botium-es.js.map +1 -1
  6. package/package.json +17 -15
  7. package/src/Capabilities.js +2 -1
  8. package/src/containers/plugins/SimpleRestContainer.js +23 -16
  9. package/src/grid/inbound/proxy.js +2 -1
  10. package/src/helpers/RetryHelper.js +13 -7
  11. package/src/scripting/Convo.js +36 -10
  12. package/src/scripting/MatchFunctions.js +10 -0
  13. package/src/scripting/ScriptingProvider.js +106 -37
  14. package/src/scripting/logichook/LogicHookConsts.js +1 -1
  15. package/src/scripting/logichook/LogicHookUtils.js +1 -1
  16. package/src/scripting/logichook/asserter/WerAsserter.js +59 -0
  17. package/src/scripting/logichook/logichooks/UpdateCustomLogicHook.js +3 -2
  18. package/test/compiler/compilercsv.spec.js +104 -3
  19. package/test/compiler/compilerjson.spec.js +0 -2
  20. package/test/compiler/compilerxlsx.spec.js +1 -1
  21. package/test/compiler/convos/csv/utterances_liveperson2.csv +12 -0
  22. package/test/connectors/simplerest.spec.js +1012 -969
  23. package/test/convo/fillAndApplyScriptingMemory.spec.js +804 -785
  24. package/test/convo/partialconvo.spec.js +345 -339
  25. package/test/convo/retryconvo.spec.js +134 -0
  26. package/test/driver/capabilities.spec.js +156 -151
  27. package/test/logichooks/hookfromsrc.spec.js +79 -73
  28. package/test/plugins/plugins.spec.js +44 -42
  29. package/test/scripting/asserters/buttonsAsserter.spec.js +257 -240
  30. package/test/scripting/asserters/cardsAsserter.spec.js +214 -212
  31. package/test/scripting/asserters/convos/wer_threshold_nok.yml +7 -0
  32. package/test/scripting/asserters/convos/wer_threshold_ok.yml +7 -0
  33. package/test/scripting/asserters/intentConfidenceAsserter.spec.js +34 -35
  34. package/test/scripting/asserters/jsonpathAsserter.spec.js +307 -308
  35. package/test/scripting/asserters/mediaAsserter.spec.js +236 -234
  36. package/test/scripting/asserters/werAsserter.spec.js +51 -0
  37. package/test/scripting/logichooks/setClearScriptingMemory.spec.js +202 -192
  38. package/test/scripting/matching/matchingmode.spec.js +306 -258
  39. package/test/scripting/scriptingProvider.spec.js +666 -633
  40. package/test/scripting/scriptingmemory/fillScriptingMemoryFromFile.spec.js +299 -281
  41. package/test/scripting/scriptingmemory/useScriptingMemoryForAssertion.spec.js +94 -80
  42. package/test/scripting/userinputs/defaultUserInputs.spec.js +233 -127
  43. package/test/scripting/userinputs/mediaInputConvos.spec.js +409 -403
  44. package/test/scripting/utteranceexpansion/associateByIndex.spec.js +259 -0
  45. package/test/scripting/utteranceexpansion/convos/associate_utterances_by_index.json +33 -0
  46. package/test/scripting/utteranceexpansion/convos/media.convo.txt +19 -0
  47. package/test/scripting/utteranceexpansion/files/step0voice0.wav +0 -0
  48. package/test/scripting/utteranceexpansion/files/step0voice1.wav +0 -0
  49. package/test/scripting/utteranceexpansion/files/step0voice2.wav +0 -0
  50. package/test/scripting/utteranceexpansion/files/step1voice0.wav +0 -0
  51. package/test/scripting/utteranceexpansion/files/step2voice0.wav +0 -0
  52. package/test/scripting/utteranceexpansion/files/step2voice1.wav +0 -0
  53. package/test/scripting/utteranceexpansion/files/step2voice2.wav +0 -0
  54. package/test/scripting/utteranceexpansion/files/step2voice4.wav +0 -0
  55. package/test/scripting/utteranceexpansion/files/step2voice5.wav +0 -0
  56. package/test/security/allowUnsafe.spec.js +274 -268
  57. 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 = { sender: 'bot', sourceData: msg.sourceData, messageText: response }
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 = { sender: 'bot', sourceData: msg.sourceData, messageText: response }
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 = { sender: 'bot', sourceData: msg.sourceData, messageText: response }
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.simpleassertion', function () {
41
- beforeEach(async function () {
42
- const myCaps = {
43
- [Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
44
- [Capabilities.CONTAINERMODE]: echoAssertConnector,
45
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
46
- }
47
- const driver = new BotDriver(myCaps)
48
- this.compiler = driver.BuildCompiler()
49
- this.container = await driver.Build()
50
- })
51
- afterEach(async function () {
52
- this.container && await this.container.Clean()
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
- it('should use scripting memory for assertion', async function () {
56
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosAssertion'))
57
- this.compiler.ExpandScriptingMemoryToConvos()
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
- try {
60
- await this.compiler.convos[0].Run(this.container)
61
- assert.fail('should have failed')
62
- } catch (err) {
63
- assert.isTrue(err.message.indexOf('Bot response (on Line 3: #me - $productName $customer) "OUTPUT1 OUTPUT2" expected to match "forcereplace1 forcereplace2"') >= 0)
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('scripting.useScriptingMemoryForAssertion.multiplefiles', function () {
69
- beforeEach(async function () {
70
- const myCaps = {
71
- [Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
72
- [Capabilities.CONTAINERMODE]: echoShopConnector,
73
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
74
- [Capabilities.SCRIPTING_MEMORY_MATCHING_MODE]: 'joker'
75
- }
76
- const driver = new BotDriver(myCaps)
77
- this.compiler = driver.BuildCompiler()
78
- this.container = await driver.Build()
79
- })
80
- afterEach(async function () {
81
- this.container && await this.container.Clean()
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
- it('should use scripting memory for assertion', async function () {
85
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemory', 'convos'))
86
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'convosMultiMemory', 'memory1'))
87
- this.compiler.ExpandScriptingMemoryToConvos()
88
- assert.lengthOf(this.compiler.convos, 2)
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
- const transcript0 = await this.compiler.convos[0].Run(this.container)
91
- assert.lengthOf(transcript0.steps, 4)
92
- assert.equal(transcript0.steps[0].scriptingMemory.$available_products, 'Bread, Beer, Eggs')
93
- assert.equal(transcript0.steps[0].scriptingMemory.$productName, 'Bread')
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
- const transcript1 = await this.compiler.convos[1].Run(this.container)
96
- assert.lengthOf(transcript1.steps, 4)
97
- assert.equal(transcript1.steps[0].scriptingMemory.$available_products, 'Bread, Beer, Eggs')
98
- assert.equal(transcript1.steps[0].scriptingMemory.$productName, 'Beer')
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('scripting.useScriptingMemoryForAssertion.multipleVariableEntries', function () {
103
- beforeEach(async function () {
104
- const myCaps = {
105
- [Capabilities.PROJECTNAME]: 'scripting.scriptingmemory',
106
- [Capabilities.CONTAINERMODE]: multipleVariableEntriesConnector,
107
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
108
- }
109
- const driver = new BotDriver(myCaps)
110
- this.compiler = driver.BuildCompiler()
111
- this.container = await driver.Build()
112
- })
113
- afterEach(async function () {
114
- this.container && await this.container.Clean()
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
- it('should use scripting memory for assertion several variables entries', async function () {
118
- // scripting variables replaced in every entry
119
- this.compiler.ReadScriptsFromDirectory(path.resolve(__dirname, 'scriptingVariablesSeveralEntries'))
120
- assert.equal(this.compiler.convos.length, 1)
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
- try {
123
- await this.compiler.convos[0].Run(this.container)
124
- assert.fail('should have failed')
125
- } catch (err) {
126
- 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)
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('UserInputs.defaults.buttonInput', function () {
11
- it('correct number of args', async function () {
12
- const bi = new ButtonInput()
13
- await bi.setUserInput({ convoStep, args: ['Test1'], meMsg: {} })
14
- })
15
- it('wrong number of args', async function () {
16
- const bi = new ButtonInput()
17
- try {
18
- await bi.setUserInput({ convoStep, args: ['Test1', 'Test2'], meMsg: {} })
19
- assert.fail('expected error')
20
- } catch (err) {
21
- assert.isDefined(err)
22
- assert.instanceOf(err, Error)
23
- }
24
- })
25
- it('empty argument list', async function () {
26
- const bi = new ButtonInput()
27
- try {
28
- await bi.setUserInput({ convoStep, meMsg: {} })
29
- assert.fail('expected error')
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
- it('empty argument list', async function () {
65
- const mi = new MediaInput()
66
- return mi.setUserInput({ convoStep, meMsg: {} })
67
- .then(() => assert.fail('expected error'))
68
- .catch((err) => {
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
- const meMsg = {}
77
- await mi.setUserInput({ convoStep, args: ['Test1'], meMsg, convo: { sourceTag: { convoDir: 'mydir', filename: 'myfile.convo.txt' } } })
78
- assert.isArray(meMsg.media)
79
- assert.lengthOf(meMsg.media, 1)
80
- assert.isTrue(meMsg.media[0].downloadUri.endsWith('mydir/Test1'))
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
- describe('UserInputs.defaults.formInput', function () {
85
- it('correct number of args', async function () {
86
- const mi = new FormInput()
87
- await mi.setUserInput({ convoStep, args: ['NAME1', 'VALUE1'], meMsg: {}, convo: { sourceTag: { filename: '' } } })
88
- })
89
- it('wrong number of args', async function () {
90
- const mi = new FormInput()
91
- return mi.setUserInput({ convoStep, args: [], meMsg: {} })
92
- .then(() => assert.fail('expected error'))
93
- .catch((err) => {
94
- assert.isDefined(err)
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
- it('empty argument list', async function () {
99
- const mi = new FormInput()
100
- return mi.setUserInput({ convoStep, meMsg: {} })
101
- .then(() => assert.fail('expected error'))
102
- .catch((err) => {
103
- assert.isDefined(err)
104
- assert.instanceOf(err, Error)
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
- it('should set form boolean in message', async function () {
108
- const mi = new FormInput()
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
- const meMsg = {}
111
- await mi.setUserInput({ convoStep, args: ['NAME1'], meMsg, convo: { sourceTag: { convoDir: 'mydir', filename: 'myfile.convo.txt' } } })
112
- assert.isArray(meMsg.forms)
113
- assert.lengthOf(meMsg.forms, 1)
114
- assert.equal(meMsg.forms[0].name, 'NAME1')
115
- assert.isTrue(meMsg.forms[0].value)
116
- })
117
- it('should set form value in message', async function () {
118
- const mi = new FormInput()
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
- const meMsg = {}
121
- await mi.setUserInput({ convoStep, args: ['NAME1', 'VALUE1'], meMsg, convo: { sourceTag: { convoDir: 'mydir', filename: 'myfile.convo.txt' } } })
122
- assert.isArray(meMsg.forms)
123
- assert.lengthOf(meMsg.forms, 1)
124
- assert.equal(meMsg.forms[0].name, 'NAME1')
125
- assert.equal(meMsg.forms[0].value, 'VALUE1')
126
- })
127
- it('should set form values in message', async function () {
128
- const mi = new FormInput()
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
- const meMsg = {}
131
- await mi.setUserInput({ convoStep, args: ['NAME1', 'VALUE1', 'VALUE2'], meMsg, convo: { sourceTag: { convoDir: 'mydir', filename: 'myfile.convo.txt' } } })
132
- assert.isArray(meMsg.forms)
133
- assert.lengthOf(meMsg.forms, 1)
134
- assert.equal(meMsg.forms[0].name, 'NAME1')
135
- assert.isArray(meMsg.forms[0].value)
136
- assert.lengthOf(meMsg.forms[0].value, 2)
137
- assert.equal(meMsg.forms[0].value[0], 'VALUE1')
138
- assert.equal(meMsg.forms[0].value[1], 'VALUE2')
139
- })
140
- it('should set multiple form value in message', async function () {
141
- const mi = new FormInput()
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
- const meMsg = {}
144
- await mi.setUserInput({ convoStep, args: ['NAME1', 'VALUE1'], meMsg, convo: { sourceTag: { convoDir: 'mydir', filename: 'myfile.convo.txt' } } })
145
- await mi.setUserInput({ convoStep, args: ['NAME2', 'VALUE2'], meMsg, convo: { sourceTag: { convoDir: 'mydir', filename: 'myfile.convo.txt' } } })
146
- assert.isArray(meMsg.forms)
147
- assert.lengthOf(meMsg.forms, 2)
148
- assert.equal(meMsg.forms[0].name, 'NAME1')
149
- assert.equal(meMsg.forms[0].value, 'VALUE1')
150
- assert.equal(meMsg.forms[1].name, 'NAME2')
151
- assert.equal(meMsg.forms[1].value, 'VALUE2')
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
  })