Skip to content

test(frontend): re-enable two skipped drag-drop tests#4971

Open
Yicong-Huang wants to merge 4 commits intoapache:mainfrom
Yicong-Huang:feat/frontend-vitest-browser-mode
Open

test(frontend): re-enable two skipped drag-drop tests#4971
Yicong-Huang wants to merge 4 commits intoapache:mainfrom
Yicong-Huang:feat/frontend-vitest-browser-mode

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang commented May 6, 2026

What changes were proposed in this PR?

The two tests in drag-drop.service.spec.ts parked under #4866 turn out not to need browser mode at all — both root causes are jsdom-friendly.

should find 3 input/output operatorPredicatesfindClosestOperators 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 #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 #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)

@github-actions github-actions Bot added feature dependencies Pull requests that update a dependency file frontend Changes related to the frontend GUI ci changes related to CI labels May 6, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.91%. Comparing base (9fc5b39) to head (7c460d5).

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     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 9fc5b39
agent-service 33.72% <ø> (ø) Carriedforward from 9fc5b39
amber 43.14% <ø> (ø) Carriedforward from 9fc5b39
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 9fc5b39
config-service 0.00% <ø> (ø) Carriedforward from 9fc5b39
file-service 33.24% <ø> (ø) Carriedforward from 9fc5b39
frontend 33.61% <ø> (+0.60%) ⬆️
python 88.90% <ø> (ø) Carriedforward from 9fc5b39
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 9fc5b39

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

@Yicong-Huang Yicong-Huang changed the title feat(frontend): wire up Vitest browser-mode infrastructure feat(frontend): Vitest browser-mode infra + re-enable findClosestOperators test May 6, 2026
@Yicong-Huang Yicong-Huang changed the title feat(frontend): Vitest browser-mode infra + re-enable findClosestOperators test test(frontend): re-enable drag-drop tests; add Vitest browser-mode infra May 6, 2026
@Yicong-Huang Yicong-Huang force-pushed the feat/frontend-vitest-browser-mode branch from d0ed12a to 2d6a759 Compare May 6, 2026 08:12
`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>
@Yicong-Huang Yicong-Huang changed the title test(frontend): re-enable drag-drop tests; add Vitest browser-mode infra test(frontend): re-enable two skipped drag-drop tests May 6, 2026
@Yicong-Huang Yicong-Huang reopened this May 6, 2026
@github-actions github-actions Bot removed dependencies Pull requests that update a dependency file ci changes related to CI labels May 6, 2026
@Yicong-Huang Yicong-Huang requested a review from Copilot May 6, 2026 08:16
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

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 findClosestOperators after 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, synthesizes mousemove, and then calls dragDropped.

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

Comment thread frontend/src/app/workspace/service/drag-drop/drag-drop.service.spec.ts Outdated
Comment thread frontend/src/app/workspace/service/drag-drop/drag-drop.service.spec.ts Outdated
Comment thread frontend/src/app/workspace/service/drag-drop/drag-drop.service.spec.ts Outdated
- 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>
@Yicong-Huang Yicong-Huang enabled auto-merge (squash) May 6, 2026 08:45
@aglinxinyuan
Copy link
Copy Markdown
Contributor

The frontend test took 6 hours and failed. Please take a look:
https://github.com/apache/texera/actions/runs/25425783736/job/74578713230

@aglinxinyuan aglinxinyuan disabled auto-merge May 6, 2026 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants