gudwin / botbuilder-unit

Library for Microsoft Bot Framework Chatbot unit testing
GNU Lesser General Public License v3.0
11 stars 7 forks source link

How to test my own dialogs in botbuilder-unit? #5

Open rjgmail88 opened 6 years ago

rjgmail88 commented 6 years ago

Hello, I am looking at timmy.js where I see in order to test conversation flow mentioned in script array a new dialog '/' has been defined. I was wondering what if I need to test my dialog from my Bot app.
Ex: I have following dialog which triggers by LUIS intent help/

bot.dialog('Help', function (session) {
       session.send("Hello, I can help you to reserve a meeting room.")
        });
        session.endDialog();
    }).triggerAction({
        matches: 'Help'
    });

I don't want re-write this dialog as shows in timmy.js.

gudwin commented 6 years ago

Hi, What do you mean by saying "re-writing the dialog"?

You can test a standalone dialog by specifying a dialog function or a watterfall in the form of array. The library produce a UniversalBot class instance and registers the given dialog with path = "/"

Also you could pass an instance of UniversalBot class. In that case, the library will not produce a testing bot instance. This option also allows to test conversation between user and the bot from end to end

best regards,

rjgmail88 commented 6 years ago

What did I mean 're-writing the dialog' In timmy.js in order to test bot's following responses dialog dialog('/') has been written in as follows. "bot": "How should I call you?" "bot": "Nice to meet you, \"Timmy\"!"

bot.dialog('/', [
  session => builder.Prompts.text(session, 'How should I call you?'),
  (session, response) => session.endDialog(`Nice to meet you, ${JSON.stringify(response.response)}!`)
]);

What am I asking ? How can I test Help dialog mentioned in my original post in my test case. Do I need to re-write the dialog in test case file ?

gudwin commented 6 years ago

no, you don't no need to re-write, you could pass the same dialog

rjgmail88 commented 6 years ago

Is there a way you can help with the syntax.

rjgmail88 commented 6 years ago

@gudwin did you get chance to review my comment?

gudwin commented 6 years ago

Yeah, I'm adding your case as example into the library. I'll commit a release soon and will leave comment here too