botium-core 1.14.4 → 1.14.5

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.14.4",
3
+ "version": "1.14.5",
4
4
  "description": "The Selenium for Chatbots",
5
5
  "main": "index.js",
6
6
  "module": "dist/botium-es.js",
@@ -3,7 +3,7 @@ const Constants = require('./Constants')
3
3
  const CompilerBase = require('./CompilerBase')
4
4
  const Utterance = require('./Utterance')
5
5
  const { ConvoHeader, Convo } = require('./Convo')
6
- const { linesToConvoStep, convoStepToLines, validateConvo, validSenders, linesToScriptingMemories } = require('./helper')
6
+ const { linesToConvoStep, convoStepToLines, validateConvo, validSenders, linesToScriptingMemories, trimExceptSpaceEnd } = require('./helper')
7
7
 
8
8
  module.exports = class CompilerTxt extends CompilerBase {
9
9
  constructor (context, caps = {}) {
@@ -120,7 +120,7 @@ module.exports = class CompilerTxt extends CompilerBase {
120
120
 
121
121
  _compileUtterances (lines) {
122
122
  if (lines && lines.length > 0) {
123
- const result = [new Utterance({ name: lines[0], utterances: lines.length > 1 ? lines.slice(1) : [] })]
123
+ const result = [new Utterance({ name: lines[0].trim(), utterances: lines.length > 1 ? lines.slice(1).map(line => trimExceptSpaceEnd(line)) : [] })]
124
124
  this.context.AddUtterances(result)
125
125
  return result
126
126
  }
@@ -1307,17 +1307,18 @@ module.exports = class ScriptingProvider {
1307
1307
  }
1308
1308
  if (utterances) {
1309
1309
  _.forEach(utterances, (utt) => {
1310
- const eu = this.utterances[utt.name]
1310
+ const uttName = utt.name?.trim()
1311
+ const eu = this.utterances[uttName]
1311
1312
  if (eu) {
1312
1313
  eu.utterances = _.uniq(_.concat(eu.utterances, utt.utterances))
1313
1314
  } else {
1314
- this.utterances[utt.name] = utt
1315
+ this.utterances[uttName] = utt
1315
1316
  }
1316
1317
 
1317
- const { ambiguous, expected } = findAmbiguous(this.utterances[utt.name].utterances)
1318
+ const { ambiguous, expected } = findAmbiguous(this.utterances[uttName].utterances)
1318
1319
 
1319
1320
  if (ambiguous && ambiguous.length > 0) {
1320
- debug(`Ambigous utterance "${utt.name}", expecting exact ${expected.length ? ('"' + expected.join(', ') + '"') : '<none>'} scripting memory variables in following user examples: ${ambiguous.map(d => `"${d}"`).join(', ')}`)
1321
+ debug(`Ambigous utterance "${uttName}", expecting exact ${expected.length ? ('"' + expected.join(', ') + '"') : '<none>'} scripting memory variables in following user examples: ${ambiguous.map(d => `"${d}"`).join(', ')}`)
1321
1322
  }
1322
1323
  })
1323
1324
  }
@@ -248,7 +248,7 @@ const linesToConvoStep = (lines, sender, context, eol, singleLineMode = false) =
248
248
  if (eol === null) {
249
249
  throw new Error('eol cant be null')
250
250
  }
251
- convoStep.messageText = textLines.join(eol).replace(WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END, '')
251
+ convoStep.messageText = trimExceptSpaceEnd(textLines.join(eol))
252
252
  }
253
253
  }
254
254
  } else {
@@ -271,6 +271,10 @@ const linesToConvoStep = (lines, sender, context, eol, singleLineMode = false) =
271
271
  return convoStep
272
272
  }
273
273
 
274
+ const trimExceptSpaceEnd = (string) => {
275
+ return string?.replace(WHITE_SPACES_EXCEPT_SPACE_CHAR_AT_THE_END, '')
276
+ }
277
+
274
278
  const convoStepToObject = (step) => {
275
279
  const result = []
276
280
  if (step.sender === 'me') {
@@ -608,5 +612,6 @@ module.exports = {
608
612
  validateConvo,
609
613
  linesToScriptingMemories,
610
614
  calculateWer,
611
- toPercent
615
+ toPercent,
616
+ trimExceptSpaceEnd
612
617
  }