Skip to content

Add tests for BitNavPanel (#11752)#11753

Merged
msynk merged 1 commit intobitfoundation:developfrom
msynk:11752-blazorui-nvapanel-tests
Nov 25, 2025
Merged

Add tests for BitNavPanel (#11752)#11753
msynk merged 1 commit intobitfoundation:developfrom
msynk:11752-blazorui-nvapanel-tests

Conversation

@msynk
Copy link
Copy Markdown
Member

@msynk msynk commented Nov 25, 2025

closes #11752

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for the NavPanel component, validating rendering, toggle functionality, overlay interactions, item click handling, and search box visibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 25, 2025

Walkthrough

A new comprehensive test suite for the BitNavPanel component has been added, containing ten test methods that verify rendering, toggling, overlay behavior, item interactions, CSS classes, search functionality, and navigation features.

Changes

Cohort / File(s) Summary
BitNavPanel test suite
src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/NavPanel/BitNavPanelTests.cs
New test class with 10 test methods covering header/footer rendering, toggle state binding, overlay click behavior, item click invocation, toggle button visibility, layout classes, icon navigation, and search box rendering for the BitNavPanel component.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Single cohesive test file with homogeneous test patterns and consistent BUnit structure
  • Tests follow established conventions for component testing in the codebase
  • Areas to verify during review:
    • Comprehensive coverage of all BitNavPanel public properties and behaviors
    • Consistency of test naming and structure with existing test suites
    • Appropriate assertion density and edge case coverage
    • Mock/parameter setup validity for accurate component state verification

Poem

🐰 A panel for navigation, now tested with care,
Ten methods dance merrily through markup and flair,
Toggles and overlays, clicks and CSS too,
We've verified the NavPanel through and through!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding tests for the BitNavPanel component, which is what the changeset delivers.
Linked Issues check ✅ Passed The PR successfully adds comprehensive unit tests for BitNavPanel covering rendering, toggle behavior, overlay interaction, item clicks, and various configuration options, directly fulfilling issue #11752's requirement.
Out of Scope Changes check ✅ Passed All changes are scoped to adding tests for BitNavPanel; no unrelated modifications or out-of-scope code changes are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/NavPanel/BitNavPanelTests.cs (1)

152-168: Tighten icon/navigation test: avoid :has selector and fix AreEqual argument order

Two small improvements here:

  1. a:has(img.bit-npn-img) depends on support for the CSS :has pseudo-class in the underlying selector engine; using the image element to find its anchor is more robust.
  2. In Assert.AreEqual(a.GetAttribute("href"), url);, the expected/actual values are reversed, which only affects the failure message but is slightly confusing.

You could rewrite this portion as:

-        var img = component.Find("img.bit-npn-img");
-        var a = component.Find("a:has(img.bit-npn-img)");
-
-        Assert.AreEqual("/logo.png", img.GetAttribute("src"));
-        Assert.AreEqual(a.GetAttribute("href"), url);
+        var img = component.Find("img.bit-npn-img");
+        var a = img.Closest("a");
+
+        Assert.IsNotNull(a);
+        Assert.AreEqual("/logo.png", img.GetAttribute("src"));
+        Assert.AreEqual(url, a!.GetAttribute("href"));

This keeps the intent the same while avoiding reliance on :has and clarifying the assertion.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 5aaca72 and 32e58ec.

📒 Files selected for processing (1)
  • src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/NavPanel/BitNavPanelTests.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build Bit.BlazorUI
🔇 Additional comments (2)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Extras/NavPanel/BitNavPanelTests.cs (2)

17-193: Comprehensive BitNavPanel test coverage looks good

Nice job covering the main behaviors: header/footer and items rendering, toggle state, overlay close, item click behavior, HideToggle/NoToggle, layout-related classes and Top, icon navigation, and search visibility/defaults. The tests are cohesive, focused per behavior, and follow consistent bUnit patterns, which should give good confidence around BitNavPanel regressions.


145-149: Review comment is incorrect—this code will compile

The test file uses MSTest (Microsoft.VisualStudio.TestTools.UnitTesting), which has overloads for Assert.IsTrue(bool?). The expression root.GetAttribute("style")?.Contains("top:24px") returns bool?, and MSTest accepts this directly without compilation error.

While the suggested refactoring provides a clearer failure message, it is not necessary to resolve a compilation issue, since no such issue exists.

Likely an incorrect or invalid review comment.

@msynk msynk merged commit a164e7a into bitfoundation:develop Nov 25, 2025
3 checks passed
@msynk msynk deleted the 11752-blazorui-nvapanel-tests branch November 25, 2025 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The BitNavPanel component needs its unit tests to be added

1 participant