The issue was happening due to race condition between the onClick handler (which set the isLoading (disabled) status to false after 1000 ms) and the waitFor method (which also have a default timeout of 1000ms). Instead of increasing the waitFor timeout for all of the use cases, I have decreased the onClick handler's timeout to 900ms.
Test failure:
After fix:
The issue was happening due to race condition between the onClick handler (which set the isLoading (disabled) status to false after 1000 ms) and the waitFor method (which also have a default timeout of 1000ms). Instead of increasing the waitFor timeout for all of the use cases, I have decreased the onClick handler's timeout to 900ms.