Facebook test app usage in automated tests - facebook

Are there someone form facebook team?
Our app has deep integration with FB api and it's critical to test if all works correct. My question is if it's legal to use test app with and test users in our automated tests and run them with headless browser like puppeteer? If not, what alternatives available for us?

Related

How can i test Facebook webhooks in a development environment?

In my app we have webhooks setup so Facebook notifies us of changes in an ad account.
It looks like you can only set 1 URL for webhooks so i cant remove the production endpoint because that would mess up the production environment.
Is there any way i can send webhooks to another URL?
The only option i can think of is just hardcoding some fake payloads and testing my code that way.
Does anyone know if there is a way to set some type of development endpoint?
EDIT:
For anyone that comes back to this, a test app can never be "live" this means that calls that require an app that is not in development will not work. Maybe the best workaround is to create a duplicate app and get it approved.
Facebook has introduced a feature called Test Apps a while ago.
https://developers.facebook.com/docs/apps/test-apps
You can create a test version of your production app, that will get its own app id, and have its own app dashboard where you can change most of the settings - including webhook endpoints.

How to have facebook messenger bot in local, staging and production

Context
I'm working on a facebook messenger bot and have a workflow issue.
To create it i used ngrok to make a facebook test application hook on my local and it worked fine.
Now the bot is in staging for test and an other application have the webhook pointing to the stage server.
For the production server i intend to do a production application that will have webhook pointing on it.
Question
But since an application has to be attached to a page to start a conversation to it, how can i test several bots ?
Do i need 3 pages (local test, staging test and production) ?
Or is there a Facebook way to it ? (test version of app is not working for now on messenger bot, known bug)
Or maybe a good practice ?
You are looking for Test Apps in Facebook App Development. You can find this setting on the Developer Page on the top left where you can find a drop-down button to create a Test App.
I use to create my dev and staging environment.
Docs on this seem non-existent. It does seem like you need separate pages and bots for test/staging environments.
Here's what I did for the bot I made.
Make test/staging pages.
Unpublish those pages so they're not publicly searchable.
Give testers/devs Page Roles on the page so they can search for and find it.
Give those same testers/devs roles in the bot dashboard so they can actually chat with the bot.

How to Test Facebook Login?

I'd like to test the server-side manual login workflow I put together using the Facebook developer guide, but I'm unaware what options I have in this regard. At this point, the clients that will use service are yet to be created.
Does facebook or third parties offer a login dialog that can be used in such manual/automated (functional) tests? Or will I have to create a temporary client that calls the login dialog and handles the redirect myself?
Facebook provides sandboxed test users (see https://developers.facebook.com/docs/apps/test-users) that you can use for testing purposes.
If you are talking about writing automated tests around this, then consider using the test users along with something like vcr (https://github.com/vcr/vcr), or the equivalent for your server-side environment (you don't say what that is).

how to test facebook app for different scenarios

how to test a facebook app for different use cases. i will take a simple example here:
assuming i have a facebook app which just does the login to a site.
now, how do i handle/ test different use cases in this:
1) user is already connected to the site and logging in again using her facebook account
2) user is a first time user and want to login to my site through his facebook credential and she a) allows the app to access her details b) deny the app to access her details
these are the very basic test cases but there could be more depending upon what exactly what we want to do with that app and the site.
so my question is how does one test all these scenarios ? if i use my facebook account once then it doesn't allow me to test the other scenario (like if i once allow an app then it doesn't allow me to test the 'deny' scenario)
thanks in advance
dev
You can use test users for manual or automated testing.

Facebook application load testing

How can i make load testing to facebook application?
Facebook prohibits the use of automated tools!!!
You should just load test your code, not Facebook's. Your app should be an iframe app, so it shouldn't be hard to load test outside of the Facebook platform. Just disable the Facebook calls.
Facebook has a much bigger setup than you and can handle a much larger load than your load testing tools could probably generate. And if Facebook is having load issues, there is nothing you can do about it anyway.
I've been developing Facebook apps for about 3 years. Facebook does have issues fairly often, but there is nothing you can do in your app except add error capture, retry and/or recovery.
What you're looking for is a tool called FriendRunner (www.friendrunner.com) which will allow you to load test a Facebook app WITHOUT modifying it, so you don't have to comment out any API calls. This will give you the most authentic results.
They can also simulate all kinds of strange situations and problems with the Facebook API so you can see how robust your application really is.
Is there a way to decouple your app from Facebook for the purposes of load testing? You can probably assume that the facebook platform can handle everything you throw at it, so you really just need to test your custom code. Once this works without any load problems, you should be good to go (assuming you can properly deal with unusual cases like facebook being down/the api being down).
We've used the approach suggested by Brent Baisley and it's a good approach, but I've always begrudged the extra work of toggling FB apis to test the app. We are trying an approach right now that should allow you to load test most apps directly in the FB canvas.
From Facebook themselves: "You can use test users for manual or automated testing."
You can also pre-authorize test users with specific permissions to your app so there's no issue of getting stuck at the permissions dialog. In the FB response, you'll get a URL that allows you to login with that test user. With one or many of these URLs in hand, easy enough to use something like Seige or Apache Bench to automate your load testing of your Facebook App in its normal environment.