Skip to content

Commit

Permalink
Merge pull request #711 from codeforequity-at/develop
Browse files Browse the repository at this point in the history
Botium Core 1.13.7
  • Loading branch information
codeforequity-at authored Oct 11, 2022
2 parents e77f6d5 + e5d83eb commit 781b0d7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 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.6",
"version": "1.13.7",
"description": "The Selenium for Chatbots",
"main": "index.js",
"module": "dist/botium-es.js",
Expand Down
6 changes: 3 additions & 3 deletions src/scripting/logichook/LogicHookUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ module.exports = class LogicHookUtils {

// 1 gives possibility to use default asserter as global asserter
if (hookType === 'asserter') {
const asserter = DEFAULT_ASSERTERS.find(asserter => src === asserter.className)
const asserter = DEFAULT_ASSERTERS.find(asserter => src === asserter.className || src === asserter.name)
if (asserter) {
return new (asserter.Class)({ ref, ...this.buildScriptContext }, this.caps, args)
}
}
if (hookType === 'logichook') {
const lh = DEFAULT_LOGIC_HOOKS.find(lh => src === lh.className)
const lh = DEFAULT_LOGIC_HOOKS.find(lh => src === lh.className || src === lh.name)
if (lh) {
return new (lh.Class)({ ref, ...this.buildScriptContext }, this.caps, args)
}
}
if (hookType === 'userinput') {
const ui = DEFAULT_USER_INPUTS.find(ui => src === ui.className)
const ui = DEFAULT_USER_INPUTS.find(ui => src === ui.className || src === ui.name)
if (ui) {
return new (ui.Class)({ ref, ...this.buildScriptContext }, this.caps, args)
}
Expand Down
7 changes: 4 additions & 3 deletions src/scripting/logichook/asserter/JsonPathAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ module.exports = class JsonPathAsserter {
))
}
}
if (assert) {

if (!_.isNil(assert)) {
const actual = (_.isArray(jsonPathValues) && jsonPathValues.length === 1) ? jsonPathValues[0] : jsonPathValues

let matchFn = this.context.Match
Expand All @@ -137,7 +138,7 @@ module.exports = class JsonPathAsserter {
const match = jsonPathValues.find(a => matchFn(a, assert))

if (not && match) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: Not expected: ${toString(actual)} in jsonPath ${path}"`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: Not expected: "${toString(actual)}" in jsonPath ${path}"`,
{
type: 'asserter',
source: this.name,
Expand All @@ -158,7 +159,7 @@ module.exports = class JsonPathAsserter {
))
}
if (!not && !match) {
return Promise.reject(new BotiumError(`${convoStep.stepTag}: Expected: ${assert} in jsonPath ${path}: Actual: ${toString(actual)}`,
return Promise.reject(new BotiumError(`${convoStep.stepTag}: Expected: "${assert}" in jsonPath ${path}, actual: ${toString(actual)}`,
{
type: 'asserter',
source: this.name,
Expand Down
14 changes: 7 additions & 7 deletions test/scripting/asserters/jsonpathAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
})
} catch (err) {
console.log(err.message)
assert.isTrue(err.message.includes('Expected: message4 in jsonPath $.messages[*].label: Actual: message1,message2,message3'))
assert.isTrue(err.message.includes('Expected: "message4" in jsonPath $.messages[*].label, actual: message1,message2,message3'))
}
})
it('should fail on not existing jsonpath', async function () {
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
}
})
} catch (err) {
assert.isTrue(err.message.indexOf('Expected: {"label":"message2"} in jsonPath $.messages[0]: Actual: {"label":"message1"}') > 0)
assert.isTrue(err.message.indexOf('Expected: "{"label":"message2"}" in jsonPath $.messages[0], actual: {"label":"message1"}') > 0)
assert.isNotNull(err.context)
assert.isNotNull(err.context.cause)
assert.isNotTrue(err.context.cause.not)
Expand All @@ -155,7 +155,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected: test2 in jsonPath $.test') > 0)
assert.isTrue(err.message.indexOf('Expected: "test2" in jsonPath $.test') > 0)
assert.isNotNull(err.context)
assert.isNotNull(err.context.cause)
assert.isNotTrue(err.context.cause.not)
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Not expected: test1 in jsonPath $.test') > 0)
assert.isTrue(err.message.indexOf('Not expected: "test1" in jsonPath $.test') > 0)
assert.isNotNull(err.context)
assert.isNotNull(err.context.cause)
assert.isTrue(err.context.cause.not)
Expand Down Expand Up @@ -252,7 +252,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected: test2 in jsonPath $.test') > 0)
assert.isTrue(err.message.indexOf('Expected: "test2" in jsonPath $.test') > 0)
assert.isNotNull(err.context)
assert.isNotNull(err.context.cause)
assert.isNotTrue(err.context.cause.not)
Expand Down Expand Up @@ -332,7 +332,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected: value in jsonPath $.test') > 0)
assert.isTrue(err.message.indexOf('Expected: "value" in jsonPath $.test') > 0)
}
})
it('should succeed on setting matching mode in global args', async function () {
Expand Down Expand Up @@ -373,7 +373,7 @@ describe('scripting.asserters.jsonPathAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected: value1 in jsonPath $.test') > 0)
assert.isTrue(err.message.indexOf('Expected: "value1" in jsonPath $.test') > 0)
}
})
})
Expand Down

0 comments on commit 781b0d7

Please sign in to comment.