diff --git a/CHANGELOG.md b/CHANGELOG.md index c1991bd23..855fe6488 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,13 @@ 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) +- 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 @@ -1439,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 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 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: 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 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/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..1e9e2e806 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; @@ -66,5 +69,45 @@ 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")] + public void Test022() + { + var cut = RenderComponent(); + + var text = cut.Find(".my-component").GetInnerText(); + + text.ShouldNotBeNull(); + } } 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" },