botium-core 1.15.8 → 1.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botium-core",
3
- "version": "1.15.8",
3
+ "version": "1.15.9",
4
4
  "description": "The Selenium for Chatbots",
5
5
  "main": "index.js",
6
6
  "module": "dist/botium-es.js",
package/src/BotDriver.js CHANGED
@@ -241,8 +241,8 @@ module.exports = class BotDriver {
241
241
  if (_.isString(newCaps[capKey])) {
242
242
  try {
243
243
  caps[capKey] = JSON.parse(newCaps[capKey])
244
- if (_.isFinite(caps[capKey])) {
245
- caps[capKey] = caps[capKey].toString()
244
+ if (_.isFinite(Number(newCaps[capKey]))) {
245
+ caps[capKey] = newCaps[capKey].toString()
246
246
  }
247
247
  } catch (err) {
248
248
  caps[capKey] = newCaps[capKey]
@@ -377,7 +377,15 @@ module.exports = class ScriptingProvider {
377
377
  throw Error(`Unknown hookType ${hookType}`)
378
378
  }
379
379
 
380
- const localHooks = (logicHooks || []).filter(l => this.logicHooks[l.name][hookType])
380
+ let localHooks = (logicHooks || []).filter(l => this.logicHooks[l.name][hookType])
381
+ // Scripting memory file are injected via SET_SCRIPTING_MEMORY in the BEGIN step
382
+ // But there might be other logic hooks that need the scripting memory variables
383
+ // Order is important (SET_SCRIPTING_MEMORY in begin can be because the user added it,
384
+ // or because the scripting memory file added it. User one has to be the last one.
385
+ localHooks = [
386
+ ...localHooks.filter(l => l.name === 'SET_SCRIPTING_MEMORY'),
387
+ ...localHooks.filter(l => l.name !== 'SET_SCRIPTING_MEMORY')
388
+ ]
381
389
 
382
390
  const convoStepPromises = localHooks
383
391
  .map(l => p(this.retryHelperLogicHook, () => this.logicHooks[l.name][hookType]({
@@ -385,6 +393,7 @@ module.exports = class ScriptingProvider {
385
393
  convoStep,
386
394
  scriptingMemory,
387
395
  container,
396
+ // Do this more sensitve for SET_SCRIPTING_MEMORY? It can have scripting variables in the args
388
397
  args: ScriptingMemory.applyToArgs(l.args, scriptingMemory, container.caps, rest.botMsg),
389
398
  isGlobal: false,
390
399
  ...rest
@@ -75,6 +75,15 @@ describe('driver.capabilities', function () {
75
75
  assert.isString(driver.caps.CAP_STRING_1)
76
76
  assert.isString(driver.caps.CAP_STRING_2)
77
77
  })
78
+ it('should merge string caps when there are numbers', function () {
79
+ const myCaps = {
80
+ CAP_STRING_1: 'Test',
81
+ CAP_STRING_2: '1234567892343434344'
82
+ }
83
+ const driver = new BotDriver(myCaps)
84
+ assert.strictEqual(driver.caps.CAP_STRING_1, myCaps.CAP_STRING_1)
85
+ assert.strictEqual(driver.caps.CAP_STRING_2, myCaps.CAP_STRING_2)
86
+ })
78
87
  it('should merge boolean envs', function () {
79
88
  process.env.BOTIUM_SIMPLEREST_PING_PROCESS_RESPONSE = 'NO'
80
89
  const driver = new BotDriver()