From 789e584469bad698aa74ef7605436d1b6bf7b512 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Wed, 6 Jan 2021 15:47:41 +0000 Subject: [PATCH] Try to make IncrementallyUpdatesCache and CachesResourcesAfterFirstLoad tests more robust --- .../HostedInAspNet.Server/BootResourceRequestLog.cs | 5 +++-- src/Components/test/E2ETest/Tests/BootResourceCachingTest.cs | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Components/WebAssembly/testassets/HostedInAspNet.Server/BootResourceRequestLog.cs b/src/Components/WebAssembly/testassets/HostedInAspNet.Server/BootResourceRequestLog.cs index 5746a4228d22..fea623aa4224 100644 --- a/src/Components/WebAssembly/testassets/HostedInAspNet.Server/BootResourceRequestLog.cs +++ b/src/Components/WebAssembly/testassets/HostedInAspNet.Server/BootResourceRequestLog.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Collections.Concurrent; using System.Collections.Generic; using Microsoft.AspNetCore.Http; @@ -8,10 +9,10 @@ namespace HostedInAspNet.Server { public class BootResourceRequestLog { - private List _requestPaths = new List(); + private ConcurrentBag _requestPaths = new ConcurrentBag(); public IReadOnlyCollection RequestPaths => _requestPaths; - + public void AddRequest(HttpRequest request) { _requestPaths.Add(request.Path); diff --git a/src/Components/test/E2ETest/Tests/BootResourceCachingTest.cs b/src/Components/test/E2ETest/Tests/BootResourceCachingTest.cs index ca1d769f4011..cb479bd36916 100644 --- a/src/Components/test/E2ETest/Tests/BootResourceCachingTest.cs +++ b/src/Components/test/E2ETest/Tests/BootResourceCachingTest.cs @@ -54,6 +54,7 @@ public void CachesResourcesAfterFirstLoad() // On subsequent loads, we skip the items referenced from blazor.boot.json // which includes .dll files and dotnet.wasm Navigate("about:blank"); + Browser.Equal(string.Empty, () => Browser.Title); Navigate("/"); WaitUntilLoaded(); var subsequentResourcesRequested = GetAndClearRequestedPaths(); @@ -87,6 +88,7 @@ public void IncrementallyUpdatesCache() // On the next load, we'll fetch only the items we need (not things already cached) GetAndClearRequestedPaths(); Navigate("about:blank"); + Browser.Equal(string.Empty, () => Browser.Title); Navigate("/"); WaitUntilLoaded(); var subsequentResourcesRequested = GetAndClearRequestedPaths();