test(frontend): re-enable two skipped drag-drop tests#4971
test(frontend): re-enable two skipped drag-drop tests#4971Yicong-Huang wants to merge 4 commits intoapache:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4971 +/- ##
============================================
+ Coverage 42.68% 42.91% +0.22%
Complexity 2183 2183
============================================
Files 1031 1031
Lines 38110 38110
Branches 4004 4004
============================================
+ Hits 16266 16353 +87
+ Misses 20828 20727 -101
- Partials 1016 1030 +14
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d0ed12a to
2d6a759
Compare
`should find 3 input/output operatorPredicates`:
- `findClosestOperators` was called *before* `addOperator`, so the
captured result was always [].
- Reorder the calls and relax the assertion from a strict ordered
`toEqual([…])` to `arrayContaining` + `toHaveLength`. The function
returns its closest-N priority queue as an unsorted heap, so the
original assertion was over-specified.
`should update highlighting, add operator, and add links when an
operator is dropped`:
- Drive the actual flow through `attachMainJointPaper` (real paper on
a hidden host), `dragStarted("MultiInputOutput")`, a synthetic
`window.dispatchEvent(new MouseEvent('mousemove', ...))` to populate
the suggestion lists, and `dragDropped`.
- Place inputs at x=-100 and outputs at x=100 because jsdom's
polyfilled `pageToLocalPoint` always resolves to (0, 0) — fine for
classification, which only compares operator x against mouse x.
- Tighten assertions around link membership and unhighlight set
rather than asserting on jasmine-era sentinel arrays.
Closes apache#4866.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Re-enables two previously skipped DragDropService unit tests by fixing the test logic (ordering of calls) and driving the drag/drop flow through a real (hidden) JointJS paper under jsdom, avoiding browser-mode-only dependencies.
Changes:
- Re-enabled the “closest operators” test by calling
findClosestOperatorsafter operators are added and relaxing assertions to be order-independent. - Replaced the previously skipped “drop operator” test with an integration-style jsdom test that attaches a real JointJS paper, triggers
dragStarted, synthesizesmousemove, and then callsdragDropped.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace the misleading `pageToLocalPoint(x, y) ≈ (x, y)` note with the actual behavior: the SVG polyfill's identity matrices collapse the call to (0, 0) regardless of input. That's the real reason operators are placed at x=±100 around the origin. - Wrap DOM mutation in try/finally so paperHost / flyingOpHost are removed even if an assertion throws. - Dispatch a synthetic `mouseup` after `dragDropped` so the window-level mousemove subscriptions installed by `dragStarted` tear down before the next spec runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The frontend test took 6 hours and failed. Please take a look: |
What changes were proposed in this PR?
The two tests in
drag-drop.service.spec.tsparked under #4866 turn out not to need browser mode at all — both root causes are jsdom-friendly.should find 3 input/output operatorPredicates—findClosestOperatorswas called beforeaddOperator, so the captured result was always[]. Reorder, and relax the assertion from a strict orderedtoEqual([…])toarrayContaining+toHaveLengthsince 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 throughattachMainJointPaper(real paper on a hidden host),dragStarted("MultiInputOutput"), a syntheticwindow.dispatchEvent(new MouseEvent('mousemove', ...))to populate the suggestion pipeline, anddragDropped. No mocks. Inputs are placed atx=-100and outputs atx=100because jsdom's polyfilledpageToLocalPointalways resolves to (0, 0) — fine for input/output classification which only compares operator x against mouse x.Any related issues, documentation, discussions?
Part of #4866 — re-enables the drag-drop half. The remaining
workflow-editor.component.spec.tsis still excluded for an unrelated reason: it transitively pulls indownload.service.ts's top-levelrequire("content-disposition"), which esbuild can't rewrite for the browser bundle. That cleanup belongs in a separate PR, and #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:ciclean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.7 (1M context)