-
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
Core Data: Fix redo behavior and expand test coverage. #17827
Conversation
await clickBlockAppender(); | ||
|
||
await page.keyboard.type( 'This' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'is' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( 'test' ); | ||
await new Promise( ( resolve ) => setTimeout( resolve, 1000 ) ); |
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.
Why is this timeout added? Can't we add a separate test case with the timeout? Are we still testing without the timeout if we add it here?
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.
The test fail when this is removed, which is curious. This line shouldn't be necessary for it to pass.
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.
We need it to make sure the timeout after typing for the undo level creation fires.
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.
Hm, this shouldn't be necessary. You should be able to undo and redo without waiting a second.
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.
How does the last level get created otherwise? It's implemented with a timeout.
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.
Sure, but when you undo, and there is content in the undo buffer, the buffer should be undone first, then the undo level. Does that make sense?
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.
Yes, but that's not how it currently works. I'll add that.
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.
This is something that was previously tested with withHistory
unit tests. Do you think it's possible to add unit tests for this new reducer?
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.
Yes
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 adjusted the test a bit so it also tests if the content is the same. It's still weird that the timeout at the start is needed now, but let's try to resolve that in a separate PR. This is already a vast improvement. |
We should bring back the snapshots I added. If we only compare the content against itself like that, we are not actually testing that the levels are being created at the right places, just that the total number of levels is correct. The snapshots actually tested that |
It doesn't just test the total number of levels? It compares the content to make sure it's restored correctly. We take snapshots during the creation of the content and compare it to the content produced after undoing and redoing changes. |
Yes, exactly, but it doesn't care about what that content is, so you're just testing the number of levels of content. |
That's not just testing the number of levels? We don't care what the content is, we only care that the content is correctly undone and redone. |
With the snapshots we also test that |
So not just the number. 😉 It also tests that the state is equal to the one before any redo or undo actions occurred. We are saving the content while it's being created: gutenberg/packages/e2e-tests/specs/undo.test.js Lines 60 to 80 in 42167a2
|
Yes, but that code won't detect if the behavior regresses from something like:
to
|
It would? It would not be the same as the content first created. |
They would be the same, |
Huh, we are not just comparing the amount of levels...
We are verifying if the content is the correct after undo/redo. If levels would be created in the wrong place, these checks would fail. |
To me this is much clearer than snapshots, as we are explicitly comparing the initially created text with the changes after undo/redo. |
Oh because the levels are created right after every |
* Core Data: Fix redo behavior and expand test coverage. * e2e test: compare text content instead of matching snapshots
Fixes #17825
Description
This PR fixes an issue where explicit undo level creation was being ignored when the last recorded edit had no non-transient edits, i.e. not the
blocks
property. These explicit undo level actions were also creating an extra undo level, because of some conflicting logic with regular edit actions. This PR also fixes that.How has this been tested?
E2E tests were expanded to verify that undoing and redoing creates and uses undo levels correctly.
Types of Changes
Bug Fix: Fix redo levels inconsistencies.
Checklist: