Skip to content

Local e2e tests createNewPost() not waiting for the page to be fully loaded #51933

@jeryj

Description

@jeryj

Description

When running the e2e tests locally, I often have to set a breakpoint or await page.pause() immediately after the createNewPost(). Otherwise, the test will fail since it's trying to do things to the page (typing, inserting blocks, etc) before the editor is ready for it to be doing those steps. I had thought it was only happening to me, but @scruffian and I paired and I can see the same issue happening on his setup.

So, I think we need to add some kind of "page ready" for createNewPost. A lot of the tests seem to start with the expectation that the title is focused, so one potential would be adding an await for the post title to be focused.

Step-by-step reproduction instructions

  1. Pick an e2e test that relies on createNewPost() and run it locally, such as npm run test:e2e:playwright -- -g "can be created by selecting text and using keyboard shortcuts".
  2. The test will fail at the first assertion or element being missing, as it will do all the things in the test like typing and inserting blocks until it has to do something it can't locate. For example, if you create a post and start typing, it'll allow typing, but what you're typing won't appear on the page. What you're typing will only appear on the page once the editor is fully loaded. We need to wait until the page is fully loaded and the editor is ready before continuing with the test.
  3. Add await page.pause() after the createNewPost().
  4. Run the same test again
  5. When you see the debugger popover, press Play to continue the test past the breakpoint.
  6. The test will pass since you allowed time for the editor to be fully loaded.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions