LiveView asynchronous task patterns

As for testing, what I would do it to refactor make_slow_api_call into another module, like App.PrivateAPIs, and have a config in my application like config :my_app, private_api: App.PrivateAPIs and have something like @private_api Application.get_env(:my_app, :private_api) in my LiveView.

If you want to make it more “standard”, you can use adapter pattern.

This way, you can test your private api individually, and you can also write a mock module for when you want to test other things.