Skip to content

Commit

Permalink
Merge pull request #653 from codeforequity-at/develop
Browse files Browse the repository at this point in the history
Botium Core 1.11.13
  • Loading branch information
Botium authored Sep 14, 2021
2 parents 8772243 + 0101aea commit b743664
Show file tree
Hide file tree
Showing 11 changed files with 1,142 additions and 383 deletions.
1,386 changes: 1,044 additions & 342 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botium-core",
"version": "1.11.12",
"version": "1.11.13",
"description": "The Selenium for Chatbots",
"main": "index.js",
"module": "dist/botium-es.js",
Expand All @@ -19,7 +19,7 @@
"test": "cross-env NODE_PATH=\"./test/plugins/plugindir/fromfolder:./test/plugins/plugindir/fromfile:./test/security/resources\" mocha \"./test/**/*.spec.js\"",
"coverage:report": "nyc report --reporter=lcov npm test",
"license-checker": "license-checker > LICENSES-3RDPARTY.txt",
"update-dependencies": "npm-check-updates -u --timeout 120000"
"update-dependencies": "npm-check-updates --reject globby -u --timeout 120000"
},
"repository": {
"type": "git",
Expand All @@ -32,17 +32,17 @@
},
"homepage": "https://www.botium.ai",
"dependencies": {
"@babel/runtime": "^7.15.3",
"@babel/runtime": "^7.15.4",
"async": "^3.2.1",
"body-parser": "^1.19.0",
"boolean": "^3.1.2",
"boolean": "^3.1.4",
"bottleneck": "^2.19.5",
"csv-parse": "^4.16.0",
"csv-parse": "^4.16.3",
"debug": "^4.3.2",
"esprima": "^4.0.1",
"express": "^4.17.1",
"globby": "11.0.4",
"ioredis": "^4.27.7",
"ioredis": "^4.27.9",
"is-class": "^0.0.9",
"is-json": "^2.0.1",
"jsonpath": "^1.1.1",
Expand All @@ -59,38 +59,38 @@
"rimraf": "^3.0.2",
"sanitize-filename": "^1.6.3",
"slugify": "^1.6.0",
"socket.io": "^4.1.3",
"socket.io-client": "^4.1.3",
"socket.io": "^4.2.0",
"socket.io-client": "^4.2.0",
"socketio-auth": "^0.1.1",
"swagger-jsdoc": "^6.1.0",
"swagger-ui-express": "^4.1.6",
"uuid": "^8.3.2",
"vm2": "^3.9.3",
"write-yaml": "^1.0.0",
"xlsx": "^0.17.0",
"xlsx": "^0.17.1",
"xregexp": "^5.1.0",
"yaml": "^1.10.2"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/node": "^7.14.9",
"@babel/core": "^7.15.5",
"@babel/node": "^7.15.4",
"@babel/plugin-transform-runtime": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-env": "^7.15.6",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"cross-env": "^7.0.3",
"eslint": "^7.32.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^4.1.0",
"license-checker": "^25.0.1",
"mocha": "^9.0.3",
"nock": "^13.1.1",
"npm-check-updates": "^11.8.3",
"mocha": "^9.1.1",
"nock": "^13.1.3",
"npm-check-updates": "^11.8.5",
"nyc": "^15.1.0",
"rollup": "^2.56.2",
"rollup": "^2.56.3",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
Expand Down
11 changes: 5 additions & 6 deletions src/scripting/ScriptingProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ module.exports = class ScriptingProvider {
}

GetConversationFlowView ({
getConvoNodeHash = null, detectLoops = false, summarizeMultiSteps = true, includeConvoSteps = false,
getConvoNodeHash = null, detectLoops = false, summarizeMultiSteps = true,
extPickMeNodeProps = [], extPickBotNodeProps = [], extPickMeHashProps = [], extPickBotHashProps = []
} = {}) {
const root = []
Expand Down Expand Up @@ -1139,8 +1139,7 @@ module.exports = class ScriptingProvider {
const convoNodeHeader = {
header: _.pick(convo.header, ['name', 'description']),
sourceTag: convo.sourceTag,
convoStepIndices: convoNode.convoStepIndices,
conversation: includeConvoSteps ? convo.conversation : undefined
convoStepIndices: convoNode.convoStepIndices
}

let hash = getConvoNodeHash && getConvoNodeHash({ convo, convoNode })
Expand All @@ -1154,7 +1153,7 @@ module.exports = class ScriptingProvider {

const existingChildNode = currentChildren.find(c => c.hash === hash)
if (existingChildNode) {
existingChildNode.convos.push(convoNodeHeader)
existingChildNode.convos.push(_.cloneDeep(convoNodeHeader))
currentChildren = existingChildNode.childNodes
continue
}
Expand All @@ -1170,7 +1169,7 @@ module.exports = class ScriptingProvider {
if (existingConvo) {
existingConvo.convoStepIndices = [...existingConvo.convoStepIndices, ...convoNodeHeader.convoStepIndices]
} else {
existingBotNode.convos.push(convoNodeHeader)
existingBotNode.convos.push(_.cloneDeep(convoNodeHeader))
}
currentChildren = existingBotNode.childNodes
continue
Expand All @@ -1180,7 +1179,7 @@ module.exports = class ScriptingProvider {
key: randomize('0', 20),
hash: hash,
convoNodes: convoNodeValues,
convos: [convoNodeHeader],
convos: [_.cloneDeep(convoNodeHeader)],
childNodes: []
}
if (node.sender === 'bot') {
Expand Down
6 changes: 3 additions & 3 deletions src/scripting/logichook/asserter/BaseCountAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = class BaseCountAsserter {

_getBotiumErrMsg (argv, not, count, check) {
const { convoStep } = argv
if (not) return `${convoStep.stepTag} Not expected ${this.elementName} count ${count}${check}`
else return `${convoStep.stepTag} Expected ${this.elementName} count ${count}${check}`
if (not) return `${convoStep.stepTag} Not expected ${this.elementName} count ${count} to be ${check}`
else return `${convoStep.stepTag} Expected ${this.elementName} count ${count} to be ${check}`
}

_getBotiumErrArgs (argv, not, count, check) {
Expand Down Expand Up @@ -48,7 +48,7 @@ module.exports = class BaseCountAsserter {
if (arg.startsWith('>')) return count > parseInt(arg.slice(1))
if (arg.startsWith('==')) return count === parseInt(arg.slice(2))
if (arg.startsWith('=')) return count === parseInt(arg.slice(1))
return count === arg
return count === parseInt(arg)
}

async assertNotConvoBegin (argv) { return this._assertNot(argv) }
Expand Down
4 changes: 2 additions & 2 deletions src/scripting/logichook/asserter/BaseTextAsserter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = class BaseTextAsserter {
))
}
return Promise.reject(new BotiumError(
`${convoStep.stepTag}: Not expected ${this.mode === 'all' ? 'texts' : 'any text'} in response "${founds}"`,
`${convoStep.stepTag}: Not expected ${this.mode === 'all' ? 'text(s)' : 'any text'} in response "${founds}"`,
{
type: 'asserter',
source: this.name,
Expand Down Expand Up @@ -92,7 +92,7 @@ module.exports = class BaseTextAsserter {
))
}
return Promise.reject(new BotiumError(
`${convoStep.stepTag}: Expected ${this.mode === 'all' ? 'texts' : 'any text'} in response "${notFounds}"`,
`${convoStep.stepTag}: Expected ${this.mode === 'all' ? 'text(s)' : 'any text'} in response "${notFounds}"`,
{
type: 'asserter',
source: this.name,
Expand Down
58 changes: 58 additions & 0 deletions test/scripting/asserters/buttonsAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,52 @@ describe('scripting.asserters.buttonsCountAsserter', function () {
}
})
})
it('should succeed on 3 with 3 buttons', async function () {
await this.buttonsCountAsserter.assertConvoStep({
convoStep: { stepTag: 'test' },
args: ['3'],
botMsg: {
buttons: [{ text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }],
cards: [
{ buttons: [{ text: 'test.jpg' }], cards: [{ buttons: [{ text: 'test.jpg' }] }] }
]
}
})
})
it('should fail on 3 with 4 buttons', async function () {
try {
await this.buttonsCountAsserter.assertConvoStep({
convoStep: { stepTag: 'test' },
args: ['3'],
botMsg: {
buttons: [{ text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }],
cards: [
{ buttons: [{ text: 'test.jpg' }], cards: [{ buttons: [{ text: 'test.jpg' }] }] }
]
}
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected Buttons count 4 to be 3') >= 0)
}
})
it('should fail on >3 with 3 buttons', async function () {
try {
await this.buttonsCountAsserter.assertConvoStep({
convoStep: { stepTag: 'test' },
args: ['>3'],
botMsg: {
buttons: [{ text: 'test.jpg' }, { text: 'test.jpg' }, { text: 'test.jpg' }],
cards: [
{ buttons: [{ text: 'test.jpg' }], cards: [{ buttons: [{ text: 'test.jpg' }] }] }
]
}
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected Buttons count 3 to be >3') >= 0)
}
})
it('should succeed on >=3 with rec buttons', async function () {
await this.buttonsCountRecAsserter.assertConvoStep({
convoStep: { stepTag: 'test' },
Expand All @@ -204,4 +250,16 @@ describe('scripting.asserters.buttonsCountAsserter', function () {
}
})
})
it('should succeed on 3 with rec buttons', async function () {
await this.buttonsCountRecAsserter.assertConvoStep({
convoStep: { stepTag: 'test' },
args: ['3'],
botMsg: {
buttons: [{ text: 'test.jpg' }],
cards: [
{ buttons: [{ text: 'test.jpg' }], cards: [{ buttons: [{ text: 'test.jpg' }] }] }
]
}
})
})
})
2 changes: 1 addition & 1 deletion test/scripting/asserters/jsonpathAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('scripting.asserters.jsonPathCountAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected JsonPath count 2>2') >= 0)
assert.isTrue(err.message.indexOf('Expected JsonPath count 2 to be >2') >= 0)
}
})
})
8 changes: 4 additions & 4 deletions test/scripting/asserters/mediaAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('scripting.asserters.mediaCountAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected Media count 0>0') >= 0)
assert.isTrue(err.message.indexOf('Expected Media count 0 to be >0') >= 0)
}
})
it('should succeed on >=0 with one media', async function () {
Expand Down Expand Up @@ -228,7 +228,7 @@ describe('scripting.asserters.mediaCountAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Expected Media count 1>1') >= 0)
assert.isTrue(err.message.indexOf('Expected Media count 1 to be >1') >= 0)
}
})
it('should succeed on <=1 with one media', async function () {
Expand Down Expand Up @@ -269,7 +269,7 @@ describe('scripting.asserters.mediaCountAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Not expected Media count 1>0') >= 0)
assert.isTrue(err.message.indexOf('Not expected Media count 1 to be >0') >= 0)
}
})
it('should succeed on >1 with ! no media', async function () {
Expand All @@ -292,7 +292,7 @@ describe('scripting.asserters.mediaCountAsserter', function () {
})
assert.fail('should have failed')
} catch (err) {
assert.isTrue(err.message.indexOf('Not expected Media count 2>1') >= 0)
assert.isTrue(err.message.indexOf('Not expected Media count 2 to be >1') >= 0)
}
})
it('should succeed on >3 with rec media', async function () {
Expand Down
12 changes: 6 additions & 6 deletions test/scripting/asserters/textContainsAllAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('scripting.asserters.textContainsAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_contains_all_nok_base/Line 2: assertion error - Line 2: Expected texts in response "word3"')
assert.equal(err.message, 'text_contains_all_nok_base/Line 2: assertion error - Line 2: Expected text(s) in response "word3"')
}
})

Expand All @@ -91,7 +91,7 @@ describe('scripting.asserters.textContainsAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_contains_all_nok_more_words/Line 2: assertion error - Line 2: Expected texts in response "word3,word4,word5"')
assert.equal(err.message, 'text_contains_all_nok_more_words/Line 2: assertion error - Line 2: Expected text(s) in response "word3,word4,word5"')
}
})

Expand All @@ -105,7 +105,7 @@ describe('scripting.asserters.textContainsAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_contains_all_nok_more_words/Line 2: assertion error - Line 2: Expected texts in response "word3,word4"')
assert.equal(err.message, 'text_contains_all_nok_more_words/Line 2: assertion error - Line 2: Expected text(s) in response "word3,word4"')
}
})

Expand All @@ -119,7 +119,7 @@ describe('scripting.asserters.textContainsAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_contains_all_nok_utterances/Line 2: assertion error - Line 2: Expected texts in response "word3,word4,hi,hello!"')
assert.equal(err.message, 'text_contains_all_nok_utterances/Line 2: assertion error - Line 2: Expected text(s) in response "word3,word4,hi,hello!"')
}
})

Expand All @@ -133,7 +133,7 @@ describe('scripting.asserters.textContainsAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_contains_all_nok_ignore_case/Line 2: assertion error - Line 2: Expected texts in response "Word3"')
assert.equal(err.message, 'text_contains_all_nok_ignore_case/Line 2: assertion error - Line 2: Expected text(s) in response "Word3"')
}
})

Expand All @@ -147,7 +147,7 @@ describe('scripting.asserters.textContainsAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_contains_all_nok_negate/Line 2: assertion error - Line 2: Not expected texts in response "word2"')
assert.equal(err.message, 'text_contains_all_nok_negate/Line 2: assertion error - Line 2: Not expected text(s) in response "word2"')
}
})
})
2 changes: 1 addition & 1 deletion test/scripting/asserters/textRegexpAllAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('scripting.asserters.textRegexpAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_regexp_all_nok/Line 2: assertion error - Line 2: Expected texts in response "id2_\\d\\d\\d"')
assert.equal(err.message, 'text_regexp_all_nok/Line 2: assertion error - Line 2: Expected text(s) in response "id2_\\d\\d\\d"')
}
})
})
2 changes: 1 addition & 1 deletion test/scripting/asserters/textWildcardAllAsserter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('scripting.asserters.textWildcardAllAsserter', function () {
await this.compiler.convos[0].Run(this.container)
assert.fail('expected error')
} catch (err) {
assert.equal(err.message, 'text_wildcard_all_nok/Line 2: assertion error - Line 2: Expected texts in response "id2_*3"')
assert.equal(err.message, 'text_wildcard_all_nok/Line 2: assertion error - Line 2: Expected text(s) in response "id2_*3"')
}
})
})

0 comments on commit b743664

Please sign in to comment.