test(Table): add SearchItemMetaData unit test#7774
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds propagation and unit test coverage for the SearchFormItemMetaData property in table column extension copying logic. Class diagram for ITableColumn and CopyValue extension updateclassDiagram
class ITableColumn {
bool? IsRequiredWhenAdd
bool? IsRequiredWhenEdit
bool? IgnoreWhenExport
object SearchFormItemMetaData
}
class TableColumnExtensions {
+void CopyValue(ITableColumn col, ITableColumn dest)
}
TableColumnExtensions ..> ITableColumn : uses
Flow diagram for CopyValue SearchFormItemMetaData propagationflowchart TD
A[CopyValue called with col and dest] --> B{col.IsRequiredWhenAdd has value?}
B -->|yes| C[dest.IsRequiredWhenAdd = col.IsRequiredWhenAdd]
B -->|no| D[skip]
C --> E{col.IsRequiredWhenEdit has value?}
D --> E
E -->|yes| F[dest.IsRequiredWhenEdit = col.IsRequiredWhenEdit]
E -->|no| G[skip]
F --> H{col.IgnoreWhenExport has value?}
G --> H
H -->|yes| I[dest.IgnoreWhenExport = col.IgnoreWhenExport]
H -->|no| J[skip]
I --> K{col.SearchFormItemMetaData is not null?}
J --> K
K -->|yes| L[dest.SearchFormItemMetaData = col.SearchFormItemMetaData]
K -->|no| M[skip]
L --> N[CopyValue returns]
M --> N
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Copying
SearchFormItemMetaDataby reference may lead to unintended shared mutable state between columns; consider whether a defensive clone or copy-constructor is more appropriate here, consistent with how you expect this metadata to be used. - The new unit test only checks
SearchFormItemMetaDatafor non-null; to ensure the new behavior is actually verified, assert that the destination column received the same instance or expected property values from the source.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Copying `SearchFormItemMetaData` by reference may lead to unintended shared mutable state between columns; consider whether a defensive clone or copy-constructor is more appropriate here, consistent with how you expect this metadata to be used.
- The new unit test only checks `SearchFormItemMetaData` for non-null; to ensure the new behavior is actually verified, assert that the destination column received the same instance or expected property values from the source.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7774 +/- ##
========================================
Coverage 99.99% 100.00%
========================================
Files 764 764
Lines 33953 33960 +7
Branches 4673 4675 +2
========================================
+ Hits 33951 33960 +9
+ Misses 2 0 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds unit coverage for (and fixes) propagation of custom search-form metadata when copying table column definitions, ensuring SearchFormItemMetaData isn’t dropped during column merges/copy operations.
Changes:
- Extend
ITableColumnExtensions.CopyValueto copySearchFormItemMetaDatawhen present. - Update the existing
CopyValue_Okunit test to setSearchFormItemMetaDataon the source column and assert it is present on the destination after copy.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs |
Copies SearchFormItemMetaData during ITableColumn → ITableColumn value transfer. |
test/UnitTest/Extensions/ITableColumnExtensionsTest.cs |
Adds coverage asserting SearchFormItemMetaData is populated after CopyValue. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Link issues
fixes #7773
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Ensure table column metadata copying includes search form metadata and add unit coverage for it.
Enhancements:
Tests: