Commit Graph

469 Commits

Author SHA1 Message Date
Luigi Teschio b90e0ffdc9 Interactivity API and Product Button (https://github.com/woocommerce/woocommerce-blocks/pull/10006)
* Update Interactivity API JS files

* Disable TS checks in the Interactivity API for now

* Add new SSR files

* Replace wp_ prefixes with wc_ ones

* Replace wp- prefix with wc-

* Replace guternberg_ prefix with woocommerce_

* Remove file comments from Gutenberg

* Rename files with `wp` prefix

* Fix code to load Interactivity API php files

* Remove TODO comments

* Replace @wordpress with @woocommerce

* Update Webpack configuration

* Fix directive prefix

* Remove interactivity folder from tsconfig exclude

* Add client-side navigation meta tag code

* Remove unneeded blocks.php file

* Fix store tag id

* Register Interactivity API runtime script

* Fix Interactivity API runtime registering

* Remove all files related to directive processing in PHP

* Move json_encode to Store's render method

* WIP

* WIP

* WIP

* WIP

* Preserve previous context

* Ignore Minicart block on client-side navigation

* Refresh page on store updatRefresh page on store updatee

* Refactor logic

* Add console error when a path is missing

* fix PHP lint error

* WIP store

* use store approach

* update jest configuration

* restore Mini Cart changes

* move cart store subscription to interactivity package

* move interactivity flag

* format HTML

* move addToCartText to the context

* Load product-query stylesheet when rendering the Products block

* update sideEffects array

* fix catch

* rename moreThanOneItem to isThereMoreThanOneItem

* improve how scripts are enqueued

* update default value for the filter woocommerce_blocks_enable_interactivity_api

* Update assets/js/atomic/blocks/product-elements/button/block.json

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update assets/js/interactivity/cart/cart-store.ts

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* fix block.json

* remove updateStore function

* restore interactivity api changes

* import cart store

* show notice when there is an error

* add logic to dequeue script on classic themes and block themes

* imrpove logic about notice

* Interactivity API: add `afterLoad` callbacks to `store()` function (https://github.com/woocommerce/woocommerce-blocks/pull/10338)

* show notice when there is an error

* Add initial implementation for store callbacks

* Run `afterLoad` callbacks after `init`

* Move cart state subscription to Product button

* Remove cart-store from Interactivity API internals

* Change callbacks with options and save only afterLoad callbacks

* ProductButton: Add animation (https://github.com/woocommerce/woocommerce-blocks/pull/10351)

* implement animation

* improve logic

* refactor logic

* refactor code

* address feedback about code style

* add support for woocommerce_add_to_cart_quantity

* Fix animation flickering

* Introduce wp-effect, reduce the amount of numberOfItem variables to 2 and consolidate animation status

* add support for added class

* Remove unnecessary selector

* Don't fetch cart if it was already fetched

* remove added class

---------

Co-authored-by: Luis Herranz <luisherranz@gmail.com>

---------

Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Luis Herranz <luisherranz@gmail.com>

* update deepsignal

* remove added class

* update deepsignal

* Interactivity API and Product Button: Add E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/10036)

* Add FrontendUtils class

* fix conflicts

* use locator

* restore click usage

* Product Button: Add E2E test

* fix util

* fix E2E tests

* remove comment

* Add E2E test to ensure that woocommerce_product_add_to_cart_text works

* update sideEffects array

* add zip and unzip as package

* fix wp-env configuration

* fix E2E test

* add report

* try now

* try now

* try now

* fix E2E test

* E2E: Add documentation for testing actions and filters. Fixes woocommerce/woocommerce-blocks#10135 (https://github.com/woocommerce/woocommerce-blocks/pull/10206)

* update description

* fix label

* rename files

* make requestUtils private

* remove page.goto

* use toHaveCount

* use productsToDisplay variable

* fix E2E tests

* rename class utils

---------

Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>

---------

Co-authored-by: David Arenas <david.arenas@automattic.com>
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
2023-08-10 14:02:33 +00:00
Mike Jolley 4fd16267be Refactor Push Changes Readability and Performance (https://github.com/woocommerce/woocommerce-blocks/pull/10315)
* Add local state to address-form

* Update test with valid postcode and required fields

* Push changes refactoring

* Avoid loops due to retrying same data

* Callbacks to prevent rerenders

* Move validation functions

* Filter incoming values to only those included as fields to prevent errors

* Keep track of country changes to prevent excessive updates of addressFormFields.

* Use helpers in test

* Fill company

* Revert local state in address form

* Update address form to remove validation handling for postcode (country clears the field).

* Revert "Update test with valid postcode and required fields"

This reverts commit 718a6006df24f6e957297ad4d1ef9d6f690793bd.

* Clear postcode when country changes if invalid

* Revalidate fields when country changes

* Comment for pick

* Revert unneccessary test change

* Revery moving of functions to reduce diff size

* Increase push timeout in tests

* Revert test changes
2023-08-09 18:24:51 +01:00
Thomas Roberts f3bdfaee98 Update E2E util to allow adding to cart by name from the shop page (https://github.com/woocommerce/woocommerce-blocks/pull/10507)
* Allow adding to cart by name from the shop page

* Remove networkidle
2023-08-09 16:17:05 +02:00
Mike Jolley 2b80d3e830 Rename commands and directories for Playwright and JEST e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10493)
* Move e2e to e2e-jest

* Move e2e-pw to e2e

* Update e2e usage + scripts

* Missed some directory renames

* Update gitignore

* Remove test results as its in gitignore
2023-08-08 17:58:12 +01:00
Luigi Teschio be1cefc4b4 Add ESLint `eslint-plugin-playwright` package (https://github.com/woocommerce/woocommerce-blocks/pull/10487)
* Add eslint playwright plugin configuration

* replace networkidle with commit

* address  Unnecessary await expression. This method does not return a Promise error

* address 'Unexpected usage of not.toBeVisible(). Use toBeHidden() instead' error

* address 'Unexpected use of the .skip()  annotation.' error

* address 'toHaveCount' must be awaited or returned' error

* address ''page' is defined but never used '

* address ''toBeVisible' must be awaited or returned'

* address 'Unexpected use of element handles'

* address 'Unnecessary await expression. This method does not return a Promise'

* address 'Test has no assertions'

* address 'Unexpected use of page.waitForTimeout()'

* address 'Avoid having conditionals in tests'
2023-08-08 13:25:45 +00:00
Thomas Roberts 8e79fdcc45 Preliminary work to add Playwright E2E tests for the Cart block & merchant cart tests (https://github.com/woocommerce/woocommerce-blocks/pull/9739)
* Add cartCheckout project

* Add navigation utils

* Add global block inserter utils to EditorUtils class

* Add initial Cart block tests

* Add slug to block data type

* Get block editor selector when navigating in editor

* add test for inner block filtering

* Update navigation util to use block name instead of title

* Add view switcher test

* Update block name/title

* Run only cart/checkout tests in cartCheckout project

* Remove old comment

* Update selector to use locator instead

* Revert selector type change

* Fix TS issues

* Remove unnecessary admin state

* Update tests to use editorUtils and fix TS issue with selector

* Replace string concatenation with template

* Rename cart test to contain block_theme suffix

* Change page to editor.page and use canvas where necessary

* Rename directory to cart-checkout

* Wait for editor response before continuing

* Remove cartcheckout playwright project

* Remove typecast and switch to .toNotBeHidden

* Remove double comment

* Force click the empty cart button

* Wait for empty cart button for longer

* Isolate test to run in CI

* Dispatch click event instead of simulating click

* Remove timeouts

* Revert "Isolate test to run in CI"

This reverts commit 28af5a50700476639d0a4f12fca9800a4a5aed91.
2023-08-07 08:59:06 -07:00
Mike Jolley 427fe33af3 Fix wcSettings inconsistent property naming style (https://github.com/woocommerce/woocommerce-blocks/pull/10439)
* Mass convert all snake case settings keys to camel case

* Handling for payment method data props
2023-08-07 11:30:53 +01:00
Daniel Dudzic c411137ba4 E2E: Product Gallery Thumbnails block tests (https://github.com/woocommerce/woocommerce-blocks/pull/10370)
* WIP Product Gallery: Add the Thumbnails block

* Product Gallery Thumbnails: Add block settings

* Add template for the Product Gallery block

* Add template for the Product Gallery block. Add the rest of the files.

* Product Gallery Thumbnails: Add context settings sharing between the Product Gallery and Thumbnails block.

* Product Gallery Thumbnails: Add UI functionality and frontend functionality. Add settings for the Thumbnails in both places - Product Gallery and the Thumbnails block.

* Product Gallery Thumbnails: Move the static template ouside of the component

* Make sure the context is set before accesing the array values

* Product Gallery Thumbnails: Move the setGroupAttributes() function outside of the component

* Product Gallery Thumbnails: Fix TS errors

* Product Gallery Thumbnails: Update the Features Flags and Experimental Interfaces doc

* Product Gallery Thumbnails: Fix TS error

* Product Gallery Thumbnails: Remove unused stylesheet

* Product Gallery Thumbnails: Fix TS errors

* Product Gallery Thumbnails: Remove unused context and fix the thumbnails bottom position styling on the frontend.

* Product Gallery Thumbnails: Allow the user to move the horizontal thumbnails above the large image and don't overwrite that automatically

* E2E: Add tests for the Product Gallery Thumbnails block

* Product Gallery Thumbnails: Add code comments and remove the incorrect conditional check when moving thumbnails up and down

* Product Gallery Thumbnails: Add failure handling

* Product Gallery Thumbnails: Fix the eslint dependency error

* Product Gallery Thumbnails: Add inner blocks to the sideEffects array

* Product Gallery Thumbnails: Refactor Product Gallery edit code and move the logic to a utils file

* Product Gallery Thumbnails: Update the utils file

* Product Gallery Thumbnails: Update the utils file. Fix comment indentation

* Product Gallery Thumbnails: Fix failing tests

* Revert unrelated package.json changes

* Product Gallery Thumbnails: Further package.json reverts

* Product Gallery Thumbnails: Rename the test screenshots

* Product Gallery Thumbnails: Fix undefined variable html when only 1 product image is set

* Product Gallery: Rename clientId to productGalleryClientId

* Product Gallery Thumbnails: Combine the useEffect code having the same dependencies

* Product Gallery Thumbnails: Combine all useEffect code together

* Product Gallery Thumbnails: Add a ThumbnailsPosition enum

* Product Gallery Thumbnails: Update the thumbnailsPosition to an enum

* Product Gallery Thumbnails: Fix TS errors

* Product Gallery Thumbnails: Fix TS errors

* Product Gallery Thumbnails: Add missing dependency

* Product Gallery Thumbnails: Uppercase the enum and fix the thumbnails position bug when initially adding the Product Gallery block

* Product Gallery Thumbnails: Fix E2E tests

* Product Gallery Thumbnails: Remove unused function from frontend utils

* Product Gallery Thumbnails: Remove unused screenshots and config amendment

* Product Gallery Thumbnails: Add check for the order of block on the frontend

* Product Gallery: Add crop, zoom and full-screen settings

* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error

* Product Gallery Thumbnails: Replace ts-ignore with ts-expect-error

* Product Gallery Thumbnails: Revert back to ts-ignore

* Revert "Product Gallery: Add crop, zoom and full-screen settings"

This reverts commit 840654197619e2611029b81990493387ae0b543d.

* Product Gallery: Add crop, zoom and full-screen settings

* Product Gallery: Remove the redundant React Fragment

* Product Gallery E2E: Simplify and combine the tests
2023-08-04 13:07:31 +02:00
Manish Menaria bf60eb60e7 Product collection - Fix test_merging_filter_by_attribute_queries unit test (https://github.com/woocommerce/woocommerce-blocks/pull/10302)
* Add PHPUnit tests for the ProductCollection block type

This commit introduces PHPUnit tests for the ProductCollection block type. A new test file, `ProductCollection.php`, has been added under the `BlockTypes` directory within the tests. The test file sets up a mock instance of `ProductCollection` and verifies its behavior. Particularly, it tests the merging of on-sale queries, ensuring the results are as expected.

To assist in the testing, a new mock class, `ProductCollectionMock`, has been created under the `Mocks` directory. This class extends the `ProductCollection` block type and provides methods for setting parsed block data and attribute filter query arguments.

These tests should help ensure the correctness and reliability of the `ProductCollection` block type.

* Expand PHPUnit tests for ProductCollection block to cover stock status queries

This commit expands the existing PHPUnit tests for the ProductCollection block type to cover scenarios involving stock status queries. Specifically, a new test method, `test_merging_stock_status_queries`, has been added.

This method tests if the 'woocommerceStockStatus' attribute is correctly merged into the query parameters. It verifies that the stock status is correctly incorporated into the 'meta_query' array as part of the constructed query.

This addition enhances the coverage of our test suite, ensuring that the ProductCollection block behaves as expected in scenarios involving stock status queries.

* Add extensive testing for ProductCollection block's query merging

The following test methods were added:

1. `test_merging_default_stock_queries`: This tests the merging of default stock queries, verifying the absence of meta_query in certain conditions.

2. `test_merging_attribute_queries`: This tests the merging of attribute queries, ensuring the correct taxonomy and terms are used in the merged tax_query.

3. `test_merging_order_by_rating_queries` and `test_merging_order_by_popularity_queries`: These test the merging of order by queries, checking for the right orderby and meta_key in the merged query.

4. `test_product_visibility_query_exist_in_merged_query`: This tests if the product visibility query exists in the merged query.

This additional testing improves the reliability and coverage of our tests, ensuring the correct functionality of the ProductCollection block's query merging process.

* Add unit tests for merged queries in ProductCollection block

- Merging multiple queries
- Merging filter by max price queries
- Merging filter by min price queries
- Merging filter by min and max price queries
- Merging filter by stock status queries
- Merging filter by attribute queries
- Merging multiple filter queries

These tests use PHPUnit assertions to validate the correctness of the merged queries.

* Add tests for REST query modifications in ProductCollection block

This commit adds two new test cases and a helper method to the `ProductCollection` test class.

The helper method, `build_request()`, constructs a simplified `WP_REST_Request` object for testing purposes. This request object simulates a typical request from the ProductCollection block, including potential WooCommerce parameters such as 'woocommerceOnSale', 'woocommerceAttributes', and 'woocommerceStockStatus'.

The first new test, `test_updating_rest_query_without_attributes()`, tests the block's capability to modify a REST query that doesn't include any product attribute filters. It verifies that the correct '_stock_status' and 'product_visibility' parameters are set in the meta and tax queries respectively.

The second test, `test_updating_rest_query_with_attributes()`, does the same as the previous one but with the inclusion of a product attribute filter in the REST request. This test verifies that the block can handle REST queries with attribute filters correctly.

These tests improve coverage on the ProductCollection block's REST query handling, ensuring that it can merge different filter queries correctly.

* Add test for merging taxonomies query in ProductCollection block

This commit introduces a new test, `test_merging_taxonomies_query()`, in the `ProductCollection` test class.

The test simulates a situation where the block has to merge taxonomy queries related to product categories and tags. The parsed block attributes are configured to include 'product_cat' and 'product_tag' taxonomies with certain term IDs.

The test then asserts that the merged query correctly includes these taxonomies with the appropriate term IDs and 'include_children' set to false. This confirms that the block correctly merges taxonomy filters when building the final query.

* Fix failing test

* Try again

* Try again

* Remove test_merging_filter_by_attribute_queries test

This commit removes the `test_merging_filter_by_attribute_queries()` test from the `ProductCollection` test class.

* Reintroduce test for merging attribute filter queries

This commit reintroduces the `test_merging_filter_by_attribute_queries()` test in the `ProductCollection` test class.

The test checks the correct merging of queries when filtering by color and size attributes. It sets various query variables and asserts the correct structure and content of the merged query.

This could be because the previous removal of this test was a mistake, or because changes in the code have once again made this test relevant.

* fix: passing correct block instance to build_frontend_query method

---------

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-07-31 14:12:03 +05:30
dependabot[bot] f218cfb51e Bump phpunit/phpunit from 8.5.33 to 9.2.6 (https://github.com/woocommerce/woocommerce-blocks/pull/9188)
* Bump phpunit/phpunit from 8.5.33 to 9.2.6

Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 8.5.33 to 9.2.6.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/9.2.6/ChangeLog-9.2.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/8.5.33...9.2.6)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update dependencies to avoid conflicts in php8

* Fix test due to array order of values

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-07-28 16:19:45 +01:00
dependabot[bot] 5ca496c20b Bump yoast/phpunit-polyfills from 1.0.5 to 2.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/9795)
* Bump yoast/phpunit-polyfills from 1.0.5 to 2.0.0

Bumps [yoast/phpunit-polyfills](https://github.com/Yoast/PHPUnit-Polyfills) from 1.0.5 to 2.0.0.
- [Release notes](https://github.com/Yoast/PHPUnit-Polyfills/releases)
- [Changelog](https://github.com/Yoast/PHPUnit-Polyfills/blob/2.x/CHANGELOG.md)
- [Commits](https://github.com/Yoast/PHPUnit-Polyfills/compare/1.0.5...2.0.0)

---
updated-dependencies:
- dependency-name: yoast/phpunit-polyfills
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Remove expect exception usage

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-07-28 12:53:40 +01:00
Albert Juhé Lluveras 22be5a532a Add tests in Playwright for Mini-Cart drawer closing (https://github.com/woocommerce/woocommerce-blocks/pull/10305)
* Add tests in Playwright for Mini-Cart drawer closing

* Make use of waitForSelector instead of waitForTimeout

* Make use of waitForSelector instead of waitForTimeout (II)
2023-07-27 08:53:24 +02:00
Manish Menaria 6e10e2fbcb Product Collection - Add PHP unit tests (https://github.com/woocommerce/woocommerce-blocks/pull/10289)
* Add PHPUnit tests for the ProductCollection block type

This commit introduces PHPUnit tests for the ProductCollection block type. A new test file, `ProductCollection.php`, has been added under the `BlockTypes` directory within the tests. The test file sets up a mock instance of `ProductCollection` and verifies its behavior. Particularly, it tests the merging of on-sale queries, ensuring the results are as expected.

To assist in the testing, a new mock class, `ProductCollectionMock`, has been created under the `Mocks` directory. This class extends the `ProductCollection` block type and provides methods for setting parsed block data and attribute filter query arguments.

These tests should help ensure the correctness and reliability of the `ProductCollection` block type.

* Expand PHPUnit tests for ProductCollection block to cover stock status queries

This commit expands the existing PHPUnit tests for the ProductCollection block type to cover scenarios involving stock status queries. Specifically, a new test method, `test_merging_stock_status_queries`, has been added.

This method tests if the 'woocommerceStockStatus' attribute is correctly merged into the query parameters. It verifies that the stock status is correctly incorporated into the 'meta_query' array as part of the constructed query.

This addition enhances the coverage of our test suite, ensuring that the ProductCollection block behaves as expected in scenarios involving stock status queries.

* Add extensive testing for ProductCollection block's query merging

The following test methods were added:

1. `test_merging_default_stock_queries`: This tests the merging of default stock queries, verifying the absence of meta_query in certain conditions.

2. `test_merging_attribute_queries`: This tests the merging of attribute queries, ensuring the correct taxonomy and terms are used in the merged tax_query.

3. `test_merging_order_by_rating_queries` and `test_merging_order_by_popularity_queries`: These test the merging of order by queries, checking for the right orderby and meta_key in the merged query.

4. `test_product_visibility_query_exist_in_merged_query`: This tests if the product visibility query exists in the merged query.

This additional testing improves the reliability and coverage of our tests, ensuring the correct functionality of the ProductCollection block's query merging process.

* Add unit tests for merged queries in ProductCollection block

- Merging multiple queries
- Merging filter by max price queries
- Merging filter by min price queries
- Merging filter by min and max price queries
- Merging filter by stock status queries
- Merging filter by attribute queries
- Merging multiple filter queries

These tests use PHPUnit assertions to validate the correctness of the merged queries.

* Add tests for REST query modifications in ProductCollection block

This commit adds two new test cases and a helper method to the `ProductCollection` test class.

The helper method, `build_request()`, constructs a simplified `WP_REST_Request` object for testing purposes. This request object simulates a typical request from the ProductCollection block, including potential WooCommerce parameters such as 'woocommerceOnSale', 'woocommerceAttributes', and 'woocommerceStockStatus'.

The first new test, `test_updating_rest_query_without_attributes()`, tests the block's capability to modify a REST query that doesn't include any product attribute filters. It verifies that the correct '_stock_status' and 'product_visibility' parameters are set in the meta and tax queries respectively.

The second test, `test_updating_rest_query_with_attributes()`, does the same as the previous one but with the inclusion of a product attribute filter in the REST request. This test verifies that the block can handle REST queries with attribute filters correctly.

These tests improve coverage on the ProductCollection block's REST query handling, ensuring that it can merge different filter queries correctly.

* Add test for merging taxonomies query in ProductCollection block

This commit introduces a new test, `test_merging_taxonomies_query()`, in the `ProductCollection` test class.

The test simulates a situation where the block has to merge taxonomy queries related to product categories and tags. The parsed block attributes are configured to include 'product_cat' and 'product_tag' taxonomies with certain term IDs.

The test then asserts that the merged query correctly includes these taxonomies with the appropriate term IDs and 'include_children' set to false. This confirms that the block correctly merges taxonomy filters when building the final query.

* Fix failing test

* Try again

* Try again

* Remove test_merging_filter_by_attribute_queries test

This commit removes the `test_merging_filter_by_attribute_queries()` test from the `ProductCollection` test class.
2023-07-21 15:43:22 +05:30
Darren Ethier f708593adb Add Color Panel (https://github.com/woocommerce/woocommerce-blocks/pull/10062)
* Add new ColorPanel component

* Implement new ColorPanel component for the Mini-Cart

* Move ColorPanel types into their own types.ts file alongside the ColorPanel component

* Add useColorPanelStyles hook

* Rename classes to className

* Disable @wordpress/no-unsafe-wp-apis

* Fix tests: Move defaultColorItem object to utils file

* Remove unnecssary types from QuantityBadge

* Fix conflicts

* Remove context

* Fix color picker JS error

* Migrate attribute data to be compatible with ColorPanel component

* Fix incompatible attributes

* Remove useColorPanelStyles hook

* migrateAttributesToColorPanel JS unit tests

* PHP MiniCartUtils tests

* Remove unncessary code for classNames in MiniCart edit

---------

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2023-07-21 10:35:32 +01:00
Albert Juhé Lluveras d248d62db1 Add Mini-Cart block Playwright e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/9757)
* Add Mini-Cart block Playwright e2e tests

* Verify tests fail

* Revert "Verify tests fail"

This reverts commit 47f666657d8a37bb486a4510ece44fd4d82c031d.

* Fix permalink-settings test
2023-07-21 09:44:01 +02:00
Mike Jolley ac1d7a251e Replace sanitization functions to enforce string values (https://github.com/woocommerce/woocommerce-blocks/pull/10242) 2023-07-17 08:47:25 -07:00
Manish Menaria bd892c4781 Add E2E tests for 'Inherit query from template' control in Product Collection block (https://github.com/woocommerce/woocommerce-blocks/pull/10174)
Key updates:

1. Additional CSS class to Inherit Query Control: A CSS class named `wc-block-product-collection__inherit-query-control` has been added to the ToggleControl component. This provides a precise target for E2E tests and potential custom styles.

2. E2E tests for 'Inherit query from template' control: Numerous scenarios have been covered to ensure the control's correct behavior. These scenarios include verifying visibility under different circumstances and checking its functionality in a Product Catalog template.

3. E2E test code enhancements: The E2E test code now exports the `SELECTORS` object to assist in locating different elements during the tests. This includes the new 'Inherit query from template' control. The `setShowOnlyProductsOnSale()` function has been refactored to improve readability and provide more granular control over its operations.

4. Test scenario for 'Show only products on sale': The existing E2E test for this functionality has been extended to check that it retains its state when the 'Inherit query from template' control is toggled.

These changes increase the robustness of our E2E tests, providing better coverage for the 'Inherit query from template' control in the Product Collection block.
2023-07-14 10:52:19 +05:30
Niels Lange 73f1ebf605 Return null or object for ImageAttachmentSchema response (https://github.com/woocommerce/woocommerce-blocks/pull/9962)
* Return null or object for ImageAttachmentSchema response

* Adjust docblock

* Update unit tests for ImageAttachmentSchema
2023-07-11 13:43:58 +02:00
Manish Menaria d4c3d43f9d Product Collection - Add more E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/10090)
* Add E2E tests for category-based product filtering

This commit refactors the product filtering in the product collection E2E tests and adds the ability to filter products based on their category.

Changes:
1. The method `setHandpickedProducts` was renamed to `setFilterComboboxValue` to reflect the fact that it's now used for more than just handpicked products. This method is now used to set the values of different filters.
2. The `addFilter` method was extended to support the 'Show Taxonomies' filter. It also includes a delay to ensure the correct rendering of the UI before further interactions.
3. A new test was added for filtering products based on their category using the 'Show Taxonomies' filter.
4. The tests for filtering products by handpicked selection and keyword were updated to use the new `setFilterComboboxValue` method.

These changes improve the robustness of the E2E tests and increase their coverage by including category-based filtering.

* Add product attribute filters to end-to-end tests

- A new test case has been added in the `product-collection.block_theme.spec.ts` to test the functionality of filtering products based on their attributes like color and size. This is done using the `addFilter` and `setProductAttribute` methods.

- Additionally, the `addFilter` method in `product-collection.page.ts` has been updated to include the 'Show Product Attributes' filter.

- A new method `setProductAttribute` has been introduced to set the attribute value which will trigger the filter action.

These updates enhance the test coverage by verifying the functionality of product attribute filters in the product collection.

* Add responsiveness test for product collection block

This commit introduces a new end-to-end test to ensure that the product collection block responds correctly to changes in screen size.

The new test in `product-collection.block_theme.spec.ts` verifies that the number of product columns adjusts as expected for different viewport sizes. In the initial viewport size, the width of a product should be less than the parent width as multiple columns are expected. When the viewport size is reduced, the product width should be approximately equal to the parent width, indicating a single column layout.

These changes provide more robust testing of the product collection block's responsiveness, helping to ensure a consistent user experience across different device sizes.

* Refactor product assertions and add setViewportSize method in ProductCollection tests

This commit refactors the Product Collection tests to enhance test readability and consistency. It switches the product count checks from `productImages` to `products` which is more semantically correct.

Additionally, a new method `setViewportSize` has been added in the `ProductCollectionPage` class for adjusting the viewport size in the tests.

- Changed product count assertions to use `products` instead of `productImages`
- Added `setViewportSize` method to `ProductCollectionPage`
- Updated existing tests to use the newly added `setViewportSize` method

* Add test case for product filtering based on stock status in Product Collection tests

This commit adds a new test case in the Product Collection suite to test product filtering based on their stock status. The test case checks if the filter for 'Out of stock' status works correctly.

Note: This test case is currently commented out because there are no products with 'Out of stock' status in the test data. The assertions will need to be uncommented once the test data includes 'Out of stock' products.

* Add new test case for toolbar settings

This commit does two main things:

1) Adds a new test case under 'Toolbar settings' to test 'Items per page', 'offset' & 'max page to show' settings in the product collection block.

2) It extends the ProductCollectionPage class to add methods for setting display settings and for handling pagination. It also defines a new 'pagination' locator to find the pagination navigation on the page.

This update will allow us to more effectively test the behavior of the product collection block when dealing with large collections and pagination. Note: the 'Product can be filtered based on stock status' test has been marked as skipped until there are products with 'Out of stock' status in the test data.

* Refactor e2e test files for Product Collection

Changes in `product-collection.block_theme.spec.ts`:
- Marked the test 'Products can be filtered based on category' as a 'fixme'. This test is currently failing due to a bug in the product collection block.

Changes in `product-collection.page.ts`:
- Reorganized constant block data into a more extensive set of selectors.
- Introduced a new method `locateSidebarSettings` to locate the sidebar settings region, improving readability and reusability.
- Used the new method `locateSidebarSettings` in various places where settings values are being set.
- Refactored other methods to better locate elements based on the reorganized selectors.
- Adjusted the product-related locators to rely on these newly defined selectors.

* Fix: Frontend Category Filtering in Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/10132)

* Fix: Product collection - Product category filter isn't working on frontend

* Remove fixme from test

* Refactor variables names
2023-07-11 16:05:29 +05:30
Albert Juhé Lluveras ad973e9b46 Fix Filter blocks e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/10116)
* Revert "fix save method"

This reverts commit f6623c55320bf55ee7fa3c23eb294f06d79ee4a5.

* Revert "Revert "fix save method""

This reverts commit 739db2e3b0b62e10fbe1ebabd1ec6bbae8425b3c.

* Update Filter by Attribute and Filter by Stock e2e test fixtures

* Update Filter by Attribute 'can hide product count' test
2023-07-06 16:39:19 +02:00
Roy Ho 5c72cfdb4d Update/fixtures html (https://github.com/woocommerce/woocommerce-blocks/pull/10080)
* Remove data attributes from fixture for active filters

* Remove data attributes from fixture for filter by price

* Remove data attributes from fixture for filter by attribute

* Remove data attributes from fixture for filter by stock
2023-07-05 06:16:36 -07:00
Luigi Teschio 78d320bc47 Products block: Improve stability E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/10075) 2023-07-05 07:45:38 +00:00
Luigi Teschio aa48386834 Mark order confirmation template E2E test as flaky (https://github.com/woocommerce/woocommerce-blocks/pull/10041) 2023-07-03 12:26:47 +00:00
Luigi Teschio a06dd1d7c9 Add FrontendUtils class (https://github.com/woocommerce/woocommerce-blocks/pull/10033)
* Add FrontendUtils class

* fix conflicts

* use locator

* restore click usage

* fix util
2023-06-30 09:08:14 +02:00
Paulo Arromba f1df8fb975 Add Cart/Checkout/Order-Received Templates (https://github.com/woocommerce/woocommerce-blocks/pull/9301)
* WIP: dirty attempt to dry run Cart & Checkout templates

* Added Cart and Checkout to the template hierarchies

* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates

* Updated cart & Checkout templates

* Order Received FSE template (https://github.com/woocommerce/woocommerce-blocks/pull/8937)

* Order Received template bootstrap

* typo

* WIP: new block

* add logic here

* Order received classic template

* reverted constants.ts

* Added the post title (buggy)

* Corrected page title

* Updated constants.ts

* Fixed template typo

* removed placeholder for order received block

* add order-received template description

* updated placeholder description

* Formatting fixes

* Template description.

* replaced hardcoded string with OrderReceivedTemplate::SLUG

---------

Co-authored-by: Luigi <gigitux@gmail.com>

* Code formatting (https://github.com/woocommerce/woocommerce-blocks/pull/8350)

* Code formatting

* page_template_hierarchy priority to 1 (https://github.com/woocommerce/woocommerce-blocks/pull/9323)

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Migrate Cart and Checkout Pages to the Template Editor when using a FSE theme (https://github.com/woocommerce/woocommerce-blocks/pull/9339)

* Introduce woocommerce_blocks_template_content hook

* Migrate cart and checkout page content to the template editor

* Add redirection from edit page to edit template

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Removed header and footer from checkout template. (https://github.com/woocommerce/woocommerce-blocks/pull/9378)

* Removed header and footer from checkout template.

* Removed header and footer from checkout template migration

* Permalink solution for the checkout endpoint/template (https://github.com/woocommerce/woocommerce-blocks/pull/9406)

* Checkout endpoint work

* Move setting field to util

* Include link to edit the template

* Remove todo

* Refactor checkout templates to share logic (https://github.com/woocommerce/woocommerce-blocks/pull/9411)

* Sync endpoints with pages (https://github.com/woocommerce/woocommerce-blocks/pull/9426)

* Switch to page syncing

* Update settings descriptions

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Migrate pages to templates once (https://github.com/woocommerce/woocommerce-blocks/pull/9488)

* Migrate content on init, once

* Skip migration if page does not exist

* Put back HTML for header and footer parts

* Fix page redirect due to wrong ID

* fix loading template part

* Removed unnecessary var

* update cart and checkout html templates

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Include a notice to redirect user to template editor (https://github.com/woocommerce/woocommerce-blocks/pull/9508)

* Template Placeholder Design for the Order Received Template (https://github.com/woocommerce/woocommerce-blocks/pull/9602)

* Load frontend styles in editor iframe

* Update placeholder to include skeleton and updated icons

* Update classic template configs

* 1px border for .wp-block-woocommerce-classic-template__placeholder-copy

* Show copy on focus

* Sample data

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Add simplified header on checkout template (https://github.com/woocommerce/woocommerce-blocks/pull/9607)

* Added simplified header on checkout template

* Moved simplified header to template part

* updated constants.ts

* added template part to checkout.html

* Add missing translation

* frontpage_template_hierarchy no longer needed

* Allow plugin based template parts (https://github.com/woocommerce/woocommerce-blocks/pull/9667)

* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates

* Synced templates on blockified folder

* Add blockified order-received.html

* removed WooCommerce prefix

* Refactor/rebrand order received template to order confirmation (https://github.com/woocommerce/woocommerce-blocks/pull/9734)

* rebrand order received to order confirmation

* updated descriptions for templates

* updated descriptions for order confirmation placeholder

* Resolve merge conflict

* Resolve merge conflicts

* Resolve more merge conflicts after rebase

* Fix formatting

* Use patterns for localisation (https://github.com/woocommerce/woocommerce-blocks/pull/9883)

* e2e tests for cart and checkout templates (https://github.com/woocommerce/woocommerce-blocks/pull/9939)

* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates

* Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates

* Resolve merge conflicts

* Add e2e for permalink settings

* Test that templates exist

* Add test to check that templates can be edited

* Add tests to confirm templates can be edited

* Ensure cart has contents before running tests on frontend views

* Commend out problem test

* Make sure search has multiple results

* Remove useThrottle - bad rebase

* Revert changes to docs after rebase

* Revert function call for noReviewsPlaceholder

* Bad rebase

* Reverts

* Remove revertTemplate

* Spacing

* Wait for networkidle after navigation

* Always wait for network

* Use button roles in site editor

* More specific button locator

* Update option comparison

* Fix template content

* Disable failing tests

* Disable failing classic template tests

* Use enterEditMode

* More enterEditMode usage

* enterEditMode

* Use test.skip

* More robust selectors

* Alt iframe selector

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Skip flakey test

---------

Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-06-29 14:41:22 +01:00
Luigi Teschio 0441e10623 Single Product Template: fix compatibility layer logic when the blocks aren't wrapped in a group block (https://github.com/woocommerce/woocommerce-blocks/pull/9982) 2023-06-27 18:16:18 +02:00
Luigi Teschio 1a77ce0da4 Fix Products block tests (https://github.com/woocommerce/woocommerce-blocks/pull/9951)
* fix Products block test

* test now

* fix test

* improve E2E test

* restore pw configuration

* change order

* remove timeout

---------

Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
2023-06-27 12:01:38 +02:00
Alba Rincón c0ddfa68d8 Update rating filter test to match the new logic (https://github.com/woocommerce/woocommerce-blocks/pull/9974) 2023-06-23 11:18:47 +02:00
Manish Menaria a6c1a2de52 Add E2E tests for Product Collection Block (https://github.com/woocommerce/woocommerce-blocks/pull/9825)
* Add E2E tests for Product Collection Block

This commit does the following changes:

1. Adjusts the .gitignore file to ignore the test-results and artifacts directories under all subdirectories named 'e2e-pw'.

2. Adds new E2E tests for the Product Collection block, specifically testing:
   - If the block renders correctly, including validating the number of product images, titles, prices, and 'Add to Cart' buttons.
   - If the sidebar settings correctly control the number of displayed columns.

3. Implements the 'ProductCollectionPage' class, providing methods to perform actions such as creating a new post, inserting a block, publishing a post, and locating various elements on the page.

4. Adjusts the directory structure for the E2E tests to improve organization and readability.

* Minor improvements

* Update E2E tests for Product Collection block sidebar settings

This commit updates the E2E tests for the sidebar settings of the Product Collection block. The changes include:

1. Refactoring the test assertions to use property accessors instead of method calls for the `ProductCollectionPage` class. This improves readability and consistency.

2. Updating the `ProductCollectionPage` class to initialize locators for editor and frontend elements separately. This allows easier differentiation between editor and frontend locators.

The test file `sidebar-settings.block_theme.spec.ts` has been deleted, as its functionality is now covered by the updated tests in `product-collection.block_theme.spec.ts`.

* Don't update package.json files

* Don't update gitignore file

* Add E2E test for order by control

This commit updates the E2E tests for the sidebar settings and order by control of the Product Collection block. The changes include:

1. Refactoring the test assertions and descriptions for improved readability and clarity.

2. Adding a new test case to verify the correct sorting of products by title in descending order.

3. Updating the `ProductCollectionPage` class to include a new method `setOrderBy()` to set the order by value in the order by control.

4. Adding a new method `waitForProductsToLoad()` in the `ProductCollectionPage` class to wait for the products to load in the block.

These changes ensure that the sidebar settings and order by control are functioning correctly in the Product Collection block.

* Minor improvements

* Add tests for "on sale" filter

* Add tests for Hand picked products filter

This commit updates the E2E tests for the handpicked products filter in the Product Collection block. The changes include:

1. Adding a new test case to verify that products can be filtered based on the selection in the handpicked products option.

2. Adding a new method `addFilter()` to the `ProductCollectionPage` class to select a filter option from the dropdown.

3. Adding a new method `setHandpickedProducts()` to the `ProductCollectionPage` class to set the handpicked products in the block settings.

These changes ensure that the handpicked products filter is functioning correctly in the Product Collection block.

* Verify that on sale filter works on frontend

Adding assertions to verify the count and presence of on-sale products in the frontend after publishing.

* Add tests for Keyword filter

This commit updates the E2E tests for the keyword filter in the Product Collection block. The changes include:

1. Adding assertions to verify that the products are correctly filtered based on the keyword entered.

2. Adding assertions to verify the filtered products in the frontend after publishing.

These changes ensure that the keyword filter in the Product Collection block is functioning correctly.

* Use fixture to setup product collection page

This commit refactors the E2E tests for the Product Collection block to improve test structure and readability. The changes include:

1. Refactoring the test structure using the `test.extend` function to define shared setup and teardown logic.

2. Moving the creation of the `ProductCollectionPage` instance to the shared setup logic.

3. Using the `pageObject` fixture in each test to access the `ProductCollectionPage` instance.

4. Removing duplicate code for creating the `ProductCollectionPage` instance.

These changes enhance the maintainability and readability of the E2E tests for the Product Collection block.
2023-06-20 10:56:12 +05:30
Thomas Roberts 3ebcd7f601 Add `CartEventContext` and dispatch events when pressing proceed to checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/7809)
* Add CartEventsContext with onProceedToCheckout event

* Wrap Cart in CartEventsProvider

* Dispatch onProceedToCheckout event when button is pressed

* Update type of children on CartEventsProvider

* Add test for ProceedToCheckout block

* Add tests for CartEventProvider

* Remove superfluous div

* Fix incorrect nesting after rebase

* Wrap mini cart in CartEventsProvider

* Dispatch onProceedToCheckout event when clicking button in mini cart

* Add tests for mini cart onProceedToCheckout emitter

* Make observer fail so navigation isn't attempted

* Prevent console error on navigation

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests

* Try preventing navigation in unit tests
2023-06-19 08:44:37 -07:00
Mike Jolley c30c6afc53 Wait for cart to be removed when emptied (https://github.com/woocommerce/woocommerce-blocks/pull/9829) 2023-06-14 16:59:21 +01:00
Alba Rincón 4cd22fb705 Create `Customer account` block e2e playwright tests (https://github.com/woocommerce/woocommerce-blocks/pull/9505)
* Create customer account block playwright tests

* Refactor after review

* Refacto after review
2023-06-05 14:39:11 +02:00
Luigi Teschio d85a6ecbd2 Blockified Single Product Template: add product-classes via `wc_get_product_class` (https://github.com/woocommerce/woocommerce-blocks/pull/9697)
* Blockified Single Product Template: add product-classes via wc_get_product_class

* Update src/BlockTemplatesController.php

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>

---------

Co-authored-by: Karol Manijak <karol.manijak@automattic.com>
2023-06-02 14:16:20 +00:00
Roy Ho cd84b4bed3 Add e2e tests for attributes count (https://github.com/woocommerce/woocommerce-blocks/pull/9500)
* Add e2e tests for attributes count

* Add test with pricing filter and turn on debug to prevent cache

* Prevent tests from passing if test page is not loaded

* Use WP wrapper to call WC CLI

* Refactor to use more of PW methods

* Use existing active filters block post for testing

* Move prepareAttributes function to global setup
2023-06-01 07:14:50 -07:00
Saad Tarhi bdf9a5e218 Fix local pickup e2e test (https://github.com/woocommerce/woocommerce-blocks/pull/9643)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-06-01 13:01:36 +01:00
Luigi Teschio f17a09340f Enable blockified templates (https://github.com/woocommerce/woocommerce-blocks/pull/9551)
* Enable blockified templates

* add html template

* fix function

* WIP

* Migrate Classic Block E2E tests to Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/9575)

* Add E2E tests

* add comment

* set worker to 1

* try now

* add beforeAll and afterAll hook

* restore woocommerce-gutenberg-products-block.php

* enable plugin with .wp-env configuration

* remove waitForNetworkIdle

* Products block: Add e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/9577)

* migrate classic block to Playwright

* fix can be inserted more than once tests

* migrate classic block to Playwright

* fix command

* remove old tests

* improve E2E tests

* skip test

* Products block: add E2E pw tests

* Add E2E tests

* fix E2E test

* test now

* try now

* rename path

* set one worker

* try now

* try now

* try now

* set 1 worker
2023-06-01 11:51:59 +00:00
Mike Jolley c6e0ca1d8b Combine country asset data to reduce the amount of data consumed by the cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9552)
* Combine countryData using shared util

* Update tests for shared util

* Update client to use countryData

* Avoid duplication of country names

* Use cart version of deep_sort_with_accents

* Update assets/js/settings/blocks/constants.ts

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update LocaleSpecificAddressField type

* Support nested arrays

---------

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2023-05-31 10:30:44 +01:00
Albert Juhé Lluveras 3b28b74777 Mini Cart: stop using Modal component (https://github.com/woocommerce/woocommerce-blocks/pull/9345)
* Remove unused styles

* Replace usage of Modal component with custom Drawer

* Update MiniCart.php class structure

* Update tests

* Prevent focus styles to appear unnecessarily when opening the Mini Cart drawer

* Work-around issue with disabled buttons causing lose of focus inside the Mini-Cart drawer

* Revert "Work-around issue with disabled buttons causing lose of focus inside the Mini-Cart drawer"

This reverts commit 4360f77384ad1f1d90a3ba8a0385ad79da2449f2.

* QuantitySelector: focus text input field after decrease or increase button become disabled

* Move focus to the input field also when the body has focus, that fixes the issue in Chrome

* Add explanatory comment
2023-05-16 10:41:26 +02:00
Albert Juhé Lluveras d236af2a8c Only show the Mini Cart count badge when there are items in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/9259)
* Only show the Mini Cart count badge when there are items in the cart

* Update badge to new design

* Add tests

* Make sure colors don't break existing themes

* Update Mini Cart e2e test
2023-05-11 17:23:36 +02:00
Albert Juhé Lluveras 2b6eef516b Update Mini-Cart block editor sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/9420)
* Update Mini-Cart block editor sidebar

* Rename Mini Cart block to Mini-Cart

* Update Mini-Cart block editor sidebar (II)

* Update two instances of mini-cart to uppercase
2023-05-11 14:52:03 +02:00
Karol Manijak 8d6344a07d Skip the failing test (https://github.com/woocommerce/woocommerce-blocks/pull/9405)
* Skip the failing test

* Add an explanation to the skipped test and eslint disable
2023-05-10 11:03:22 +02:00
Luigi Teschio 739fa60fea Improve the E2E testing process with Playwright (https://github.com/woocommerce/woocommerce-blocks/pull/9148)
* Add Playwright infrastucture

* improve documentation

* improve type

* remove puppeteer tests

* fix wp-env.json

* add link on how run E2E tests

* chore on playwright.yml

* remove unnecessary flush command

* improve stability E2E test

* remove build:e2e-test command

* Update .github/workflows/playwright.yml

Co-authored-by: Niels Lange <info@nielslange.de>

* Update .github/workflows/playwright.yml

Co-authored-by: Niels Lange <info@nielslange.de>

* Update docs/contributors/contributing/e2e-guidelines.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update docs/contributors/contributing/e2e-guidelines.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update docs/contributors/contributing/e2e-guidelines.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* remove emptyline and fix JSDoc warning

* add link about E2E guidelines

* fix theme name

* improve style

* improve markdown

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-05-05 11:03:36 +00:00
Albert Juhé Lluveras 349ae658bb Mini Cart drawer: print width in PHP (https://github.com/woocommerce/woocommerce-blocks/pull/9329)
* Mini Cart drawer: print width in PHP

* Remove unnecessary timeout

* Make sure classic themes have a Mini Cart contents width value set up
2023-05-05 11:44:41 +02:00
Thomas Roberts fdfb445a58 Prevent email address being removed when changing shipping method/entering shipping address (https://github.com/woocommerce/woocommerce-blocks/pull/9328)
* Preserve email when rendering shipping address form for the first time

* Ensure billing email does not reset when changing form values

* Add test to ensure email does not get overwritten
2023-05-03 06:45:57 -07:00
Luigi Teschio fed679cbeb Rename Add to Cart (https://github.com/woocommerce/woocommerce-blocks/pull/9315)
* rename Add to Cart

* fix E2E test
2023-05-03 10:31:59 +00:00
Mike Jolley 2d506f9f57 Fix/you do not need lodash (https://github.com/woocommerce/woocommerce-blocks/pull/9161)
* Remove lodash `without` usage

* isNumber

* Remove lodash `difference`

* Replace lodash isEmpty with type guard

* Replace isObject with type guard

* remove lodash noop

* Replace lodash clamp

* replace lodash uniqueId

* Remove uniqueId import

* Add eslint rule to restrict lodash import

* Replace lodash range

* Replace lodash has() function

Replace lodash has

* replace omitby

* Replace lodash isEqual with fastDeepEqual

* Replace kebabCase with change-case package

* Replace lodash camelCase

Replace lodash mapKeys with function

Move mapkeys to utility

Create camelCaseKeys which replaces usage of mapKeys

* Replace lodash debounce with custom utiity

* replace lodash keyby

* Replace lodash pick with native function

* Replace lodash cloneDeep with klona

* Replace snake case keys package with change case

* Replace sortBy with fast sort package

* replace isEmpty with type guard

* Replace pickBy usage in validation reducer

* Replace groupBy usage in search list control

* Replace flatten, uniqBy usage in getProducts()

* Remove setWith and clone from updateState

* Replace custom useThrottle with useThrottledCallback from use-debounce package

* onSelectRate can use-debounce

* Fix missing flatten

* Update assets/js/data/cart/test/push-changes.ts

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-28 11:29:45 +01:00
Tarun Vijwani 4934d19b6a Fix coupon code translation in e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/9247)
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-04-28 10:40:36 +04:00
Luigi Teschio 1d0ff02f8f Rename Add To Cart Form to Add To Cart Options (https://github.com/woocommerce/woocommerce-blocks/pull/9238) 2023-04-27 17:05:50 +00:00
Thomas Roberts 30aecd2068 Reinstate "Hide shipping costs until an address is entered" but disable it when using local pickup (https://github.com/woocommerce/woocommerce-blocks/pull/8964)
* Add class property to track local pickup enabled

* Force shipping enabled only when local pickup is also enabled

Otherwise, skip filtering and leave it to the current value

* Disabled and add text to WC Core hide shipping option

* Skip forcing shipping to be enabled in all cases

* Remove WC Core setting changes for hidden shipping rates option

* Add warning to local pickup UI about hidden rates setting in core

* Add local_pickup_enabled util function

* Revert "Skip forcing shipping to be enabled in all cases"

This reverts commit 0bf1886e73d791f7828ac86988f681cdce808b12.

* Check if local pickup is enabled before force enabling shipping

* Show correct shipping placeholder if rates hidden until address entered

* Remove tests for removed functionality

* Remove shippingCostRequiresAddress prop

* Update tests for shipping settings

* Remove irrelevant tests and fix existing ones

* Fix typo in comment

* Disable local pickup after each test

* Get shipping data from useCustomerData hook

* Change div in help prop to span

This prevents a DOM Nesting error, div cannot appear as a descendant of p

* Prevent hide shipping notice showing if the setting was originally off
2023-04-22 02:10:11 -07:00
Tarun Vijwani e39a27bd74 Add theme-level global styles to Cart and Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/8809)
* Dummy commit to open a PR

* Revert the last change

* Ensure Checkout block supports the theme-level global styles for `Colors » Buttons` (https://github.com/woocommerce/woocommerce-blocks/pull/8844)

* Add GS support for button colors in Checkout block

* Sync button hover effect with GB

* Fix link margin/padding (https://github.com/woocommerce/woocommerce-blocks/pull/8908)

* Replace <AddToCartButton /> with <ProductButton /> (https://github.com/woocommerce/woocommerce-blocks/pull/8914)

* Add GS support for button typography in Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/8918)

* Ensure Checkout block supports the theme-level global styles for Typography » Buttons (https://github.com/woocommerce/woocommerce-blocks/pull/8892)

* Remove classname from cart image to avoid conflicts (https://github.com/woocommerce/woocommerce-blocks/pull/8898)

Co-authored-by: Niels Lange <info@nielslange.de>

* Use consistent and semantically correct HTML elements in the Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/9065)

* Allow button height to adjust

* Ensure to display full width heading background

* Inherit font style and font weight for headings

* Inherit font style and font weight for textarea

* Inherit font family and font weight for buttons

---------

Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-04-22 00:11:10 +04:00