From 1cccb7ca4be0c1f771f6c4b890756d38687066cb Mon Sep 17 00:00:00 2001 From: Egil Hansen Date: Sat, 29 Mar 2025 01:51:57 +0000 Subject: [PATCH 1/8] docs: update sponsors link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 691daaa00..2d9170d9f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/egil). T
- + @syncfusion
Syncfusion From c91ef3d3c92b9dafe8f0155deb7dd80232140c3c Mon Sep 17 00:00:00 2001 From: Egil Hansen Date: Sat, 29 Mar 2025 01:54:36 +0000 Subject: [PATCH 2/8] docs: update bunit.dev index sponsor links --- docs/site/index.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/site/index.md b/docs/site/index.md index 9d0242daa..c10804d1e 100644 --- a/docs/site/index.md +++ b/docs/site/index.md @@ -53,11 +53,16 @@ bUnit is available on NuGet in various incarnations. Most users should just pick A huge thank you to the [sponsors of bUnit](https://github.com/sponsors/egil). The higher tier sponsors are:
## Contributors From 4f15022e8193ba38daa6354cfdf7c12f44ac20c1 Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Fri, 4 Apr 2025 17:23:28 +0200 Subject: [PATCH 3/8] fix: bUnit can handle relative units in Markup --- CHANGELOG.md | 1 + src/bunit.web/Rendering/BunitHtmlParser.cs | 12 ++++++++++-- .../ComponentWithRelativeUnitAsWidth.razor | 2 ++ .../Rendering/RenderedComponentTest.cs | 13 +++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor diff --git a/CHANGELOG.md b/CHANGELOG.md index c1991bd23..17778f6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to **bUnit** will be documented in this file. The project ad ### Fixed - Do not set the `Uri` or `BaseUri` property on the `FakeNavigationManager` if navigation is prevented by a handler on `net7.0` or greater. Reported and fixed by [@ayyron-dev](https://github.com/ayyron-dev) in [#1647](https://github.com/bUnit-dev/bUnit/issues/1647) +- Use default renderer properties for AngleSharp. Reported by [@jtleaming](https://github.com/jtleaming) in [#1692]. ## [1.38.5] - 2025-01-12 diff --git a/src/bunit.web/Rendering/BunitHtmlParser.cs b/src/bunit.web/Rendering/BunitHtmlParser.cs index 6f8edb5f7..08093cc0a 100644 --- a/src/bunit.web/Rendering/BunitHtmlParser.cs +++ b/src/bunit.web/Rendering/BunitHtmlParser.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Diagnostics; using AngleSharp; +using AngleSharp.Css; using AngleSharp.Dom; using AngleSharp.Html.Parser; using Bunit.Diffing; @@ -28,7 +29,8 @@ public sealed class BunitHtmlParser : IDisposable /// with a AngleSharp context without a registered. /// public BunitHtmlParser() - : this(Configuration.Default.WithCss().With(new HtmlComparer())) { } + : this(Configuration.Default.WithCss() + .With(new HtmlComparer())) { } /// /// Initializes a new instance of the class @@ -43,7 +45,13 @@ public BunitHtmlParser(HtmlComparer htmlComparer, TestContextBase testContext) private BunitHtmlParser(IConfiguration angleSharpConfiguration) { - var config = angleSharpConfiguration.With(this); + var config = angleSharpConfiguration + .With(this) + .WithRenderDevice(new DefaultRenderDevice + { + ViewPortWidth = 1920, + ViewPortHeight = 1080, + }); context = BrowsingContext.New(config); var parseOptions = new HtmlParserOptions { diff --git a/tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor b/tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor new file mode 100644 index 000000000..69e5a86c7 --- /dev/null +++ b/tests/bunit.testassets/SampleComponents/ComponentWithRelativeUnitAsWidth.razor @@ -0,0 +1,2 @@ +
+
\ No newline at end of file diff --git a/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs b/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs index 412779aad..89b00e548 100644 --- a/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs +++ b/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs @@ -1,3 +1,6 @@ +using AngleSharp; +using AngleSharp.Css; +using AngleSharp.Dom; using Bunit.Rendering; namespace Bunit; @@ -67,4 +70,14 @@ public void Test021() cut.Instance.JSRuntime.ShouldNotBeNull(); } #endif + + [Fact(DisplayName = "Using relative units in style attribute can be retrieved")] + public void Test022() + { + var cut = RenderComponent(); + + var text = cut.Find(".my-component").GetInnerText(); + + text.ShouldNotBeNull(); + } } From f60013ee0bb001991940cd43e2f963ab9831de1c Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Fri, 4 Apr 2025 17:55:30 +0200 Subject: [PATCH 4/8] fix: Add test for FindComponents with base and derived components --- CHANGELOG.md | 1 + src/bunit.core/Rendering/TestRenderer.cs | 8 ++++- .../Rendering/RenderedComponentTest.cs | 30 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17778f6f1..887959bbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to **bUnit** will be documented in this file. The project ad - Do not set the `Uri` or `BaseUri` property on the `FakeNavigationManager` if navigation is prevented by a handler on `net7.0` or greater. Reported and fixed by [@ayyron-dev](https://github.com/ayyron-dev) in [#1647](https://github.com/bUnit-dev/bUnit/issues/1647) - Use default renderer properties for AngleSharp. Reported by [@jtleaming](https://github.com/jtleaming) in [#1692]. +- `FindComponents` throws an exception, when a base and derived class was searched for. Reported by [@BlueDragon709](https://github.com/BlueDragon709) in [#1691]. ## [1.38.5] - 2025-01-12 diff --git a/src/bunit.core/Rendering/TestRenderer.cs b/src/bunit.core/Rendering/TestRenderer.cs index f26e77fd0..18625e39e 100644 --- a/src/bunit.core/Rendering/TestRenderer.cs +++ b/src/bunit.core/Rendering/TestRenderer.cs @@ -610,7 +610,13 @@ private IRenderedComponentBase GetOrCreateRenderedComponent)renderedComponent; + if (renderedComponent is IRenderedComponentBase typedComponent) + { + return typedComponent; + } + + renderedComponent.Dispose(); + renderedComponents.Remove(componentId); } LoadRenderTreeFrames(componentId, framesCollection); diff --git a/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs b/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs index 89b00e548..1e9e2e806 100644 --- a/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs +++ b/tests/bunit.web.tests/Rendering/RenderedComponentTest.cs @@ -69,6 +69,36 @@ public void Test021() cut.Instance.JSRuntime.ShouldNotBeNull(); } + + [Fact(DisplayName = "Searching first for derived component and then base component finds correct (#1691)")] + public void Test023() + { + var cut = RenderComponent( + ps => ps.AddChildContent() + .AddChildContent()); + + Should.NotThrow(() => + { + cut.FindComponents(); + cut.FindComponents(); + }); + } + + private class BaseComponent : ComponentBase + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, "base"); + } + } + + private sealed class DerivedComponent : BaseComponent + { + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.AddContent(0, "derived"); + } + } #endif [Fact(DisplayName = "Using relative units in style attribute can be retrieved")] From 971e4b8594512b1edfeeb37bd7d9d7dd6caf78df Mon Sep 17 00:00:00 2001 From: bUnit bot Date: Fri, 4 Apr 2025 16:21:15 +0000 Subject: [PATCH 5/8] Set version to '1.39' --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 16a7c71ab..6bec143ea 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.39-preview", + "version": "1.39", "assemblyVersion": { "precision": "revision" }, From a33e06db2fc078f0809521a66b1ff4897726416b Mon Sep 17 00:00:00 2001 From: bUnit bot Date: Fri, 4 Apr 2025 16:21:16 +0000 Subject: [PATCH 6/8] Set version to '1.40-preview' --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index 16a7c71ab..6bee41558 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.39-preview", + "version": "1.40-preview", "assemblyVersion": { "precision": "revision" }, From 7b86ed80309d5959ffb45d3076e28008eaef64fa Mon Sep 17 00:00:00 2001 From: bUnit bot Date: Fri, 4 Apr 2025 16:35:40 +0000 Subject: [PATCH 7/8] Updated CHANGELOG.md for 1.39.5 release --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 887959bbe..855fe6488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to **bUnit** will be documented in this file. The project ad ## [Unreleased] +## [1.39.5] - 2025-04-04 + ### Fixed - Do not set the `Uri` or `BaseUri` property on the `FakeNavigationManager` if navigation is prevented by a handler on `net7.0` or greater. Reported and fixed by [@ayyron-dev](https://github.com/ayyron-dev) in [#1647](https://github.com/bUnit-dev/bUnit/issues/1647) @@ -1441,7 +1443,8 @@ The latest version of the library is availble on NuGet: - **Wrong casing on keyboard event dispatch helpers.** The helper methods for the keyboard events was not probably cased, so that has been updated. E.g. from `Keypress(...)` to `KeyPress(...)`. -[unreleased]: https://github.com/bUnit-dev/bUnit/compare/v1.38.5...HEAD +[unreleased]: https://github.com/bUnit-dev/bUnit/compare/v1.39.5...HEAD +[1.39.5]: https://github.com/bUnit-dev/bUnit/compare/v1.38.5...1.39.5 [1.38.5]: https://github.com/bUnit-dev/bUnit/compare/v1.37.7...v1.38.5 [1.37.7]: https://github.com/bUnit-dev/bUnit/compare/v1.36.0...1.37.7 [1.36.0]: https://github.com/bUnit-dev/bUnit/compare/v1.35.3...v1.36.0 From 59f24d81f037672ea3b7679cae241c7f46ef754e Mon Sep 17 00:00:00 2001 From: RiRiSharp <30719799+RichardPoes@users.noreply.github.com> Date: Sun, 13 Apr 2025 21:42:09 +0200 Subject: [PATCH 8/8] Add missing closing bracket in semantic-html-comparison.md --- docs/site/docs/verification/semantic-html-comparison.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/site/docs/verification/semantic-html-comparison.md b/docs/site/docs/verification/semantic-html-comparison.md index 0ef9bd5d0..f03fa02f3 100644 --- a/docs/site/docs/verification/semantic-html-comparison.md +++ b/docs/site/docs/verification/semantic-html-comparison.md @@ -105,7 +105,7 @@ Here are the customization options you have available to you: ```html

HeLLo world

-
``` To perform case insensitive comparison of the text inside the `id` attribute, do the following: