Change Detection: Add a test case for post trashing.#18290
Merged
Conversation
5 tasks
aduth
reviewed
Nov 5, 2019
Member
aduth
left a comment
There was a problem hiding this comment.
There's a (likely related) end-to-end test failure:
FAIL packages/e2e-tests/specs/editor/various/change-detection.test.js (60.563s)
● Change detection › should not prompt to confirm unsaved changes when trashing an existing post
expect(jest.fn()).not.toHaveErrored(expected)
Expected mock function not to be called but it was called with:
["Failed to load resource: the server responded with a status of 500 (Internal Server Error)"]
at Object.expect (../jest-console/build/@wordpress/jest-console/src/index.js:34:4)
at runMicrotasks (<anonymous>)
| await page.waitForSelector( '.editor-post-saved-state.is-saved' ); | ||
|
|
||
| // Check that the dialog didn't show. | ||
| await assertIsDirty( false ); |
Member
There was a problem hiding this comment.
From your comment at #18275 (comment) :
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,
assertIsDirtywouldn't assertfalse.
But the 'dialog' event handler isn't added until assertIsDirty is called, so if the dialog was already present by the time we reach this line, the event callback would never be triggered.
Contributor
Author
There was a problem hiding this comment.
True! I missed that.
Contributor
Author
|
Fixed! |
aduth
reviewed
Nov 6, 2019
packages/e2e-tests/specs/editor/various/change-detection.test.js
Outdated
Show resolved
Hide resolved
packages/e2e-tests/specs/editor/various/change-detection.test.js
Outdated
Show resolved
Hide resolved
Co-Authored-By: Andrew Duthie <andrew@andrewduthie.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follows #18275
Description
This PR fixes and reintroduces the test case from #18275.
It also replaces some ad-hoc saving code with the correct e2e test util,
saveDraft.How has this been tested?
The new tests were verified to test for the issue fixed in #18275.
Checklist: