Handling Phoenix Presence during testing

As a temporary solution, adding this code at the end of the channel test

ref = leave(socket)
assert_reply ref, :ok
IO.puts "socket leave"
:timer.sleep(200)

makes the fetch function in Presence be called before the test finishes, which works with the Ecto’s sandbox shared strategy. If I remove the :timer.sleep call, the error continues.

** (stop) exited in: GenServer.call(#PID<0.384.0>, {:checkout, 
   #Reference<0.1150698256.1547436035.131411>, true, 15000}, 5000)
** (EXIT) shutdown: "owner #PID<0.383.0> exited with: shutdown"