Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test if Bot is showing dynamic data #98

Open
stephenws opened this issue Oct 18, 2018 · 6 comments
Open

How to test if Bot is showing dynamic data #98

stephenws opened this issue Oct 18, 2018 · 6 comments
Labels

Comments

@stephenws
Copy link

Hello All

My Testing Bot is showing dynamic data
Suppose, I asked to Bot : What is Emp id of Stephen
Then he will Reply : 12214

Like wise for Dynamic data how can we test

@codeforequity-at
Copy link
Owner

Two options:

  1. You can use regular expressions, for this you can configure the matching mode capability (https://github.com/codeforequity-at/botium-core/wiki/Botium-Configuration#scripting_matching_mode)

  2. Dependening on your scenario, you can use seperate utterances files as well - if you would allow one of several bot responses (https://github.com/codeforequity-at/botium-core/wiki/Botium-Scripting#composing-in-text-files)

@piotrjak
Copy link

piotrjak commented Oct 3, 2019

I found this documentation page https://botium.atlassian.net/wiki/spaces/BOTIUM/pages/60817419/What+are+the+Advanced+Scripting+Settings+in+Botium+Box , but the regular expressions are still not working for me in botium-bindings.

my config

{
  "botium": {
    "Capabilities": {
      "PROJECTNAME": "Kelle Chatbot",
      "CONTAINERMODE": "simplerest",
      "WAITFORBOTTIMEOUT": "10000",
      "SCRIPTING_ENABLE_MEMORY": "true", // i think this is vital?
      "SIMPLEREST_METHOD": "POST",
      "SIMPLEREST_URL": "http://localhost:3000/webhook",
      "SIMPLEREST_HEADERS_TEMPLATE": {
        "Content-Type": "application/json"
      },
      "SIMPLEREST_REQUEST_HOOK": "./botium/modules/requestHook.js",
      "SIMPLEREST_BODY_TEMPLATE": {
        "plainText": true,
        "userId": "b6742761-f00b-4ca3-96c9-07b6e044d903",
        "message": "{{msg.messageText}}"
      },
      "SIMPLEREST_PING_URL": "http://localhost:3000/ping",
      "SIMPLEREST_RESPONSE_JSONPATH": "$.payload.facebook.text",
      "SIMPLEREST_RESPONSE_HOOK": "botMsg.cards = context.payload.attachments && context.payload.attachments.adaptiveCards",
      "SIMPLEREST_CONTEXT_JSONPATH": "$",
      "SIMPLEREST_MEDIA_JSONPATH": "$.payload.attachments.adaptiveCards[*].body[*].columns[*].items[1].text",
      "ASSERTERS": [
        {
          "ref": "CARDS",
          "src": "./botium/asserters/CardAsserter.js"
        },
        {
          "ref": "LOCATION",
          "src": "./botium/asserters/LocationAsserter.js"
        },
        {
          "ref": "POLYGON",
          "src": "./botium/asserters/PolygonAsserter.js"
        }
      ]
    },
    "Sources": {},
    "Envs": {}
  }
}

test convo

Profit Share this year

#me
profit share 2019

#bot
Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals $655.72.
CARDS profitshare

error


    TranscriptError: BotiumError: Profit Share this year/Line 6: Expected bot response (on Line 3: #me - profit share 2019) "Your total profit share for 2019 from January to October totals $655.72." to match one of "Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals $655.72."

It seems that whatever I type it's always escaped...

@codeforequity-at
Copy link
Owner

SCRIPTING_ENABLE_MEMORY is not vital for this example.
SCRIPTING_MATCHING_MODE capability is missing, you have to tell Botium to interpret the assertions as regular expressions.
Finally, the $ character and the . characters have to be escaped to use it as literal in a regular expression:

#bot
Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals \$655\.72\.

@piotrjak
Copy link

piotrjak commented Oct 4, 2019

thanks for the response, but unfortunately it still doesn't work
botum.json

      "SCRIPTING_MATCHING_MODE": "regexpIgnoreCase", // regexp doesn't work either

error

   TranscriptError: BotiumError: Profit Share this year/Line 6: Expected bot response (on Line 3: #me - profit share 2019) "Your total profit share for 2019 from January to October totals $655.72." to match one of "Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals \$655\.72\."

starting botium bindings

bb.helper.jest().setupJestTestSuite();

@piotrjak
Copy link

piotrjak commented Oct 4, 2019

ok, it works for "regexp", but not for "regexpIgnoreCase" when I actually provide the right regex

January|February

and not

[January|February]

@codeforequity-at
Copy link
Owner

the mode regexpIgnoreCase is only included in the very very latest botium-core build. maybe you have to update the software first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants