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

Update Playwright to 1.44.1 from 1.41.1 #48291

Merged
merged 18 commits into from
Jun 11, 2024
Merged

Conversation

lanej0
Copy link
Contributor

@lanej0 lanej0 commented Jun 7, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

We had fallen a bit behind in Playwright in the monorepo, mostly because Playwright introduced this breaking change a few versions back. This PR updates Playwright to the latest release and refactors some shopper/merchant tests in core so that they're compatible with the latest version.

Also updates the Blocks e2e tests to the latest version (ran tests, and no apparent issues with new version of Playwright)

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

  1. Ensure CI passes for both Core and Blocks e2e tests
  2. pnpm env:restart && pnpm test:e2e-pw (for core tests). Will probably be prompted to install updated browsers first.
  3. pnpm env:restart && pnpm test:e2e (for blocks tests)

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

@github-actions github-actions bot added focus: e2e tests Issues related to e2e tests focus: monorepo infrastructure Issues and PRs related to monorepo tooling. plugin: woocommerce Issues related to the WooCommerce Core plugin. labels Jun 7, 2024
@woocommercebot woocommercebot requested a review from a team June 7, 2024 18:17
Copy link
Contributor

github-actions bot commented Jun 7, 2024

Hi @WunderBart, @gigitux, @woocommerce/vortex

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

@lanej0 lanej0 requested review from WunderBart and gigitux June 7, 2024 18:18
Copy link
Contributor

github-actions bot commented Jun 7, 2024

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

Copy link
Contributor

github-actions bot commented Jun 7, 2024

Size Change: +10 B (0%)

Total Size: 2.47 MB

compressed-size-action

@lanej0
Copy link
Contributor Author

lanej0 commented Jun 7, 2024

@WunderBart @gigitux -- I'd like to update Playwright to the latest version in the Monorepo (we're about 3 versions old currently). Looks like everything is okay, except there's one Blocks Playwright test that seems to have turned flaky with this PR.

Releasing the `page.goto` before the `load` event (default) doesn't really speed up the tests because we still need to wait for the locator that we're going to interact with. Furthermore, it can destabilize the test because the said locator timer starts earlier than it normally would (after page "load"), so it might timeout in a situation when a page takes longer to load than usually.
@WunderBart WunderBart force-pushed the dev/update-playwright-1_44_1 branch from 8877a70 to 1d627f3 Compare June 10, 2024 10:29
Comment on lines +20 to +24
// The mini cart button scripts are loaded when the button is either
// hovered or focused. The click event alone does not trigger neither of
// those actions so we need to perform one explicitly.
await miniCartButton.hover();
await miniCartButton.click();
Copy link
Contributor

@WunderBart WunderBart Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix the failing mini cart tests. Those tests failed because the cart scripts aren't loaded until the cart button is explicitly either hovered or focused. This is an implementation detail and, ideally, it should not be necessary to account for it in the test. However, it is weird that the Playwright's physical click event does not seem to lead with hover, as it's only possible to click with hovering first. I'll try to investigate whether it's a bug or an intentional change with the newer release.

cc: @Aljullu, since you last worked on mini cart frontend scripts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, @WunderBart! It makes sense to me. 👍

Copy link
Contributor

@WunderBart WunderBart Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've investigated it a bit further, and the issue seems to be that the mini cart button scripts (loaded lazily on button hover) aren't hydrating the button element — they remove it and replace it with a new one. This means there's no continuity in the click handler, which should be enough to load the scripts lazy and open the mini cart drawer. A workaround could be re-querying the button, for which I put together a PoC here: #48330.

In general, the current implementation should not be an issue with fast machines/connection, but it can cause further flakiness due to the disconnection between the button being ready to be clicked and the actual click happening. Let me know if it makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've investigated it a bit further, and the issue seems to be that the mini cart button scripts (loaded lazily on button hover) aren't hydrating the button element — they remove it and replace it with a new one. This means there's no continuity in the click handler, which should be enough to load the scripts lazy and open the mini cart drawer.

Right, good catch! I didn't think that was the reason of the issue, but it makes total sense. 💯

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the issue is clear, but let me share these awesome diagrams I created by explaining the issue to GPT and asking for a mermaid output. 😅 TIL that it works that well! 💪

Successful scenario

sequenceDiagram
    participant User
    participant CartButton
    participant Scripts

    User->>CartButton: Hover
    CartButton->>Scripts: Trigger lazy load
    Scripts-->>CartButton: Scripts loaded

    User->>CartButton: Click
    CartButton->>Scripts: Open cart drawer
    Scripts-->>User: Cart drawer opened
Loading

Failure scenario

sequenceDiagram
    participant User
    participant CartButton
    participant Scripts

    User->>CartButton: Hover
    CartButton->>Scripts: Trigger lazy load

    User->>CartButton: Click
    CartButton->>User: No action

    Scripts-->>CartButton: Scripts loaded
Loading

@lanej0
Copy link
Contributor Author

lanej0 commented Jun 10, 2024

Not sure why the JS Unit tests are having issues. Seems to be different ones, so maybe just flaky?

@WunderBart
Copy link
Contributor

Not sure why the JS Unit tests are having issues. Seems to be different ones, so maybe just flaky?

Looks like pnpm 9.1.4 is breaking @wordpress/data dependency. The solution seems to be downgrading to 9.1.3 (see p1717495487961929/1717436616.890969-slack-C03CPM3UXDJ)

@adimoldovan
Copy link
Contributor

🤔 I wonder if the lint errors in @woocommerce/block-library are caused by #48234

@adimoldovan
Copy link
Contributor

I wonder if the lint errors in @woocommerce/block-library are caused by #48234

It looks like it. I reverted that change with 8186094

Copy link
Contributor

@adimoldovan adimoldovan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you @lanej0 for this much needed update.

@adimoldovan adimoldovan merged commit e5e51a4 into trunk Jun 11, 2024
96 checks passed
@adimoldovan adimoldovan deleted the dev/update-playwright-1_44_1 branch June 11, 2024 18:52
@github-actions github-actions bot added this to the 9.1.0 milestone Jun 11, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jun 11, 2024
@Stojdza Stojdza added status: analysis complete Indicates if a PR has been analysed by Solaris and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Jun 12, 2024
thealexandrelara pushed a commit that referenced this pull request Jul 18, 2024
Co-authored-by: Jon Lane <jon.lane@automattic.com>
Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
Co-authored-by: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: e2e tests Issues related to e2e tests focus: monorepo infrastructure Issues and PRs related to monorepo tooling. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants