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 Adaptive Cards #69

Open
ihachani opened this issue Feb 27, 2018 · 3 comments
Open

How to test Adaptive Cards #69

ihachani opened this issue Feb 27, 2018 · 3 comments

Comments

@ihachani
Copy link

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.

@ihachani
Copy link
Author

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.

@microsoftly
Copy link
Owner

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?

@microsoftly
Copy link
Owner

&/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

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