-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Accept blazor.web.js startup options format in blazor.server.js and blazor.webassembly.js #64629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
04dbbc8
Initial plan
Copilot ab6ec40
Accept blazor.web.js startup options format in blazor.server.js and b…
Copilot ef361b3
Add E2E tests for nested blazor options format
Copilot 7a7d677
Remove XML doc comments from test files per review feedback
Copilot f3abc77
Simplify nested options test files by removing unnecessary code
Copilot ec0f843
Fix nestedWebAssemblyOptions.html by adding required getRuntimeBuildC…
Copilot 7c72dd2
Changes before error encountered
Copilot 7181172
Fix WebAssemblyNestedOptionsTest by using query parameter instead of …
Copilot f78b0c4
Revert unintended changes to package-lock.json
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/Components/test/E2ETest/ServerExecutionTests/ServerNestedOptionsTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using BasicTestApp; | ||
| using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; | ||
| using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; | ||
| using Microsoft.AspNetCore.E2ETesting; | ||
| using OpenQA.Selenium; | ||
| using TestServer; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests; | ||
|
|
||
| /// <summary> | ||
| /// Tests that the blazor.web.js options format (with nested <c>circuit:</c> property) | ||
| /// is accepted by blazor.server.js. | ||
| /// </summary> | ||
| public class ServerNestedOptionsTest : ServerTestBase<BasicTestAppServerSiteFixture<ServerStartup>> | ||
| { | ||
| public ServerNestedOptionsTest( | ||
| BrowserFixture browserFixture, | ||
| BasicTestAppServerSiteFixture<ServerStartup> serverFixture, | ||
| ITestOutputHelper output) | ||
| : base(browserFixture, serverFixture, output) | ||
| { | ||
| } | ||
|
|
||
| protected override void InitializeAsyncCore() | ||
| { | ||
| // Navigate to the page that uses the nested circuit options format | ||
| Navigate($"{ServerPathBase}/nestedCircuitOptions"); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void NestedCircuitOptionsAreAccepted() | ||
| { | ||
| // Verify the page loads and the counter component works, | ||
| // which confirms the circuit options were processed correctly | ||
| var appElement = Browser.MountTestComponent<CounterComponent>(); | ||
| var countDisplayElement = appElement.FindElement(By.TagName("p")); | ||
| Browser.Equal("Current count: 0", () => countDisplayElement.Text); | ||
|
|
||
| // Clicking button increments count | ||
| appElement.FindElement(By.TagName("button")).Click(); | ||
| Browser.Equal("Current count: 1", () => countDisplayElement.Text); | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
src/Components/test/E2ETest/Tests/WebAssemblyNestedOptionsTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using BasicTestApp; | ||
| using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; | ||
| using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; | ||
| using Microsoft.AspNetCore.E2ETesting; | ||
| using OpenQA.Selenium; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.AspNetCore.Components.E2ETest.Tests; | ||
|
|
||
| /// <summary> | ||
| /// Tests that the blazor.web.js options format (with nested <c>webAssembly:</c> property) | ||
| /// is accepted by blazor.webassembly.js. | ||
| /// </summary> | ||
| public class WebAssemblyNestedOptionsTest : ServerTestBase<BlazorWasmTestAppFixture<BasicTestApp.Program>> | ||
| { | ||
| public WebAssemblyNestedOptionsTest( | ||
| BrowserFixture browserFixture, | ||
| BlazorWasmTestAppFixture<Program> serverFixture, | ||
| ITestOutputHelper output) | ||
| : base(browserFixture, serverFixture, output) | ||
| { | ||
| _serverFixture.PathBase = "/subdir"; | ||
| } | ||
|
|
||
| protected override void InitializeAsyncCore() | ||
| { | ||
| base.InitializeAsyncCore(); | ||
|
|
||
| // Navigate to the page that uses the nested webAssembly options format | ||
javiercn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Navigate($"{ServerPathBase}/nestedWebAssemblyOptions.html"); | ||
| Browser.MountTestComponent<ConfigureRuntime>(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void NestedWebAssemblyOptionsAreAccepted() | ||
| { | ||
| // Verify that the configureRuntime option inside the nested webAssembly property works | ||
javiercn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var element = Browser.Exists(By.Id("environment")); | ||
| Browser.Equal("true", () => element.Text); | ||
| } | ||
| } | ||
81 changes: 81 additions & 0 deletions
81
src/Components/test/testassets/BasicTestApp/wwwroot/nestedWebAssemblyOptions.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Basic test app - Nested WebAssembly Options</title> | ||
| <base href="/subdir/" /> | ||
| <link href="style.css" rel="stylesheet" /> | ||
| <link rel="icon" href="data:,"> | ||
|
|
||
| <!-- Used by ExternalContentPackage --> | ||
| <link href="_content/TestContentPackage/styles.css" rel="stylesheet" /> | ||
|
|
||
| <!-- App bundle that contains a reference to the scoped css bundle created by TestContentPackage --> | ||
| <link href="BasicTestApp.styles.css" rel="stylesheet" /> | ||
| </head> | ||
|
|
||
| <body> | ||
| <root>Loading...</root> | ||
|
|
||
| <!-- Explicit display:none required so StartupErrorNotificationTest can observe it change --> | ||
| <div id="blazor-error-ui" style="display: none;"> | ||
| An unhandled error has occurred. | ||
| <a href="." class="reload">Reload</a> | ||
| <span class="dismiss">🗙</span> | ||
| </div> | ||
|
|
||
| <!-- Used for specific test cases --> | ||
| <script src="js/circuitContextTest.js"></script> | ||
| <script src="js/jsinteroptests.js"></script> | ||
| <script src="js/renderattributestest.js"></script> | ||
| <script src="js/webComponentPerformingJsInterop.js"></script> | ||
| <script src="js/customLinkElement.js"></script> | ||
| <script src="js/jsRootComponentInitializers.js"></script> | ||
| <script src="js/customElementTests.js"></script> | ||
|
|
||
| <script> | ||
| // Used by ElementRefComponent | ||
| function setElementValue(element, newValue) { | ||
| element.value = newValue; | ||
| return element.value; | ||
| } | ||
|
|
||
| function navigationManagerNavigate() { | ||
| Blazor.navigateTo('/subdir/some-path'); | ||
| } | ||
|
|
||
| function getCurrentUrl() { | ||
| return location.href; | ||
| } | ||
|
|
||
| function getRuntimeBuildConfiguration() { | ||
| return Blazor.runtime.runtimeBuildInfo.buildConfiguration; | ||
| } | ||
javiercn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </script> | ||
| <script src="_framework/blazor.webassembly.js" autostart="false"></script> | ||
|
|
||
| <script> | ||
| (function () { | ||
| if (location.hash.indexOf('initializer') !== -1) { | ||
| const element = document.createElement('div'); | ||
| element.id = 'initializers-content'; | ||
| document.body.append(element); | ||
| } | ||
|
|
||
| // Use the blazor.web.js options format with nested webAssembly property | ||
| Blazor.start({ | ||
| webAssembly: { | ||
| configureRuntime: dotnet => { | ||
| dotnet.withEnvironmentVariable("CONFIGURE_RUNTIME", "true"); | ||
| } | ||
| } | ||
| }); | ||
| })(); | ||
| </script> | ||
|
|
||
| <!-- Used by ExternalContentPackage --> | ||
| <script src="_content/TestContentPackage/prompt.js"></script> | ||
| </body> | ||
|
|
||
| </html> | ||
75 changes: 75 additions & 0 deletions
75
src/Components/test/testassets/Components.TestServer/Pages/NestedCircuitOptions.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| @page "/nestedCircuitOptions" | ||
| @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <title>Basic test app - Nested Circuit Options</title> | ||
| <base href="~/" /> | ||
| <link href="style.css" rel="stylesheet" /> | ||
| <link rel="icon" href="data:,"> | ||
|
|
||
| <!-- Used by ExternalContentPackage --> | ||
| <link href="_content/TestContentPackage/styles.css" rel="stylesheet" /> | ||
| <link href="Components.TestServer.styles.css" rel="stylesheet" /> | ||
| <component type="typeof(Microsoft.AspNetCore.Components.Web.HeadOutlet)" render-mode="Server" /> | ||
| </head> | ||
| <body> | ||
| <root><component type="typeof(BasicTestApp.Index)" render-mode="Server" /></root> | ||
|
|
||
| <!-- Used for specific test cases --> | ||
| <script src="js/circuitContextTest.js"></script> | ||
| <script src="js/jsinteroptests.js"></script> | ||
| <script src="js/renderattributestest.js"></script> | ||
| <script src="js/webComponentPerformingJsInterop.js"></script> | ||
| <script src="js/customLinkElement.js"></script> | ||
| <script src="js/jsRootComponentInitializers.js"></script> | ||
|
|
||
| <div id="blazor-error-ui"> | ||
| An unhandled error has occurred. | ||
| <a href="." class="reload">Reload</a> | ||
| <span class="dismiss">🗙</span> | ||
| </div> | ||
|
|
||
| <script> | ||
| // Used by ElementRefComponent | ||
| function setElementValue(element, newValue) { | ||
| element.value = newValue; | ||
| return element.value; | ||
| } | ||
|
|
||
| function navigationManagerNavigate() { | ||
| Blazor.navigateTo('/subdir/some-path'); | ||
| } | ||
| </script> | ||
|
|
||
| <script> | ||
| if (location.hash.indexOf('initializer') !== -1) { | ||
| const element = document.createElement('div'); | ||
| element.id = 'initializers-content'; | ||
| document.body.append(element); | ||
| } | ||
| </script> | ||
|
|
||
| <script src="_framework/blazor.server.js" autostart="false"></script> | ||
| <script> | ||
| // Use the blazor.web.js options format with nested circuit property | ||
| Blazor.start({ | ||
| circuit: { | ||
| reconnectionOptions: { | ||
| // It's easier to test the reconnection logic if we wait a bit | ||
| // before attempting to reconnect | ||
| retryIntervalMilliseconds: Array.prototype.at.bind([5000, 5000, 5000, 10000, 30000]), | ||
| }, | ||
| }, | ||
| }); | ||
| </script> | ||
| <script src="js/jsRootComponentInitializers.js"></script> | ||
|
|
||
| <!-- Used by ExternalContentPackage --> | ||
| <script src="_content/TestContentPackage/prompt.js"></script> | ||
| <script> | ||
| console.log('Blazor server-side with nested circuit options'); | ||
| </script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.