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

2 Problems with setup() method in the RequestUtils class of @wordpress/e2e-test-utils-playwright #53277

Open
kopepasah opened this issue Aug 2, 2023 · 2 comments
Labels
Needs Testing Needs further testing to be confirmed. [Package] E2E Test Utils /packages/e2e-test-utils [Type] Bug An existing feature does not function as intended

Comments

@kopepasah
Copy link
Member

Description

While I know @wordpress/e2e-test-utils-playwright is under active development, when working with the package it was expected that I could use RequestUtils.setup() to make WP REST API requests; however, I am experiencing two different issues when trying to use this setup method:

Issue 1: Unable to pass custom baseURL

I am unable to change the baseURL by passing a custom url within the RequestUtils.setup( { baseUrl: 'http://example.com' } ). This could be expected behavior, because I can pass the WP_BASE_URL as an environment variable (i.e. WP_BASE_URL=http://example.com npx playwright test), but it seems that this parameter should be overwritten within the setup() method.

You can see an example of this problem within custom-baseURL branch of this repo: https://github.com/kopepasah/wp-playwright-request-utils-test/tree/custom-baseURL

Issue 2: Multiple requests causes random failures

When running requests using RequestUtils.setup() and npx playwright test, I cannot make multiple requests, as one of the two requests will always fail (which one is random). You can see and an example of this problem in the multiple-requests branch of this repo: https://github.com/kopepasah/wp-playwright-request-utils-test/tree/multiple-requests

Now, I can see that the Gutenberg e2e tests are setting up their own requestContext in Playwright, but it seems odd that the RequestUtils class does not perform that setup automatically, as it is expected that RequestUtils.setup() will handle this here. I have not tried the newContext in Playwright (like the Gutenberg e2e tests) way yet, because I was hoping this setup will be handled by the RequestUtils class.


Thanks for taking a look, and all help is appreciated!

Step-by-step reproduction instructions

Please visit this repo for reproducing these issues: https://github.com/kopepasah/wp-playwright-request-utils-test/

This repo is a blank plugin, which installs the lates WordPress using @wordpress/env. In addition, it installs and sets up @playwright/test and @wordpress/e2e-test-utils-playwright for testing.

Screenshots, screen recording, code snippet

No response

Environment info

"@playwright/test": "^1.36.2",
"@wordpress/e2e-test-utils-playwright": "^0.6.0"

Regarding this issue, the WordPress and Gutenberg versions are not relevant, and all other code is default WordPress.

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

@kopepasah kopepasah added the [Package] E2E Test Utils /packages/e2e-test-utils label Aug 2, 2023
@jordesign jordesign added [Type] Bug An existing feature does not function as intended Needs Testing Needs further testing to be confirmed. labels Aug 3, 2023
@kou029w
Copy link

kou029w commented Sep 1, 2023

Issue 1: Unable to pass custom baseURL

It appears to me that perhaps rewriting this line as follows should solve the problem:

const response = await request.head( WP_BASE_URL );

	const response = await request.head( '' );

But I did not know if this method was good or not.

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Hi,
This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Oct 2, 2023
@jordesign jordesign removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed. [Package] E2E Test Utils /packages/e2e-test-utils [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants