Skip to content

test: add real test cases for PresetService spec #4991

Merged
aglinxinyuan merged 6 commits intoapache:mainfrom
Ma77Ball:test/PresetService
May 9, 2026
Merged

test: add real test cases for PresetService spec #4991
aglinxinyuan merged 6 commits intoapache:mainfrom
Ma77Ball:test/PresetService

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

@Ma77Ball Ma77Ball commented May 8, 2026

What changes were proposed in this PR?

Replaces the old all-commented-out preset.service.spec.ts with a real, runnable Vitest test suite for PresetService, and re-enables the file in angular.json and tsconfig.spec.json (it was previously excluded from the build).

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

  • Preset I/O: applyPresetStream / savePresetsStream event emission; savePresets routing non-empty lists to userConfig.set and empty lists to userConfig.delete; default vs. suppressed save toast; createPreset / updatePreset /
    deletePreset / getPresets happy paths and error cases.
  • Operator preset application: applyPreset is a no-op for non-operator types and unknown operator IDs; valid presets merge into operator properties; invalid presets leave properties unchanged.
  • Validation: isValidOperatorPreset and isValidNewOperatorPreset accept/reject the expected shapes.
  • Static helpers: getOperatorPresetSchema, getOperatorPreset, and filterOperatorPresetProperties.

Also registers the project's custom "enable-presets" Ajv keyword as a no-op in the test file so Ajv 8 strict mode doesn't reject the operator schemas at compile time.

Any related issues, documentation, or discussions?

Closes: #4968

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 8, 2026
@Ma77Ball
Copy link
Copy Markdown
Contributor Author

Ma77Ball commented May 9, 2026

/request-review @aglinxinyuan

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the previously commented-out PresetService spec with a runnable Vitest suite and re-enables that spec file in the Angular/Vitest test configuration so it executes in CI.

Changes:

  • Replaced preset.service.spec.ts placeholder with real unit tests using stubbed UserConfigService and NzMessageService.
  • Re-enabled preset.service.spec.ts by removing it from the test exclusion lists in tsconfig.spec.json and angular.json.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
frontend/src/tsconfig.spec.json Removes preset.service.spec.ts from the excluded specs so it’s compiled/executed.
frontend/angular.json Removes preset.service.spec.ts from the unit-test builder’s exclude list so Vitest runs it.
frontend/src/app/workspace/service/preset/preset.service.spec.ts Adds a full Vitest test suite for PresetService, including preset I/O, operator application, validation, and static helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/app/workspace/service/preset/preset.service.spec.ts Outdated
Comment thread frontend/src/app/workspace/service/preset/preset.service.spec.ts Outdated
Comment thread frontend/src/app/workspace/service/preset/preset.service.spec.ts Outdated
Comment thread frontend/src/app/workspace/service/preset/preset.service.spec.ts Outdated
@aglinxinyuan aglinxinyuan enabled auto-merge (squash) May 9, 2026 07:49
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.95%. Comparing base (6f088ab) to head (18e2076).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4991      +/-   ##
============================================
+ Coverage     42.73%   42.95%   +0.21%     
  Complexity     2187     2187              
============================================
  Files          1031     1031              
  Lines         38152    38153       +1     
  Branches       4004     4004              
============================================
+ Hits          16305    16389      +84     
+ Misses        20831    20742      -89     
- Partials       1016     1022       +6     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 6f088ab
agent-service 33.72% <ø> (ø) Carriedforward from 6f088ab
amber 43.23% <ø> (ø) Carriedforward from 6f088ab
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 6f088ab
config-service 0.00% <ø> (ø) Carriedforward from 6f088ab
file-service 32.18% <ø> (ø) Carriedforward from 6f088ab
frontend 33.67% <ø> (+0.59%) ⬆️
python 88.90% <ø> (ø) Carriedforward from 6f088ab
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 6f088ab

*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.

@aglinxinyuan aglinxinyuan merged commit 7f7bba8 into apache:main May 9, 2026
15 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 PresetService

4 participants