Skip to content

How to test Adaptive Cards #69

Open

Description

@ihachani

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.

Activity

  1. ihachani commented on Feb 27, 2018

    @ihachani
    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.

  2. microsoftly commented on Feb 27, 2018

    @microsoftly
    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?

  3. microsoftly commented on Feb 27, 2018

    @microsoftly
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions