Skip to content

test(hierarchical-document-list): cover drag-and-drop moves with Playwright - #2251

Merged
pedrobonamin merged 1 commit into
mainfrom
cursor/hierarchical-document-list-e2e-315b
Nov 2, 2026
Merged

pedrobonamin merged 1 commit into
mainfrom
cursor/hierarchical-document-list-e2e-315b

Conversation

@pedrobonamin

@pedrobonamin pedrobonamin commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Second of three stacked PRs, on top of #2246:

  1. fix(hierarchical-document-list): restore nesting and same-level moves in the tree #2246: pin @nosferatu500/react-sortable-tree to 5.0.0 and fix same-level moves.
  2. This PR: a Playwright suite for the tree's drag-and-drop.
  3. fix(hierarchical-document-list): update react-sortable-tree to 7.1.0 #2253: upgrade to 7.1.0, checked by this suite.

Summary

This wires @sanity/hierarchical-document-list into dev/e2e-studio, adding a hierarchyBook schema, the plugin's hierarchy.tree type, and a Hierarchy structure item for the hierarchy-e2e-tree document in both workspaces. It also adds a spec that drags rows by their handle with real mouse movement.

Test Seeded tree Drag Expected
moves an item up within the same level alpha, bravo, charlie charlie over alpha charlie, alpha, bravo
moves an item down within the same level alpha, bravo, charlie alpha over charlie bravo, charlie, alpha
nests an item under the item above it alpha, bravo, charlie bravo 60px right alpha[bravo], charlie
moves a nested item out to the root alpha[bravo], charlie bravo 30px left alpha, bravo, charlie
moves an item together with its nested children alpha, bravo[delta], charlie bravo over alpha bravo[delta], alpha, charlie
video.webm
video.webm
video.webm
video.webm

Each test seeds the books and the tree through the Content Lake API and deletes them in finally. Every test checks both the saved document (sibling order plus parent) and the rendered rows (order plus indentation). The tests share one tree document, so the describe block runs serially.

The structure tool now has a custom structure: all document type lists, then the hierarchy item. The other suites navigate with intents, so they aren't affected.

Testing

Run locally against ephemeral datasets:

  • This spec: 5/5 pass in Chromium and 5/5 in Firefox.
  • The whole e2e suite: 56 passed, 4.3 minutes.
  • Against main's code (react-sortable-tree 5.1.0 and the old canDrop), all five scenarios fail in Chromium. For example, the move-up test expects charlie, alpha, bravo and gets alpha, bravo, charlie.

pnpm lint, pnpm knip, the e2e studio build and tsc for e2e/ pass.

Open in Web Open in Cursor 

Note

Low Risk
Changes are limited to the e2e studio, Playwright tests, and documentation; no production plugin runtime behavior is modified in this PR.

Reviewed by Cursor Bugbot for commit 326b58a. Configure here.

@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: dc42312

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
plugins-studio Ready Ready Preview Nov 2, 2026 7:44am UTC
1 Skipped Deployment
Project Deployment Actions Updated
plugins-e2e-test-studio Ignored Ignored Nov 2, 2026 7:44am UTC

Request Review

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ E2E Tests

🟢 55 passed • 🟡 1 flaky • view full report • view run

Studio: https://plugins-e2e-test-studio-fk8dwhdxn.sanity.dev

Datasets: pr-2251-chromium-41408071595, pr-2251-firefox-41408071595

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 38.95% 7911 / 20306
🔵 Statements 38.91% 8509 / 21865
🔵 Functions 34.5% 2161 / 6262
🔵 Branches 31.14% 4608 / 14796
File CoverageNo changed files found.
Generated in workflow #11490 for commit dc42312 by the Vitest Coverage Report Action

@pedrobonamin
pedrobonamin marked this pull request as ready for review October 23, 2026 09:42
@pedrobonamin
pedrobonamin requested a review from a team as a code owner October 23, 2026 09:42
@pedrobonamin
pedrobonamin requested review from bjoerge, juice49 and stipsan and removed request for a team and bjoerge October 23, 2026 09:42
Base automatically changed from cursor/hierarchical-document-list-sortable-tree-5-0-315b to main October 23, 2026 10:23
pedrobonamin added a commit that referenced this pull request Oct 23, 2026
… in the tree (#2246)

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
First of three stacked PRs:

1. **This PR:** pin `@nosferatu500/react-sortable-tree` to 5.0.0 and fix
same-level moves.
2. #2251: a Playwright suite covering reordering, nesting, un-nesting
and moving a whole subtree.
3. #2253: upgrade to 7.1.0, checked by that suite.

## Summary


https://github.com/user-attachments/assets/d5bee535-58cc-4fd9-a93d-feadfe6cc0a4


Two separate bugs broke drag-and-drop in the tree.

**Nesting saved the item at the top level** (commit 1). Renovate moved
the plugin from `^5.0.0` to `^5.1.0` in #1881, and 5.1.0 has a
regression in `insertNode`. Its recursive helper spreads `...params`,
which carries `isPseudoRoot: true` into every nested level, so
`onMoveNode` always receives `nextParentNode: null`. 5.0.0 passes
explicit arguments, and 7.1.0 fixes it with `isPseudoRoot: false`. This
pins the dependency to exactly `5.0.0`. The lockfile change is
hand-edited to just the library and its `virtua` dependency (0.50.6 →
0.48.8, only used by this library), because a regular install
re-resolves the Studio `next` overrides. `pnpm install
--frozen-lockfile` accepts it, including the supply-chain checks.

**Moving an item up or down within its level snapped it back** (commit
2). This bug isn't version-specific. Since 9113861, `getNodeKey`
returns the row's `_key`, so tree paths are made of keys rather than
positions. `canDrop` rejected a drop when the new path started with the
old one, which is always true for a move within the same level
(`['charlie']` before and after). It now only rejects drops whose new
parents include the dragged row itself.

This supersedes #2245, which worked around the missing parent but left
same-level moves broken.

## Testing

#2251 adds a Playwright suite covering moving an item up and down,
nesting, un-nesting and moving an item with its children. It passes on
this branch in Chromium and Firefox. With `main`'s code (5.1.0 and the
old `canDrop`), all five scenarios fail in Chromium. `pnpm build`, `pnpm
lint`, `pnpm knip` and the plugin's Vitest project pass.
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-010edcd6-3b41-43cc-a8a6-2b950822315b?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-010edcd6-3b41-43cc-a8a6-2b950822315b&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Dependency pin and lockfile-only transitive changes; restores prior
nesting behavior without touching plugin application logic.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ae56fa1. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
@pedrobonamin
pedrobonamin force-pushed the cursor/hierarchical-document-list-e2e-315b branch from 326b58a to 83c4295 Compare October 23, 2026 10:23
@cursor
cursor Bot force-pushed the cursor/hierarchical-document-list-e2e-315b branch from 83c4295 to 6282206 Compare October 26, 2026 15:36
…wright

Co-authored-by: Pedro Bonamin <pedrobonamin@users.noreply.github.com>
@pedrobonamin
pedrobonamin merged commit 6f2c9a1 into main Nov 2, 2026
25 checks passed
@pedrobonamin
pedrobonamin deleted the cursor/hierarchical-document-list-e2e-315b branch November 2, 2026 15:56

This branch was successfully deployed

1 active deployment
Preview – plugins-studio — dc42312e Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ ai PR authored by an AI agent (🤖 bot is for CI automation/Renovate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants