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
@@ -8,442 +8,448 @@ const Capabilities = require('../../../').Capabilities
8
8
  const echoConnector = ({ queueBotSays }) => {
9
9
  return {
10
10
  UserSays (msg) {
11
- const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText }
11
+ const botMsg = {
12
+ sender: 'bot',
13
+ sourceData: msg.sourceData,
14
+ messageText: msg.messageText
15
+ }
12
16
  queueBotSays(botMsg)
13
17
  }
14
18
  }
15
19
  }
16
20
 
17
- describe('scripting.userinputs.mediaInputConvos.relative', function () {
18
- beforeEach(async function () {
19
- const myCaps = {
20
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
21
- [Capabilities.CONTAINERMODE]: echoConnector,
22
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
23
- }
24
- const driver = new BotDriver(myCaps)
25
- this.compiler = driver.BuildCompiler()
26
- this.container = await driver.Build()
27
- })
28
- afterEach(async function () {
29
- this.container && await this.container.Clean()
30
- })
31
-
32
- it('should fail on media with no arg', async function () {
33
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediaNoArg.convo.txt')
34
- try {
35
- await this.compiler.convos[0].Run(this.container)
36
- assert.fail('it should have failed')
37
- } catch (err) {
38
- assert.isTrue(err.message.indexOf('Line 3: MediaInput requires at least 1 and at most 2 arguments') > 0)
39
- }
40
- })
41
-
42
- it('should add media in user message', async function () {
43
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
44
- assert.equal(this.compiler.convos.length, 1)
45
- assert.equal(this.compiler.convos[0].conversation.length, 1)
46
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
47
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
48
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
49
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'botium.png')
50
-
51
- const transcript = await this.compiler.convos[0].Run(this.container)
52
- assert.equal(transcript.steps.length, 1)
53
- assert.equal(transcript.steps[0].actual.media.length, 1)
54
- assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('test/scripting/userinputs/convos/botium.png'))
55
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
56
- })
57
-
58
- it('should fail when media is out of convo dir', async function () {
59
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediaOutOfConvoDir.convo.txt')
60
-
61
- try {
62
- await this.compiler.convos[0].Run(this.container)
63
- assert.fail('expected error')
64
- } catch (err) {
65
- assert.isTrue(err.message.startsWith('mediaoutofconvodir/Line 3: error sending to bot - The uri \'../botium.png\' is pointing out of the base directory'))
66
- }
67
- })
68
-
69
- it('should add multi media in user message', async function () {
70
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'medias.convo.txt')
71
-
72
- const transcript = await this.compiler.convos[0].Run(this.container)
73
- assert.equal(transcript.steps.length, 1)
74
- assert.equal(transcript.steps[0].actual.media.length, 2)
75
- assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('test/scripting/userinputs/convos/test1.jpg'))
76
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/jpeg')
77
- assert.isTrue(transcript.steps[0].actual.media[1].downloadUri.endsWith('test/scripting/userinputs/convos/test2.jpg'))
78
- assert.equal(transcript.steps[0].actual.media[1].mimeType, 'image/jpeg')
79
- })
80
- it('should expand media list in user message', async function () {
81
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'medialist.convo.txt')
82
- this.compiler.ExpandConvos()
83
- assert.equal(this.compiler.convos.length, 3)
84
- assert.equal(this.compiler.convos[0].conversation.length, 1)
85
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
86
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'test1.jpg')
87
- assert.equal(this.compiler.convos[1].conversation[0].userInputs[0].args[0], 'test2.jpg')
88
- assert.equal(this.compiler.convos[2].conversation[0].userInputs[0].args[0], 'test3.jpg')
89
- })
90
- it('should expand media wc from convoDir in user message', async function () {
91
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediawc.convo.txt')
92
- this.compiler.ExpandConvos()
93
- assert.equal(this.compiler.convos.length, 3)
94
- assert.equal(this.compiler.convos[0].conversation.length, 1)
95
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
96
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'files/botium0.png')
97
- assert.equal(this.compiler.convos[1].conversation[0].userInputs[0].args[0], 'files/botium1.png')
98
- assert.equal(this.compiler.convos[2].conversation[0].userInputs[0].args[0], 'files/botium2.png')
99
- })
100
-
101
- it('should use dataUri as media in user message', async function () {
102
- const mediaData = fs.readFileSync(path.resolve(__dirname, 'convos', 'files', 'botium0.png'))
103
- const mediaUri = `data:image/png;base64,${mediaData.toString('base64')}`
104
- const script = `should use dataUri as media in user message
21
+ describe('scripting.userinputs.mediaInputConvos', function () {
22
+ describe('relative', function () {
23
+ beforeEach(async function () {
24
+ const myCaps = {
25
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
26
+ [Capabilities.CONTAINERMODE]: echoConnector,
27
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
28
+ }
29
+ const driver = new BotDriver(myCaps)
30
+ this.compiler = driver.BuildCompiler()
31
+ this.container = await driver.Build()
32
+ })
33
+ afterEach(async function () {
34
+ this.container && await this.container.Clean()
35
+ })
36
+
37
+ it('should fail on media with no arg', async function () {
38
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediaNoArg.convo.txt')
39
+ try {
40
+ await this.compiler.convos[0].Run(this.container)
41
+ assert.fail('it should have failed')
42
+ } catch (err) {
43
+ assert.isTrue(err.message.indexOf('Line 3: MediaInput requires at least 1 and at most 2 arguments') > 0)
44
+ }
45
+ })
46
+
47
+ it('should add media in user message', async function () {
48
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
49
+ assert.equal(this.compiler.convos.length, 1)
50
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
51
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
52
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
53
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
54
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'botium.png')
55
+
56
+ const transcript = await this.compiler.convos[0].Run(this.container)
57
+ assert.equal(transcript.steps.length, 1)
58
+ assert.equal(transcript.steps[0].actual.media.length, 1)
59
+ assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('test/scripting/userinputs/convos/botium.png'))
60
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
61
+ })
62
+
63
+ it('should fail when media is out of convo dir', async function () {
64
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediaOutOfConvoDir.convo.txt')
65
+
66
+ try {
67
+ await this.compiler.convos[0].Run(this.container)
68
+ assert.fail('expected error')
69
+ } catch (err) {
70
+ assert.isTrue(err.message.startsWith('mediaoutofconvodir/Line 3: error sending to bot - The uri \'../botium.png\' is pointing out of the base directory'))
71
+ }
72
+ })
73
+
74
+ it('should add multi media in user message', async function () {
75
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'medias.convo.txt')
76
+
77
+ const transcript = await this.compiler.convos[0].Run(this.container)
78
+ assert.equal(transcript.steps.length, 1)
79
+ assert.equal(transcript.steps[0].actual.media.length, 2)
80
+ assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('test/scripting/userinputs/convos/test1.jpg'))
81
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/jpeg')
82
+ assert.isTrue(transcript.steps[0].actual.media[1].downloadUri.endsWith('test/scripting/userinputs/convos/test2.jpg'))
83
+ assert.equal(transcript.steps[0].actual.media[1].mimeType, 'image/jpeg')
84
+ })
85
+ it('should expand media list in user message', async function () {
86
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'medialist.convo.txt')
87
+ this.compiler.ExpandConvos()
88
+ assert.equal(this.compiler.convos.length, 3)
89
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
90
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
91
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'test1.jpg')
92
+ assert.equal(this.compiler.convos[1].conversation[0].userInputs[0].args[0], 'test2.jpg')
93
+ assert.equal(this.compiler.convos[2].conversation[0].userInputs[0].args[0], 'test3.jpg')
94
+ })
95
+ it('should expand media wc from convoDir in user message', async function () {
96
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediawc.convo.txt')
97
+ this.compiler.ExpandConvos()
98
+ assert.equal(this.compiler.convos.length, 3)
99
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
100
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
101
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'files/botium0.png')
102
+ assert.equal(this.compiler.convos[1].conversation[0].userInputs[0].args[0], 'files/botium1.png')
103
+ assert.equal(this.compiler.convos[2].conversation[0].userInputs[0].args[0], 'files/botium2.png')
104
+ })
105
+
106
+ it('should use dataUri as media in user message', async function () {
107
+ const mediaData = fs.readFileSync(path.resolve(__dirname, 'convos', 'files', 'botium0.png'))
108
+ const mediaUri = `data:image/png;base64,${mediaData.toString('base64')}`
109
+ const script = `should use dataUri as media in user message
105
110
 
106
111
  #me
107
112
  MEDIA ${mediaUri}
108
113
  `
109
114
 
110
- this.compiler.Compile(script, 'SCRIPTING_FORMAT_TXT', 'SCRIPTING_TYPE_CONVO')
111
- assert.equal(this.compiler.convos.length, 1)
112
- assert.equal(this.compiler.convos[0].conversation.length, 1)
113
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
114
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
115
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
116
- assert.isTrue(this.compiler.convos[0].conversation[0].userInputs[0].args[0].startsWith('data:image/png'))
117
-
118
- const transcript = await this.compiler.convos[0].Run(this.container)
119
- assert.equal(transcript.steps.length, 1)
120
- assert.equal(transcript.steps[0].actual.media.length, 1)
121
- assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.startsWith('data:image/png'))
122
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
115
+ this.compiler.Compile(script, 'SCRIPTING_FORMAT_TXT', 'SCRIPTING_TYPE_CONVO')
116
+ assert.equal(this.compiler.convos.length, 1)
117
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
118
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
119
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
120
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
121
+ assert.isTrue(this.compiler.convos[0].conversation[0].userInputs[0].args[0].startsWith('data:image/png'))
122
+
123
+ const transcript = await this.compiler.convos[0].Run(this.container)
124
+ assert.equal(transcript.steps.length, 1)
125
+ assert.equal(transcript.steps[0].actual.media.length, 1)
126
+ assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.startsWith('data:image/png'))
127
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
128
+ })
123
129
  })
124
- })
125
130
 
126
- describe('scripting.userinputs.mediaInputConvos.baseUri', function () {
127
- beforeEach(async function () {
128
- const myCaps = {
129
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
130
- [Capabilities.CONTAINERMODE]: echoConnector,
131
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
132
- [Capabilities.USER_INPUTS]: [
133
- {
134
- ref: 'MEDIA',
135
- src: 'MediaInput',
136
- args: {
137
- baseUri: 'https://www.botium.at'
131
+ describe('baseUri', function () {
132
+ beforeEach(async function () {
133
+ const myCaps = {
134
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
135
+ [Capabilities.CONTAINERMODE]: echoConnector,
136
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
137
+ [Capabilities.USER_INPUTS]: [
138
+ {
139
+ ref: 'MEDIA',
140
+ src: 'MediaInput',
141
+ args: {
142
+ baseUri: 'https://www.botium.at'
143
+ }
138
144
  }
139
- }
140
- ]
141
- }
142
- const driver = new BotDriver(myCaps)
143
- this.compiler = driver.BuildCompiler()
144
- this.container = await driver.Build()
145
- })
146
- afterEach(async function () {
147
- this.container && await this.container.Clean()
148
- })
149
-
150
- it('should add media in user message', async function () {
151
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
152
- assert.equal(this.compiler.convos.length, 1)
153
- assert.equal(this.compiler.convos[0].conversation.length, 1)
154
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
155
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
156
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
157
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'botium.png')
158
-
159
- const transcript = await this.compiler.convos[0].Run(this.container)
160
- assert.equal(transcript.steps.length, 1)
161
- assert.equal(transcript.steps[0].actual.media.length, 1)
162
- assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/botium.png')
163
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
145
+ ]
146
+ }
147
+ const driver = new BotDriver(myCaps)
148
+ this.compiler = driver.BuildCompiler()
149
+ this.container = await driver.Build()
150
+ })
151
+ afterEach(async function () {
152
+ this.container && await this.container.Clean()
153
+ })
154
+
155
+ it('should add media in user message', async function () {
156
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
157
+ assert.equal(this.compiler.convos.length, 1)
158
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
159
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
160
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
161
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
162
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'botium.png')
163
+
164
+ const transcript = await this.compiler.convos[0].Run(this.container)
165
+ assert.equal(transcript.steps.length, 1)
166
+ assert.equal(transcript.steps[0].actual.media.length, 1)
167
+ assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/botium.png')
168
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
169
+ })
170
+
171
+ it('should add multi media in user message', async function () {
172
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'medias.convo.txt')
173
+
174
+ const transcript = await this.compiler.convos[0].Run(this.container)
175
+ assert.equal(transcript.steps.length, 1)
176
+ assert.equal(transcript.steps[0].actual.media.length, 2)
177
+ assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/test1.jpg')
178
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/jpeg')
179
+ assert.equal(transcript.steps[0].actual.media[1].downloadUri, 'https://www.botium.at/test2.jpg')
180
+ assert.equal(transcript.steps[0].actual.media[1].mimeType, 'image/jpeg')
181
+ })
164
182
  })
165
183
 
166
- it('should add multi media in user message', async function () {
167
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'medias.convo.txt')
168
-
169
- const transcript = await this.compiler.convos[0].Run(this.container)
170
- assert.equal(transcript.steps.length, 1)
171
- assert.equal(transcript.steps[0].actual.media.length, 2)
172
- assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/test1.jpg')
173
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/jpeg')
174
- assert.equal(transcript.steps[0].actual.media[1].downloadUri, 'https://www.botium.at/test2.jpg')
175
- assert.equal(transcript.steps[0].actual.media[1].mimeType, 'image/jpeg')
176
- })
177
- })
178
-
179
- describe('scripting.userinputs.mediaInputConvos.baseUris', function () {
180
- beforeEach(async function () {
181
- const myCaps = {
182
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
183
- [Capabilities.CONTAINERMODE]: echoConnector,
184
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
185
- [Capabilities.USER_INPUTS]: [
186
- {
187
- ref: 'MEDIA',
188
- src: 'MediaInput',
189
- args: {
190
- baseUri: 'https://www.default.at',
191
- baseUris: {
192
- testset1: 'https://www.botium.at',
193
- testset2: 'https://www.google.at'
184
+ describe('baseUris', function () {
185
+ beforeEach(async function () {
186
+ const myCaps = {
187
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
188
+ [Capabilities.CONTAINERMODE]: echoConnector,
189
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
190
+ [Capabilities.USER_INPUTS]: [
191
+ {
192
+ ref: 'MEDIA',
193
+ src: 'MediaInput',
194
+ args: {
195
+ baseUri: 'https://www.default.at',
196
+ baseUris: {
197
+ testset1: 'https://www.botium.at',
198
+ testset2: 'https://www.google.at'
199
+ }
194
200
  }
195
201
  }
196
- }
197
- ]
198
- }
199
- const driver = new BotDriver(myCaps)
200
- this.compiler = driver.BuildCompiler()
201
- this.container = await driver.Build()
202
- })
203
- afterEach(async function () {
204
- this.container && await this.container.Clean()
202
+ ]
203
+ }
204
+ const driver = new BotDriver(myCaps)
205
+ this.compiler = driver.BuildCompiler()
206
+ this.container = await driver.Build()
207
+ })
208
+ afterEach(async function () {
209
+ this.container && await this.container.Clean()
210
+ })
211
+
212
+ it('should add media from test set baseUri in user message', async function () {
213
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
214
+ assert.equal(this.compiler.convos.length, 1)
215
+
216
+ this.compiler.convos[0].sourceTag.testSetId = 'testset2'
217
+
218
+ const transcript = await this.compiler.convos[0].Run(this.container)
219
+ assert.equal(transcript.steps.length, 1)
220
+ assert.equal(transcript.steps[0].actual.media.length, 1)
221
+ assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.google.at/botium.png')
222
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
223
+ })
224
+ it('should add media with default baseUri in user message', async function () {
225
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
226
+ assert.equal(this.compiler.convos.length, 1)
227
+
228
+ this.compiler.convos[0].sourceTag.testSetId = 'testset3'
229
+
230
+ const transcript = await this.compiler.convos[0].Run(this.container)
231
+ assert.equal(transcript.steps.length, 1)
232
+ assert.equal(transcript.steps[0].actual.media.length, 1)
233
+ assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('https://www.default.at/botium.png'))
234
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
235
+ })
205
236
  })
206
237
 
207
- it('should add media from test set baseUri in user message', async function () {
208
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
209
- assert.equal(this.compiler.convos.length, 1)
210
-
211
- this.compiler.convos[0].sourceTag.testSetId = 'testset2'
212
-
213
- const transcript = await this.compiler.convos[0].Run(this.container)
214
- assert.equal(transcript.steps.length, 1)
215
- assert.equal(transcript.steps[0].actual.media.length, 1)
216
- assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.google.at/botium.png')
217
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
218
- })
219
- it('should add media with default baseUri in user message', async function () {
220
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
221
- assert.equal(this.compiler.convos.length, 1)
222
-
223
- this.compiler.convos[0].sourceTag.testSetId = 'testset3'
224
-
225
- const transcript = await this.compiler.convos[0].Run(this.container)
226
- assert.equal(transcript.steps.length, 1)
227
- assert.equal(transcript.steps[0].actual.media.length, 1)
228
- assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('https://www.default.at/botium.png'))
229
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
230
- })
231
- })
232
-
233
- describe('scripting.userinputs.mediaInputConvos.baseUrisCustomSelector', function () {
234
- beforeEach(async function () {
235
- const myCaps = {
236
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
237
- [Capabilities.CONTAINERMODE]: echoConnector,
238
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
239
- [Capabilities.USER_INPUTS]: [
240
- {
241
- ref: 'MEDIA',
242
- src: 'MediaInput',
243
- args: {
244
- baseUris: {
245
- customval1: 'https://www.botium.at'
246
- },
247
- baseSelector: 'sourceTag.customField'
238
+ describe('baseUrisCustomSelector', function () {
239
+ beforeEach(async function () {
240
+ const myCaps = {
241
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
242
+ [Capabilities.CONTAINERMODE]: echoConnector,
243
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
244
+ [Capabilities.USER_INPUTS]: [
245
+ {
246
+ ref: 'MEDIA',
247
+ src: 'MediaInput',
248
+ args: {
249
+ baseUris: {
250
+ customval1: 'https://www.botium.at'
251
+ },
252
+ baseSelector: 'sourceTag.customField'
253
+ }
248
254
  }
249
- }
250
- ]
251
- }
252
- const driver = new BotDriver(myCaps)
253
- this.compiler = driver.BuildCompiler()
254
- this.container = await driver.Build()
255
+ ]
256
+ }
257
+ const driver = new BotDriver(myCaps)
258
+ this.compiler = driver.BuildCompiler()
259
+ this.container = await driver.Build()
260
+ })
261
+ afterEach(async function () {
262
+ this.container && await this.container.Clean()
263
+ })
264
+
265
+ it('should add media from custom test set baseUri in user message', async function () {
266
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
267
+ assert.equal(this.compiler.convos.length, 1)
268
+
269
+ this.compiler.convos[0].sourceTag.customField = 'customval1'
270
+
271
+ const transcript = await this.compiler.convos[0].Run(this.container)
272
+ assert.equal(transcript.steps.length, 1)
273
+ assert.equal(transcript.steps[0].actual.media.length, 1)
274
+ assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/botium.png')
275
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
276
+ })
255
277
  })
256
- afterEach(async function () {
257
- this.container && await this.container.Clean()
258
- })
259
-
260
- it('should add media from custom test set baseUri in user message', async function () {
261
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
262
- assert.equal(this.compiler.convos.length, 1)
263
-
264
- this.compiler.convos[0].sourceTag.customField = 'customval1'
265
-
266
- const transcript = await this.compiler.convos[0].Run(this.container)
267
- assert.equal(transcript.steps.length, 1)
268
- assert.equal(transcript.steps[0].actual.media.length, 1)
269
- assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/botium.png')
270
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
271
- })
272
- })
273
278
 
274
- describe('scripting.userinputs.mediaInputConvos.baseDir', function () {
275
- beforeEach(async function () {
276
- const myCaps = {
277
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
278
- [Capabilities.CONTAINERMODE]: echoConnector,
279
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
280
- [Capabilities.USER_INPUTS]: [
281
- {
282
- ref: 'MEDIA',
283
- src: 'MediaInput',
284
- args: {
285
- downloadMedia: true,
286
- baseDir: path.join(__dirname, 'convos', 'files')
279
+ describe('baseDir', function () {
280
+ beforeEach(async function () {
281
+ const myCaps = {
282
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputConvos',
283
+ [Capabilities.CONTAINERMODE]: echoConnector,
284
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
285
+ [Capabilities.USER_INPUTS]: [
286
+ {
287
+ ref: 'MEDIA',
288
+ src: 'MediaInput',
289
+ args: {
290
+ downloadMedia: true,
291
+ baseDir: path.join(__dirname, 'convos', 'files')
292
+ }
287
293
  }
288
- }
289
- ]
290
- }
291
- const driver = new BotDriver(myCaps)
292
- this.compiler = driver.BuildCompiler()
293
- this.container = await driver.Build()
294
- })
295
- afterEach(async function () {
296
- this.container && await this.container.Clean()
297
- })
298
-
299
- it('should expand media wc from baseDir in user message', async function () {
300
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediawcbasedir.convo.txt')
301
- this.compiler.ExpandConvos()
302
- assert.equal(this.compiler.convos.length, 3)
303
- assert.equal(this.compiler.convos[0].conversation.length, 1)
304
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
305
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'botium0.png')
306
- assert.equal(this.compiler.convos[1].conversation[0].userInputs[0].args[0], 'botium1.png')
307
- assert.equal(this.compiler.convos[2].conversation[0].userInputs[0].args[0], 'botium2.png')
308
-
309
- await this.container.Start()
310
- const transcript0 = await this.compiler.convos[0].Run(this.container)
311
- assert.equal(transcript0.steps.length, 1)
312
- assert.equal(transcript0.steps[0].actual.media.length, 1)
313
- assert.isTrue(transcript0.steps[0].actual.media[0].downloadUri.endsWith('files/botium0.png'))
314
- assert.equal(transcript0.steps[0].actual.media[0].mimeType, 'image/png')
315
- await this.container.Stop()
316
-
317
- await this.container.Start()
318
- const transcript1 = await this.compiler.convos[1].Run(this.container)
319
- assert.equal(transcript1.steps.length, 1)
320
- assert.equal(transcript1.steps[0].actual.media.length, 1)
321
- assert.isTrue(transcript1.steps[0].actual.media[0].downloadUri.endsWith('files/botium1.png'))
322
- assert.equal(transcript1.steps[0].actual.media[0].mimeType, 'image/png')
323
- await this.container.Stop()
324
-
325
- await this.container.Start()
326
- const transcript2 = await this.compiler.convos[2].Run(this.container)
327
- assert.equal(transcript2.steps.length, 1)
328
- assert.equal(transcript2.steps[0].actual.media.length, 1)
329
- assert.isTrue(transcript2.steps[0].actual.media[0].downloadUri.endsWith('files/botium2.png'))
330
- assert.equal(transcript2.steps[0].actual.media[0].mimeType, 'image/png')
331
- await this.container.Stop()
332
- })
333
-
334
- it('should fail when media is out of baseDir', async function () {
335
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediaOutOfBasedir.convo.txt')
336
-
337
- try {
338
- await this.compiler.convos[0].Run(this.container)
339
- assert.fail('expected error')
340
- } catch (err) {
341
- assert.isTrue(err.message.startsWith('mediaoutofbasedir/Line 3: error sending to bot - The uri \'../*.png\' is pointing out of the base directory'))
342
- }
343
- })
344
-
345
- it('should use dataUri as media in user message', async function () {
346
- const mediaData = fs.readFileSync(path.resolve(__dirname, 'convos', 'files', 'botium0.png'))
347
- const mediaUri = `data:image/png;base64,${mediaData.toString('base64')}`
348
- const script = `should use dataUri as media in user message
294
+ ]
295
+ }
296
+ const driver = new BotDriver(myCaps)
297
+ this.compiler = driver.BuildCompiler()
298
+ this.container = await driver.Build()
299
+ })
300
+ afterEach(async function () {
301
+ this.container && await this.container.Clean()
302
+ })
303
+
304
+ it('should expand media wc from baseDir in user message', async function () {
305
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediawcbasedir.convo.txt')
306
+ this.compiler.ExpandConvos()
307
+ assert.equal(this.compiler.convos.length, 3)
308
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
309
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
310
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args[0], 'botium0.png')
311
+ assert.equal(this.compiler.convos[1].conversation[0].userInputs[0].args[0], 'botium1.png')
312
+ assert.equal(this.compiler.convos[2].conversation[0].userInputs[0].args[0], 'botium2.png')
313
+
314
+ await this.container.Start()
315
+ const transcript0 = await this.compiler.convos[0].Run(this.container)
316
+ assert.equal(transcript0.steps.length, 1)
317
+ assert.equal(transcript0.steps[0].actual.media.length, 1)
318
+ assert.isTrue(transcript0.steps[0].actual.media[0].downloadUri.endsWith('files/botium0.png'))
319
+ assert.equal(transcript0.steps[0].actual.media[0].mimeType, 'image/png')
320
+ await this.container.Stop()
321
+
322
+ await this.container.Start()
323
+ const transcript1 = await this.compiler.convos[1].Run(this.container)
324
+ assert.equal(transcript1.steps.length, 1)
325
+ assert.equal(transcript1.steps[0].actual.media.length, 1)
326
+ assert.isTrue(transcript1.steps[0].actual.media[0].downloadUri.endsWith('files/botium1.png'))
327
+ assert.equal(transcript1.steps[0].actual.media[0].mimeType, 'image/png')
328
+ await this.container.Stop()
329
+
330
+ await this.container.Start()
331
+ const transcript2 = await this.compiler.convos[2].Run(this.container)
332
+ assert.equal(transcript2.steps.length, 1)
333
+ assert.equal(transcript2.steps[0].actual.media.length, 1)
334
+ assert.isTrue(transcript2.steps[0].actual.media[0].downloadUri.endsWith('files/botium2.png'))
335
+ assert.equal(transcript2.steps[0].actual.media[0].mimeType, 'image/png')
336
+ await this.container.Stop()
337
+ })
338
+
339
+ it('should fail when media is out of baseDir', async function () {
340
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'mediaOutOfBasedir.convo.txt')
341
+
342
+ try {
343
+ await this.compiler.convos[0].Run(this.container)
344
+ assert.fail('expected error')
345
+ } catch (err) {
346
+ assert.isTrue(err.message.startsWith('mediaoutofbasedir/Line 3: error sending to bot - The uri \'../*.png\' is pointing out of the base directory'))
347
+ }
348
+ })
349
+
350
+ it('should use dataUri as media in user message', async function () {
351
+ const mediaData = fs.readFileSync(path.resolve(__dirname, 'convos', 'files', 'botium0.png'))
352
+ const mediaUri = `data:image/png;base64,${mediaData.toString('base64')}`
353
+ const script = `should use dataUri as media in user message
349
354
 
350
355
  #me
351
356
  MEDIA ${mediaUri}
352
357
  `
353
358
 
354
- this.compiler.Compile(script, 'SCRIPTING_FORMAT_TXT', 'SCRIPTING_TYPE_CONVO')
355
- assert.equal(this.compiler.convos.length, 1)
356
- assert.equal(this.compiler.convos[0].conversation.length, 1)
357
- assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
358
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
359
- assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
360
- assert.isTrue(this.compiler.convos[0].conversation[0].userInputs[0].args[0].startsWith('data:image/png'))
361
-
362
- const transcript = await this.compiler.convos[0].Run(this.container)
363
- assert.equal(transcript.steps.length, 1)
364
- assert.equal(transcript.steps[0].actual.media.length, 1)
365
- assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.startsWith('data:image/png'))
366
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
367
- assert.isTrue(Buffer.isBuffer(transcript.steps[0].actual.media[0].buffer))
359
+ this.compiler.Compile(script, 'SCRIPTING_FORMAT_TXT', 'SCRIPTING_TYPE_CONVO')
360
+ assert.equal(this.compiler.convos.length, 1)
361
+ assert.equal(this.compiler.convos[0].conversation.length, 1)
362
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs.length, 1)
363
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].name, 'MEDIA')
364
+ assert.equal(this.compiler.convos[0].conversation[0].userInputs[0].args.length, 1)
365
+ assert.isTrue(this.compiler.convos[0].conversation[0].userInputs[0].args[0].startsWith('data:image/png'))
366
+
367
+ const transcript = await this.compiler.convos[0].Run(this.container)
368
+ assert.equal(transcript.steps.length, 1)
369
+ assert.equal(transcript.steps[0].actual.media.length, 1)
370
+ assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.startsWith('data:image/png'))
371
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
372
+ assert.isTrue(Buffer.isBuffer(transcript.steps[0].actual.media[0].buffer))
373
+ })
368
374
  })
369
- })
370
375
 
371
- describe('scripting.userinputs.mediaInputDownloadConvos.relative', function () {
372
- beforeEach(async function () {
373
- const myCaps = {
374
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputDownloadConvos',
375
- [Capabilities.CONTAINERMODE]: echoConnector,
376
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
377
- [Capabilities.USER_INPUTS]: [
378
- {
379
- ref: 'MEDIA',
380
- src: 'MediaInput',
381
- args: {
382
- downloadMedia: true
376
+ describe('mediaInputDownloadConvos.relative', function () {
377
+ beforeEach(async function () {
378
+ const myCaps = {
379
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputDownloadConvos',
380
+ [Capabilities.CONTAINERMODE]: echoConnector,
381
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
382
+ [Capabilities.USER_INPUTS]: [
383
+ {
384
+ ref: 'MEDIA',
385
+ src: 'MediaInput',
386
+ args: {
387
+ downloadMedia: true
388
+ }
383
389
  }
384
- }
385
- ]
386
- }
387
- const driver = new BotDriver(myCaps)
388
- this.compiler = driver.BuildCompiler()
389
- this.container = await driver.Build()
390
- })
391
- afterEach(async function () {
392
- this.container && await this.container.Clean()
393
- })
394
-
395
- it('should add media buffer in user message', async function () {
396
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
397
-
398
- const transcript = await this.compiler.convos[0].Run(this.container)
399
- assert.equal(transcript.steps.length, 1)
400
- assert.equal(transcript.steps[0].actual.media.length, 1)
401
- assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('test/scripting/userinputs/convos/botium.png'))
402
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
403
- assert.isTrue(Buffer.isBuffer(transcript.steps[0].actual.media[0].buffer))
390
+ ]
391
+ }
392
+ const driver = new BotDriver(myCaps)
393
+ this.compiler = driver.BuildCompiler()
394
+ this.container = await driver.Build()
395
+ })
396
+ afterEach(async function () {
397
+ this.container && await this.container.Clean()
398
+ })
399
+
400
+ it('should add media buffer in user message', async function () {
401
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
402
+
403
+ const transcript = await this.compiler.convos[0].Run(this.container)
404
+ assert.equal(transcript.steps.length, 1)
405
+ assert.equal(transcript.steps[0].actual.media.length, 1)
406
+ assert.isTrue(transcript.steps[0].actual.media[0].downloadUri.endsWith('test/scripting/userinputs/convos/botium.png'))
407
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
408
+ assert.isTrue(Buffer.isBuffer(transcript.steps[0].actual.media[0].buffer))
409
+ })
404
410
  })
405
- })
406
411
 
407
- describe('scripting.userinputs.mediaInputDownloadConvos.baseUri', function () {
408
- beforeEach(async function () {
409
- const myCaps = {
410
- [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputDownloadConvos',
411
- [Capabilities.CONTAINERMODE]: echoConnector,
412
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
413
- [Capabilities.USER_INPUTS]: [
414
- {
415
- ref: 'MEDIA',
416
- src: 'MediaInput',
417
- args: {
418
- downloadMedia: true,
419
- baseUri: 'https://www.botium.at'
412
+ describe('scripting.userinputs.mediaInputDownloadConvos.baseUri', function () {
413
+ beforeEach(async function () {
414
+ const myCaps = {
415
+ [Capabilities.PROJECTNAME]: 'scripting.userinputs.mediaInputDownloadConvos',
416
+ [Capabilities.CONTAINERMODE]: echoConnector,
417
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
418
+ [Capabilities.USER_INPUTS]: [
419
+ {
420
+ ref: 'MEDIA',
421
+ src: 'MediaInput',
422
+ args: {
423
+ downloadMedia: true,
424
+ baseUri: 'https://www.botium.at'
425
+ }
420
426
  }
421
- }
422
- ]
423
- }
424
- const driver = new BotDriver(myCaps)
425
- this.compiler = driver.BuildCompiler()
426
- this.container = await driver.Build()
427
- })
428
- afterEach(async function () {
429
- this.container && await this.container.Clean()
430
- })
431
-
432
- it('should add media in user message', async function () {
433
- const scope = nock('https://www.botium.at')
434
- .get('/botium.png')
435
- .reply(200, Buffer.from('hello world'))
436
- .persist()
437
-
438
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
439
-
440
- const transcript = await this.compiler.convos[0].Run(this.container)
441
- assert.equal(transcript.steps.length, 1)
442
- assert.equal(transcript.steps[0].actual.media.length, 1)
443
- assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/botium.png')
444
- assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
445
- assert.isTrue(Buffer.isBuffer(transcript.steps[0].actual.media[0].buffer))
446
-
447
- scope.persist(false)
427
+ ]
428
+ }
429
+ const driver = new BotDriver(myCaps)
430
+ this.compiler = driver.BuildCompiler()
431
+ this.container = await driver.Build()
432
+ })
433
+ afterEach(async function () {
434
+ this.container && await this.container.Clean()
435
+ })
436
+
437
+ it('should add media in user message', async function () {
438
+ const scope = nock('https://www.botium.at')
439
+ .get('/botium.png')
440
+ .reply(200, Buffer.from('hello world'))
441
+ .persist()
442
+
443
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'media.convo.txt')
444
+
445
+ const transcript = await this.compiler.convos[0].Run(this.container)
446
+ assert.equal(transcript.steps.length, 1)
447
+ assert.equal(transcript.steps[0].actual.media.length, 1)
448
+ assert.equal(transcript.steps[0].actual.media[0].downloadUri, 'https://www.botium.at/botium.png')
449
+ assert.equal(transcript.steps[0].actual.media[0].mimeType, 'image/png')
450
+ assert.isTrue(Buffer.isBuffer(transcript.steps[0].actual.media[0].buffer))
451
+
452
+ scope.persist(false)
453
+ })
448
454
  })
449
455
  })