-
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
Editor: Fix move to trash redirect save race conditions. #18275
Changes from 3 commits
22475bb
4d58c79
9b7ff56
3344ad7
fb86309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import { | |
pressKeyWithModifier, | ||
ensureSidebarOpened, | ||
publishPost, | ||
openDocumentSettingsSidebar, | ||
} from '@wordpress/e2e-test-utils'; | ||
|
||
describe( 'Change detection', () => { | ||
|
@@ -348,4 +349,25 @@ describe( 'Change detection', () => { | |
// Verify that the post is not dirty. | ||
await assertIsDirty( false ); | ||
} ); | ||
|
||
it( 'should not prompt to confirm unsaved changes when trashing an existing post', async () => { | ||
// Enter title. | ||
await page.type( '.editor-post-title__input', 'Hello World' ); | ||
|
||
// Save | ||
await Promise.all( [ | ||
// Wait for "Saved" to confirm save complete. | ||
page.waitForSelector( '.editor-post-saved-state.is-saved' ), | ||
|
||
// Keyboard shortcut Ctrl+S save. | ||
pressKeyWithModifier( 'primary', 'S' ), | ||
] ); | ||
|
||
// Trash post. | ||
await openDocumentSettingsSidebar(); | ||
await page.click( '.editor-post-trash.components-button' ); | ||
|
||
// Check that the dialog didn't show. | ||
await assertIsDirty( false ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works because refreshing a page with a dialog doesn't get rid of the dialog. So if navigation didn't happen because the dialog stopped it, |
||
} ); | ||
} ); |
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.
Aside: There's a helper for this
saveDraft
. The file as a whole could do for some refactoring to use it.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, good catch.