For an automatic failover to happen the following criteria must be met...
The current primary and at least one secondary must be configured for synchronous commit
The WSFC failure threshold must not be breached (default is n-1 failures in a 6 hour window, where n is number of nodes)
The state of the current primary that instigates a failover is governed by the Failure-Condition Level.
1 - OnServerDown
2 - OnServerUnresponsive
3 - OnCriticalServerError
4 - OnModerateServerError
5 - OnAnyQualifiedFailureConditions
To set the Failure Condition Level...
ALTER AVAILABILITY GROUP AG1 SET (FAILURE_CONDITION_LEVEL = 1);
To set the Health Check Timeout (relevant for Level 2)...
ALTER AVAILABILITY GROUP AG1 SET (HEALTH_CHECK_TIMEOUT = 60000);
Default is 30000 milliseconds (30 seconds)