Skip to content

Conversation

@msynk
Copy link
Member

@msynk msynk commented Nov 14, 2025

closes #11608

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit tests for the BitCollapse component, verifying child content rendering, expanded state transitions with CSS class management, and custom styling configuration across component elements.

@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Walkthrough

A new unit test file for the BitCollapse Blazor component is introduced using MSTest and BUnit. Tests cover child content rendering, expanded state CSS class toggles, and custom styling via BitCollapseClassStyles configuration.

Changes

Cohort / File(s) Summary
BitCollapse Unit Tests
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.cs
New test file covering component rendering, expanded state behavior, and custom class/style assignments for root and content elements

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Straightforward test file addition following established MSTest/BUnit patterns
  • No complex logic or architectural changes
  • Tests use standard assertions and component lifecycle verification

Poem

🐰 A collapse component now has its proof,
With tests that hop through every truth,
Child content renders, states expand and fold,
BUnit's gentle assertions make testing bold! 🧪✨

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 PR title contains a typo ('BitCollapase' instead of 'BitCollapse') but accurately summarizes the main change of adding tests for the BitCollapse component.
Linked Issues check ✅ Passed The PR successfully addresses issue #11608 by introducing comprehensive unit tests for the BitCollapse component covering rendering, expanded state, and custom styling.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to fulfilling the objective of adding unit tests for BitCollapse; no out-of-scope modifications detected.
✨ 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

@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: 1

🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.cs (1)

47-71: Consider testing the Expanded=false case for custom styles.

The test verifies that custom classes and styles are applied when Expanded=true, but doesn't test that the Expanded-specific class and style are NOT applied when Expanded=false. Adding a test case for Expanded=false would improve coverage and ensure the component correctly applies conditional styling.

Consider adding:

[TestMethod]
public void BitCollapseShouldNotApplyExpandedStylesWhenCollapsed()
{
    var classes = new BitCollapseClassStyles { Root = "root-class", Content = "content-class", Expanded = "expanded-class" };
    var styles = new BitCollapseClassStyles { Root = "width:1px", Content = "width:2px", Expanded = "width:3px" };

    var component = RenderComponent<BitCollapse>(parameters =>
    {
        parameters.Add(p => p.Classes, classes);
        parameters.Add(p => p.Styles, styles);
        parameters.Add(p => p.Expanded, false);
        parameters.AddChildContent("<div>content</div>");
    });

    var root = component.Find(".bit-col");
    Assert.IsTrue(root.ClassList.Contains("root-class"));
    Assert.IsFalse(root.ClassList.Contains("expanded-class"));

    Assert.IsTrue(root.GetAttribute("style")?.Contains("width:1px") ?? false);
    Assert.IsFalse(root.GetAttribute("style")?.Contains("width:3px") ?? false);
}
📜 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 77e5b9f and 4e688fb.

📒 Files selected for processing (1)
  • src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.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 and test
🔇 Additional comments (3)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.cs (3)

9-20: LGTM! Child content rendering test is well-structured.

The test correctly verifies that child content is rendered within the BitCollapse component and that the root element is present.


22-45: LGTM! Expanded state test is comprehensive.

Good use of DataTestMethod to cover both expanded and collapsed states. The CSS class assertions correctly verify the component's state-based styling.


68-70: Verify conflicting width styles on the root element.

Lines 68 and 70 both assert that the root element's style attribute contains different width values ("width:1px" from Root and "width:3px" from Expanded). When both are present in the style attribute, only one width value can take effect in CSS (typically the last one).

Please verify this is the intended behavior and that the component correctly combines these styles in the style attribute string.

@msynk msynk merged commit ec6585c into bitfoundation:develop Nov 14, 2025
3 checks passed
@msynk msynk deleted the 11608-blazorui-collapse-tests branch November 14, 2025 12:08
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.

There is no unit test developed for the BitCollapse component

1 participant