[@wordpress/e2e-test-utils-playwright] Add openPostInEditor function
#51333
+32
−0
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.
What?
Adds an
openPostInEditorfunction to theAdminclass. This function will search for (by title), then open the specified page in the editor.Why?
When testing, people may set up their test env with pre-published pages containing blocks they wish to test. The tests may need to open these pages to update block-specific settings to test different code paths.
It is not guaranteed that the IDs of the specific pages will be the same across runs, so it makes sense to be able to open the page by name, like a user would.
How?
It opens the admin page for the specified post type and searches for the specified post name. When the search is complete, it finds the link to edit the post and then clicks it. When the network is idle the function returns.
Testing Instructions
Set up
wp-env.Add a new test file,
test/e2e/specs/editor/various/open-in-editor.spec.jsand add the following code:Run
npm run test:e2e:playwright -- open-in-editorand ensure the test passes.Note: If you run this multiple times it will fail because the pages will be duplicated, so be sure to clear them between runs!
Open a test file, for example:
Testing Instructions for Keyboard
This PR does not affect the UI.