Skip to content
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

E2E Utils: Wait for canvas instead of window.wp #58318

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

WunderBart
Copy link
Member

What?

In testing against a slower env (wp.com in my case) it turned out that the window.wp.* is ready before the canvas is, so calling utils like insertBlock immediately after creating a post has no effect. Waiting for the canvas instead gives stable results and makes the affected utils work as expected.

Why?

For stability.

Testing Instructions

Nothing particular. All the tests should pass.

@WunderBart WunderBart self-assigned this Jan 26, 2024
@WunderBart WunderBart added the [Package] E2E Test Utils /packages/e2e-test-utils label Jan 26, 2024
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: [Package] E2E Test Utils.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@WunderBart WunderBart marked this pull request as ready for review January 26, 2024 15:21
@WunderBart WunderBart marked this pull request as draft January 26, 2024 15:48
@WunderBart
Copy link
Member Author

WunderBart commented Feb 1, 2024

This one's breaking because the editor.canvas locator does not automatically switch when tests switch to legacy canvas. I know this was discussed before, but maybe some new ideas have come up since? @kevin940726 @Mamaduka

I've refreshed my research, and it still doesn't seem to be supported natively by Playwright, as the locator.or cannot be mixed with a frame locator, e.g.

canvas() {
  return this.page.locator('.canvas').or(
    this.page.frameLocator('canvas-iframe').locator('.canvas')
  );
}

The only way that would work would be making the canvas getter async, which would break almost all the tests as it would need to be awaited. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Test Utils /packages/e2e-test-utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant