botium-core 1.14.7 → 1.14.8
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
CHANGED
|
@@ -77,7 +77,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
|
|
|
77
77
|
var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
|
|
78
78
|
|
|
79
79
|
var name = "botium-core";
|
|
80
|
-
var version$1 = "1.14.
|
|
80
|
+
var version$1 = "1.14.8";
|
|
81
81
|
var description = "The Selenium for Chatbots";
|
|
82
82
|
var main = "index.js";
|
|
83
83
|
var module$1 = "dist/botium-es.js";
|
package/dist/botium-es.js
CHANGED
|
@@ -35,7 +35,7 @@ import express from 'express';
|
|
|
35
35
|
import bodyParser from 'body-parser';
|
|
36
36
|
|
|
37
37
|
var name = "botium-core";
|
|
38
|
-
var version$1 = "1.14.
|
|
38
|
+
var version$1 = "1.14.8";
|
|
39
39
|
var description = "The Selenium for Chatbots";
|
|
40
40
|
var main = "index.js";
|
|
41
41
|
var module = "dist/botium-es.js";
|
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
const Capabilities = require('../../../Capabilities')
|
|
1
2
|
const { BotiumError } = require('../../BotiumError')
|
|
3
|
+
const { normalizeText, toString } = require('../../helper')
|
|
4
|
+
const _ = require('lodash')
|
|
2
5
|
|
|
3
6
|
module.exports = class BaseTextAsserter {
|
|
4
7
|
constructor (context, caps = {}, matchFn = null, mode = null, noArgIsJoker = false) {
|
|
@@ -12,6 +15,18 @@ module.exports = class BaseTextAsserter {
|
|
|
12
15
|
this.noArgIsJoker = noArgIsJoker
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
_checkNormalizeText (str) {
|
|
19
|
+
return normalizeText(str, !!this.caps[Capabilities.SCRIPTING_NORMALIZE_TEXT])
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_normalize (botresponse) {
|
|
23
|
+
if (_.isUndefined(botresponse) || _.isNil(botresponse)) return ''
|
|
24
|
+
if (_.isObject(botresponse) && _.has(botresponse, 'messageText')) {
|
|
25
|
+
return toString(botresponse.messageText) || ''
|
|
26
|
+
}
|
|
27
|
+
return toString(botresponse)
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
_evalText (convo, args, botMsg) {
|
|
16
31
|
let allUtterances = []
|
|
17
32
|
if (this.noArgIsJoker && (!args || args.length === 0)) {
|
|
@@ -24,7 +39,7 @@ module.exports = class BaseTextAsserter {
|
|
|
24
39
|
const founds = []
|
|
25
40
|
const notFounds = []
|
|
26
41
|
for (const utterance of allUtterances) {
|
|
27
|
-
(this.matchFn(botMsg, utterance) ? founds : notFounds).push(utterance)
|
|
42
|
+
(this.matchFn(this._checkNormalizeText(this._normalize(botMsg)), this._checkNormalizeText(utterance)) ? founds : notFounds).push(utterance)
|
|
28
43
|
}
|
|
29
44
|
return { found: (this.mode === 'all' ? notFounds.length === 0 : founds.length > 0), allUtterances, founds, notFounds }
|
|
30
45
|
}
|