Skip to content

Commit

Permalink
Merge pull request #710 from codeforequity-at/develop
Browse files Browse the repository at this point in the history
Botium Core 1.13.6
  • Loading branch information
codeforequity-at authored Oct 10, 2022
2 parents 9cde8cc + 0ce0075 commit e77f6d5
Show file tree
Hide file tree
Showing 57 changed files with 192 additions and 90 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botium-core",
"version": "1.13.5",
"version": "1.13.6",
"description": "The Selenium for Chatbots",
"main": "index.js",
"module": "dist/botium-es.js",
Expand Down
5 changes: 3 additions & 2 deletions src/helpers/RetryHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ module.exports = class RetryHelper {
factor: caps[`RETRY_${section.toUpperCase()}_FACTOR`] || (_.isNil(options.factor) ? 1 : options.factor),
minTimeout: caps[`RETRY_${section.toUpperCase()}_MINTIMEOUT`] || (_.isNil(options.minTimeout) ? 1000 : options.minTimeout)
}

debug(`Retry for ${section} is ${this.retrySettings.retries > 0 ? 'enabled' : 'disabled'}. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`)
if (this.retrySettings.retries > 0) {
debug(`Retry for ${section} is enabled. Settings: ${JSON.stringify(this.retrySettings)} Patterns: ${JSON.stringify(this.retryErrorPatterns.map(r => r.toString()))}`)
}
}

shouldRetry (err) {
Expand Down
4 changes: 3 additions & 1 deletion src/scripting/MatchFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const equals = (ignoreCase) => (botresponse, utterance) => {
const wer = () => (botresponse, utterance, args) => {
botresponse = _normalize(botresponse || '')
utterance = toString(utterance || '')
return speechScorer.wordErrorRate(botresponse, utterance) <= args[0]

const threshold = ([',', '.'].find(p => `${args[0]}`.includes(p)) ? parseFloat(args[0]) : parseInt(args[0]) / 100)
return speechScorer.wordErrorRate(botresponse, utterance) <= threshold
}

const getMatchFunction = (matchingMode) => {
Expand Down
18 changes: 14 additions & 4 deletions src/scripting/ScriptingProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ module.exports = class ScriptingProvider {
}
debug(`assertBotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} = ${tomatch} ...`)
const found = _.find(tomatch, (utt) => this.matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]))
const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'WerAsserter' : 'TextMatchAsserter'
const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'Word Error Rate Asserter' : 'Text Match Asserter'
if (_.isNil(found)) {
let message = `${stepTag}: Bot response `
message += meMsg ? `(on ${meMsg}) ` : ''
Expand All @@ -148,13 +148,18 @@ module.exports = class ScriptingProvider {
{
type: 'asserter',
source: asserterType,
params: {
matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE],
args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
},
context: {
stepTag
},
cause: {
expected: tomatch,
actual: botresponse,
matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE]
matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE],
args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
}
}
)
Expand All @@ -166,7 +171,7 @@ module.exports = class ScriptingProvider {
}
debug(`assertBotNotResponse ${stepTag} ${meMsg ? `(${meMsg}) ` : ''}BOT: ${botresponse} != ${nottomatch} ...`)
const found = _.find(nottomatch, (utt) => this.matchFn(botresponse, utt, this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS]))
const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'WerAsserter' : 'TextMatchAsserter'
const asserterType = this.caps[Capabilities.SCRIPTING_MATCHING_MODE] === 'wer' ? 'Word Error Rate Asserter' : 'Text Match Asserter'
if (!_.isNil(found)) {
let message = `${stepTag}: Bot response `
message += meMsg ? `(on ${meMsg}) ` : ''
Expand All @@ -179,14 +184,19 @@ module.exports = class ScriptingProvider {
{
type: 'asserter',
source: asserterType,
params: {
matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE],
args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
},
context: {
stepTag
},
cause: {
not: true,
expected: nottomatch,
actual: botresponse,
matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE]
matchingMode: this.caps[Capabilities.SCRIPTING_MATCHING_MODE],
args: this.caps[Capabilities.SCRIPTING_MATCHING_MODE_ARGS] || null
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const BaseCountAsserter = require('./BaseCountAsserter')
module.exports = class BotRepliesConsumedAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'BotReplies')
this.name = 'BotRepliesConsumedAsserter'
this.name = 'Bot Replies Consumed Asserter'
}

async _getCount (argv) { return argv.container._QueueLength() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const BaseCountAsserter = require('./BaseCountAsserter')
module.exports = class BotRepliesUnconsumedCountAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'unconsumed bot replies')
this.name = 'BotRepliesUnconsumedCountAsserter'
this.name = 'Bot Replies Unconsumed Count Asserter'
}

async _getCount (argv) { return argv.container._QueueLength() }
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/ButtonsAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class ButtonsAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'ButtonsAsserter'
this.name = 'Buttons Asserter'
}

_evalButtons (args, botMsg) {
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/ButtonsCountAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _buttonsCount = ({ botMsg }) => {
module.exports = class ButtonsCountAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'Buttons')
this.name = 'ButtonsCountAsserter'
this.name = 'Buttons Count Asserter'
}

async _getCount (argv) { return _buttonsCount(argv) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _buttonsCount = ({ botMsg }) => {
module.exports = class ButtonsCountRecAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'Buttons')
this.name = 'ButtonsCountRecAsserter'
this.name = 'Buttons Count (recursive) Asserter'
}

async _getCount (argv) { return _buttonsCount(argv) }
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/CardsAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = class CardsAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'CardsAsserter'
this.name = 'Cards Asserter'
}

_evalCards (args, botMsg) {
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/CardsCountAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _cardsCount = ({ botMsg }) => {
module.exports = class CardsCountAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'Cards')
this.name = 'CardsCountAsserter'
this.name = 'Cards Count Asserter'
}

async _getCount (argv) { return _cardsCount(argv) }
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/CardsCountRecAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _cardsCount = ({ botMsg }) => {
module.exports = class CardsCountRecAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'Cards')
this.name = 'CardsCountRecAsserter'
this.name = 'Cards Count (recursive) Asserter'
}

async _getCount (argv) { return _cardsCount(argv) }
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/EntitiesAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = class EntitiesAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'EntitiesAsserter'
this.name = 'NLU Entities Asserter'
}

assertConvoStep ({ convo, convoStep, args, botMsg }) {
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/logichook/asserter/EntityContentAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ module.exports = class EntityContentAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'EntityContentAsserter'
this.name = 'NLU Entity Content Asserter'
}

assertConvoStep ({ convo, convoStep, args, botMsg }) {
if (!args || args.length < 2) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: EntityContentAsserter Missing argument`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Missing argument`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/EntityValuesAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = class EntityValuesAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'EntityValuesAsserter'
this.name = 'NLU Entity Values Asserter'
}

assertConvoStep ({ convo, convoStep, args, botMsg }) {
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/FormsAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = class FormsAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'FormsAsserter'
this.name = 'Form Elements Asserter'
}

_formTextsFromCardsRecursive (cards) {
Expand Down
6 changes: 3 additions & 3 deletions src/scripting/logichook/asserter/IntentAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = class IntentAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'IntentAsserter'
this.name = 'NLU Intent Asserter'
}

assertConvoStep ({ convo, convoStep, args, botMsg }) {
if (!args || args.length < 1) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: IntentAsserter Missing argument`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Missing argument`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand All @@ -20,7 +20,7 @@ module.exports = class IntentAsserter {
))
}
if (args.length > 1) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: IntentAsserter Too much argument "${args}"`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Too much arguments "${args}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand Down
8 changes: 4 additions & 4 deletions src/scripting/logichook/asserter/IntentConfidenceAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ module.exports = class IntentConfidenceAsserter {
throw Error(`IntentConfidenceAsserter Excepted minimum is not valid ${this.globalExpectedMinimum}`)
}
}
this.name = 'IntentConfidenceAsserter'
this.name = 'NLU Intent Confidence Asserter'
}

assertConvoStep ({ convo, convoStep, args, botMsg, isGlobal }) {
if (args.length > 1) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: IntentConfidenceAsserter Too much arguments "${args}"`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: ${this.name} Too much arguments "${args}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand All @@ -35,7 +35,7 @@ module.exports = class IntentConfidenceAsserter {
const hasLocalExpectedMinimum = args && args.length

if (!this.hasGlobalExpectedMinimum && !hasLocalExpectedMinimum) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: IntentConfidenceAsserter configured neither global, nor local`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: NLU Intent Confidence Asserter configured neither global, nor local`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand All @@ -53,7 +53,7 @@ module.exports = class IntentConfidenceAsserter {
if (hasLocalExpectedMinimum) {
expectedMinimum = Number(args[0])
if (parseInt(expectedMinimum, 10) !== expectedMinimum) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: IntentConfidenceAsserter Wrong argument. It must be integer "${args[0]}"`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: NLU Intent Confidence Asserter Wrong argument. It must be integer "${args[0]}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/logichook/asserter/IntentUniqueAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ module.exports = class IntentUniqueAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'IntentUniqueAsserter'
this.name = 'NLU Intent Unique Asserter'
}

assertConvoStep ({ convo, convoStep, args, botMsg }) {
if (args.length > 0) {
return Promise.reject(new BotiumError(
`${convoStep.stepTag}: IntentUniqueAsserter Too much argument "${args}"`,
`${convoStep.stepTag}: ${this.name} Too much argument "${args}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand Down
10 changes: 5 additions & 5 deletions src/scripting/logichook/asserter/JsonPathAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = class JsonPathAsserter {
this.context = context
this.caps = caps
this.globalArgs = globalArgs
this.name = context.ref || 'JsonPathAsserter'
this.name = context.ref || 'JsonPath Asserter'
}

assertNotConvoStep (params) {
Expand All @@ -24,7 +24,7 @@ module.exports = class JsonPathAsserter {
_getConfig (convoStep, args) {
if (this.globalArgs && this.globalArgs.path) {
if (args && args.length > 1) {
throw new BotiumError(`${convoStep.stepTag}: JsonPathAsserter 0 or 1 arguments expected "${toString(args)}"`,
throw new BotiumError(`${convoStep.stepTag}: ${this.name} 0 or 1 arguments expected "${toString(args)}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand All @@ -44,7 +44,7 @@ module.exports = class JsonPathAsserter {
if (_.has(this.globalArgs, 'argCount')) {
const argCount = this.globalArgs.argCount
if (argCount === 0 && args && args.length > 0) {
throw new BotiumError(`${convoStep.stepTag}: JsonPathAsserter ${argCount} arguments expected "${toString(args)}"`,
throw new BotiumError(`${convoStep.stepTag}: ${this.name} ${argCount} arguments expected "${toString(args)}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand All @@ -56,7 +56,7 @@ module.exports = class JsonPathAsserter {
}
)
} else if (!args || args.length !== argCount) {
throw new BotiumError(`${convoStep.stepTag}: JsonPathAsserter ${argCount} arguments expected "${toString(args)}"`,
throw new BotiumError(`${convoStep.stepTag}: ${this.name} ${argCount} arguments expected "${toString(args)}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand All @@ -75,7 +75,7 @@ module.exports = class JsonPathAsserter {
}
} else {
if (!args || args.length === 0 || args.length > 2) {
throw new BotiumError(`${convoStep.stepTag}: JsonPathAsserter 1 or 2 arguments expected "${toString(args)}"`,
throw new BotiumError(`${convoStep.stepTag}: ${this.name} 1 or 2 arguments expected "${toString(args)}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/logichook/asserter/JsonPathCountAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const _jsonPathCount = ({ botMsg, args }) => {
module.exports = class JsonPathCountAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'JsonPath', 1)
this.name = 'JsonPathCountAsserter'
this.name = 'JsonPath Count Asserter'
}

async _getCount (argv) { return _jsonPathCount(argv) }
Expand All @@ -20,7 +20,7 @@ module.exports = class JsonPathCountAsserter extends BaseCountAsserter {
const { args, convoStep } = argv

if (!args || args.length < 1 || args.length > 2) {
throw new BotiumError(`${convoStep.stepTag}: JsonPathCountAsserter 1 or 2 arguments expected "${args}"`,
throw new BotiumError(`${convoStep.stepTag}: ${this.name} 1 or 2 arguments expected "${args}"`,
{
type: 'asserter',
subtype: 'wrong parameters',
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/MediaAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = class MediaAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'MediaAsserter'
this.name = 'Media Attachment Asserter'
}

_evalMedia (args, botMsg) {
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/MediaCountAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _mediaCount = ({ botMsg }) => {
module.exports = class MediaCountAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'Media')
this.name = 'MediaCountAsserter'
this.name = 'Media Attachment Count Asserter'
}

async _getCount (argv) { return _mediaCount(argv) }
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/MediaCountRecAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const _mediaCount = ({ botMsg }) => {
module.exports = class MediaCountRecAsserter extends BaseCountAsserter {
constructor (context, caps = {}) {
super(context, caps, 'Media')
this.name = 'MediaCountRecAsserter'
this.name = 'Media Count (recursive) Asserter'
}

async _getCount (argv) { return _mediaCount(argv) }
Expand Down
2 changes: 1 addition & 1 deletion src/scripting/logichook/asserter/PauseAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = class PauseAsserter {
constructor (context, caps = {}) {
this.context = context
this.caps = caps
this.name = 'PauseAsserter'
this.name = 'Pause Asserter'
}

assertConvoBegin ({ convo, args }) {
Expand Down
Loading

0 comments on commit e77f6d5

Please sign in to comment.