Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: use assert_redirect with default timeout
What changed? ============= Whenever our LiveViewWatcher tells our test that the LiveView process died. We try to perform an `assert_redirect` (since a redirect is our best guess -- otherwise, the process should've just timed out). The problem is that we're asserting that a redirect happened in the past (i.e. we're passing a timeout of `0`). We're doing that in an effort to keep the `timeout` provided by the user as close to the timeout requested as possible. But there's a possible race condition (which I've seen in the wild) where the LiveView dies and redirects very fast (before the watcher can actually set the timeout), but the watcher informs the test that the LiveView died and we check for a redirect before the redirect message is sent. Thus, the `0` timeout in `assert_redirect` actually fails due to a race condition. So, we now avoid specifying the timeout in `assert_redirect`, relying on the default (which is 100ms or whatever ExUnit timeout is configured), to try to avoid the race condition. That causes a potential longer timeout for some test runs, but hopefully avoids flakiness due to race conditions.
- Loading branch information