question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MarkupMatches partially broken since 1.16.2 (regression)

See original GitHub issue

Describe the bug

Comparison of the markup of a rendered component is broken for medium complex markup since version 1.16.2.

Example: Here’s the actual markup that got rendered (taken from cut.Markup):

<div class="main" b-l9zz05p28t><div class="pane master-pane" b-l9zz05p28t><div class="header" b-l9zz05p28t><div class="zui-header" style="font: var(--zui-typography-h2); " b-9gghzsuirm>Custom Metadata Definitions</div>
            <zui-button id="add-button" emphasis="primary-highlight" blazor:onclick="1" disabled style="width: 100%;">Add new<zui-icon-symbols-plus slot="icon" size="s32"></zui-icon-symbols-plus></zui-button></div><div style="display: flex; align-items: center; align-self: start;"><zui-progress-ring size="s16" emphasis="highlight" mode="activity" style="margin-right: 5px;"></zui-progress-ring>
    <em>Loading...</em></div></div>
    <div class="details-pane-outer" b-l9zz05p28t><div class="placeholder-container" b-nfzpgxci6j><div class="placeholder-header" b-nfzpgxci6j>No custom metadata definition selected</div>
    <div class="placeholder-body" b-nfzpgxci6j>Please select a custom metadata definition from the list to view the details</div></div></div></div>

And this is the markup that it is compared to using cut.MarkupMatches. This worked up to bUnit version <= 1.15.5.

<div class="main">
                    <div class="pane master-pane">
                        <div class="header">
                            <div class="zui-header" style="font: var(--zui-typography-h2);">Custom Metadata Definitions</div>
                            <zui-button id="add-button" emphasis="primary-highlight" disabled style="width: 100%;">
                                Add new
                                <zui-icon-symbols-plus slot="icon" size="s32"></zui-icon-symbols-plus>
                            </zui-button>
                        </div>
                        <div diff:ignoreAttributes>
                            <zui-progress-ring diff:ignoreAttributes></zui-progress-ring>
                            <em>Loading...</em>
                        </div>
                    </div>
                    <div class="details-pane-outer">
                        <div class="placeholder-container" diff:ignoreChildren></div>
                    </div>
                </div>

Since version 1.16.2 it fails with the following error message: An attribute source map cannot be created unless a element comparison source is provided. (Parameter ‘elementSource’)

CustomMetadataPageTests.Render_ItemsIsNull_ShouldRenderBasicLayout threw exception: 
System.ArgumentException: An attribute source map cannot be created unless a element comparison source is provided. (Parameter 'elementSource')
    at AngleSharp.Diffing.Core.SourceMap..ctor(ComparisonSource& elementSource)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareElementAttributes(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareElement(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareNode(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.<CompareNodes>b__11_0(Comparison comparison)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareElement(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareNode(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.<CompareNodes>b__11_0(Comparison comparison)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareElement(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareNode(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.<CompareNodes>b__11_0(Comparison comparison)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareElement(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareNode(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.<CompareNodes>b__11_0(Comparison comparison)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareElement(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.CompareNode(Comparison& comparison)
   at AngleSharp.Diffing.Core.HtmlDifferenceEngine.<CompareNodes>b__11_0(Comparison comparison)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Bunit.CompareToExtensions.CompareTo(INodeList actual, INodeList expected) in /_/src/bunit.web/Asserting/CompareToExtensions.cs:line 106
   at Bunit.MarkupMatchesAssertExtensions.MarkupMatches(INodeList actual, INodeList expected, String userMessage) in /_/src/bunit.web/Asserting/MarkupMatchesAssertExtensions.cs:line 234
   at Bunit.MarkupMatchesAssertExtensions.MarkupMatches(IRenderedFragment actual, String expected, String userMessage) in /_/src/bunit.web/Asserting/MarkupMatchesAssertExtensions.cs:line 113
   at CustomMetadataPageTests.Render_ItemsIsNull_ShouldRenderBasicLayout()

Expected behavior:

It should work the same way as before.

Version info:

  • bUnit version: 1.16.2 and higher (checked up to latest available 1.18.4)
  • .NET Runtime and Blazor version: 6.0.16
  • OS type and version: Windows 10

Additional context:

I first assumed this problem was caused by the upgrade of AngleSharp.Diffing, but bUnit 1.15.5 and 1.16.2 both use AngleSharp.Diffing 0.17.1. So it seems to be a problem somewhere within bUnit.

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
linkdotnetcommented, Apr 25, 2023

There should be another preview version available soon. I would love to get your feedback on the newest version

1reaction
linkdotnetcommented, Apr 26, 2023

@candritzky release is out! You can now use the stable 1.19 version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vscode-cpptools/Extension/CHANGELOG.md at main
Official repository for the Microsoft C/C++ extension for VS Code. - vscode-cpptools/Extension/CHANGELOG.md at main · microsoft/vscode-cpptools.
Read more >
Changelog — Auspice documentation
This version reverts the change to URL parsing introduced in 2.18.2 which broke Auspice on Safari (and perhaps other browsers).
Read more >
Releases — HoloViews v1.17.1
This release includes a breaking change as notebooks will no longer be inlining as default. This change will reduce the size of the...
Read more >
Erlang -- STDLIB Release Notes
The application/erlang+html documentation storage format used by ... The undocumented and partially broken ets:filter/3 function has been removed.
Read more >
Changelog — Paramiko documentation
[Bug] #1933: Align signature verification algorithm with OpenSSH re: zero-padding signatures which don't match their nominal size/length. This shouldn't affect ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found