Skip to content

UnitTests.Viewer: List test components and allow selecting one #658

Open

Description

@redgp0g

Problem

tests/CodeBeam.MudBlazor.Extensions.UnitTests.Viewer/Pages/Index.razor still comes from the default Blazor template and renders test components hardcoded by hand (currently MultiSelectTestRequiredValue and DebounceTextFieldTest). To look at any other of the ~50 test components you have to edit Index.razor, and these viewing-only edits tend to ride along in unrelated PRs. The nav menu also outdated and default.

The property public static string __description__ = "..." isn't used.

Proposal

Replace Index.razor with a small picker, modeled on MudBlazor's src/MudBlazor.UnitTests.Viewer/Pages/Index.razor, kept much simpler:

  • Find test components by reflection: types in the Viewer assembly whose namespace is MudExtensions.UnitTests.TestComponents and that implement IComponent.
  • List them in a MudDrawer with a search field that filters by name.
  • Show the selected component's name and its __description__, with a fallback when it's missing.
  • Keep the selection in the URL (e.g. /viewer/ChipFieldRequiredTest) so it survives reloads and can be linked.
  • Render the selected component through DynamicComponent inside an ErrorBoundary, wrapped in <CascadingValue Name="UsePopoverProvider" Value="false">, because many test components render their own MudPopoverProvider for bUnit.
  • Remove the leftover template pages/links (NavMenu, Bootstrap layout) and use a plain MudBlazor layout.

No changes to the test components or the unit tests are needed.

I'm happy to open a PR for this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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