botium-core 1.14.8 → 1.14.9
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 +9 -8
- package/dist/botium-cjs.js.map +1 -1
- package/dist/botium-es.js +9 -8
- package/dist/botium-es.js.map +1 -1
- package/package.json +1 -1
- package/src/scripting/Convo.js +5 -1
- package/src/scripting/helper.js +4 -7
- package/test/convo/convos/welcome_multiple_botsteps_opt.convo.txt +22 -0
- package/test/convo/transcript.spec.js +54 -0
- package/test/scripting/asserters/convoStepParameters.spec.js +6 -0
- package/test/scripting/asserters/convos/convo_step_parameter_optional_with_timeout.convo.txt +16 -0
- package/test/scripting/txt/decompile.spec.js +0 -25
package/package.json
CHANGED
package/src/scripting/Convo.js
CHANGED
|
@@ -416,7 +416,7 @@ class Convo {
|
|
|
416
416
|
await this.scriptingEvents.onBotStart({ convo: this, convoStep, container, scriptingMemory, transcript, transcriptStep })
|
|
417
417
|
transcriptStep.botBegin = new Date()
|
|
418
418
|
if (!botMsg) {
|
|
419
|
-
botMsg = await container.WaitBotSays(convoStep.channel)
|
|
419
|
+
botMsg = await container.WaitBotSays(convoStep.channel, convoStepParameters?.stepTimeout)
|
|
420
420
|
}
|
|
421
421
|
transcriptStep.botEnd = new Date()
|
|
422
422
|
transcriptStep.actual = new BotiumMockMessage(botMsg)
|
|
@@ -426,6 +426,10 @@ class Convo {
|
|
|
426
426
|
} catch (err) {
|
|
427
427
|
transcriptStep.botEnd = new Date()
|
|
428
428
|
|
|
429
|
+
if (convoStep.optional) {
|
|
430
|
+
continue
|
|
431
|
+
}
|
|
432
|
+
|
|
429
433
|
const failErr = botiumErrorFromErr(`${this.header.name}/${convoStep.stepTag}: error waiting for bot - ${err.message}`, err)
|
|
430
434
|
debug(failErr)
|
|
431
435
|
try {
|
package/src/scripting/helper.js
CHANGED
|
@@ -404,13 +404,6 @@ const validateConvo = (convo) => {
|
|
|
404
404
|
if (optionalSet.size > 1) {
|
|
405
405
|
validationResult.errors.push(new Error(`Step ${i + 1}: Failed to decompile conversation. Mixed optional flag is not allowed inside one step.`))
|
|
406
406
|
}
|
|
407
|
-
|
|
408
|
-
if (optionalSet.size === 1 && optionalSet.has(true)) {
|
|
409
|
-
const nextStep = convo.conversation[i + 1]
|
|
410
|
-
if (!nextStep || nextStep.sender !== 'bot') {
|
|
411
|
-
validationResult.errors.push(new Error(`Step ${i + 1}: Optional bot convo step has to be followed by a bot convo step.`))
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
407
|
}
|
|
415
408
|
if (!validateSender(step.sender)) {
|
|
416
409
|
validationResult.errors.push(new Error(`Step ${i + 1}: Sender #${step.sender} is invalid.`))
|
|
@@ -456,6 +449,10 @@ const convoStepToLines = (step) => {
|
|
|
456
449
|
} else {
|
|
457
450
|
if (step.messageText) {
|
|
458
451
|
lines.push((step.optional ? '?' : '') + (step.not ? '!' : '') + step.messageText)
|
|
452
|
+
} else {
|
|
453
|
+
if (step.optional) {
|
|
454
|
+
lines.push('?')
|
|
455
|
+
}
|
|
459
456
|
}
|
|
460
457
|
if (step.buttons && step.buttons.length > 0) lines.push('BUTTONS' + _formatAppendArgs(step.buttons.filter(b => b.text).map(b => flatString(b.text))))
|
|
461
458
|
if (step.media && step.media.length > 0) lines.push('MEDIA' + _formatAppendArgs(step.media.filter(m => !m.buffer && m.mediaUri).map(m => m.mediaUri)))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
welcome multiple botsteps opt
|
|
2
|
+
|
|
3
|
+
#me
|
|
4
|
+
Welcome
|
|
5
|
+
|
|
6
|
+
#bot
|
|
7
|
+
Welcome
|
|
8
|
+
|
|
9
|
+
#bot
|
|
10
|
+
?Select an option:
|
|
11
|
+
CONVO_STEP_PARAMETERS {"stepTimeout": 300}
|
|
12
|
+
|
|
13
|
+
#bot
|
|
14
|
+
?
|
|
15
|
+
?BUTTONS First Button|Second Button
|
|
16
|
+
CONVO_STEP_PARAMETERS {"stepTimeout": 300}
|
|
17
|
+
|
|
18
|
+
#me
|
|
19
|
+
Thanks
|
|
20
|
+
|
|
21
|
+
#bot
|
|
22
|
+
Thanks
|
|
@@ -21,6 +21,34 @@ const echoConnector = ({ queueBotSays }) => {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const echoConnectorMultipleBotMessages = ({ queueBotSays }) => {
|
|
25
|
+
return {
|
|
26
|
+
UserSays (msg) {
|
|
27
|
+
const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
|
|
28
|
+
if (msg.messageText === 'Welcome') {
|
|
29
|
+
botMsg.messageText = 'Welcome'
|
|
30
|
+
queueBotSays(botMsg)
|
|
31
|
+
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
botMsg.messageText = 'Select an option:'
|
|
34
|
+
queueBotSays(botMsg)
|
|
35
|
+
}, 200)
|
|
36
|
+
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
botMsg.messageText = ''
|
|
39
|
+
botMsg.buttons = [
|
|
40
|
+
{ text: 'First Button' },
|
|
41
|
+
{ text: 'Second Button' }
|
|
42
|
+
]
|
|
43
|
+
queueBotSays(botMsg)
|
|
44
|
+
}, 200)
|
|
45
|
+
} else {
|
|
46
|
+
queueBotSays(botMsg)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
24
52
|
describe('convo.transcript', function () {
|
|
25
53
|
beforeEach(async function () {
|
|
26
54
|
const myCaps = {
|
|
@@ -54,6 +82,16 @@ describe('convo.transcript', function () {
|
|
|
54
82
|
this.compilerSkipAssertErrors = this.driverSkipAssertErrors.BuildCompiler()
|
|
55
83
|
this.containerSkipAssertErrors = await this.driverSkipAssertErrors.Build()
|
|
56
84
|
await this.containerSkipAssertErrors.Start()
|
|
85
|
+
|
|
86
|
+
const myCapsMultipleBotMessages = {
|
|
87
|
+
[Capabilities.PROJECTNAME]: 'convo.transcript',
|
|
88
|
+
[Capabilities.CONTAINERMODE]: echoConnectorMultipleBotMessages,
|
|
89
|
+
[Capabilities.SCRIPTING_FORCE_BOT_CONSUMED]: true
|
|
90
|
+
}
|
|
91
|
+
this.driverMultipleBotmessages = new BotDriver(myCapsMultipleBotMessages)
|
|
92
|
+
this.compilerMultipleBotmessages = this.driverMultipleBotmessages.BuildCompiler()
|
|
93
|
+
this.containerMultipleBotmessages = await this.driverMultipleBotmessages.Build()
|
|
94
|
+
await this.containerMultipleBotmessages.Start()
|
|
57
95
|
})
|
|
58
96
|
afterEach(async function () {
|
|
59
97
|
await this.container.Stop()
|
|
@@ -143,6 +181,22 @@ describe('convo.transcript', function () {
|
|
|
143
181
|
assert.isDefined(transcript)
|
|
144
182
|
assert.equal(transcript.steps.length, 2)
|
|
145
183
|
})
|
|
184
|
+
it('should provide transcript optional multiple bot steps on getting all bot messages', async function () {
|
|
185
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'welcome_multiple_botsteps_opt.convo.txt')
|
|
186
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
187
|
+
|
|
188
|
+
const transcript = await this.compiler.convos[0].Run(this.containerMultipleBotmessages)
|
|
189
|
+
assert.isDefined(transcript)
|
|
190
|
+
assert.equal(transcript.steps.length, 6)
|
|
191
|
+
})
|
|
192
|
+
it('should provide transcript optional multiple bot steps on not getting all bot messages', async function () {
|
|
193
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'welcome_multiple_botsteps_opt.convo.txt')
|
|
194
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
195
|
+
|
|
196
|
+
const transcript = await this.compiler.convos[0].Run(this.container)
|
|
197
|
+
assert.isDefined(transcript)
|
|
198
|
+
assert.equal(transcript.steps.length, 6)
|
|
199
|
+
})
|
|
146
200
|
it('should include pause in transcript steps', async function () {
|
|
147
201
|
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), '2stepsWithPause.convo.txt')
|
|
148
202
|
assert.equal(this.compiler.convos.length, 1)
|
|
@@ -84,6 +84,12 @@ describe('scripting.asserters.convoStepParametersForAssert', function () {
|
|
|
84
84
|
|
|
85
85
|
await this.compiler.convos[0].Run(this.container)
|
|
86
86
|
})
|
|
87
|
+
it('should skip optional bot message', async function () {
|
|
88
|
+
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'convo_step_parameter_optional_with_timeout.convo.txt')
|
|
89
|
+
assert.equal(this.compiler.convos.length, 1)
|
|
90
|
+
|
|
91
|
+
await this.compiler.convos[0].Run(this.container)
|
|
92
|
+
})
|
|
87
93
|
it('should retry until succesful asserters', async function () {
|
|
88
94
|
this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'convo_step_parameter_retry_asserters_good.convo.txt')
|
|
89
95
|
assert.equal(this.compiler.convos.length, 1)
|
|
@@ -126,31 +126,6 @@ botText2
|
|
|
126
126
|
`
|
|
127
127
|
)
|
|
128
128
|
})
|
|
129
|
-
it('should fail decompile convo with optional step not followed bot step', async function () {
|
|
130
|
-
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
131
|
-
await scriptingProvider.Build()
|
|
132
|
-
|
|
133
|
-
const convo = {
|
|
134
|
-
header: {
|
|
135
|
-
name: 'test convo'
|
|
136
|
-
},
|
|
137
|
-
conversation: [
|
|
138
|
-
{
|
|
139
|
-
sender: 'bot',
|
|
140
|
-
messageText: 'botText',
|
|
141
|
-
not: true,
|
|
142
|
-
optional: true
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
scriptingProvider.Decompile([convo], 'SCRIPTING_FORMAT_TXT')
|
|
149
|
-
assert.fail('expected error')
|
|
150
|
-
} catch (err) {
|
|
151
|
-
assert.equal(err.message, 'Step 1: Optional bot convo step has to be followed by a bot convo step.')
|
|
152
|
-
}
|
|
153
|
-
})
|
|
154
129
|
it('should fail decompile convo with mixed optional step', async function () {
|
|
155
130
|
const scriptingProvider = new ScriptingProvider(DefaultCapabilities)
|
|
156
131
|
await scriptingProvider.Build()
|