I have added a custom bot to Microsoft teams channel and I am trying to do test automation for this bot using Microsoft graph API. I was able to send text messages to a bot in a team's channel by following the doc: https://docs.microsoft.com/en-us/graph/api/channel-post-message?view=graph-rest-1.0&tabs=http. I want to know if it is possible to replicate user click action on a button using graph APIs. Thanks in advance.
2 Answers
At the end of the day, your 'bot' is basically just a REST web service. To test it, you can send it messages that match the payload that would have been sent from Teams when the user clicked your button. To get this payload, I'd suggest debugging locally using NGrok, and loading the ngrok logging page (http://localhost:4000), which will show you the calls that are made. Capture that call and replay it using a testing harness of some sort, and you would be fine.
However, depending on what you're wanting to test, it might be possible to bypass the web call altogether, and create code that doesn't depend on any bot infrastructure at all (e.g. turnContexts and Activities). That would make your code more testable anyway, and the tests would run much faster.