Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix e2e tests for price filter #10031

Merged
merged 11 commits into from
Jul 4, 2023
Merged

Fix e2e tests for price filter #10031

merged 11 commits into from
Jul 4, 2023

Conversation

imanish003
Copy link
Contributor

@imanish003 imanish003 commented Jun 29, 2023

Some E2E tests related to the Price Filter block were failing. I have fixed the failing tests and made some other improvements. Here are the highlights of the changes:

  1. Refactored E2E Tests for Price Filter: We have revamped our E2E tests in price-filter.block_theme.side_effects.spec.ts. A key highlight of this refactoring is the introduction of a new page object model, PriceFilterPage, which consolidates the logic for interacting with the price filter block. This includes adding the price filter block to new posts, setting the price filter range, and locating the images and products on a page.

  2. Modified Playwright Configuration: Changes have been made to the Playwright configuration file playwright.config.ts to capture full-page screenshots only on failure. This helps in better understanding the failures and improves debugging efficiency.

Impact of Changes

  • These changes will enhance the readability and maintainability of the code.
  • It will also reduce the complexity of the test suite, making it easier to understand and modify.
  • The improved Playwright configuration will assist in efficient debugging of test failures.

Areas of Concern

  • Please review the changes in the playwright.config.ts to ensure that it aligns with our testing strategy.
  • The refactored tests need to be carefully reviewed to ensure that all aspects of the previous tests are covered.
  • The new PriceFilterPage class should be reviewed for potential improvements in the encapsulation of interactions with the price filter block.

Part of #9875

Testing

  1. Run npm run env:start or npm run env:restart
  2. Execute end-to-end tests with Playwright using the command: npm run test:e2e-pw.
  3. Confirm that all tests complete successfully without any failures.
  4. Verify that the Continuous Integration (CI) pipeline Playwright Tests / Playwright E2E tests runs without any errors or failures.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

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.
@imanish003 imanish003 changed the base branch from trunk to update/wordpress/env June 29, 2023 11:01
@github-actions
Copy link
Contributor

github-actions bot commented Jun 29, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-10031.zip

Script Dependencies Report

The compare-assets action has detected some changed script dependencies between this branch and trunk. Please review and confirm the following are correct before merging.

Script Handle Added Removed
reviews-frontend.js wc-settings, wp-a11y, wp-api-fetch, wp-compose, wp-element, wp-i18n, wp-is-shallow-equal, wp-polyfill ⚠️
active-filters-frontend.js wc-blocks-data-store, wc-price-format, wc-settings, wp-data, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-primitives, wp-url ⚠️
all-products-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-context, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-a11y, wp-api-fetch, wp-autop, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-primitives, wp-style-engine, wp-url, wp-warning, wp-wordcount ⚠️
attribute-filter-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-settings, wp-a11y, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
cart-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-context, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-a11y, wp-api-fetch, wp-autop, wp-blocks, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-plugins, wp-polyfill, wp-primitives, wp-style-engine, wp-url, wp-warning, wp-wordcount ⚠️
checkout-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-blocks-shared-hocs, wc-price-format, wc-settings, wp-a11y, wp-api-fetch, wp-autop, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-plugins, wp-polyfill, wp-primitives, wp-url, wp-warning, wp-wordcount ⚠️
filter-wrapper-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-price-format, wc-settings, wp-a11y, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-style-engine, wp-url, wp-warning ⚠️
mini-cart-frontend.js wc-price-format, wc-settings, wp-i18n, wp-polyfill ⚠️
price-filter-frontend.js react, wc-blocks-data-store, wc-price-format, wc-settings, wp-data, wp-element, wp-i18n, wp-is-shallow-equal, wp-polyfill, wp-url ⚠️
rating-filter-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-settings, wp-a11y, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
stock-filter-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-settings, wp-a11y, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-url, wp-warning ⚠️
mini-cart-component-frontend.js lodash, react, wc-blocks-checkout, wc-blocks-data-store, wc-blocks-registry, wc-price-format, wc-settings, wp-a11y, wp-autop, wp-compose, wp-data, wp-deprecated, wp-dom, wp-element, wp-hooks, wp-html-entities, wp-i18n, wp-is-shallow-equal, wp-keycodes, wp-polyfill, wp-primitives, wp-style-engine, wp-url, wp-warning, wp-wordcount ⚠️

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 461
  • Total errors: 2229

⚠️ ⚠️ This PR introduces new TS errors on 5 files:

assets/js/atomic/blocks/product-elements/rating/block.tsx

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-items-counter-block/block.tsx

assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-title-label-block/block.tsx

assets/js/blocks/product-tag/block.js

assets/js/blocks/product-tag/edit.tsx

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Jun 29, 2023

Size Change: 0 B

Total Size: 1.17 MB

ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 8.64 kB
build/active-filters-wrapper-frontend.js 7.58 kB
build/active-filters.js 7.49 kB
build/all-products-frontend.js 12.2 kB
build/all-products.js 40.3 kB
build/all-reviews.js 7.87 kB
build/attribute-filter-frontend.js 23 kB
build/attribute-filter-wrapper-frontend.js 7.73 kB
build/attribute-filter.js 13.3 kB
build/blocks-checkout.js 35.1 kB
build/breadcrumbs.js 2.13 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-cross-sells-products--product-price-frontend.js 2.92 kB
build/cart-blocks/cart-cross-sells-products-frontend.js 3.78 kB
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.16 kB
build/cart-blocks/cart-express-payment-frontend.js 720 B
build/cart-blocks/cart-items-frontend.js 301 B
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.48 kB
build/cart-blocks/cart-line-items-frontend.js 1.06 kB
build/cart-blocks/cart-order-summary-frontend.js 1.28 kB
build/cart-blocks/cart-totals-frontend.js 307 B
build/cart-blocks/empty-cart-frontend.js 346 B
build/cart-blocks/filled-cart-frontend.js 656 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.63 kB
build/cart-blocks/order-summary-discount-frontend.js 2.12 kB
build/cart-blocks/order-summary-fee-frontend.js 272 B
build/cart-blocks/order-summary-heading-frontend.js 334 B
build/cart-blocks/order-summary-shipping-frontend.js 17.1 kB
build/cart-blocks/order-summary-subtotal-frontend.js 273 B
build/cart-blocks/order-summary-taxes-frontend.js 436 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.44 kB
build/cart-frontend.js 29.9 kB
build/cart.js 45 kB
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/actions-frontend.js 1.88 kB
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.69 kB
build/checkout-blocks/billing-address-frontend.js 1.18 kB
build/checkout-blocks/contact-information-frontend.js 2.04 kB
build/checkout-blocks/express-payment-frontend.js 1.14 kB
build/checkout-blocks/fields-frontend.js 331 B
build/checkout-blocks/order-note-frontend.js 1.14 kB
build/checkout-blocks/order-summary-cart-items-frontend.js 3.76 kB
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.79 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-fee-frontend.js 275 B
build/checkout-blocks/order-summary-frontend.js 1.28 kB
build/checkout-blocks/order-summary-shipping-frontend.js 17 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 273 B
build/checkout-blocks/order-summary-taxes-frontend.js 435 B
build/checkout-blocks/payment-frontend.js 9.27 kB
build/checkout-blocks/pickup-options-frontend.js 4.84 kB
build/checkout-blocks/shipping-address-frontend.js 1.17 kB
build/checkout-blocks/shipping-method-frontend.js 2.63 kB
build/checkout-blocks/shipping-methods-frontend.js 6.41 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 361 B
build/checkout-frontend.js 31.8 kB
build/checkout.js 47.6 kB
build/customer-account.js 3.19 kB
build/featured-category.js 15.1 kB
build/featured-product.js 15.3 kB
build/filter-wrapper-frontend.js 14.3 kB
build/filter-wrapper.js 2.4 kB
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/handpicked-products.js 8.04 kB
build/legacy-template.js 6.82 kB
build/mini-cart-component-frontend.js 30.7 kB
build/mini-cart-contents-block/cart-button-frontend.js 1.73 kB
build/mini-cart-contents-block/checkout-button-frontend.js 1.81 kB
build/mini-cart-contents-block/empty-cart-frontend.js 360 B
build/mini-cart-contents-block/filled-cart-frontend.js 267 B
build/mini-cart-contents-block/footer-frontend.js 3.83 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 587 B
build/mini-cart-contents-block/shopping-button-frontend.js 531 B
build/mini-cart-contents-block/title-frontend.js 1.9 kB
build/mini-cart-contents-block/title-items-counter-frontend.js 1.59 kB
build/mini-cart-contents-block/title-label-frontend.js 1.53 kB
build/mini-cart-contents.js 18.1 kB
build/mini-cart-frontend.js 2.84 kB
build/mini-cart.js 5.93 kB
build/price-filter-frontend.js 14.7 kB
build/price-filter-wrapper-frontend.js 6.79 kB
build/price-filter.js 8.56 kB
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button--product-image--product-price--product-rating--product-sale-bad--49d3ecb2.js 272 B
build/product-add-to-cart--product-button--product-image--product-rating--product-title.js 151 B
build/product-add-to-cart-frontend.js 6.52 kB
build/product-add-to-cart.js 8.84 kB
build/product-best-sellers.js 8.36 kB
build/product-button--product-image--product-price--product-rating--product-sale-badge--product-sku--prod--5bce0384.js 954 B
build/product-button-frontend.js 2.67 kB
build/product-button.js 3.97 kB
build/product-categories.js 2.72 kB
build/product-category.js 9.37 kB
build/product-collection.js 12.3 kB
build/product-image-frontend.js 2.63 kB
build/product-image.js 4.14 kB
build/product-new.js 8.65 kB
build/product-on-sale.js 8.65 kB
build/product-price-frontend.js 231 B
build/product-price.js 1.68 kB
build/product-query.js 11.9 kB
build/product-rating-frontend.js 2.35 kB
build/product-rating.js 1.04 kB
build/product-results-count.js 1.65 kB
build/product-sale-badge-frontend.js 1.8 kB
build/product-sale-badge.js 665 B
build/product-search.js 2.63 kB
build/product-sku-frontend.js 1.85 kB
build/product-sku.js 535 B
build/product-stock-indicator-frontend.js 2.04 kB
build/product-stock-indicator.js 730 B
build/product-summary-frontend.js 2.26 kB
build/product-summary.js 1.01 kB
build/product-tag.js 9.01 kB
build/product-template.js 3.34 kB
build/product-title-frontend.js 2.22 kB
build/product-title.js 3.66 kB
build/product-top-rated.js 8.91 kB
build/products-by-attribute.js 9.76 kB
build/rating-filter-frontend.js 21.5 kB
build/rating-filter-wrapper-frontend.js 6.25 kB
build/rating-filter.js 6.94 kB
build/reviews-by-category.js 12.1 kB
build/reviews-by-product.js 13.3 kB
build/reviews-frontend.js 7.17 kB
build/single-product.js 11.1 kB
build/stock-filter-frontend.js 21.7 kB
build/stock-filter-wrapper-frontend.js 6.5 kB
build/stock-filter.js 7.67 kB
build/store-notices.js 1.69 kB
build/vendors--attribute-filter-wrapper--cart-blocks/order-summary-coupon-form--cart-blocks/order-summary--48e1e4bb-frontend.js 6.83 kB
build/vendors--attribute-filter-wrapper--cart-blocks/order-summary-shipping--checkout-blocks/billing-addr--d9f38f9d-frontend.js 4.2 kB
build/vendors--attribute-filter-wrapper-frontend.js 5.11 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.57 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js 19.4 kB
build/vendors--checkout-blocks/pickup-options--checkout-blocks/shipping-methods-frontend.js 8.25 kB
build/vendors--checkout-blocks/shipping-method-frontend.js 12.4 kB
build/vendors--price-filter-wrapper-frontend.js 2.2 kB
build/vendors--product-add-to-cart-frontend.js 7.25 kB
build/vendors--rating-filter-wrapper-frontend.js 5.11 kB
build/vendors--stock-filter-wrapper-frontend.js 5.11 kB
build/wc-blocks-data.js 22.4 kB
build/wc-blocks-editor-style-rtl.css 6.21 kB
build/wc-blocks-editor-style.css 6.21 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 934 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.1 kB
build/wc-blocks-shared-hocs.js 1.75 kB
build/wc-blocks-style-rtl.css 28 kB
build/wc-blocks-style.css 27.9 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 kB
build/wc-blocks-vendors.js 65.1 kB
build/wc-blocks.js 3.71 kB
build/wc-interactivity.js 10.4 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB
build/wc-shipping-method-pickup-location.js 30.4 kB

compressed-size-action

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.
@imanish003 imanish003 added skip-changelog PRs that you don't want to appear in the changelog. category: tests labels Jun 29, 2023
@imanish003 imanish003 requested a review from gigitux June 29, 2023 11:37
@imanish003 imanish003 marked this pull request as ready for review June 29, 2023 11:37
@woocommercebot woocommercebot requested a review from a team June 29, 2023 11:37
@imanish003 imanish003 requested a review from kmanijak June 30, 2023 05:23
Copy link
Contributor

@kmanijak kmanijak left a comment

Choose a reason for hiding this comment

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

I reviewed the testing steps and they seem to cover the same as before. This PR really improved readability, so thanks for it!

For some reason, one test is failing for me locally:

1) [blockThemeWithGlobalSideEffects] › price-filter/price-filter.block_theme.side_effects.spec.ts:68:2 › woocommerce/price-filter Block - with PHP classic template › should show all products 

    Test timeout of 90000ms exceeded.

It stops at:

      at price-filter/price-filter.page.ts:68
      > 68 |              await this.page.waitForLoadState( 'networkidle' );

Based on the output image it seems all good, but the event was not fired, so do you think it could be a race condition? 🤔

test-failed-1

One minor thing, I know testing instructions won't be included in the release, but still worth adding a step to re-install deps to update wp-env locally before running the docker and tests.

Comment on lines 163 to 167
if ( minPrice ) {
result += `min_price=${ minPrice }`;
}
if ( maxPrice ) {
result += `&max_price=${ maxPrice }`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Detail, but in case there's no min_price query would start with an ampersand (&max_price). I don't know if that may influence the test results, but I'd keep it the closest to the real env possible. Unless you're sure that's ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the output image it seems all good, but the event was not fired, so do you think it could be a race condition? 🤔

I am not sure because all tests are running successfully locally for me. I will try to reproduce the issue by following these steps:

  1. Destroying the environment: npm run wp-env destroy
  2. Start the environment again using: npm run env:start
  3. Once the environment is up and running, re-run the tests using: npm run test:e2e-pw

I will update you once I have more information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Detail, but in case there's no min_price query would start with an ampersand (&max_price). I don't know if that may influence the test results, but I'd keep it the closest to the real env possible. Unless you're sure that's ok.

Agreed, I made the changes in 8c3efcb. Now function uses URLSearchParams to generate the query string. This object automatically encodes special characters and manages the & delimiter.

@kmanijak
Copy link
Contributor

kmanijak commented Jun 30, 2023

@imanish003, an update to the previous comment. I re-run the tests locally and this time two tests failed:

1) [blockThemeWithGlobalSideEffects] › price-filter/price-filter.block_theme.side_effects.spec.ts:68:2 › woocommerce/price-filter Block - with PHP classic template › should show all products 

 2) [blockThemeWithGlobalSideEffects] › price-filter/price-filter.block_theme.side_effects.spec.ts:75:2 › woocommerce/price-filter Block - with PHP classic template › should show only products that match the filter

on the exactly same step

await this.page.waitForLoadState( 'networkidle' );

so seems like it introduces some flakiness 🤔 Do you think that may be related to my local setup somehow? Have you faced the same problem?

Upgrade `@playwright/test` package from version `1.32.3` to `1.35.1`.
package.json Outdated
@@ -109,7 +109,7 @@
"@bartekbp/typescript-checkstyle": "5.0.0",
"@octokit/action": "5.0.2",
"@octokit/graphql": "5.0.5",
"@playwright/test": "1.32.3",
"@playwright/test": "^1.35.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

We should stick to the fixed version:

Suggested change
"@playwright/test": "^1.35.1",
"@playwright/test": "1.35.1",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have any strong opinion on this as this is a dev dependency. I will go ahead and change it to fixed version 🤝

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's the convention, but can't find the resource mentioning it, sorry. But I think we can assume that based on other dependencies 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the changes in ec0c613

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.
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.
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).
@github-actions
Copy link
Contributor

github-actions bot commented Jul 3, 2023

Soon products beta block will be replaced by Product Coll...

Soon products beta block will be replaced by Product Collection block. Update this accordingly.


// TODO Soon products beta block will be replaced by Product Collection block. Update this accordingly.
return await this.page.locator(
'.products-block-post-template .product'
);
}
/**
* Private functions to be used in this class
*/
private generatePriceFilterQueryString(
minPrice: number | null,
maxPrice: number | null

🚀 This comment was generated by the automations bot based on a todo comment in de415ce in #10031. cc @imanish003

@imanish003 imanish003 requested a review from kmanijak July 4, 2023 06:30
@imanish003
Copy link
Contributor Author

Hi @kmanijak, After making some changes. I have tested it locally & all tests are passing for me. Can you please review again?

As you can see in the demo video below, all tests are passing for me:
npm run test:e2e-pw -- --ui

Screen.Recording.2023-07-04.at.12.01.50.PM.mov

Copy link
Contributor

@kmanijak kmanijak left a comment

Choose a reason for hiding this comment

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

All the tests are passing just right! 💪

@github-actions github-actions bot added this to the 10.6.0 milestone Jul 4, 2023
@imanish003 imanish003 merged commit b219865 into update/wordpress/env Jul 4, 2023
@imanish003 imanish003 deleted the fix/e2e-tests branch July 4, 2023 08:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
skip-changelog PRs that you don't want to appear in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants