CatalystCode / alarm-bot-unit-testing

Example bot application with LUIS intents and unit testing
12 stars 3 forks source link

HeroCard Actions with button #3

Open chill-cod3r opened 6 years ago

chill-cod3r commented 6 years ago

Is there a way to interact with the HeroCards through this method of dialog flow?

module.exports = [
    {
        out: 'Set an alarm for 10pm',
    },
    {
        in: (message: any, assert: any, callback: any) => {
            // assert against proper herocard content
            // can i interact with it here in any way? is there a good strategy to mock that functionality in this style of integration test?
            callback();
        },
    },
];
morsh commented 6 years ago

@wolfejw86 - no, since the only input/output for those tests is textual. You can't simulate a mouse/component action.

chill-cod3r commented 6 years ago

good to know! thanks!

chill-cod3r commented 6 years ago

Actually this is not true! I just discovered that the text of a button is passed like a query string parameter: action?SetAlarm=<data to pass> If you set this as an:

{
  out: `action?SetAlarm=<data to pass>`
}

it will actually interact with the hero card! Potentially this could help a lot of folks who are trying to use this method of testing.

morsh commented 6 years ago

If it's supposed to simulate the text of a button, it should be something like:

{
  out: `<button text>`
}
chill-cod3r commented 6 years ago

not just simulate, but actually trigger. what i posted above will actually trigger the action of a user clicking a button on a HeroCard or something similar. Very useful when working with integration tests. Not sure if this is the right place for this discovery, but I found it very useful and thought I'd share.