Skip to content

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

Closed
WunderBart wants to merge 1 commit intotrunkfrom
refactor/e2e-wp-api-waiter
Closed

E2E Utils: Wait for canvas instead of window.wp#58318
WunderBart wants to merge 1 commit intotrunkfrom
refactor/e2e-wp-api-waiter

Conversation

@WunderBart
Copy link
Copy Markdown
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 [Tool] E2E Test Utils /packages/e2e-test-utils label Jan 26, 2024
@github-actions
Copy link
Copy Markdown

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
Copy Markdown
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. 😅

@WunderBart WunderBart closed this May 14, 2024
@WunderBart WunderBart deleted the refactor/e2e-wp-api-waiter branch May 14, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Tool] E2E Test Utils /packages/e2e-test-utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant