From 4fe429572022763508b3344d6a2c025c3fb6b9ca Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Wed, 27 Feb 2019 04:28:07 -0800 Subject: [PATCH] [Components][Fixes #7405] Increase CanTriggerEventHandlerDisposedInEarlierPendingBatchAsync timeout to reduce test flakyness Increases the timeout from 500 to 1000 --- src/Components/Components/test/RendererTest.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Components/Components/test/RendererTest.cs b/src/Components/Components/test/RendererTest.cs index 0a170b5ca2..5eedeb6630 100644 --- a/src/Components/Components/test/RendererTest.cs +++ b/src/Components/Components/test/RendererTest.cs @@ -2566,8 +2566,15 @@ namespace Microsoft.AspNetCore.Components.Test // Act/Assert 3: After we complete the first UI update in which a given // event handler ID is disposed, we can no longer reuse that event handler ID + + // From here we can't see when the async disposal is completed. Just give it plenty of time (Task.Yield isn't enough). + // There is a small chance in which the continuations from TaskCompletionSource run asynchronously. + // In that case we might not be able to see the results from RemoveEventHandlerIds as they might run asynchronously. + // For that case, we are going to queue a continuation on render1TCS.Task, include a 1s delay and await the resulting + // task to offer the best chance that we get to see the error in all cases. + var awaitableTask = render1TCS.Task.ContinueWith(_ => Task.Delay(1000)).Unwrap(); render1TCS.SetResult(null); - await Task.Delay(500); // From here we can't see when the async disposal is completed. Just give it plenty of time (Task.Yield isn't enough). + await awaitableTask; var ex = await Assert.ThrowsAsync(() => { return renderer.DispatchEventAsync(eventHandlerId, new UIEventArgs());