microsoftly/BotTester

Test prompt objects other than text

Opened this issue · 1 comments

I would like to test the bot ability to respond with choices prompts and be able to answer those prompts.
So for:

var salesData = {
    "west": {
        units: 200,
        total: "$6,000"
    },
    "central": {
        units: 100,
        total: "$3,000"
    },
    "east": {
        units: 300,
        total: "$9,000"
    }
};

bot.dialog('getSalesData', [
    function (session) {
        builder.Prompts.choice(session, "Which region would you like sales for?", salesData); 
    },
    function (session, results) {
        if (results.response) {
            var region = salesData[results.response.entity];
            session.send(`We sold ${region.units} units for a total of ${region.total}.`); 
        } else {
            session.send("OK");
        }
    }
]);

do:

var expectedChoicePrompt  = PromptChoice("Which region would you like sales for?", salesData)
new BotTester(bot)
            .sendMessageToBot("hello", expectedChoicePrompt)
            .sendMessageToBot("central", " We sold 100 units for a total of \"300$\".")
            .runTest();

I find this issue important. The way I'm creating my tests is using the direct line cli client to see what's sent/received and recreate it as an object and passing along as the 'output' parameter. The important point to notice in @shaikatzir question is maybe the "PromptChoice" that would recreate it easily. I recreated the attachment and other activities as well, it's just not that easy (or beautiful to see a lot of unnecessary javascript objects in my beautifully simple test). Btw, kudos to you @microsoftly , this library is a bless, and your work helped me save I don't know how many hours of work (I've created hundreds of tests using this library already!). Really, thank you very much. I also am trying to learning Typescript in my free hours so that I can help you, but is there any other way I can help you in the meantime ? o/