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,204 +7,214 @@ const echoConnector = ({ queueBotSays }) => {
7
7
  return {
8
8
  UserSays (msg) {
9
9
  const response = msg.messageText && msg.messageText.replace('INPUT1', 'OUTPUT1').replace('INPUT2', 'OUTPUT2')
10
- const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: response, cards: [{ text: 'card text', content: 'card content' }] }
10
+ const botMsg = {
11
+ sender: 'bot',
12
+ sourceData: msg.sourceData,
13
+ messageText: response,
14
+ cards: [{
15
+ text: 'card text',
16
+ content: 'card content'
17
+ }]
18
+ }
11
19
  queueBotSays(botMsg)
12
20
  }
13
21
  }
14
22
  }
15
23
 
16
- describe('SetClearScriptingMemory', function () {
17
- beforeEach(async function () {
18
- const myCaps = {
19
- [Capabilities.PROJECTNAME]: 'scripting.logichooks',
20
- [Capabilities.CONTAINERMODE]: echoConnector,
21
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
22
- }
23
- const driver = new BotDriver(myCaps)
24
- this.compiler = driver.BuildCompiler()
25
- this.container = await driver.Build()
26
- })
27
-
28
- afterEach(async function () {
29
- this.container && await this.container.Clean()
30
- })
31
-
32
- it('should be created by begin', async function () {
33
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_by_begin.convo.txt')
34
- assert.equal(this.compiler.convos.length, 1)
35
-
36
- const transcript = await this.compiler.convos[0].Run(this.container)
37
- assert.isObject(transcript.scriptingMemory)
38
- assert.isDefined(transcript.scriptingMemory.$created_by_begin)
39
- assert.equal(transcript.scriptingMemory.$created_by_begin, 'created_by_begin_from_begin')
40
- })
41
-
42
- it('should be created two by begin', async function () {
43
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_two_by_begin.convo.txt')
44
- assert.equal(this.compiler.convos.length, 1)
45
-
46
- const transcript = await this.compiler.convos[0].Run(this.container)
47
- assert.isObject(transcript.scriptingMemory)
48
- assert.isDefined(transcript.scriptingMemory.$created_by_begin_one)
49
- assert.equal(transcript.scriptingMemory.$created_by_begin_one, 'created_by_begin_one_from_begin')
50
- assert.isDefined(transcript.scriptingMemory.$created_by_begin_two)
51
- assert.equal(transcript.scriptingMemory.$created_by_begin_two, 'created_by_begin_two_from_begin')
52
- })
53
-
54
- it('should be created by logic hook', async function () {
55
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_by_logic_hook.convo.txt')
56
- assert.equal(this.compiler.convos.length, 1)
57
-
58
- const transcript = await this.compiler.convos[0].Run(this.container)
59
- assert.isObject(transcript.scriptingMemory)
60
- assert.isDefined(transcript.scriptingMemory.$created_by_logic_hook)
61
- assert.equal(transcript.scriptingMemory.$created_by_logic_hook, 'created_by_logic_hook_from_logic_hook')
62
- })
63
-
64
- it('should be cleared by logic hook', async function () {
65
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_cleared_by_logic_hook.convo.txt')
66
- assert.equal(this.compiler.convos.length, 1)
67
-
68
- const transcript = await this.compiler.convos[0].Run(this.container)
69
- assert.isObject(transcript.scriptingMemory)
70
- assert.notExists(transcript.scriptingMemory.cleared_by_logic_hook)
71
- })
72
-
73
- it('should be overwritten by convo', async function () {
74
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_overwritten_by_convo.convo.txt')
75
- assert.equal(this.compiler.convos.length, 1)
76
-
77
- const transcript = await this.compiler.convos[0].Run(this.container)
78
- assert.isObject(transcript.scriptingMemory)
79
- assert.isDefined(transcript.scriptingMemory.$overwritten_by_convo)
80
- assert.equal(transcript.scriptingMemory.$overwritten_by_convo, 'overwritten_by_convo_from_begin')
81
- })
82
-
83
- it('should be overwritten by logic hook', async function () {
84
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_overwritten_by_logic_hook.convo.txt')
85
- assert.equal(this.compiler.convos.length, 1)
86
-
87
- const transcript = await this.compiler.convos[0].Run(this.container)
88
- assert.isObject(transcript.scriptingMemory)
89
- assert.isDefined(transcript.scriptingMemory.$overwritten_by_logic_hook)
90
- assert.equal(transcript.scriptingMemory.$overwritten_by_logic_hook, 'overwritten_by_logic_hook_from_logic_hook')
91
- })
92
-
93
- it('reserved word, just a log on console', async function () {
94
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_reserved_word.convo.txt')
95
- assert.equal(this.compiler.convos.length, 1)
96
- const transcript = await this.compiler.convos[0].Run(this.container)
97
- assert.isObject(transcript.scriptingMemory)
98
- assert.isDefined(transcript.scriptingMemory.$year)
99
- assert.equal(transcript.scriptingMemory.$year, '2012')
100
- })
101
-
102
- it('numbers, parse currencies', async function () {
103
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_numbers.convo.txt')
104
- assert.equal(this.compiler.convos.length, 1)
105
- const transcript = await this.compiler.convos[0].Run(this.container)
106
- assert.isObject(transcript.scriptingMemory)
107
- // assert.isDefined(transcript.scriptingMemory['$year'])
108
- // assert.equal(transcript.scriptingMemory['$year'], '2012')
109
- })
110
-
111
- it('should use scripting memory for assertions', async function () {
112
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_progress.convo.txt')
113
- try {
114
- await this.compiler.convos[0].Run(this.container)
115
- assert.fail('should have failed')
116
- } catch (err) {
117
- assert.isTrue(err.message.indexOf('Bot response (on Line 6: #me - sending input: $input) "sending input: OUTPUT1" expected to match "sending input: INPUT1"') >= 0)
118
- }
119
- })
120
- it('should overwrite scripting memory and use for assertions', async function () {
121
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_overwrite_and_check.convo.txt')
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 9: #me - this is a variable: VARVALUE2) "this is a variable: VARVALUE2" expected to match "this is a variable: VARVALUE1"') >= 0)
127
- assert.isUndefined(err.transcript.steps[0].scriptingMemory.$myvar)
128
- assert.equal(err.transcript.steps[1].scriptingMemory.$myvar, 'VARVALUE1')
129
- assert.equal(err.transcript.steps[2].scriptingMemory.$myvar, 'VARVALUE1')
130
- assert.equal(err.transcript.steps[3].scriptingMemory.$myvar, 'VARVALUE1')
131
- }
132
- })
133
- it('should be assigned from jsonpath', async function () {
134
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_from_jsonpath.convo.txt')
135
- assert.equal(this.compiler.convos.length, 1)
136
-
137
- const transcript = await this.compiler.convos[0].Run(this.container)
138
- assert.isObject(transcript.scriptingMemory)
139
- assert.isDefined(transcript.scriptingMemory.$cardcontent)
140
- assert.equal(transcript.scriptingMemory.$cardcontent, 'card content')
141
- })
142
- it('should fail on invalid jsonpath', async function () {
143
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_from_invalidjsonpath.convo.txt')
144
- try {
145
- await this.compiler.convos[0].Run(this.container)
146
- assert.fail('should have failed')
147
- } catch (err) {
148
- assert.isTrue(err.message.indexOf('no result from JSON-Path query') >= 0)
149
- }
150
- })
151
- })
152
-
153
- describe('scripting.logichooks.global', function () {
154
- beforeEach(async function () {
155
- const myCaps = {
156
- [Capabilities.PROJECTNAME]: 'scripting.logichooks',
157
- [Capabilities.CONTAINERMODE]: echoConnector,
158
- [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
159
- [Capabilities.LOGIC_HOOKS]: [
160
- {
161
- src: 'SetScriptingMemoryLogicHook',
162
- ref: 'created_by_global',
163
- global: true,
164
- args: {
165
- name: 'created_by_global',
166
- value: 'created_by_global_from_global'
167
- }
168
- },
169
- {
170
- src: 'SetScriptingMemoryLogicHook',
171
- ref: 'created_by_begin',
172
- global: true,
173
- args: {
174
- name: 'created_by_begin',
175
- value: 'created_by_begin_from_global'
24
+ describe('scripting.logichooks.global.setClearScriptingMemory', function () {
25
+ describe('SetClearScriptingMemory', function () {
26
+ beforeEach(async function () {
27
+ const myCaps = {
28
+ [Capabilities.PROJECTNAME]: 'scripting.logichooks',
29
+ [Capabilities.CONTAINERMODE]: echoConnector,
30
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true
31
+ }
32
+ const driver = new BotDriver(myCaps)
33
+ this.compiler = driver.BuildCompiler()
34
+ this.container = await driver.Build()
35
+ })
36
+
37
+ afterEach(async function () {
38
+ this.container && await this.container.Clean()
39
+ })
40
+
41
+ it('should be created by begin', async function () {
42
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_by_begin.convo.txt')
43
+ assert.equal(this.compiler.convos.length, 1)
44
+
45
+ const transcript = await this.compiler.convos[0].Run(this.container)
46
+ assert.isObject(transcript.scriptingMemory)
47
+ assert.isDefined(transcript.scriptingMemory.$created_by_begin)
48
+ assert.equal(transcript.scriptingMemory.$created_by_begin, 'created_by_begin_from_begin')
49
+ })
50
+
51
+ it('should be created two by begin', async function () {
52
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_two_by_begin.convo.txt')
53
+ assert.equal(this.compiler.convos.length, 1)
54
+
55
+ const transcript = await this.compiler.convos[0].Run(this.container)
56
+ assert.isObject(transcript.scriptingMemory)
57
+ assert.isDefined(transcript.scriptingMemory.$created_by_begin_one)
58
+ assert.equal(transcript.scriptingMemory.$created_by_begin_one, 'created_by_begin_one_from_begin')
59
+ assert.isDefined(transcript.scriptingMemory.$created_by_begin_two)
60
+ assert.equal(transcript.scriptingMemory.$created_by_begin_two, 'created_by_begin_two_from_begin')
61
+ })
62
+
63
+ it('should be created by logic hook', async function () {
64
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_by_logic_hook.convo.txt')
65
+ assert.equal(this.compiler.convos.length, 1)
66
+
67
+ const transcript = await this.compiler.convos[0].Run(this.container)
68
+ assert.isObject(transcript.scriptingMemory)
69
+ assert.isDefined(transcript.scriptingMemory.$created_by_logic_hook)
70
+ assert.equal(transcript.scriptingMemory.$created_by_logic_hook, 'created_by_logic_hook_from_logic_hook')
71
+ })
72
+
73
+ it('should be cleared by logic hook', async function () {
74
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_cleared_by_logic_hook.convo.txt')
75
+ assert.equal(this.compiler.convos.length, 1)
76
+
77
+ const transcript = await this.compiler.convos[0].Run(this.container)
78
+ assert.isObject(transcript.scriptingMemory)
79
+ assert.notExists(transcript.scriptingMemory.cleared_by_logic_hook)
80
+ })
81
+
82
+ it('should be overwritten by convo', async function () {
83
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_overwritten_by_convo.convo.txt')
84
+ assert.equal(this.compiler.convos.length, 1)
85
+
86
+ const transcript = await this.compiler.convos[0].Run(this.container)
87
+ assert.isObject(transcript.scriptingMemory)
88
+ assert.isDefined(transcript.scriptingMemory.$overwritten_by_convo)
89
+ assert.equal(transcript.scriptingMemory.$overwritten_by_convo, 'overwritten_by_convo_from_begin')
90
+ })
91
+
92
+ it('should be overwritten by logic hook', async function () {
93
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_overwritten_by_logic_hook.convo.txt')
94
+ assert.equal(this.compiler.convos.length, 1)
95
+
96
+ const transcript = await this.compiler.convos[0].Run(this.container)
97
+ assert.isObject(transcript.scriptingMemory)
98
+ assert.isDefined(transcript.scriptingMemory.$overwritten_by_logic_hook)
99
+ assert.equal(transcript.scriptingMemory.$overwritten_by_logic_hook, 'overwritten_by_logic_hook_from_logic_hook')
100
+ })
101
+
102
+ it('reserved word, just a log on console', async function () {
103
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_reserved_word.convo.txt')
104
+ assert.equal(this.compiler.convos.length, 1)
105
+ const transcript = await this.compiler.convos[0].Run(this.container)
106
+ assert.isObject(transcript.scriptingMemory)
107
+ assert.isDefined(transcript.scriptingMemory.$year)
108
+ assert.equal(transcript.scriptingMemory.$year, '2012')
109
+ })
110
+
111
+ it('numbers, parse currencies', async function () {
112
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_numbers.convo.txt')
113
+ assert.equal(this.compiler.convos.length, 1)
114
+ const transcript = await this.compiler.convos[0].Run(this.container)
115
+ assert.isObject(transcript.scriptingMemory)
116
+ // assert.isDefined(transcript.scriptingMemory['$year'])
117
+ // assert.equal(transcript.scriptingMemory['$year'], '2012')
118
+ })
119
+
120
+ it('should use scripting memory for assertions', async function () {
121
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_progress.convo.txt')
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 - sending input: $input) "sending input: OUTPUT1" expected to match "sending input: INPUT1"') >= 0)
127
+ }
128
+ })
129
+ it('should overwrite scripting memory and use for assertions', async function () {
130
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_overwrite_and_check.convo.txt')
131
+ try {
132
+ await this.compiler.convos[0].Run(this.container)
133
+ assert.fail('should have failed')
134
+ } catch (err) {
135
+ assert.isTrue(err.message.indexOf('Bot response (on Line 9: #me - this is a variable: VARVALUE2) "this is a variable: VARVALUE2" expected to match "this is a variable: VARVALUE1"') >= 0)
136
+ assert.isUndefined(err.transcript.steps[0].scriptingMemory.$myvar)
137
+ assert.equal(err.transcript.steps[1].scriptingMemory.$myvar, 'VARVALUE1')
138
+ assert.equal(err.transcript.steps[2].scriptingMemory.$myvar, 'VARVALUE1')
139
+ assert.equal(err.transcript.steps[3].scriptingMemory.$myvar, 'VARVALUE1')
140
+ }
141
+ })
142
+ it('should be assigned from jsonpath', async function () {
143
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_from_jsonpath.convo.txt')
144
+ assert.equal(this.compiler.convos.length, 1)
145
+
146
+ const transcript = await this.compiler.convos[0].Run(this.container)
147
+ assert.isObject(transcript.scriptingMemory)
148
+ assert.isDefined(transcript.scriptingMemory.$cardcontent)
149
+ assert.equal(transcript.scriptingMemory.$cardcontent, 'card content')
150
+ })
151
+ it('should fail on invalid jsonpath', async function () {
152
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_from_invalidjsonpath.convo.txt')
153
+ try {
154
+ await this.compiler.convos[0].Run(this.container)
155
+ assert.fail('should have failed')
156
+ } catch (err) {
157
+ assert.isTrue(err.message.indexOf('no result from JSON-Path query') >= 0)
158
+ }
159
+ })
160
+ })
161
+
162
+ describe('global', function () {
163
+ beforeEach(async function () {
164
+ const myCaps = {
165
+ [Capabilities.PROJECTNAME]: 'scripting.logichooks',
166
+ [Capabilities.CONTAINERMODE]: echoConnector,
167
+ [Capabilities.SCRIPTING_ENABLE_MEMORY]: true,
168
+ [Capabilities.LOGIC_HOOKS]: [
169
+ {
170
+ src: 'SetScriptingMemoryLogicHook',
171
+ ref: 'created_by_global',
172
+ global: true,
173
+ args: {
174
+ name: 'created_by_global',
175
+ value: 'created_by_global_from_global'
176
+ }
177
+ },
178
+ {
179
+ src: 'SetScriptingMemoryLogicHook',
180
+ ref: 'created_by_begin',
181
+ global: true,
182
+ args: {
183
+ name: 'created_by_begin',
184
+ value: 'created_by_begin_from_global'
185
+ }
176
186
  }
177
- }
178
-
179
- ]
180
- }
181
- const driver = new BotDriver(myCaps)
182
- this.compiler = driver.BuildCompiler()
183
- this.container = await driver.Build()
184
- })
185
-
186
- afterEach(async function () {
187
- this.container && await this.container.Clean()
188
- })
189
-
190
- it('should be created by global', async function () {
191
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'no_scripting_memory.convo.txt')
192
- assert.equal(this.compiler.convos.length, 1)
193
-
194
- const transcript = await this.compiler.convos[0].Run(this.container)
195
- assert.isObject(transcript.scriptingMemory)
196
- assert.isDefined(transcript.scriptingMemory.$created_by_global)
197
- assert.equal(transcript.scriptingMemory.$created_by_global, 'created_by_global_from_global')
198
- })
199
-
200
- // It must be just an accident that the global is overwritten by begin. feel free to change this test
201
- it('should be overwritten by global', async function () {
202
- this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_by_begin.convo.txt')
203
- assert.equal(this.compiler.convos.length, 1)
204
187
 
205
- const transcript = await this.compiler.convos[0].Run(this.container)
206
- assert.isObject(transcript.scriptingMemory)
207
- assert.isDefined(transcript.scriptingMemory.$created_by_begin)
208
- assert.equal(transcript.scriptingMemory.$created_by_begin, 'created_by_begin_from_global')
188
+ ]
189
+ }
190
+ const driver = new BotDriver(myCaps)
191
+ this.compiler = driver.BuildCompiler()
192
+ this.container = await driver.Build()
193
+ })
194
+
195
+ afterEach(async function () {
196
+ this.container && await this.container.Clean()
197
+ })
198
+
199
+ it('should be created by global', async function () {
200
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'no_scripting_memory.convo.txt')
201
+ assert.equal(this.compiler.convos.length, 1)
202
+
203
+ const transcript = await this.compiler.convos[0].Run(this.container)
204
+ assert.isObject(transcript.scriptingMemory)
205
+ assert.isDefined(transcript.scriptingMemory.$created_by_global)
206
+ assert.equal(transcript.scriptingMemory.$created_by_global, 'created_by_global_from_global')
207
+ })
208
+
209
+ // It must be just an accident that the global is overwritten by begin. feel free to change this test
210
+ it('should be overwritten by global', async function () {
211
+ this.compiler.ReadScript(path.resolve(__dirname, 'convos'), 'scripting_memory_created_by_begin.convo.txt')
212
+ assert.equal(this.compiler.convos.length, 1)
213
+
214
+ const transcript = await this.compiler.convos[0].Run(this.container)
215
+ assert.isObject(transcript.scriptingMemory)
216
+ assert.isDefined(transcript.scriptingMemory.$created_by_begin)
217
+ assert.equal(transcript.scriptingMemory.$created_by_begin, 'created_by_begin_from_global')
218
+ })
209
219
  })
210
220
  })