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

Add Playwright infrastructure for E2E tests #2733

Merged
merged 7 commits into from
Sep 6, 2024

Conversation

acicovic
Copy link
Collaborator

@acicovic acicovic commented Aug 26, 2024

Description

Per #1927, we're migrating our E2E tests to Playwright. This PR introduces the basis for this work, by adding the essentials to operate with Playwright. It adds:

  • The required packages.
  • A base configuration file, which doesn't currently differ from WordPress defaults. We can probably delete it if we don't need any overrides.
  • An untested GitHub workflow, so Playwright E2E tests can run as checks in PRs. It will need to be tested and finalized, though we might need to merge it as-is before refining it.
  • A migrated E2E test (passing locally and located in a default directory, outside our current tests), to validate that things work.

To run our tests with Playwright, we're introducing these 2 new commands:

  • npm run test:e2e:playwright: Runs Playwright E2E tests.
  • npm run test:e2e:playwright:debug: Runs Playwright E2E tests in debug mode.

The original E2E test commands have been left untouched, so we can run the existing tests along the new Playwright ones. The commands will be updated and finalized once all the ests have been migrated.

Motivation and context

Begin the work on #1927.

How has this been tested?

  • The migrated test passes locally, and is to be tested on GitHub.
  • The GitHub workflow is pending testing, to verify that it works or follow-up with fixes.

Summary by CodeRabbit

  • New Features

    • Introduced an end-to-end testing workflow using Playwright for the WordPress application.
    • Added a new configuration file for Playwright testing, ensuring compatibility with WordPress.
    • Created a test suite for verifying the action link functionality of a WordPress plugin.
  • Improvements

    • Enhanced test execution control by refining the scope of tests run with Jest and Playwright.
    • Added new scripts for running and debugging Playwright tests, improving testing capabilities.
    • Updated the testing workflow to utilize the latest versions of Node.js and Ubuntu for better performance.

@acicovic acicovic added this to the 3.17.0 milestone Aug 26, 2024
@acicovic acicovic self-assigned this Aug 26, 2024
Copy link
Contributor

coderabbitai bot commented Aug 26, 2024

Walkthrough

Walkthrough

A new end-to-end testing workflow using Playwright has been introduced for a WordPress application, along with updates to existing configuration files. The workflow includes changes to the .github/workflows/e2e-tests.yml for improved environment specifications and additional steps. The jest-e2e.config.js file now includes refined test matching, while package.json reflects new dependencies and scripts. A Playwright configuration file and an initial test for a plugin's action link functionality have also been added.

Changes

File Change Summary
.github/workflows/e2e-tests-playwright.yml, .github/workflows/e2e-tests.yml Introduced a new end-to-end testing workflow using Playwright with updated naming, environment specifications, and additional steps for setting up and running tests.
jest-e2e.config.js Added testMatch property to specify test file patterns, preventing Playwright tests from running with Jest tests, and retained increased testTimeout of 35,000 ms.
package.json Added dependencies for Playwright and WordPress testing utilities, along with new scripts for running and debugging Playwright tests.
test/e2e/playwright.config.ts Created a new Playwright configuration file merging base settings from WordPress scripts, allowing for customization of the testing environment.
test/e2e/specs/plugin-action-link.spec.ts Introduced a new test file for validating the action link functionality of a WordPress plugin, verifying navigation to the settings page.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@acicovic
Copy link
Collaborator Author

The GitHub workflow worked immediately, but the migrated test was failing due to an oversight. Also, Jest was trying to run the Playwright test, which didn't work well 😄

All these are now fixed, so opening the PR for review.

@acicovic acicovic marked this pull request as ready for review August 26, 2024 16:05
@acicovic acicovic requested a review from a team as a code owner August 26, 2024 16:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2bfe980 and 8e5420f.

Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
Files selected for processing (5)
  • .github/workflows/e2e-tests-playwright.yml (1 hunks)
  • jest-e2e.config.js (1 hunks)
  • package.json (3 hunks)
  • test/e2e/playwright.config.ts (1 hunks)
  • test/e2e/specs/plugin-action-link.spec.ts (1 hunks)
Additional context used
Path-based instructions (3)
jest-e2e.config.js (1)

Pattern **/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
test/e2e/playwright.config.ts (1)

Pattern **/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
test/e2e/specs/plugin-action-link.spec.ts (1)

Pattern **/*.{js,ts,tsx,jsx}: "Perform a detailed review of the provided code with following key aspects in mind:

  • Review the code to ensure it is well-structured and adheres to best practices.
  • Verify compliance with WordPress coding standards.
  • Ensure the code is well-documented.
  • Check for security vulnerabilities and confirm the code is secure.
  • Optimize the code for performance, removing any unnecessary elements.
  • Validate JSDoc comments for accuracy, currency, and adherence to WordPress coding standards.
  • Ensure each line comment concludes with a period.
  • Confirm every JSDoc comment includes a @SInCE tag indicating the next version of the plugin to include the code.
  • Guarantee compatibility with the latest version of WordPress, avoiding deprecated functions or features."
Additional comments not posted (8)
jest-e2e.config.js (1)

6-7: LGTM!

The addition of the testMatch property and the increase in testTimeout are appropriate and align with the PR objectives.

The code changes are approved.

test/e2e/playwright.config.ts (1)

1-16: LGTM!

The Playwright configuration is correctly set up and extends the base configuration from WordPress scripts.

The code changes are approved.

test/e2e/specs/plugin-action-link.spec.ts (1)

1-15: LGTM!

The Playwright test for the plugin action link is well-structured and follows best practices.

The code changes are approved.

.github/workflows/e2e-tests-playwright.yml (3)

1-8: LGTM!

The workflow name and trigger events are correctly defined.

The code changes are approved.


10-16: LGTM!

The concurrency settings are correctly defined to avoid redundant runs.

The code changes are approved.


17-62: LGTM!

The job definition and environment setup are comprehensive and correctly defined.

The code changes are approved.

package.json (2)

Line range hint 46-67: LGTM!

The new dependencies @playwright/test and @wordpress/e2e-test-utils-playwright are correctly added for Playwright E2E testing.

The code changes are approved.


106-108: LGTM!

The new scripts test:e2e:playwright and test:e2e:playwright:debug are correctly added for running and debugging Playwright E2E tests.

The code changes are approved.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8e5420f and a35e696.

Files selected for processing (1)
  • .github/workflows/e2e-tests.yml (3 hunks)
Additional comments not posted (6)
.github/workflows/e2e-tests.yml (6)

1-1: Workflow name update.

The workflow name has been simplified for clarity. This change is appropriate.


19-20: Update to Ubuntu 24.04.

The workflow now runs on ubuntu-24.04 instead of ubuntu-20.04. Ensure that all dependencies and tools are compatible with this version.

Verify compatibility of all dependencies and tools with ubuntu-24.04.


32-33: Update to Node.js 18.

The Node.js version has been updated from 16 to 18. Ensure that all Node.js dependencies are compatible with this version.

Verify compatibility of all Node.js dependencies with version 18.


39-41: Install Playwright dependencies.

A new step to install Playwright dependencies has been added. This is necessary for running Playwright tests.


47-49: Rename step for running E2E tests.

The step name has been changed to "Running E2E tests" for clarity. This change is appropriate.


52-56: Add step for running Playwright E2E tests.

A new step to run Playwright E2E tests has been added. Ensure that the Playwright tests are correctly configured and run as expected.

Verify that the Playwright tests are correctly configured and run as expected.

@acicovic
Copy link
Collaborator Author

In the latest update, I've merged the two E2E workflow files into one, which should save some time. I've also updated the tooling (e.g. we now use React 18 instead of 16, and Ubuntu 24 instead of 20).

After the changes, the tests continue to pass fine.

@acicovic acicovic modified the milestones: 3.17.0, Summer 2024 Sep 5, 2024
@acicovic acicovic merged commit 394e62e into develop Sep 6, 2024
36 checks passed
@acicovic acicovic deleted the add/playwright-infrastructure branch September 6, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant