-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Sections support #46727
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
Sections support #46727
Changes from 3 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
89c686d
sections support
surayya-MS 7e99bde
change SecionsTest
surayya-MS cbb63aa
fix
surayya-MS 397b91a
use Browser.Exists in tests; move code block to the end of .razor file
surayya-MS 0e7d9c5
E2E tests
surayya-MS 269b8d4
use private fields for buttons in tests; use "-" instead of "_" fir ids
surayya-MS 85f3a7c
support changing IsDefaultContent; fix tests
surayya-MS ebca897
fix
surayya-MS 32fb842
Merge branch 'main' into sectionsSupport
surayya-MS 85b8ec6
use object SectionId instead of string Name
surayya-MS 435716a
fix
surayya-MS 4cca921
Merge branch 'main' into sectionsSupport
surayya-MS c42520a
Update src/Components/Components/src/Sections/SectionContent.cs
surayya-MS d3352be
fix
surayya-MS 495bff4
Update src/Components/test/E2ETest/Tests/SectionsTest.cs
surayya-MS 4742a2d
Update src/Components/Web/src/Head/HeadOutlet.cs
surayya-MS 7323ca1
Update src/Components/Components/src/Sections/SectionOutlet.cs
surayya-MS b7be8b4
Update src/Components/Components/src/Sections/SectionContent.cs
surayya-MS cb0d2e3
Update src/Components/Components/src/Sections/SectionOutlet.cs
surayya-MS 52bc8d9
fix
surayya-MS e21ae58
Merge branch 'sectionsSupport' of https://github.com/surayya-MS/aspne…
surayya-MS ae3171e
fix
surayya-MS 35d13b9
fix
surayya-MS 275100b
change exceptions messages in SectionRegistry
surayya-MS 4b92f0c
remove IsDefaultContent from SectionContent
surayya-MS 48538d1
remove IsDefaultContent from PublicAPI
surayya-MS 08ebe15
Merge branch 'main' into sectionsSupport
surayya-MS e418aa6
fix
surayya-MS 853e6ea
Merge branch 'main' into sectionsSupport
surayya-MS 157bdaf
Revert "remove IsDefaultContent from PublicAPI"
surayya-MS 036dc2d
Revert "remove IsDefaultContent from SectionContent"
surayya-MS a6ef091
made IsDefaultContent internal
surayya-MS 403d493
Merge branch 'main' into sectionsSupport
surayya-MS b1b8be8
fix
surayya-MS 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
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
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,78 @@ | ||
// 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.ServerFixtures; | ||
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; | ||
using Microsoft.AspNetCore.E2ETesting; | ||
using Xunit.Abstractions; | ||
using Microsoft.AspNetCore.Components.E2ETest; | ||
using OpenQA.Selenium; | ||
|
||
namespace Microsoft.AspNetCore.Components.E2ETests.Tests; | ||
public class SectionsTest : ServerTestBase<ToggleExecutionModeServerFixture<Program>> | ||
surayya-MS marked this conversation as resolved.
Show resolved
Hide resolved
surayya-MS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
private IWebElement _appElement; | ||
|
||
public SectionsTest | ||
(BrowserFixture browserFixture, | ||
ToggleExecutionModeServerFixture<Program> serverFixture, | ||
ITestOutputHelper output) | ||
: base(browserFixture, serverFixture, output) | ||
{ | ||
} | ||
|
||
protected override void InitializeAsyncCore() | ||
{ | ||
Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); | ||
surayya-MS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_appElement = Browser.MountTestComponent<BasicTestApp.SectionsTest.ParentComponent>(); | ||
} | ||
|
||
[Fact] | ||
public void SectionOutletInParentComponentRendersSectionContentOfChildComponent() | ||
{ | ||
//Nothing is chosen yet | ||
Assert.False(TryGetElementById(out _, "counter")); | ||
surayya-MS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var options = _appElement.FindElement(By.Id("child-component")); | ||
|
||
// Choose Counter | ||
options.FindElement(By.Name("counter")).Click(); | ||
Assert.True(TryGetElementById(out var counter, "counter")); | ||
|
||
Assert.Equal("0", counter.Text); | ||
var incrememntButton = _appElement.FindElement(By.Id("increment_button")); | ||
|
||
incrememntButton.Click(); | ||
Assert.Equal("1", counter.Text); | ||
} | ||
|
||
[Fact] | ||
public void SectionOutletInParentComponentRendersSectionContentOfAnotherChildComponent() | ||
{ | ||
var options = _appElement.FindElement(By.Id("child-component")); | ||
|
||
// Choose Counter | ||
options.FindElement(By.Name("counter")).Click(); | ||
Assert.True(TryGetElementById(out _, "counter")); | ||
|
||
// Choose Simple Component | ||
options.FindElement(By.Name("simple-component")).Click(); | ||
Assert.True(TryGetElementById(out var simpleComponentText, "text")); | ||
Assert.Equal("Hello!", simpleComponentText.Text); | ||
Assert.False(TryGetElementById(out _, "counter")); | ||
} | ||
|
||
private bool TryGetElementById(out IWebElement counter, string id) | ||
{ | ||
try | ||
{ | ||
counter = _appElement.FindElement(By.Id(id)); | ||
return true; | ||
} | ||
catch (OpenQA.Selenium.NoSuchElementException) | ||
{ | ||
counter = null; | ||
return false; | ||
} | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/Components/test/testassets/BasicTestApp/SectionsTest/Counter.razor
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,20 @@ | ||
@using Microsoft.AspNetCore.Components.Sections | ||
|
||
<PageTitle>Counter</PageTitle> | ||
|
||
<h1>Counter</h1> | ||
|
||
<SectionContent Name="test"> | ||
<p id="counter">@currentCount</p> | ||
</SectionContent> | ||
|
||
<button id="increment_button" @onclick="IncrementCount">Click me</button> | ||
|
||
@code { | ||
int currentCount = 0; | ||
|
||
void IncrementCount() | ||
{ | ||
currentCount++; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Components/test/testassets/BasicTestApp/SectionsTest/ParentComponent.razor
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,24 @@ | ||
@using Microsoft.AspNetCore.Components.Sections | ||
|
||
<h1>Parent Component</h1> | ||
|
||
<SectionOutlet Name="test" /> | ||
|
||
<select id="child-component" @bind=SelectedComponent> | ||
<option value="none" name="none">Choose...</option> | ||
<option value="counter" name="counter">Counter</option> | ||
<option value="simple-component" name="simple-component">Simple Component</option> | ||
</select> | ||
|
||
@code { | ||
surayya-MS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
string SelectedComponent { get; set; } = "none"; | ||
} | ||
|
||
@if (SelectedComponent == "counter") | ||
{ | ||
<Counter></Counter> | ||
} | ||
else if (SelectedComponent == "simple-component") | ||
{ | ||
<SimpleComponent></SimpleComponent> | ||
} |
6 changes: 6 additions & 0 deletions
6
src/Components/test/testassets/BasicTestApp/SectionsTest/SimpleComponent.razor
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,6 @@ | ||
@using Microsoft.AspNetCore.Components.Sections | ||
<h3>SimpleComponent</h3> | ||
|
||
<SectionContent Name="test"> | ||
<p id="text">Hello!</p> | ||
</SectionContent> |
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.