* E2E test showing it already works when navigating inside the app * E2E test showing expected behavior around both sides of prerendering
This commit is contained in:
parent
e043f9317f
commit
22fbeac336
|
|
@ -55,6 +55,26 @@ namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests
|
|||
Browser.Equal("Hello from interop call", () => Browser.FindElement(By.Id("val-set-by-interop")).GetAttribute("value"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanReadUrlHashOnlyOnceConnected()
|
||||
{
|
||||
var urlWithoutHash = "prerendered/show-uri?my=query&another=value";
|
||||
var url = $"{urlWithoutHash}#some/hash?tokens";
|
||||
|
||||
// The server doesn't receive the hash part of the URL, so you can't
|
||||
// read it during prerendering
|
||||
Navigate(url);
|
||||
Browser.Equal(
|
||||
_serverFixture.RootUri + urlWithoutHash,
|
||||
() => Browser.FindElement(By.TagName("strong")).Text);
|
||||
|
||||
// Once connected, you do have access to the full URL
|
||||
BeginInteractivity();
|
||||
Browser.Equal(
|
||||
_serverFixture.RootUri + url,
|
||||
() => Browser.FindElement(By.TagName("strong")).Text);
|
||||
}
|
||||
|
||||
private void BeginInteractivity()
|
||||
{
|
||||
Browser.FindElement(By.Id("load-boot-script")).Click();
|
||||
|
|
|
|||
|
|
@ -388,6 +388,19 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests
|
|||
Browser.Equal(initialUrl, () => app.FindElement(By.Id("test-info")).Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UriHelperCanReadAbsoluteUriIncludingHash()
|
||||
{
|
||||
var app = MountTestComponent<UriHelperComponent>();
|
||||
Browser.Equal(Browser.Url, () => app.FindElement(By.Id("test-info")).Text);
|
||||
|
||||
var uri = "/mytestpath?my=query&another#some/hash?tokens";
|
||||
var expectedAbsoluteUri = $"{_serverFixture.RootUri}subdir{uri}";
|
||||
|
||||
SetUrlViaPushState(uri);
|
||||
Browser.Equal(expectedAbsoluteUri, () => app.FindElement(By.Id("test-info")).Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanArriveAtRouteWithExtension()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
@page "/show-uri"
|
||||
@inject IUriHelper UriHelper
|
||||
The current URL is <strong>@UriHelper.GetAbsoluteUri()</strong>
|
||||
Loading…
Reference in New Issue