-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List View: Add tests for some of the drag and drop logic #49631
Conversation
rootClientId: '', | ||
}, | ||
{ | ||
blockIndex: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this is intentionally blockIndex: 0
because it is at the zero position within its container block.
Size Change: 0 B Total Size: 1.35 MB ℹ️ View Unchanged
|
Flaky tests detected in 33b3614. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4626268394
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing! |
What?
Add tests for some of the list view logic for drag and drop. In particular, the added tests are for the logic in
getListViewDropTarget
which determines whether to drop above or below the target block, or inside that block.Why?
I'm currently exploring some ideas surrounding how to drag to a parent level within the list view, and I noticed that I'm hacking around with this function. Before going too much further with that hacking around (being explored over in #49498), I thought I'd have a go at writing a few tests for the current behaviour, to make sure that I don't accidentally break anything.
Note: these tests are arguably testing implementation details — I've tried to keep them as simple as I can, but I'm aware they might not be very easy to read given the structure of the objects. On balance, given that it's hard to write tests for drag and drop behaviour, I think the additions will be helpful, but happy for feedback on this!
How?
getListViewDropTarget
isExpanded
toWPListViewDropZoneBlocks
, which I forget to do back in List View: Allow dragging underneath collapsed non-empty container blocks #49390Testing Instructions
Check that tests pass, or to test locally, run: