Skip to content

test: add test cases for PresetWrapperComponent spec#5009

Merged
mengw15 merged 3 commits into
apache:mainfrom
Ma77Ball:test/preset-wrapper
May 10, 2026
Merged

test: add test cases for PresetWrapperComponent spec#5009
mengw15 merged 3 commits into
apache:mainfrom
Ma77Ball:test/preset-wrapper

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Replaces the placeholder/commented-out body of preset-wrapper.component.spec.ts with a real Vitest suite for PresetWrapperComponent, and re-enables the file in angular.json and tsconfig.spec.json (it was previously excluded from the build).

The new suite uses fake PresetService and NzMessageService providers and covers:

  • ngOnInit guards: throws when field.key, templateOptions, or presetKey are missing; populates searchResults from getPresets.
  • Functional API: applyPreset / deletePreset forward to PresetService with the configured preset key triple; getEntryTitle, getEntryDescription, and the show-all / prefix-match / empty-term / no-match branches of
    getSearchResults.
  • Dropdown visibility: opening re-fetches presets, closing does not.
  • Stream subscriptions: savePresetsStream updates searchResults only when type + target match; valueChanges only refreshes while the menu is open; ngOnDestroy tears down subscriptions.
  • savePreset: builds the payload from sibling preset-wrapper fields (ignoring non-preset siblings) and routes valid presets to createPreset; invalid presets surface a toast error.

Any related issues, documentation, or discussions?

Closes: #4963

How was this PR tested?

npx ng test --watch=false --include='src/app/common/formly/preset-wrapper/preset-wrapper.component.spec.ts' --> 24 tests pass locally under the Vitest runner.

Was this PR authored or co-authored using generative AI tooling?

Was this PR authored or co-authored using generative AI tooling?

Co-Authored with Claude Opus 4.7 in compliance with ASF.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label May 10, 2026
@Ma77Ball Ma77Ball changed the title add real test cases for PresetWrapperComponent spec test: add test cases for PresetWrapperComponent spec May 10, 2026
@chenlica chenlica requested a review from mengw15 May 10, 2026 07:09
@chenlica
Copy link
Copy Markdown
Contributor

@mengw15 Please review this PR.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.36%. Comparing base (bb78cca) to head (f87f295).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5009      +/-   ##
============================================
- Coverage     43.76%   43.36%   -0.40%     
- Complexity     1218     2183     +965     
============================================
  Files           768     1035     +267     
  Lines         31243    38818    +7575     
  Branches       3049     4061    +1012     
============================================
+ Hits          13673    16833    +3160     
- Misses        16865    20930    +4065     
- Partials        705     1055     +350     
Flag Coverage Δ *Carryforward flag
access-control-service 39.88% <ø> (ø) Carriedforward from 6f9f0e3
agent-service 33.72% <ø> (ø) Carriedforward from 6f9f0e3
amber 43.22% <ø> (-2.16%) ⬇️ Carriedforward from 6f9f0e3
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 6f9f0e3
config-service 0.00% <ø> (ø) Carriedforward from 6f9f0e3
file-service 32.10% <ø> (ø) Carriedforward from 6f9f0e3
frontend 35.17% <ø> (+0.37%) ⬆️
python 88.90% <ø> (ø) Carriedforward from 6f9f0e3
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 6f9f0e3

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Contributor

@mengw15 mengw15 left a comment

Choose a reason for hiding this comment

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

LGTM

@mengw15 mengw15 enabled auto-merge (squash) May 10, 2026 16:28
@mengw15 mengw15 merged commit c93c8f7 into apache:main May 10, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for PresetWrapperComponent

4 participants