-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d734375
commit d9e7582
Showing
22 changed files
with
3,613 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,34 @@ | ||
# chatbot-test | ||
# chatbot-test | ||
|
||
Test a specific task reminder chatbot running on WebSocket - ws://localhost:5555 and http://localhost:7777 | ||
|
||
This repo uses the chatbot test framework, [Botium](https://botium-docs.readthedocs.io/en/latest/) | ||
|
||
|
||
# Installation | ||
|
||
Please install node.js if you have not done so. | ||
|
||
``` | ||
npm install -g botium-bindings | ||
npm install -g botium-connector-websocket | ||
botium-bindings init mocha | ||
npm install && npm run mocha | ||
``` | ||
|
||
# Unit Tests | ||
|
||
Simply run: | ||
``` | ||
$ npm test | ||
``` | ||
|
||
# NOTE | ||
|
||
## spec/convo/give_me_a_picture.convo.txt | ||
|
||
This file is installed by one of botium packages. I couldn't figure out how to avoid it. | ||
|
||
# TODOs | ||
|
||
1. Test when there are at least 2 reminders in the queue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"botium": { | ||
"Capabilities": { | ||
"PROJECTNAME": "ChatBot Project Websocket", | ||
"CONTAINERMODE": "websocket", | ||
"WEBSOCKET_URL": "ws://127.0.0.1:5555", | ||
"WEBSOCKET_REQUEST_BODY_RAW": true, | ||
"WEBSOCKET_RESPONSE_RAW": true, | ||
"WEBSOCKET_RESPONSE_HOOK": "handle-response-reminders.js" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Response hook to pre-process response before calling unit testing scripts (botiumscripts) | ||
*/ | ||
module.exports = ({ botMsg }) => { | ||
// return "HELP" when handling the help reminder | ||
// what is returned is what we match with in the convo text (botiumscript) file | ||
if (botMsg.messageText.includes('I am a reminder bot')) { | ||
botMsg.messageText = 'HELP' | ||
return botMsg | ||
} | ||
|
||
// return if not dealing with a list of reminders in the queue | ||
if (!botMsg.messageText.includes('<table')) { | ||
return botMsg | ||
} | ||
|
||
// return "id: <id>, text: <text of action>" when handling list of reminders in the queue | ||
// what is returned is what we match with in the convo text (botiumscript) file | ||
let actual | ||
const regex = RegExp('<td>(.*?)</td>', 'gi') | ||
|
||
let arr | ||
let i = 0 | ||
while ((arr = regex.exec(botMsg.sourceData)) !== null) { | ||
arr[0] = arr[0].replace('<td>', '').replace('</td>', '') | ||
if (i === 0) { | ||
actual = `id: ${arr[0]}, text: ` | ||
} else if (i === 2) { | ||
actual += arr[0] | ||
} | ||
i++ | ||
} | ||
botMsg.messageText = actual | ||
|
||
return botMsg | ||
} |
Oops, something went wrong.