Refactor block drop event handlers into a single hook to support drag and drop in List View#24649
Conversation
|
Size Change: +525 B (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
tellthemachines
left a comment
There was a problem hiding this comment.
Tested with blocks and files and it works well in the editor; not sure how to test an HTML drop though.
| ); | ||
| } ); | ||
|
|
||
| it( 'adjusts the index blocks are dropped at when moved down under the same root block', () => { |
There was a problem hiding this comment.
Hmm, is this too much of an implementation detail to be worth testing?
There was a problem hiding this comment.
e2e tests would definitely be better here, but there aren't any at the moment and they'd take a bit of investment.
This particular code has been buggy before (#24183), so a test seems beneficial.
| } ); | ||
|
|
||
| it( 'does nothing if the block has no matching file transforms', () => { | ||
| findTransform.mockImplementation( () => {} ); |
There was a problem hiding this comment.
Why do we need to mock findTransform again here? And could we use noop defined at the top of the file?
There was a problem hiding this comment.
Hmm, I suppose not strictly required since jest.fn() also returns nothing, though I feel like having this line helps demonstrate that it's performing the inverse of the following test.
I switched it over to use noop and also added some comments.
@tellthemachines The easiest test I've found is to drag a link from another website. I'll update the testing instructions. |
tellthemachines
left a comment
There was a problem hiding this comment.
Re-tested, HTML drop is working fine!
Description
Separated from #23952.
Moves the code for handling block drop events into a separate react hook. This is required for #23952, as it'll allow List View to use the same drop event logic.
How has this been tested?
Types of changes
Non-breaking refactor.
Checklist: