-
Notifications
You must be signed in to change notification settings - Fork 219
Update @wordpress/env to 8.1.1 and re-enable PHP Unit Tests for PHP v 8.1 and 8.2 #9875
Conversation
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
🎉 🎉 This PR does not introduce new TS errors. |
Size Change: 0 B Total Size: 1.44 MB ℹ️ View Unchanged
|
…er wp-env version
Changes: 1. Removed unnecessary backslash escaping of double quotes within command arguments. For instance, changed `--post_content=\"$post_content\"` to `--post_content="$post_content"`. 2. Fixed the inconsistency in the command pattern by removing quotes around command arguments, e.g., changed `"wp option update woocommerce_myaccount_page_id $post_id"` to `wp option update woocommerce_myaccount_page_id $post_id`. 3. Simplified the escaping of double quotes within JSON strings. For example, changed `\"enabled\":\"yes\"` to `"enabled":"yes"`. This refactor improves the script's readability without affecting its functionality.
The changes primarily involve: 1. Removed escaping quotes when reading the post contents from text files. The script now directly reads the file content without using `sed` to escape double quotes. 2. Changed the format of `wp-env run` command, moving `--` before `wp`.
Update: I have addressed the failing E2E tests in PR #10031 and made the necessary fixes. Once that PR is merged, we can mark this PR as "Ready for review." |
* Fix e2e tests for price filter This commit makes two primary changes: 1. Update the Playwright configuration to capture full-page screenshots on test failures. This change will help in better debugging of failed tests by providing a full context of the application state at the time of the failure. 2. Refactor the end-to-end tests for the price filter feature of the WooCommerce Blocks plugin. The refactoring includes: - Introduction of a new `PriceFilterPage` class which encapsulates the logic for interacting with the price filter within the tests. This change improves the structure of the tests and makes them easier to understand. - The tests have been restructured to use this new class, resulting in a significant reduction in the amount of boilerplate code in the tests. - Removal of unused code and imports from the tests. * Refactor price filter tests for clarity and remove unused utility file Key changes: 1. Variable `img` was renamed to `firstProductImage` to improve clarity. 2. The method `setPrice` was renamed to `setPriceFilterRange` to better reflect its purpose. 3. Removed the function `urlSearchParamWhenFilterIsApplied` from the `blockData` object, as it was relocated to a private method inside the `PriceFilterPage` class named `generatePriceFilterQueryString`. 4. Replaced hardcoded strings 'woocommerce/filter-wrapper' and 'woocommerce/all-products' with constants WOOCOMMERCE_FILTER_WRAPPER and WOOCOMMERCE_ALL_PRODUCTS, respectively. 5. The `getAllProducts` method in `PriceFilterPage` class was renamed to `locateAllProducts` to reflect the actual operation it's performing. 6. The utility file `utils.ts` was deleted as it was no longer in use. These changes make the test scripts more readable and maintainable, removing unnecessary code and improving method names for better understanding of their functionality. * Upgrade @playwright/test package Upgrade `@playwright/test` package from version `1.32.3` to `1.35.1`. * Change playwright version to fixed version * Fix failing tests * Wait for 1 second * Refactor e2e tests for price filter and remove unnecessary timeouts This commit performs a series of changes to the end-to-end tests related to the price filter: 1. Refactored the price filter e2e tests by splitting the `price-filter.block_theme.side_effects.spec.ts` test into two separate tests: `price-filter-with-all-products.block_theme.side_effects.spec.ts` and `price-filter-with-classic-template.block_theme.side_effects.spec.ts`. This provides better organization and clarity for these tests, and enables us to focus more closely on each distinct context in isolation. 2. Deleted the old `price-filter.block_theme.side_effects.spec.ts` test as its responsibilities have been taken over by the new tests. 3. Removed unnecessary `await page.waitForTimeout( 1000 );` lines from the classic-template block theme test and the products block theme test. This reduces the overall time taken to run these tests and eliminates a potential source of flakiness. 4. Made a small adjustment to the `price-filter.page.ts` by removing an unnecessary call to `this.editor.openDocumentSettingsSidebar()` and another unnecessary timeout. * Refactor URL parameter creation in price filter test This commit refactors the `getPriceFilterQuery` method in `price-filter.page.ts` to use the built-in URLSearchParams API for constructing URL parameters. Previously, the method was manually creating a string representation of URL parameters. Now, it leverages the URLSearchParams API to improve readability and handle potential edge cases better. The new approach appends 'min_price' and 'max_price' as URL parameters if they are not null. The `toString()` function is then called on the URLSearchParams object to return a string that can be used in a URL. * Refactor E2E price filter tests and update test scripts in global-setup Here are the key changes: 1. Refactored the way the 'wp action-scheduler run' command is run in the 'global-setup.ts' script. Now, it correctly separates the wp command from the arguments passed to it. 2. Consolidated the 'price-filter-with-all-products.block_theme.side_effects.spec.ts' and 'price-filter-with-classic-template.block_theme.side_effects.spec.ts' tests into a single 'price-filter.block_theme.side_effects.spec.ts' file. The new file contains tests for both scenarios: with all products block and with PHP classic template. Also, updated the product locator function to distinguish between classic templates and products beta block. 3. Deleted the original 'price-filter-with-all-products.block_theme.side_effects.spec.ts' and 'price-filter-with-classic-template.block_theme.side_effects.spec.ts' test files as they are no longer needed. 4. Updated the 'price-filter.page.ts' file to remove the 'waitForLoadState' method call after inserting the block in the editor and added logic to handle locating products in different scenarios (classic template vs products beta block). * Use -- instead of quotes * Minor improvements
Soon products beta block will be replaced by Product Coll...Soon products beta block will be replaced by Product Collection block. Update this accordingly.
woocommerce-blocks/tests/e2e-pw/tests/price-filter/price-filter.page.ts Lines 159 to 170 in 1cf25ab
🚀 This comment was generated by the automations bot based on a
|
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
@kmanijak @imanish003 @albarin and the reviewer of this PR, in the recent commits, I
I did that because I don't think we should fix the Playwright test in this PR. We should only commit the relevant changes related to |
@@ -171,7 +171,7 @@ | |||
"@wordpress/e2e-test-utils-playwright": "0.6.0", | |||
"@wordpress/e2e-tests": "^4.6.0", | |||
"@wordpress/element": "4.20.0", | |||
"@wordpress/env": "7.0.0", | |||
"@wordpress/env": "8.1.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think if instead of 8.1.1
, we use wp-6.2
?
My idea is to follow this approach: #10331
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gigitux Let's continue the discussion in your PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! LGTM! I added a comment, but feel free to skip it for now, but I'm really interested in your feedback!
This PR:
@wordpress/env
to version 8.1.1 which includes the fix wp-env: try to fix failing PHP Github actions WordPress/gutenberg#51513 that allows to run PHP Unit Tests with PHP versions 8.1 and 8.2Fixes #9862
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility