Fix wasm caching on localhost and various E2E test issues (#25689)
* Fix caching of WASM resources on localhost * Fix test server startup * Add missing server variant of VirtualizationTest * Make test namespaces consistent * Fix VirtualizationTest cases * Update BootResourceCachingTest
This commit is contained in:
parent
646925127b
commit
c5bcd68853
File diff suppressed because one or more lines are too long
|
|
@ -165,9 +165,9 @@ async function getCacheToUseIfEnabled(bootConfig: BootJsonData): Promise<Cache |
|
|||
return null;
|
||||
}
|
||||
|
||||
// cache integrity is compromised if the first request has been served over http
|
||||
// cache integrity is compromised if the first request has been served over http (except localhost)
|
||||
// in this case, we want to disable caching and integrity validation
|
||||
if (document.location.protocol !== 'https:') {
|
||||
if (window.isSecureContext === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,4 +83,12 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class ServerVirtualizationTest : VirtualizationTest
|
||||
{
|
||||
public ServerVirtualizationTest(BrowserFixture browserFixture, ToggleExecutionModeServerFixture<Program> serverFixture, ITestOutputHelper output)
|
||||
: base(browserFixture, serverFixture.WithServerExecution(), output)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,16 +71,16 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
|||
Navigate("/");
|
||||
WaitUntilLoaded();
|
||||
var cacheEntryUrls1 = GetCacheEntryUrls();
|
||||
var cacheEntryForMsCorLib = cacheEntryUrls1.Single(url => url.Contains("/mscorlib.dll"));
|
||||
var cacheEntryForComponentsDll = cacheEntryUrls1.Single(url => url.Contains("/Microsoft.AspNetCore.Components.dll"));
|
||||
var cacheEntryForDotNetWasm = cacheEntryUrls1.Single(url => url.Contains("/dotnet.wasm"));
|
||||
var cacheEntryForDotNetWasmWithChangedHash = cacheEntryForDotNetWasm.Replace(".sha256-", ".sha256-different");
|
||||
|
||||
// Remove some items we do need, and add an item we don't need
|
||||
RemoveCacheEntry(cacheEntryForMsCorLib);
|
||||
RemoveCacheEntry(cacheEntryForComponentsDll);
|
||||
RemoveCacheEntry(cacheEntryForDotNetWasm);
|
||||
AddCacheEntry(cacheEntryForDotNetWasmWithChangedHash, "ignored content");
|
||||
var cacheEntryUrls2 = GetCacheEntryUrls();
|
||||
Assert.DoesNotContain(cacheEntryForMsCorLib, cacheEntryUrls2);
|
||||
Assert.DoesNotContain(cacheEntryForComponentsDll, cacheEntryUrls2);
|
||||
Assert.DoesNotContain(cacheEntryForDotNetWasm, cacheEntryUrls2);
|
||||
Assert.Contains(cacheEntryForDotNetWasmWithChangedHash, cacheEntryUrls2);
|
||||
|
||||
|
|
@ -91,13 +91,13 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
|||
WaitUntilLoaded();
|
||||
var subsequentResourcesRequested = GetAndClearRequestedPaths();
|
||||
Assert.Collection(subsequentResourcesRequested.Where(url => url.Contains(".dll")),
|
||||
requestedDll => Assert.Contains("/mscorlib.dll", requestedDll));
|
||||
requestedDll => Assert.Contains("/Microsoft.AspNetCore.Components.dll", requestedDll));
|
||||
Assert.Collection(subsequentResourcesRequested.Where(url => url.Contains(".wasm")),
|
||||
requestedDll => Assert.Contains("/dotnet.wasm", requestedDll));
|
||||
|
||||
// We also update the cache (add new items, remove unnecessary items)
|
||||
var cacheEntryUrls3 = GetCacheEntryUrls();
|
||||
Assert.Contains(cacheEntryForMsCorLib, cacheEntryUrls3);
|
||||
Assert.Contains(cacheEntryForComponentsDll, cacheEntryUrls3);
|
||||
Assert.Contains(cacheEntryForDotNetWasm, cacheEntryUrls3);
|
||||
Assert.DoesNotContain(cacheEntryForDotNetWasmWithChangedHash, cacheEntryUrls3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using TestServer;
|
|||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components.E2ETests.Tests
|
||||
namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||
{
|
||||
public class ClientRenderingMultpleComponentsTest : ServerTestBase<BasicTestAppServerSiteFixture<MultipleComponents>>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System.Linq;
|
||||
using BasicTestApp;
|
||||
using Microsoft.AspNetCore.Components.E2ETest;
|
||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
||||
using Microsoft.AspNetCore.E2ETesting;
|
||||
|
|
@ -11,7 +10,7 @@ using OpenQA.Selenium;
|
|||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components.E2ETests.Tests
|
||||
namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||
{
|
||||
public class HeadComponentsTest : ServerTestBase<ToggleExecutionModeServerFixture<Program>>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using BasicTestApp;
|
||||
using Microsoft.AspNetCore.Components.E2ETest;
|
||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure;
|
||||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
|
||||
using Microsoft.AspNetCore.E2ETesting;
|
||||
|
|
@ -12,7 +11,7 @@ using OpenQA.Selenium.Support.Extensions;
|
|||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.Components.E2ETests.Tests
|
||||
namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
||||
{
|
||||
public class VirtualizationTest : ServerTestBase<ToggleExecutionModeServerFixture<Program>>
|
||||
{
|
||||
|
|
@ -121,7 +120,7 @@ namespace Microsoft.AspNetCore.Components.E2ETests.Tests
|
|||
var itemSizeInput = Browser.FindElement(By.Id("item-size-input"));
|
||||
|
||||
// Change the item size.
|
||||
itemSizeInput.SendKeys("\b\b\b50\n");
|
||||
itemSizeInput.SendKeys("\b\b\b10\n");
|
||||
|
||||
// Validate that the list has been re-rendered to show more items.
|
||||
Browser.True(() => GetItemCount() > initialItemCount);
|
||||
|
|
@ -146,7 +145,7 @@ namespace Microsoft.AspNetCore.Components.E2ETests.Tests
|
|||
var itemSizeInput = Browser.FindElement(By.Id("item-size-input"));
|
||||
|
||||
// Change the item size.
|
||||
itemSizeInput.SendKeys("\b\b\b50\n");
|
||||
itemSizeInput.SendKeys("\b\b\b10\n");
|
||||
|
||||
// Validate that the same number of loaded items is rendered.
|
||||
Browser.Equal(initialItemCount, GetItemCount);
|
||||
|
|
|
|||
Loading…
Reference in New Issue