Skip to content

test(TreeView): add IconTempalte unit test#8160

Merged
ArgoZhang merged 1 commit into
mainfrom
test-tv
Jun 24, 2026
Merged

test(TreeView): add IconTempalte unit test#8160
ArgoZhang merged 1 commit into
mainfrom
test-tv

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Jun 24, 2026

Copy link
Copy Markdown
Member

Link issues

fixes #8159

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add unit coverage for TreeView icon customization behavior.

Tests:

  • Add unit test verifying TreeView respects per-item IconTemplate and suppresses default icons.
  • Add unit test verifying TreeView renders SvgIcon correctly when UseSvg, SvgHref, and Icon are configured.

@bb-auto bb-auto Bot added the test This is unit test label Jun 24, 2026
@bb-auto bb-auto Bot added this to the v10.7.0 milestone Jun 24, 2026
@sourcery-ai

sourcery-ai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds unit tests to verify TreeView icon rendering when using custom IconTemplate and SVG-based icons, ensuring correct priority and output structure.

File-Level Changes

Change Details Files
Add unit test to verify custom IconTemplate rendering and its precedence over default and SVG icons in TreeView.
  • Create IconTemplate_Ok test that assigns a custom IconTemplate to the first tree item.
  • Render TreeView with icons enabled and verify the custom template output is present.
  • Assert that when IconTemplate is provided, the rendered HTML contains the custom icon markup and excludes SvgIcon markup.
test/UnitTest/Components/TreeViewTest.cs
Add unit test to verify TreeView renders SVG icons correctly when UseSvg is enabled on a tree item.
  • Create UseSvg_Ok test that sets UseSvg, SvgHref, and Icon on the first tree item.
  • Render TreeView with icons enabled and retrieve the SvgIcon component from the render tree.
  • Assert that SvgIcon is configured with the expected Name and Href values and that the expected CSS classes and href fragment are rendered.
test/UnitTest/Components/TreeViewTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#8159 Add a unit test for the TreeView IconTemplate behavior to verify that a custom icon template is rendered and takes precedence over default/SVG icons.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit b7ada7a into main Jun 24, 2026
5 checks passed
@ArgoZhang ArgoZhang deleted the test-tv branch June 24, 2026 07:47

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto approved by bb-auto

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In IconTemplate_Ok, TreeFoo.GetTreeItems() is mutated (setting IconTemplate on items[0]), so if this helper returns a cached/shared collection it could introduce cross-test coupling; consider ensuring a fresh list (e.g., clone or a factory that always returns new instances) before mutating.
  • In IconTemplate_Ok you assert the SVG icon is not rendered, but the comment also mentions skipping the default <i> tag; consider explicitly asserting that the default icon element/class is absent to more fully validate the intended precedence behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `IconTemplate_Ok`, `TreeFoo.GetTreeItems()` is mutated (setting `IconTemplate` on `items[0]`), so if this helper returns a cached/shared collection it could introduce cross-test coupling; consider ensuring a fresh list (e.g., clone or a factory that always returns new instances) before mutating.
- In `IconTemplate_Ok` you assert the SVG icon is not rendered, but the comment also mentions skipping the default `<i>` tag; consider explicitly asserting that the default icon element/class is absent to more fully validate the intended precedence behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1da0222) to head (de5be06).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #8160      +/-   ##
===========================================
+ Coverage   99.97%   100.00%   +0.02%     
===========================================
  Files         766       766              
  Lines       34229     34229              
  Branches     4699      4699              
===========================================
+ Hits        34221     34229       +8     
+ Misses          6         0       -6     
+ Partials        2         0       -2     
Flag Coverage Δ
BB 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

test This is unit test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(TreeView): add IconTempalte unit test

1 participant