-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block Editor: Unmount after each MediaReplaceFlow
test
#45736
Closed
+20
−4
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For any test that's async, and contains
await
statements, typicallyuser-event
calls likeawait user.click()
, this is unsound. The tests are green only because the test function starts winning a microtask race with thefloating-ui
'scomputePosition
.The popover is opened by the very first click in the test, on the "Replace" button. Then there are four more
await
s before theunmount()
. Originally, theunmount()
would be done only a few microtasks later, insideafterEach
. Now it happens a few microtask earlier.Meanwhile, the "Replace" button triggered another async function with many
await
statements, the popover'scomputePosition()
. If it starts winning the race again, the test will start failing.One way how this fixed test can be made to fail again is to simply replace fake timers with real ones. Then every
await.click
will internally do asetTimeout( 0 )
, and that guarantees that thecomputePosition
task, which doesn't do any timeouts, just microtasks, will always win and fail the test.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.
I understand your point, but this is likely true for many other tests. I believe we could make a compromise and go ahead to ship this, unblocking the upgrade.
Perhaps we could add a comment that it needs a follow-up and properly better cleanup in the component itself? From what you explained, it seems like it's an issue that actually spreads beyond the test itself.
WDYT?
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.
You can merge the PR and postpone the problem to be solved later, but I think it's suboptimal.
MediaReplaceFlow
could be a great opportunity to re-introduce the.toBePositioned()
helper created in #45587. Clicking on the "Replace" button actually shows a popover and we're actively working with it:The tests would then be like:
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.
Fair enough, @jsnajdr. I decided to go for it and crafted an alternative solution here: #45863. Please, take a look when you have a chance.