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

Test prompt objects other than text #84

Open
shaikatzir opened this issue Nov 28, 2018 · 1 comment
Open

Test prompt objects other than text #84

shaikatzir opened this issue Nov 28, 2018 · 1 comment

Comments

@shaikatzir
Copy link

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();
@pernambucano
Copy link

pernambucano commented Feb 26, 2019

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/

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

No branches or pull requests

2 participants