File tree 3 files changed +36
-0
lines changed 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,26 @@ public void CanUseJSInteropFromOnAfterRenderAsync()
55
55
Browser . Equal ( "Hello from interop call" , ( ) => Browser . FindElement ( By . Id ( "val-set-by-interop" ) ) . GetAttribute ( "value" ) ) ;
56
56
}
57
57
58
+ [ Fact ]
59
+ public void CanReadUrlHashOnlyOnceConnected ( )
60
+ {
61
+ var urlWithoutHash = "prerendered/show-uri?my=query&another=value" ;
62
+ var url = $ "{ urlWithoutHash } #some/hash?tokens";
63
+
64
+ // The server doesn't receive the hash part of the URL, so you can't
65
+ // read it during prerendering
66
+ Navigate ( url ) ;
67
+ Browser . Equal (
68
+ _serverFixture . RootUri + urlWithoutHash ,
69
+ ( ) => Browser . FindElement ( By . TagName ( "strong" ) ) . Text ) ;
70
+
71
+ // Once connected, you do have access to the full URL
72
+ BeginInteractivity ( ) ;
73
+ Browser . Equal (
74
+ _serverFixture . RootUri + url ,
75
+ ( ) => Browser . FindElement ( By . TagName ( "strong" ) ) . Text ) ;
76
+ }
77
+
58
78
private void BeginInteractivity ( )
59
79
{
60
80
Browser . FindElement ( By . Id ( "load-boot-script" ) ) . Click ( ) ;
Original file line number Diff line number Diff line change @@ -388,6 +388,19 @@ public void UsingUriHelperWithoutRouterWorks()
388
388
Browser . Equal ( initialUrl , ( ) => app . FindElement ( By . Id ( "test-info" ) ) . Text ) ;
389
389
}
390
390
391
+ [ Fact ]
392
+ public void UriHelperCanReadAbsoluteUriIncludingHash ( )
393
+ {
394
+ var app = MountTestComponent < UriHelperComponent > ( ) ;
395
+ Browser . Equal ( Browser . Url , ( ) => app . FindElement ( By . Id ( "test-info" ) ) . Text ) ;
396
+
397
+ var uri = "/mytestpath?my=query&another#some/hash?tokens" ;
398
+ var expectedAbsoluteUri = $ "{ _serverFixture . RootUri } subdir{ uri } ";
399
+
400
+ SetUrlViaPushState ( uri ) ;
401
+ Browser . Equal ( expectedAbsoluteUri , ( ) => app . FindElement ( By . Id ( "test-info" ) ) . Text ) ;
402
+ }
403
+
391
404
[ Fact ]
392
405
public void CanArriveAtRouteWithExtension ( )
393
406
{
Original file line number Diff line number Diff line change
1
+ @page " /show-uri"
2
+ @inject IUriHelper UriHelper
3
+ The current URL is <strong >@UriHelper.GetAbsoluteUri() </strong >
You can’t perform that action at this time.
0 commit comments