fix: Test/menu component#51
Open
Ma77Ball wants to merge 16 commits into
Open
Conversation
### 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: apache#4968 ### Was this PR authored or co-authored using generative AI tooling? Co-Authored with Claude Opus 4.7 in compliance with ASF
### What changes were proposed in this PR? The two tests in `drag-drop.service.spec.ts` parked under apache#4866 turn out not to need browser mode at all — both root causes are jsdom-friendly. **`should find 3 input/output operatorPredicates`** — `findClosestOperators` was called *before* `addOperator`, so the captured result was always `[]`. Reorder, and relax the assertion from a strict ordered `toEqual([…])` to `arrayContaining` + `toHaveLength` since the function returns its closest-N priority queue as an unsorted heap. **`should update highlighting, add operator, and add links when an operator is dropped`** — drive the real flow through `attachMainJointPaper` (real paper on a hidden host), `dragStarted("MultiInputOutput")`, a synthetic `window.dispatchEvent(new MouseEvent('mousemove', ...))` to populate the suggestion pipeline, and `dragDropped`. No mocks. Inputs are placed at `x=-100` and outputs at `x=100` because jsdom's polyfilled `pageToLocalPoint` always resolves to (0, 0) — fine for input/output classification which only compares operator x against mouse x. ### Any related issues, documentation, discussions? Part of apache#4866 — re-enables the drag-drop half. The remaining `workflow-editor.component.spec.ts` is still excluded for an unrelated reason: it transitively pulls in `download.service.ts`'s top-level `require("content-disposition")`, which esbuild can't rewrite for the browser bundle. That cleanup belongs in a separate PR, and apache#4866's scope can be revisited then — neither blocker is actually a browser-mode issue. ### How was this PR tested? `yarn test`: 271 pass, 9 skip, 2 todo (jsdom; +2 from baseline). `yarn format:ci` clean. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Opus 4.7 (1M context) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
### What changes were proposed in this PR? Replaced the placeholder spec at frontend/src/app/workspace/component/left-panel/settings/settings.component.spec.ts (previously just a license header) with 10 real test cases for SettingsComponent: - Component creation - Form initialization from the current workflow settings - dataTransferBatchSize validators (min(1) and required) - confirmUpdateDataTransferBatchSize writes through to WorkflowActionService and persists when the user is logged in - The > 0 guard in confirmUpdateDataTransferBatchSize blocks invalid values - UserService.isLogin() gate skips persistence when the user is logged out - updateExecutionMode writes through to the workflow service and persists - persistWorkflow errors are surfaced via NotificationService.error - Form valueChanges propagate both controls to the action service - Form valueChanges ignore invalid values Also removed settings.component.spec.ts from the placeholder exclusion lists in frontend/angular.json (test builder exclude) and frontend/src/tsconfig.spec.json (exclude) so the spec is actually compiled and run. ### Any related issues, documentation, or discussions? Closes: apache#4965 ### How was this PR tested? Ran the new spec via the Angular/Vitest test runner: npx ng test --watch=false --include="src/app/workspace/component/left-panel/settings/settings.component.spec.ts" ### Was this PR authored or co-authored using generative AI tooling? Co-Authored with Claude Opus 4.7 in compliance with ASF
# Conflicts: # frontend/angular.json # frontend/src/tsconfig.spec.json
…test/menuComponent
Signed-off-by: Matthew B. <mgball@uci.edu>
Removed preset.service.spec.ts from test exclusions. Signed-off-by: Matthew B. <mgball@uci.edu>
Signed-off-by: Matthew B. <mgball@uci.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
Any related issues, documentation, discussions?
How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?