microsoftly/BotTester

How to test Adaptive Cards

Opened this issue · 3 comments

I am trying to test an AdaptiveCard. I am using the example from the documentation to create the card.

    var msg = new builder.Message(session);
    msg.attachmentLayout(builder.AttachmentLayout.carousel)
    msg.attachments([
        new builder.HeroCard(session)
            .title("Classic White T-Shirt")
            .subtitle("100% Soft and Luxurious Cotton")
            .text("Price is $25 and carried in sizes (S, M, L, and XL)")
            .images([builder.CardImage.create(session, 'http://petersapparel.parseapp.com/img/whiteshirt.png')])
            .buttons([
                builder.CardAction.imBack(session, "buy classic white t-shirt", "Buy")
            ]),
        new builder.HeroCard(session)
            .title("Classic Gray T-Shirt")
            .subtitle("100% Soft and Luxurious Cotton")
            .text("Price is $25 and carried in sizes (S, M, L, and XL)")
            .images([builder.CardImage.create(session, 'http://petersapparel.parseapp.com/img/grayshirt.png')])
            .buttons([
                builder.CardAction.imBack(session, "buy classic gray t-shirt", "Buy")
            ])
    ]);

The example in the BotTester documentation says to test against an adaptive card object refrenece. My problem is I can't create the Adaptive card because I don't have a session object.

Another issue is the BotTester tests for undefined when a card is returned

The bot returns the message in the example above.

 return botTester
                .sendMessageToBot('someText', undefined)
                .runTest();

This passes when it should fail.

Good catch. The adaptive cards tests were a bit harder for me to work through because of how little I had interacted with them. Would you be interested in working with me on a solution?

&/also you should be able to mock the full adaptive card state without the session object. If I'm recalling correctly, the BotTester does a deep comparison and ignores anything that isn't expected