Skip to content

BUnit doesn't work with MudTooltip #1035

@kostyrin

Description

@kostyrin

BUnit doesn't work with MudTooltip

Good afternoon,

I wrote a sample

Example:
Testing this component:

@using MudBlazor

<p>@text</p>
<MudTooltip>
    <ChildContent>
        <MudMenu id="@_id">
            @{
                <MudMenuItem id="@_id" @onclick=@(() => openDialog("Y", _id))>name</MudMenuItem>
            }
        </MudMenu>
    </ChildContent>
</MudTooltip>

@code {
    private long _id { get; set; } = 1;
    public string text { get; set; }

    private void openDialog(string approval, long id)
    {
        text = "test";
    }
}

With this test:

          using var ctx = new TestContext();
          ctx.JSInterop.SetupVoid("mudPopover.connect", _ => true);
          ctx.Services.AddMudServices();
          var testComponent = ctx.RenderComponent<MudTestComponent>();

          var button = testComponent.Find("button");
          button.Click();
          testComponent.WaitForState(() => testComponent.Instance.text == "test", TimeSpan.FromSeconds(5))

Markup:

<p></p>
<div class="mud-tooltip-root mud-tooltip-inline" blazor:onmouseenter="1" blazor:onmouseleave="2" blazor:onmouseup="3" blazor:onfocusin="4" blazor:onfocusout="5">
   <div id="1" Class="mud-menu" blazor:onmouseenter="6" blazor:onmouseleave="7">
      <button blazor:onclick="8" type="button" class="mud-button-root mud-button mud-button-text mud-button-text-default mud-button-text-size-medium mud-ripple" blazor:onclick:stopPropagation blazor:elementReference=""><span class="mud-button-label"></span></button>
      <div id="popover-443c299a-34de-4546-b6c3-79b04e5c7512" class="mud-popover-cascading-value"></div>
      <div class="mud-overlay" style="" blazor:onclick="9" blazor:onclick:stopPropagation></div>
   </div>
</div>

Results in this output:

doesn't pass the test
Bunit.Extensions.WaitForHelpers.WaitForFailedException : The state predicate did not pass before the timeout period passed. Check count: 1. Component render count: 2. Total render count: 2.

Expected behavior:

When click at the button we will see a message: pass the test

Version info:

  • bUnit version: 1.18.4
  • .NET Runtime and Blazor version: 6.0.11
  • MudBlazor version: 6.2.0

Additional context:
Nothing happened when trying to debug the clicking or when set a break inside openDialog method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions