-
-
Notifications
You must be signed in to change notification settings - Fork 254
Add missing tests of BitDialog (#11665) #11666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing tests of BitDialog (#11665) #11666
Conversation
WalkthroughA comprehensive test suite for the BitDialog component is introduced, covering rendering states, user interactions, button behavior, overlay dismissal logic with blocking variants, asynchronous dialog result flows, and accessibility role attributes across various configuration combinations. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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 (3)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Dialog/BitDialogTests.cs (3)
61-61: Remove redundant ternary operator.The ternary
isBlocking ? 1 : 1always evaluates to 1, making it redundant.Apply this diff:
- Assert.AreEqual(isBlocking ? 1 : 1, overlays.Count); + Assert.AreEqual(1, overlays.Count);
136-136: Consider renaming to reflect actual test scope.The method name mentions "AndBlocking" but only tests IsAlert variations. Consider renaming to
BitDialogRoleRespectsIsAlertfor clarity.Apply this diff:
- public void BitDialogRoleRespectsIsAlertAndBlocking(bool? isAlert) + public void BitDialogRoleRespectsIsAlert(bool? isAlert)
136-157: Consider expanding test coverage for IsBlocking and IsModeless.The test sets
IsBlocking=trueandIsModeless=falsebut doesn't verify variations of these parameters. If the dialog's role attribute behavior depends on blocking or modeless states (per WAI-ARIA guidance), these scenarios should be tested.Consider adding a data-driven test that varies IsAlert, IsBlocking, and IsModeless combinations to ensure the role attribute is set correctly across all accessibility scenarios. For example:
[TestMethod] [DataRow(true, true, false, "alertdialog")] // alert, blocking, not modeless [DataRow(false, true, false, "dialog")] // not alert, blocking, not modeless [DataRow(true, false, true, "dialog")] // alert, not blocking, modeless // Add more combinations as needed based on component logic public void BitDialogRoleRespectsAccessibilityParameters(bool isAlert, bool isBlocking, bool isModeless, string expectedRole) { Context.JSInterop.Mode = JSRuntimeMode.Loose; var component = RenderComponent<BitDialog>(parameters => { parameters.Add(p => p.IsOpen, true); parameters.Add(p => p.IsAlert, isAlert); parameters.Add(p => p.IsBlocking, isBlocking); parameters.Add(p => p.IsModeless, isModeless); }); var roleDiv = component.Find("div[role]"); Assert.AreEqual(expectedRole, roleDiv.GetAttribute("role")); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Dialog/BitDialogTests.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 (4)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Dialog/BitDialogTests.cs (4)
10-39: LGTM! Comprehensive rendering test.The test effectively validates the dialog's core rendering behavior when open, checking title, message, buttons, and overlay presence.
44-75: Test logic correctly validates IsBlocking behavior.The test properly verifies that overlay clicks respect the IsBlocking flag: dialogs stay open when blocking, and close with OnDismiss invocation when not blocking.
77-96: LGTM! Clear and focused test.The test cleanly validates that clicking the close button both invokes the OnClose callback and updates the IsOpen state.
98-130: LGTM! Async flow correctly tested.The test properly validates that Show() returns the expected BitDialogResult values for both OK and Cancel button clicks. Using separate component instances for each scenario is a sound approach.
closes #11665
Summary by CodeRabbit