Commit Graph

657 Commits

Author SHA1 Message Date
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
Paulo Arromba 7c25db1c80 Add PHP 8.1/8.2 to unit testing matrix (https://github.com/woocommerce/woocommerce-blocks/pull/8757)
* Added PHP 8.1 to unit testing matrix

* Refactor unit testing to match Gutenberg repo 🤞

* Removed Gutenberg reference from debug information

* Updated image running phpunit binary

* Reverted image running phpunit binary

* Remove composer platform override

* Bump @wordpress/env and include phpunit

* Update phpunit and tests

* Change prefix

* Try admin context when install wc

* try wc install

* adjust phpunit config file

* Updated phpunit.xml.dist, composer.json and package.json

* Added PHP 8.1 to unit testing matrix

* Refactor unit testing to match Gutenberg repo 🤞

* Removed Gutenberg reference from debug information

* Updated image running phpunit binary

* Reverted image running phpunit binary

* Remove composer platform override

* Bump @wordpress/env and include phpunit

* Update phpunit and tests

* Change prefix

* Try admin context when install wc

* try wc install

* adjust phpunit config file

* Updated phpunit.xml.dist, composer.json and package.json

* Revert install changes

* updated npm packages

* updated composer lock

* updated check assets flow

* Updated check assets flow. Yaml file auto formatted.

* Updated check assets flow.

* Attempt at fixing E2E

* Reverted setup permissions step

* Add logging information to E2E

* Reverted E2E test flow

* test playwright perms fix

* test e2e perms fix

* test e2e perms fix

* test e2e perms fix

* test e2e perms fix

* languages update & debug

* languages update & debug

* revert

* force "@wordpress/env": "^4.9.0" on E2E

* update package lock

* update package lock

---------

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-21 12:07:37 +01:00
Albert Juhé Lluveras f92a4d8a13 Filter Products by Attribute e2e test: wait until networkidle before running tests (https://github.com/woocommerce/woocommerce-blocks/pull/9083)
* Wait until networkidle before running tests

* Copy logic to select first attribute from PHP classic template tests

* Create util function to insertProductByAttributeBlockWithFirstAttribute
2023-04-19 10:19:49 +02:00
Luigi Teschio a40f54e7f0 Single Product Template - Compatibility Layer: don't skip custom HTML (https://github.com/woocommerce/woocommerce-blocks/pull/9075) 2023-04-18 11:02:41 +02:00
Niels Lange e7f8a8cb6e WIP: Add Playwright setup (https://github.com/woocommerce/woocommerce-blocks/pull/9034)
* Set up Playwright

* Use caching in GitHub Actions

* Update tests/e2e-pw/README.md

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

* Rename “{blockName}” to “{blockName} block”

* Disable “no-console” for setup and teardown files

* Remove obsolete log and adjusted disabled ESLint definition

* Remove conditional logic from actions/upload-artifact

---------

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2023-04-17 19:01:41 +07:00
Alba Rincón 99efb908d3 Store API: allow searching by `slug` and include `slug` in the response (https://github.com/woocommerce/woocommerce-blocks/pull/9017)
* Add ProductBySlug, search by slug and return slug field for products

* Search for product variation

* Add slug to tests

* Sanitize the slug
2023-04-14 10:06:47 +02:00
Alba Rincón ad2003117e E2E tests fix: enable the attribute lookup direct updates settings (https://github.com/woocommerce/woocommerce-blocks/pull/9029)
* Enable the attribute lookup direct updates settings

We are importing products using the batch api and we need the lookup tables
to be updated immediately for our tests to work. Enabling this setting will
do that, instead of doing it asynchronously.

* Fix customer account test classes

* Increase timeout limit for failing tests

---------

Co-authored-by: roykho <roykho77@gmail.com>
2023-04-14 09:05:08 +02:00
Patricia Hillebrandt 8ae444b201 Filter data count mismatch > Fix PHP unit tests (https://github.com/woocommerce/woocommerce-blocks/pull/8984)
* Introduce the new get_attribute_and_meta_counts method.

* Ensure that if no term_slug or term_id is found for counting, the default list with all terms (with count equal zero) is returned instead.

* update conditional for the slug, the empty state for requests without filter attributes and the condition query for 'and'

* Introduce the get_terms_list method.

* Remove the legacy get_attribute_counts method and update its calls to rely on the new get_attribute_and_meta_counts method instead.

* Update the query to ensure that if a parent product has multiple identical attributes, they are counted once.

* Update to start relying on the get_product_by_metas method for counting product metas

* Add a new where_clause to only include product metas and attributes in the macro query if they are not empty.

* Add wpdb->prepare to the macro query and the get_terms_list method.

* Replace the raw atomic query for fetching the filtered terms with the new get_product_by_filtered_terms method.

* Update the request params for the get_attribute_and_meta_counts method.

* Update the request params for the product metas (min and max price).

* Update the query and returned value on get_terms_list.

* Update the validation for returning the default counts when no values are filtered.

* Update the query on get_terms_list to use ->prefix

* Update the  variable for the query to rely on the filtered one. Update the min_price and max_price format on get_product_by_metas.

* Ensure the get_product_by_filtered_terms method is triggered for each one of the filtered terms and update the macro query to include those term ids on the WHERE clause.

* Make adjustments for the 'and' condition to work as expected.

* Ensure the queryState.attributes is properly added as a param to the API request to correctly fetch the attribute count data.

* Ensure the get_product_by_metas method is only triggered when at least one of the metas in the request is not empty.

* Join type update: for the 'and' (all) filter condition, items with the count zero are not displayed.

* wpdb prepare the where clauses

* Update the get_product_by_filtered_terms query wpdb prepare params

* update the get_product_by_metas method's where clause preparation.

* Update the where clause preparation for get_attribute_and_meta_counts so we don't rely on interpolated variables anymore.

* Adjust the get_attribute_and_meta_counts method for usage alongside the rating filter.

* Adjust the query for fetching the attribute counts for filtered ratings.

* Add support for the filter by stock.

* Ensure the product attribute counts are correct if the parent product receives a rating.

* Ensure product_or_parent_id is used only when the filter by rating is used, not affecting price or stock filters.

* Add the missing else condition.

* Enable caching.

* Address CR

* Update query for average rating.

* remove file accidentally commited.

* When multiple ratings are selected, make sure the where clause is updated accordingly for each one of them.

* Start updating the stock_status logic to account for when multiple options are selected by the user.

* Ensure the counts are properly updated when more than one stock status is selected.

* Ditch the is_array condition for the average_rating counts as  is always an array.

* Deprecate the second param attributes for the get_attribute_counts method.

* Add the filtered_attribute to the transient_key

* Bypass cache if WP_DEBUG is enabled.

* Update formatting for macro query.

* Fix mixed tabs spaces on query

* Fix PHP unit tests for the new attribute counts.

* Update spacing/formatting for SQL queries.

* Minor: update indentation for the main SQL query

---------

Co-authored-by: roykho <roykho77@gmail.com>
2023-04-11 12:33:18 -03:00
Thomas Roberts eea5ea3aad Prevent error when entering postcode for countries without specific validation rules (https://github.com/woocommerce/woocommerce-blocks/pull/8987)
* Allow countries not covered by postcode-validator to pass validaiton

* Add "skipPushCheck" option when filling billing and shipping details

* Allow albania as a shipping/selling country

* Add test to ensure adding a postcode for a country without rules works

* Remove skipPushCheck option

no longer needed
2023-04-10 03:13:23 -07:00
Thomas Roberts 3d62b6da78 Set Cart and Checkout blocks to be wide aligned by default (https://github.com/woocommerce/woocommerce-blocks/pull/8899)
* Add default align attribute value for Cart block

* Add default align attribute value for Checkout block

* Update cart tests

* Check for not disabled insert button
2023-04-06 06:42:38 -07:00
Albert Juhé Lluveras b143048c81 Fix E2E tests with WP 6.2 (https://github.com/woocommerce/woocommerce-blocks/pull/8928)
* Update @wordpress/e2e-test-utils

* Remove WP 6.1 specific code

* Don't call switchBlockInspectorTab in blocks that don't have inspector tabs

* Typos and code styling fixes

* Make .toRenderBlock() more resilient

* Make sure we only open the Settings tab when the block has been selected

* Fix goToSiteEditor in WP 6.2

* Create insertAllProductsBlock util

* Create openSettingsSidebar util as an alternative to openDocumentSettingsSidebar so it works in WP 6.2

* Update WOOCOMMERCE_PARSED_ID

* Create enableApplyFiltersButton() util
2023-04-03 15:02:36 +02:00
Thomas Roberts 182c58d7d0 Add `additionalCartCheckoutInnerBlockTypes` filter to enable additional blocks in the Cart/Checkout blocks. (https://github.com/woocommerce/woocommerce-blocks/pull/8650)
* Add filter to change allowed blocks in Cart and Checkout blocks

* Add documentation for allowedBlockTypes

* Add test to check the filters work for the Checkout block

* Rename filter to additionalCartCheckoutInnerBlockTypes

* Update docs to reflect new name

* Add tests for additionalCartCheckoutInnerBlockTypes in Cart block

* Update Checkout test to reflect new filter name

* Update docs TOC to add example link
2023-03-28 05:33:28 -07:00
Albert Juhé Lluveras 38116064cb Remove code that disabled attribute lookup in e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/8849) 2023-03-28 12:48:34 +02:00
Seghir Nadir ad23e12dc9 fix shipping test (https://github.com/woocommerce/woocommerce-blocks/pull/8815) 2023-03-22 12:24:45 +01:00
Luigi Teschio f9cdca7625 Remove Single Product Block (https://github.com/woocommerce/woocommerce-blocks/pull/8763)
* Remove Single Product Block

* remove more files that belong the Single Product block

* fix php linter error

* remove Product Tag List and Product Category List blocks
2023-03-20 13:27:23 +00:00
Mike Jolley 68c6990872 Enhancement/local pickup order confirmation (https://github.com/woocommerce/woocommerce-blocks/pull/8727)
* Hide shipping address from local pickup order confirmation page

* Add pickup details to confirmations

* Error handling

* Update test because columns may be hidden

* use address selector

* Custom selector for local pickup

* try forcing flat rate during test
2023-03-17 14:15:13 +00:00
Tarun Vijwani 8a35fc0fcf Fix Local pickup e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/8745)
* Fix local pick-up e2e tests

- Change location_country select input to location_country_state select input in e2e tests.
- Remove location_state select input in e2e tests.

* Fix country/state value

- Change country/state value from 'US' to 'United States (US) — California'

* Add inline comment about same field for Country and State fields

- We merged the Country and State fields into the same field in the local pickup modal. Add inline comment in e2e test to avoid confusion.
2023-03-15 10:59:04 +04:00
Thomas Roberts 991e407fa9 Remove WC Core shipping settings if Cart/Checkout blocks are in use (https://github.com/woocommerce/woocommerce-blocks/pull/8679)
* Add CartCheckoutUtils class

This class will store reusable methods relating to Cart/Checkout Blocks, i.e. whether they are used on the Cart/Checkout page.

* Update ShippingController to use the new CartCheckoutUtils function

This will reduce code duplication when checking if the Cart/Checkout blocks are in use on the Cart/Checkout page.

* Add filter to remove shipping settings when Cart/Checkout are default

* Ensure setting displays correctly if cart is default but not checkout

* Add tests to ensure core shipping settings update correctly

* Add setCartCheckoutPages function to update set the cart/checkout page

* Force shipping to be enabled if the Checkout block is in use.

* Add filter to override cost requires address option

* Add shippingCostRequiresAddress option

* Check if the address is required before showing rates

* Show shipping rates in editor

* Add shippingCostRequiresAddress attribute to shipping methods block

* Update frontend type to show shippingCostRequiresAddress is a prop

* Add control to toggle shippingCostRequiresAddress option

* Show address notice in the correct scenario

* Send shippingCostRequiresAddress to Block in front end context

* Add e2e test for editor control

* Add e2e tests for shipping options on the front end

* Add updateAttributeInSiblingBlock function

* Add shippingCostRequiresAddress to shipping method block

* Ensure attribute is updated in both blocks when editing

* In Shipping Methods Block, show correct component based on block setting

* Show correct block in editor

* Remove broken test from PR

* Clean up updateAttributeInSiblingBlock

* Add setCartCheckoutPages function to update set the cart/checkout page

* Add tests to ensure core shipping settings update correctly

* Add isAddressComplete function

Borrowed from woocommerce/woocommerce-blocks#8141

* Check if the address is required before showing rates

* Show shipping rates in editor

* Show address notice in the correct scenario

* Add e2e tests for shipping options on the front end

* Ensure errorId is passed to StateInput

* Add fullShippingAddressPushed action to wc/store/cart

* Add fullShippingAddressPushed case to reducer

* Ensure fullShippingAddressPushed is set when initialising cart store

* Add fullShippingAddressPushed selector and default state entry

* Add shippingAddressHasValidationErrors util function

* Do not overwrite addresses when selecting a rate

* Set whether full address has been pushed when saving address changes

* In Shipping Methods Block, show correct component based on block setting

* Don't show from price if rates should be hidden until address entered

* Check city validation errors to assert if shipping address is valid

* Rename merchant.js to merchant.ts

* Move local pickup functions to common merchant util

* Update local pickup tests to use common merchant utils

* Add test to ensure setting toggles in both blocks

* Add navigating to settings and saving in merchant util

* Create addPickupLocation merchant util

* Add test for local pickup and require full address

* Make sure correct conditions are met to show shipping options

* Ensure checkbox is checked during local pickup tests

* Unset the checkbox when tests are finished running

* Update checkout block fixture

* Prevent error in unit tests

* Import validation store key from constants

Required because importing from the index causes the validation data store to register twice

* Update checkout terms test to wait for button not to be disabled

* Revert "Add isAddressComplete function"

This reverts commit 9967dc0d4f10cf638859ae085e6f4cc2901dd299.
2023-03-13 11:49:28 +00:00
Thomas Roberts f708214246 Add E2E test for third-party local pickup methods (https://github.com/woocommerce/woocommerce-blocks/pull/8543)
* Add third party local pickup method to woo-test-helper plugin

* Add test to check for checkout with local pickup

* Ensure local pickup is disabled when done with tests

* Add a more reliable selector for the "use same address for billing" box

* Prevent local pickup rates showing if local pickup is not enabled

* Check billing details after placing local pickup order

* Change local pickup unit test so rates dont show if localPickup disabled

* Use existing const instead of getSetting

* Update tests to mock constant from @woocommerce/block-settings

---------

Co-authored-by: Niels Lange <info@nielslange.de>
2023-03-13 10:45:48 +07:00
Thomas Roberts 9cba7ed8ad Add tests to ensure dirty props are re-pushed if the original `pushChanges` request fails (https://github.com/woocommerce/woocommerce-blocks/pull/8648)
* Add tests for pushChanges and dirty props

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

Co-authored-by: Mike Jolley <mike.jolley@me.com>

---------

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-03-06 20:52:36 -08:00
kmanijak dac10d58f3 [Products]: Fix attributes filters that do not update the editor preview correctly (https://github.com/woocommerce/woocommerce-blocks/pull/8611)
* Merge tax_query of attributes and visibility taxonomies when building Products query

* Add tests confirming the tax_query is merged correctly

* Improve syntax after code review
2023-03-06 14:36:40 +01:00
Alba Rincón 08d5e0af16 Fix add to cart form test (https://github.com/woocommerce/woocommerce-blocks/pull/8622) 2023-03-03 13:02:36 +01:00
Alba Rincón 7245ca519e Make the start shopping button show the theme style (https://github.com/woocommerce/woocommerce-blocks/pull/8567)
* Make the start shopping button show the theme style

* Center the button

* Fix test
2023-03-03 10:55:28 +01:00
Luigi Teschio 8c35002247 Single Product Template: Add compatibility layer (https://github.com/woocommerce/woocommerce-blocks/pull/8442)
* Add minimum structure for Single Product Details block

* Add Product Image Gallery woocommerce/woocommerce-blocks#8233

Add Product Image Gallery

* Add tests for Single Product Details block

* Add the initial basis for the Add to Cart button

* Trigger the single product add to cart action for each product type.

* wip: create block structure and add initial styles

* Add block details to the SingleProductDetails.php file

* Rename the block from add-to-cart-button to add-to-cart-form

* Update to use the cart icon.

* Implement the skeleton for the editor preview.

* Render tabs title with empty content

* Use woocommerce_output_product_data_tabs function to retrieve tabs data

* Update styles and add Notice for the display in the Editor.

* Update CSS.

* Add base tests for the new Add to Cart Form component.

* Add Product Image Gallery block

* remove support global styles

* remove support global styles

* Update the button CSS.

* Remove customizations for the Single Product Details block

* Update styles for the cart form.

* update td style.

* Update divs and CSS.

* Use conventional input instead of the experimental InputControl

* address CSS feedback

* add support for the custom classname

* remove save function

* Remove unnecessary console.log from the Edit.tsx file

* Remove block classname from block wrapper

* Remove unnecessary WooCommerce tabs filter from the BlockTemplatesController

* Remove attributes property from the block registration

* Remove isExperimental flag for the Single Product Details block

* Remove get_classes_and_styles_by_attributes method from SingleProductDetails block

* Prevent Single Product Details block from apppearing in Pages or Posts

* add second parameter to the subscribe function

* Implement the new design and copy provided for the editor.

* Make the notice compatible with dark themes.

* Some additional CSS tweaks

* adjust the padding for the input

* wrap the Single Product Template in a div with the product class

* Fix PHP Coding Standards warnings

* improve logic and increase coverage of unit test

* improve logic and increase coverage of unit test

* fix test

* format HTML

* fix edge case

* update @types/wordpress__data package

* update placeholder, icon and description

* update tsconfig

* update block name

* fix SCSS linter error

* address feedback

* create SingleProductTemplateCompatibility class

* Add Hooks compatibility

* remove not used file

* remove not used files

* Add compatibility layer for the Single Product template

* fix check

* address feedback

* remove unused import

* double empty line

* remove logic in the constructor

* remove hook

* generate the docs

* add missing hooks

* fix docs

* address feedback

* fix linter

* fix import

* Disable compatibility layer when the WooCommerce Product Grid Block block and WooCommerce Single Product Block are used (https://github.com/woocommerce/woocommerce-blocks/pull/8538)

* disable compatibility layer via hook

* update docs

* generate the docs

* fix version

* fix import

* fix code after merge

---------

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
2023-02-28 16:13:30 +01:00
Thomas Roberts d64881b260 Fix E2E tests - Wait for the Checkout to push changes before proceeding with tests (https://github.com/woocommerce/woocommerce-blocks/pull/8502)
* Wait for push changes before clicking place order

* Blur last field and wait for network requests when entering addresses

* Use correct quote style

* Add address_2 to fake test address

* Use correct property names when filling test address

* Use correct comment style

* Update address values to reflect what is in the config file

* Remove unnecessary waits

* Improve batch request checking when filling shipping and billing address

* Wait for network idle before selecting shipping address

* Add checkCustomerPushCompleted function

* Override checkout data with test email

* Fill in the checkout data when testing for terms and conditions text

* Improve comments

---------

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-02-24 06:27:56 -08:00
Albert Juhé Lluveras f742243c2e Fix e2e tests of the Product Details block (https://github.com/woocommerce/woocommerce-blocks/pull/8470)
* Fix e2e tests which use the insertBlock function

* Move more instances of insertBlock to insertWCBlock

* Ensure block inserter is open before searching for a block

* Get rid of openWidgetsEditorBlockInserter

* Rename insertWCBlocks to insertBlockDontWaitForInsertClose

* Fix e2e tests of the Product Details block

* Migrate to insertBlockDontWaitForInsertClose instead of insertBlock

* Go to single product template

* Fix Product Details classname and slug in tests

* Replace usage of 'foo' variable name

* Fix typo in 'can not be inserted in a post' test
2023-02-21 14:04:35 +01:00
Alba Rincón 9f035c6a51 Add more test to the BlockTemplateUtils (https://github.com/woocommerce/woocommerce-blocks/pull/8467) 2023-02-21 11:44:15 +01:00
Albert Juhé Lluveras 98efe7c43b Fix e2e tests related to inserting blocks (https://github.com/woocommerce/woocommerce-blocks/pull/8462)
* Fix e2e tests which use the insertBlock function

* Move more instances of insertBlock to insertWCBlock

* Ensure block inserter is open before searching for a block

* Get rid of openWidgetsEditorBlockInserter

* Rename insertWCBlocks to insertBlockDontWaitForInsertClose
2023-02-20 10:10:41 +01:00
Albert Juhé Lluveras fcd29f8c98 e2e tests: update close modal aria-label to match new versions of GB (https://github.com/woocommerce/woocommerce-blocks/pull/8459)
* Update close modal aria-label to match new versions of GB

* Simplify code based on PR feedback
2023-02-17 12:49:38 +01:00
Patricia Hillebrandt 9e0c20d43e Create the Add to Cart Form Block (https://github.com/woocommerce/woocommerce-blocks/pull/8284)
* Add the initial basis for the Add to Cart button

* Trigger the single product add to cart action for each product type.

* Rename the block from add-to-cart-button to add-to-cart-form

* Update to use the cart icon.

* Implement the skeleton for the editor preview.

* Update styles and add Notice for the display in the Editor.

* Update CSS.

* Add base tests for the new Add to Cart Form component.

* Update the button CSS.

* Update styles for the cart form.

* update td style.

* Update divs and CSS.

* Use conventional input instead of the experimental InputControl

* Implement the new design and copy provided for the editor.

* Make the notice compatible with dark themes.

* Some additional CSS tweaks

* adjust the padding for the input

* Update the icon for the block to match the core icon button
2023-02-16 11:43:37 +01:00
Alexandre Lara bd9295eb32 Add Single Product Details block (https://github.com/woocommerce/woocommerce-blocks/pull/8225)
* Add minimum structure for Single Product Details block

* Add tests for Single Product Details block

* wip: create block structure and add initial styles

* Add block details to the SingleProductDetails.php file

* Render tabs title with empty content

* Use woocommerce_output_product_data_tabs function to retrieve tabs data

* Remove customizations for the Single Product Details block

* Remove unnecessary console.log from the Edit.tsx file

* Remove block classname from block wrapper

* Remove unnecessary WooCommerce tabs filter from the BlockTemplatesController

* Remove attributes property from the block registration

* Remove isExperimental flag for the Single Product Details block

* Remove get_classes_and_styles_by_attributes method from SingleProductDetails block

* Prevent Single Product Details block from apppearing in Pages or Posts

* Fix PHP Coding Standards warnings

* update block name

* fix SCSS linter error

* move blocks into product-elements folder and rename to product-details

* avoid 404 error

* disable js asset enqueue

---------

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2023-02-16 11:18:16 +01:00
Luigi Teschio c13bf15862 Wrap the Single Product Template in a div with the product class (https://github.com/woocommerce/woocommerce-blocks/pull/8364)
* wrap the Single Product Template in a div with the product class

* improve logic and increase coverage of unit test

* improve logic and increase coverage of unit test

* fix test

* format HTML

* fix edge case

* address feedback

* fix name block and fix check

* wrap single product template only on the frontend
2023-02-15 10:27:18 +01:00
Alba Rincón 74e522e889 Set inherit default to true when products is inserted on archive product templates (https://github.com/woocommerce/woocommerce-blocks/pull/8375)
* Set inherit default to true when products is inserted on archive products templates

* Create new query attributes object

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

* Extract the products registration to a separate function

* Bring back variation name

* Move variation name

* Unregister the block before registering it again

* Use subscribe only on the site editor

* Undo change

* Try fixing tests

* Fix test

* Revert test only

---------

Co-authored-by: kmanijak <karol.manijak@automattic.com>
2023-02-13 16:36:38 +01:00
Thomas Roberts 73788d4378 Prevent coupon error being removed when blurring the input and fix tests (https://github.com/woocommerce/woocommerce-blocks/pull/8349)
* Prevent coupon error disappearing on blur if value unchanged

* Check for inline selector on coupon error

* Prevent coupon error disappearing on blur if value unchanged

* Check for inline selector on coupon error

* Update selector for coupon E2E test
2023-02-13 03:11:00 -08:00
Tarun Vijwani ee9a1e9ed1 Change coupon component label to "Add a coupon" (https://github.com/woocommerce/woocommerce-blocks/pull/8385)
- Revert the label change  to "Add a coupon"  so that it will be merged to WC Core and translation for the new string will be available.

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2023-02-10 00:56:30 +01:00
Mike Jolley aeed7b22b0 Update Cart/Checkout Default Template Styling (https://github.com/woocommerce/woocommerce-blocks/pull/8380)
* Switch default cart headings for cross sells to h2/h3

Fixes woocommerce/woocommerce-blocks#8193

* Style empty cart icon

woocommerce/woocommerce-blocks#8360

* Ensure editable content fields are transparent in the editor

woocommerce/woocommerce-blocks#8359 woocommerce/woocommerce-blocks#7007
2023-02-07 16:47:13 +01:00
Alba Rincón f695b92c1f Fix `catalog sorting` and `checkout` tests (https://github.com/woocommerce/woocommerce-blocks/pull/8292)
* Try fixing tests

* test

* Simplify tests

* Fix other tests

* Add comment
2023-01-27 20:52:10 +01:00
Patricia Hillebrandt 9563468dc1 Create Store Breadcrumbs Block (https://github.com/woocommerce/woocommerce-blocks/pull/8222)
* Initial structure for the breadcrumbs block

* ditch inline comment

* Fine-tune the store breadcrumbs

* Disable the breadcrumbs block for regular posts & pages

* Update the breadcrumbs block details.

* Add tests

* rely on sprintf to render the breadcrumb

* Ditch usesContext.

* Add a link to the breadcrumb editor preview

* Disable all pointer-events for the breadcrumb link in the editor preview

* Add the align attribute

* Use the Disabled component to prevent interactions and update the copy for the block description.
2023-01-27 18:31:13 +01:00
Luigi Teschio 77dbee8ed9 Fix E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/8263)
* Fix E2E tests

* skip catalog sorting E2E tests
2023-01-25 16:41:22 +01:00
Paulo Arromba d4806016c9 Fix/ Ensure variation data is populated with unspecified default attribute values (https://github.com/woocommerce/woocommerce-blocks/pull/8226)
* Fixes a bug where cart response only reflects variation data submitted and not full variation data with default values.

* Sort variation data by attribute alphabetically

* PHP unit test for checking variation data.
2023-01-25 13:03:44 +00:00
Tarun Vijwani 018af7c3af Change coupon component label to "Apply a coupon code" (https://github.com/woocommerce/woocommerce-blocks/pull/8254)
The "Coupon code" text was changed to "Add a coupon" and it resulted in the failing of an e2e test as it couldn't find the translated text for "Coupon code". The translation for  "Add a coupon" is not available so changing the text to "Apply a coupon code" until the next WC Core release since the translation for the text "Apply a coupon code"  is already available.
2023-01-23 16:11:44 +04:00
Alba Rincón fbd86f8762 Add Store Notices block (https://github.com/woocommerce/woocommerce-blocks/pull/8157)
* Block scaffolding

* Rename to store notices

* Register only in the site editor

* Update description

* Add woocommerce class

* Add tests

* Delete old test file

* Update notices message in the editor

* Remove customization

* Disable the block server side

* Fix TS error

* Add custom classes

* Reprashed test description

* Escape notices

* Remove unnecessary disabled component

* Only allow to insert the block once

* Improve class name

* Merge edit and block files

* Fix copy

* Simplify test case

* Remove align support

* Remove attributes

* Change editor markup

* Use the Notice component to display the notice placeholder on the editor

* Use sprintf to improve readability

* Inline component

* Remove styles and unregister scripts

* Use ordered placeholders

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Use info as the notices status

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix php lint error

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-18 13:40:30 +01:00
Alba Rincón 34c7fa95e1 Add Catalog Sorting filter block (https://github.com/woocommerce/woocommerce-blocks/pull/8122)
* WIP

* Render in editor and add styles

* Simplify select

* Undo change

* Update titles and description

* Wrapped text for translation

* Remove from products inner blocks

* Allow the block in the inserter

* Rename test file and add new tests for catalog-sorting block

* Register on the site editor only

* Fix tests

* Disable block server side

* Override the `enqueue_assets`

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix TS error

* Simplify edit

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Disable background color

* Add custom classes

* Remove alignment

* Inherit color and font properties

* Merge edit and block files

* Use sprintf to improve code readability

* Make fontsize small by default

* Add order placeholders and woocommerce class

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix floating issue

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Add woocommerce class

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 16:20:10 +01:00
kmanijak d00a21fbaf [Blockifying Product Archive Templates] Add Results Count block (https://github.com/woocommerce/woocommerce-blocks/pull/8078)
* Init setup to add a new block Results Count

* Render  template part as a content of ResultsCount block

* Switch to template part rendering

* Rename the block to ProductResultsCount

* Fix typo in BlockTypesController

* Change the ProductResultsCount class name

* Remove Product Results Count block from Product Query template

* Improve the way Product Results Count is rendered in the editor

* Add  prefix to places that missed renaming from ResultsCount to ProductResultsCount

* Remove unnecessary frontend.tsx file for ProductResultsCount

* Make sure global styles are applied and respected by Product Results Count block

* Make sure the Product Results Count is available inly in Product Catalog template

* Add basic tests to Product Results Count

* Remove empty line in style file

* Fix TS issue in Product Results Count

* Fix typo

* Override the enqueue_assets method to prevent unnecessary enqueue and 404 error on the frontend

* Add necessary property to block's metadata

* Address code review feedback

* Update description

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

* Remove disabled component

* Improve test description

* Merge edit and block files

* Remove align support

* Remove background support

* Simplify edit component

* Improve readability with sprintf and add custom class

* Simplify test case

* Add styles and order placeholders

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix markup to match with the frontend

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 16:19:42 +01:00
Tarun Vijwani 93441e2e52 Add coupon link instead of dropdown in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/7993)
* Add coupon link instead of dropdown in Cart and Checkout blocks

* Fix state names used for displaying the link and coupon form

* Fix storybook for coupon block

* Fix unit test for coupon block

* Fix css and accessibility

* Fix coupon block position on Checkout

* Update e2e test cases for coupon block (https://github.com/woocommerce/woocommerce-blocks/pull/8022)

* Update e2e test cases for coupon block

* Fix perfomance test for coupon block

* Fix double await typo

* Fix perfomance test for coupon block

* Remove CSS

* Use classnames to add and remove classes

Improved the code to use classnames to add and remove classes. Also, moved the logic to handle click and submit to separate functions.
2023-01-17 13:10:50 +04:00
Mike Jolley db96991492 Custom validation messages using the field name/label (https://github.com/woocommerce/woocommerce-blocks/pull/8143)
* Custom validation strings using a new function named getValidityMessageForInput

* getValidityMessageForInput tests

* Added integration test for error message

* Clear value

* update test strings
2023-01-13 15:54:35 +00:00
Nadir Seghir 7d874e736a Local Pickup: Refactor E2E tests for locations 2023-01-13 13:03:48 +01:00
Mike Jolley f2318060e1 Local Pickup: handle some UI issues
Duplicate selector

Convert to sentence case

Swap location and name in rate
2023-01-12 15:42:04 +01:00
Mike Jolley c49426570d React Based Local Pickup Settings Screen (https://github.com/woocommerce/woocommerce-blocks/pull/7581)
* Move payment methods

* Setup entrypoints

* Sortable implementation

* Sortable

* Basic UI in place for settings

* Hydrate real settings

* Form updates values

* Styling and save button placement

* useSettings hook

* Prepare for save

* delete

* Add location button

* Remove className

* Conditional display of taxes

* Save via API

* Update general settings to designs

* Modal styles

* Style table

* Border colors and radius

* Added e2e tests

* use node 16

* Enqueue states in admin

* Use render from wordpress/element

* Missing handle style

* Enable translations

* Remove curried function

* Todo for inline settings

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-01-12 15:40:15 +01:00
Tung Du e141e286a6 Fix broken E2E tests cause by edit template button class name change in latest Gutenberg release (https://github.com/woocommerce/woocommerce-blocks/pull/8107) 2023-01-09 23:44:53 +07:00
Tung Du 1fc5d2d91a E2E: Product Query: Popular filters presets (https://github.com/woocommerce/woocommerce-blocks/pull/7749) 2023-01-05 18:21:22 +07:00
Lucio Giannotta b81b8a9220 Product Query: Remove the “Products on Sale” Product Query variation (https://github.com/woocommerce/woocommerce-blocks/pull/7926) 2022-12-30 17:02:01 +01:00
kmanijak 95d5b51949 Include the types of Jest customer matchers for unit tests 2022-12-30 16:36:37 +01:00
Tung Du 8c24200e73 Update E2E tests for Gutenberg 14.8.x (https://github.com/woocommerce/woocommerce-blocks/pull/8050) 2022-12-30 18:47:33 +07:00
Niels Lange 46f0330a0a Use Woo Blocks instead Woo core translation within the Checkout order Summary block (https://github.com/woocommerce/woocommerce-blocks/pull/7995)
* Use Woo Blocks instead Woo core translation

* Activale previously skipped e2e tests

* Adjust loading order of $shared_chunks, $vendor_chunks and $chunks

* Revert chunk order of MiniCart.php
2022-12-23 19:54:04 +07:00
Luigi Teschio 0dd980998c Update @wordpress/e2e-test-utils package (https://github.com/woocommerce/woocommerce-blocks/pull/7955) 2022-12-22 16:47:23 +01:00
Alba Rincón a223af0ad5 Add 'Customer Account' block (https://github.com/woocommerce/woocommerce-blocks/pull/7876)
* Add empty 'Customer Account' block

* Add edit to render the block on the editor

* Add Customer Account icon to @woocommerce/icons library

This icon is used in the Customer Account block.

* Use customerAccount icon in the Customer Account block

* Add Block Settings to Customer Account block

Add Typography and Color settings to the Customer Account block that can be used during Edit mode.

* Add Customer Account style icons

This adds the customer account style icons to be used by the customer account block.

* Render the block in the frontend

* Add Display setting to the Customer Account block

This setting allow users to choose if they want to include an icon with the customer account link.

* Add icon style selector to Display settings

This adds an icon style selector in which users can choose the customer account link icon.

* Display on the frontend depending on the icon style

* Rename attributes

* Refactor block rendering

* Improve styling

* Make the account link dynamic

* Add alignment menu

* Get dashboardUrl with getSettings and add fallback

* Add link to account settings

* Add tests

* Fix test

* Change display title

* Split css file

* Switch to SSR

* Add styles to the front end

* Address latest feedback

* Remove experimental flag

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2022-12-22 16:01:01 +01:00
Albert Juhé Lluveras 86604e8945 Rename configurateFilterProductsByAttributeBlock() to configureAttributeFilterBlock() (https://github.com/woocommerce/woocommerce-blocks/pull/7970)
* Rename configurateFilterProductsByAttributeBlock() to configurateFilterByAttributeBlock()

* Rename configurateFilterProductsByAttributeBlock() to configureAttributeFilterBlock()
2022-12-20 17:19:20 +01:00
Tung Du b02b7f9348 Product Query: Add product visibility query support (https://github.com/woocommerce/woocommerce-blocks/pull/7951) 2022-12-19 21:05:16 +07:00
Thomas Roberts ebe05700ab Add notice on quantity change and update `wc/store/cart` to use thunks (https://github.com/woocommerce/woocommerce-blocks/pull/7938)
* Add receiveCart thunk

* Add mapCartResponseToCart helper

* Add getItemsPendingQuantityUpdate selector

* Update cart resolvers to be thunks

* Remove RECEIVE_CART action and replace with SET_CART_DATA

receiveCart will turn into a thunk.

* Add notifyQuantityChanges functions

* Remove receiveCart from action type definition, replace with setCartData

* Move apiFetchWithHeaders out of controls

This will just be a normal function since we'll be updating actions to thunks which will use this instead of a control.

* Include thunks in actions file

* Update receiveCart action to setCartData

* Update applyCoupon action to a thunk

* Update useStoreCartCoupons to get action from correct place

* Update StoreCartCoupon types

* Add types for Thunk and ThunkReturnType in mapped-types

* Change applyCoupon to a thunk

* Get applyCoupon, removeCoupon, receiveApplyingCoupon from useDispatch

This is to separate the concerns of actions vs. selectors. Previously the actions were fetched during useSelect which is not a pattern we use anywhere else in the codebase. Since we updated the MapToDispatch type, we can now get correctly typed thunks from the data store.

* Improve apiFetchWithHeaders typings

* Convert removeCoupon from generator to thunk

* Add applyCoupon and removeCoupon to CartAction type

* Remove unused old-style type-def

* Add receiveApplyingCoupon & receiveRemovingCoupon to StoreCartCoupon

* Correct issues with StoreCartCoupon type

These were not intended to reflect the actions in data store, rather the functions offered by the useStoreCartCoupons hook.

* Update applyExtensionCartUpdate to a thunk

* Update addItemToCart to thunk

* Add ResolveSelectFromMap type that works with thunks

* Add CartDispatchFromMap and CartResolveSelectFromMap types

We can add this to all data stores to get them working with thunks properly.

* Add docs and update generic name in ResolveSelectFromMap

* Add correct types for thunk resolvers in cart data store

* Update removeItemFromCart to thunk

* Update apiFetchWithHeaders to use generic

* Update selectShippingRate to thunk

* Update resolver tests to test correct thunk functionality

* Update updateCustomerData to thunk

* Update reducer test to reflect new action name

* Update comments on CartDispatchFromMap and CartResolveSelectFromMap

* Add quantity_limits to preview cart

* Make notices speak when shown

* Remove copilot comment

* Add isWithinQuantityLimits function

This is because we shouldn't show a notice if the quantity limits change, but the item's quantity is still OK.

* Add tests for notifyQuantityChanges

* Show notice when multiple_of is updated

* Update test to test for multiple_of changes

* Remove empty export

* Remove controls from cart data store

Not needed anymore since the exported value from the shared-controls file was empty.

* Export a control and async function for apiFetchWithHeaders

This is required because async functions cannot be called from sync generators.

* Use control version of apiFetchWithHeaders in the collections store

* Improve comments and remove incorrect TypeScript

* Update assets/js/data/cart/actions.ts

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update ResolveSelectFromMap to include selectors too

* Update TS in actions

* Use finally to remove duplicate code

* remove item pending delete/qty update after action runs in all cases

This will also reset the state when the request to remove it/change quantity errors

* Remove unnecessary type from param.

Not needed because we have TS now. The description can stay though, it is useful.

* Update snackbar wording to use active voice

* Remove old WP version check

* Set max quantity to high number instead of null

This would only happen in a niche case, and would require several TS changes to fix, so it's better to set it as a number here. 9999 should be high enough, and is the default quantity limit set below in get_product_quantity_limit

* Set code on woocommerce_rest_cart_invalid_key to 409

This is so the cart is returned in the response, so the client can update.

* Fix typo in comment and add CartSelectFromMap

* Remove unnecessary docblock

* Add getItemsPendingDelete selector

This is needed so we can show a notice for items that are unexpectedly removed from the cart. We need to know which ones are pending delete so we can skip showing the notice for them.

* Add type for notifyQuantityChanges args and change args to object

* Add notifyIfRemoved function

This will check items that have been removed and show a notice for them.

* Fix TS in receiveCart & pass itemsPendingDelete to notifyQuantiyChanges

* Update wording on removal notice

* Update types for notifyQuantityChanges args

* Update tests to reflect new wording and args being an object

* Check item is truth before running comparison of keys

* Update tests for unexpectedly and expectedly removed items

* Ignore print_r to satisfy phpcs

* Update PHP tests to reflect correct response code when deleting items

* Remove unnecessary controls and dispatch events directly from thunk

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-12-16 08:06:37 -08:00
Luigi Teschio e71a2fdbb0 Filter By Stock: Add E2E for the Product Query Block (https://github.com/woocommerce/woocommerce-blocks/pull/7937) 2022-12-15 14:36:54 +01:00
Niels Lange 0cd069e9ee Remove account creation setting from Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/7941)
* Remove account creation setting from Checkout block

* Add CartCheckoutFeedbackPrompt

* Adjust e2e test
2022-12-15 18:13:28 +07:00
kmanijak 6aa8a72f8e Add dropdown version of Filter by Stock Status (https://github.com/woocommerce/woocommerce-blocks/pull/7831)
* Extend Filter by Stock Editor options with dropdown and single/multiple choice

* Add dropdown implementation for Filter by Stock Status

* Adjust font-sizes to the rest of the filters

* Add tests to Filter by Stock: dropdown and list variants

* Change test file extension from .js to .tsx, so it handles types as well

* Add E2E test to Filter by Stock checking if display style can be toggled

* When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions

* Change the name of the filter blocks in the test files

* Remove unnecessary waiting step in E2E test for Filter by Stock

toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed

* Improve the STOCK_STATUS_OPTIONS type handling

* Extract onDropdownChange function instead of inline arrow function

* Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single
2022-12-14 08:16:37 +01:00
kmanijak 6d2ea8ef3a Add dropdown version of Filter by Rating (https://github.com/woocommerce/woocommerce-blocks/pull/7771)
* Rename the setting section to match Filter by Attribute

* Add Display Style toggle to the block settings

* Set list as a default value of displayStyle for Filter by Rating

* Add dropdown variant of Filter by Rating

* Extend the Editor settings with selectType: single or multiple

* Adjust the styles of a FormTokenField to other dropdown

* Align Editor settings order and wording between Filter by Attribute and Rating

* Fix the issue with cut off corners of dropdown borders

* Provide translated screen reader messages and placeholder

* Revert the label property, which is necessary to display checkbox list

* Make classname for Rating component optional and remove styling in Filter by Rating

* Cover the case when filter with zero products needs string methods for comparison

* Handle Typescript errors and add ts-ignore annotations when necessary

* Remove explicit key prop assignment in Rating component

* Remove leftover property in type definition

* Refactor JSX element extension with custom properties to more robust way with object copy

* Filter by rating tests (https://github.com/woocommerce/woocommerce-blocks/pull/7845)

* Filter by Rating tests:
  - List single
  - List multiple
  - Dropdown single
  - Dropdown multiple

* Adjust the font-size of Filter by Rating dropdown to the rest of the filters

* Fix E2E tests after the Editor settings label has been changed

* Improve sorting in Filter by Rating dropdown

With this change the order of options is always descending: in the chips, suggestions, active filters and URL

* Change the name of the filter blocks in the test files

* Prevent single dropdown input to overflow the wrapper

The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css

* Remove the unused styles of active options in Filter by Rating

Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then

* Change the approach of shared styles to fix the dropdown issue in filters

Instead of using direct classes, rewrite it to mixin and include in the filters

* Fix the Filter by Rating with Products block

The problem was with the Products block, that there was incorrect initial value of product ratings query

* Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2022-12-13 09:12:03 +01:00
Luigi Teschio 306ce007d0 Product Query - Enable "Inherit Query from template" option (https://github.com/woocommerce/woocommerce-blocks/pull/7641)
* Add Inherit Query from template option

* Update label
2022-12-12 16:06:25 +01:00
Mike Jolley bc17c19262 ValidatedTextInput fields should validate on mount (https://github.com/woocommerce/woocommerce-blocks/pull/7888)
* Validate on mount

* Update e2e text for email validation check

* Markdown linting
2022-12-08 12:14:14 +00:00
Tung Du e878431068 Product Query unit tests (https://github.com/woocommerce/woocommerce-blocks/pull/7747) 2022-12-08 08:48:42 +07:00
Luigi Teschio 9436488da4 Product Query: implement compatibility with Filter by Rating block (https://github.com/woocommerce/woocommerce-blocks/pull/7792)
* Product Query: implement compatibility with Filter by Rating block woocommerce/woocommerce-blocks#7631

Product Query: implement compatibility with Filter by Rating block

* address feedback

* address feedback

* add comment
2022-12-07 12:32:31 +01:00
Luigi Teschio 58f3217690 Remove workarounds for site-editing-templates tests woocommerce/woocommerce-blocks#7151 (https://github.com/woocommerce/woocommerce-blocks/pull/7568)
* Remove workaround for site-editing-templates tests woocommerce/woocommerce-blocks#7151

remove workaround for site-editing-templates tests

* bot: update checkstyle.xml

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-06 15:40:05 +01:00
Lucio Giannotta 99ba060720 Product Query: Polishing touches for the feature plugin debut (https://github.com/woocommerce/woocommerce-blocks/pull/7815)
* Product Query: add Feedback Prompt in inspector

The prompt doesn't appear at the very bottom as there isn't
currently any straightforward way to do this in the block variation.

More investigation is required.

* Product Query: Change icon, description and name

* Product Query: switch to Feature plugin flag

* Add all currently available atomic blocks to the default Product Query template

* Update feature flags doc

* Change SKU and Stock Indicator feature flags

* Change feature flags docs

* Add title prop to the `FeedbackPrompt` and add a title to the Product Query one

* Hacky solution to display the feedback block at the bottom

The order of the inspector controls is set in Gutenberg.
We can hack our way down by hooking to the “color” group and
display our feedback there.

Other panels would be displayed below that if added, such as borders
and margin.

* Reduce Product Query default template

* Fix e2e tests after Product Query block name change (https://github.com/woocommerce/woocommerce-blocks/pull/7840)

* Product Query: Add a better default pattern (https://github.com/woocommerce/woocommerce-blocks/pull/7833)

* Product Query: Add a better default pattern

* Product Price: Add bottom margin

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
2022-12-05 13:46:50 +01:00
Luigi Teschio 0517c06495 disable translations test for the Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/7776) 2022-11-29 12:16:30 +01:00
Albert Juhé Lluveras 91ff195c07 Rename Active Product Filters block to Active Filters (https://github.com/woocommerce/woocommerce-blocks/pull/7753)
* Rename Active Product Filters block to Active Filters

* Rename wc-block-active-product-filters__placeholder to wc-block-active-filters__placeholder

* Rename active filters fixture
2022-11-25 17:17:45 +01:00
Alba Rincón 304f2c3c23 Make `Products by category/tag/attribute` fallback to the `Product catalog` template (https://github.com/woocommerce/woocommerce-blocks/pull/7712)
* Add archive-product to the hierarchy

* Fallback to archive-product and get titles from blocks if the templates from theme don't have one

* Rename function

* Fix comment

* Add fallbacks to the db and blocks versions

* Add missing product attribute blockified template

* Update docs

* Add comment and fix comment type on wp_template

* Replate template name if we know the template in blocks

* Add comment and fix linting error

* Fix archive-product template

* Clone the fallback template from db to show them in the template lsit

* Return the fallback template when querying for a single template

* Remove unneeded condition

* Use wp function instead of gutenberg one

* Fix tests

* Fix tests on Product Catalog templates

It was checking a single product for the customization, but it should check the /shop page

* Disable tests related with deleteAllTemplates function
2022-11-24 16:45:39 +01:00
Luigi Teschio 1b55c5633b Product Query - Add E2E tests for the Filter by Attribute block (https://github.com/woocommerce/woocommerce-blocks/pull/7405)
* Product Query: Fix pagination issue

* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Price Block

* fix query relation

* fix on sale query

* Product Query - Add support for the Filter By Attributes block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Attributes block

* fix bugged pagination and on-sale filter after refactor

* address feedback

* Product Query - Add e2e tests for the Filter By Price block

* Product Query - Add e2e tests for the Filter By Attribute block

* fix comment

* fix comment

* remove not used import

* remove not used import

* address feedback

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-11-24 14:42:58 +01:00
Tung Du 418d33e22e E2E: Change label of product filters from `Product filters` to `Advanced Filters` (https://github.com/woocommerce/woocommerce-blocks/pull/7726)
* E2E: Change label of product filters from `Product filters` to `Advanced
Filters` to match with the updates from woocommerce/woocommerce-blocks#7687

* rename test file and test title to advanced filters

* E2E: Fix flaky test related to `waitForAllProductsBlockLoaded` (https://github.com/woocommerce/woocommerce-blocks/pull/7727)

* explain the reason for try/catch
2022-11-22 15:28:27 +01:00
Tung Du 65afb95e35 Product Query E2E tests: Sale and Stock status filters tests (https://github.com/woocommerce/woocommerce-blocks/pull/7684)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-21 08:08:12 +07:00
Luigi Teschio 21beb29442 Product Query - Add e2e tests for the filter by price block (https://github.com/woocommerce/woocommerce-blocks/pull/7351)
* Product Query - Add e2e tests for the Filter By Price block

* fix comment

* remove not used import

* update description

* update functions after merge

* improve check
2022-11-18 16:44:39 +01:00
Niels Lange 11815133d5 Fix various GitHub Actions warnings (https://github.com/woocommerce/woocommerce-blocks/pull/7573)
* Remove git checkout HEAD^2

* Add assertion to Cross-Sells e2e test

* Replace deprecated set-output calls

* bot: update checkstyle.xml

* Remove obsolete eslint-disable comment

* Change “actions/cache@v2” to “actions/cache@v3”

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-18 07:41:30 -08:00
Alba Rincón 87510929b5 Create the `Products by Attribute` template (https://github.com/woocommerce/woocommerce-blocks/pull/7660)
* Create the `Products by Attribute` template

* bot: update checkstyle.xml

* Fix typo

* Rename template to `taxonomy-product_attribute`

* Rename test template file

* bot: update checkstyle.xml

* Fix test enabling archives for shade attribute

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-16 14:37:41 +01:00
Tung Du e59c931a9b E2E: Fixing failed tests with Gutenberg (https://github.com/woocommerce/woocommerce-blocks/pull/7554)
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-11-16 08:52:51 +07:00
dependabot[bot] 9a7f1e17e1 Bump @woocommerce/eslint-plugin from 2.0.0 to 2.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6837)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-12 02:14:18 +07:00
Paulo Arromba f857afae0f Add PHP8 Unit Testing (https://github.com/woocommerce/woocommerce-blocks/pull/7528)
* fixed method sig

* Updated to @wordpress/env@5.5.0 and set default PHP 7.4 for wp-env.

* updated Coding Standards flow to use PHP 8.0

* Added comment to E2E flows explaining what PHP version is used

* Revert "Updated to @wordpress/env@5.5.0 and set default PHP 7.4 for wp-env."

This reverts commit 696cd7f42edc9d9726b777cf4f83a501a6d63936.

* Added comment to Unit test flows explaining what PHP version is used.
Specified PHP version on .wp-env.json

* Fixed composer-lock.json version.

* Updated tests to run on PHP Unit 9.2.6

* Updated tests to run on PHP 8

* Reverted test, mismatched results between local and pipeline

* Removed Todo

* Updated platform overrides

* Update Migrationb tests with Mockery for PHP8 compat

* try at PHP unit flow matrix

* Fix blocks.ini invalid config

* Temp disable E2E

* Downgraded woocommerce/woocommerce-sniffs as it introduced new sniffs we should be handling on a different PR

* re-enable E2E tests

* blocks.ini fix

* revert blocks.ini fix

* Update @wordpress/env

* remove .htaccess mapping

* Fix permissions for tests

* Debug permissions

* Attempt at perm fix

* Attempt at perm fix

* Downgraded @wordpress/env

* Another attempt at upgrade @wordpress/env

* Attempt at cleaning wp-env before run

* Attempt at destroying wp-env before run. Disabled E2E.

* Attempt at destroying wp-env before run.

* debug wp-env data

* attempt at deleting wp-env data (destroy won't work due to prompt)

* re-enable E2E

* Fix deprecation warnings

* Cleaned wp-env data for E2E

* Fix perms for E2E

* Updated RateLimitsTests

* debug

* Force 7.4 for wp-env

* Run sh outside of npm

* Reverted E2E flow

* reverted wp-env-config.sh debug test

* reverted .wp-env.json phpVersion force

* Update tests/php/StoreApi/Utilities/ProductQueryFilters.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartExtensions.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartItems.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Products.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/ProductCollectionData.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Batch.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Checkout.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartCoupons.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/ProductAttributes.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Cart.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* downgraded @wordpress/env to v4

* Reverted back to reflection class for pivate attribs manipulation on tests

* reverted JS unit testing job name

* Update tests/php/StoreApi/Formatters/TestMoneyFormatter.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Typo fix

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-11-09 15:28:08 +00:00
Tung Du fc4ce6dac6 E2E: Product Query: Testing atomic blocks (https://github.com/woocommerce/woocommerce-blocks/pull/7482)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-09 08:53:26 +07:00
Mike Jolley 07a612f575 Experiment: Add Rate Limits to Store API (https://github.com/woocommerce/woocommerce-blocks/pull/5962)
* Add rate limiting to cart endpoints based on session

* Handle nonce and rate checks in permission_callback

* Rate limit checkout only

* Debug

* Unused AbstractRoute

* Code standards

* Modify core rate limit table

* Add rate limit at rest api level, not route level

* Rate limit helper

* Remove rate limit from routes

* Usused dep

* Remove custom error logic no longer needed

* Remove dependency

* Remove custom permission_callback

* Hash IP and handle null

* Remove error response handler

* revert error_to_response changes

* Remove add_response_headers

* Remove IDENTIFIER

* Remove white space

* Increase limit

* Missing class comment

* Move rate limiting code within store api codebase

* white space

* Fix return type

* Check rate limit expiry greater than now

* Remove x- prefix

* reorder functions

* remove table

* pass request to add_nonce_headers

* return early and avoid elseif on AbstractCartRoute:get_response()

* Refactor get_ip_address() before implementing options for functionality

* Change rate limit to 5 requests

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Change rate limit window to 60 seconds

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Disable rate limiting by default

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Updated limits comment

* Example for Forwarded header

* Updated "woocommerce_store_api_enable_rate_limit_check" filter doc

* Added filter for the Store API rate limit check proxy support

* Add an action here that carries over the IP address being blocked.

* Added logic around setting the action_id, and returns an error when ip cannot be determined for users not logged in.

* Renamed action for limit exceeded.

* Common rate limiting header naming prefix, and fixed comment typos.

* Doc for Rate Limiting (wip)

* Example for Rate Limiting docs

* Remove private IP range block for rate limiting

* Refactored get_response() to add nonce headers to response instead of request

* Disable batching for Checkout calls to prevent bypassing Rate Limiting.

* Removed redundant arg.

* package-lock.json update

* Removed repeated func calls.

* Fix failing tests.

* Tests wip.

* Request limit and timeframe are now constants for RateLimits utility class.

* Tests for Rate Limit headers.

* Reverted PHPUnit config to enable all tests again.

* Update src/StoreApi/Authentication.php comment wording

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

* Removed possibly unnecessary get_ip_address() call.

* Changed wording on comment for get_ip_address() method.

* Simplified validate_ip() method.

* Fixed wrong header entry for "Forwarded" check.

* Unit testing for Authentication::get_ip_address()

* Comment explaining the reason to use ReflectionClass for testing get_ip_address().

* Support for error output outside batch request.

* MD linting.

* Refactor to implement options through a single filter.

* fixed md lint error and config file

* reverted accidental default func arg value removal

* re-enabled batch support for checkout

* action for limit exceed now also triggered in case we can't resolve the IP.

* Doc tweak.

* Return unresolved IP address when REMOTE_ADDR isn't set with proxy support disabled.

* Group unresolved ips for rate limiting

* Fixed bug where current limit wasn't properly initialized.

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-11-04 15:53:00 +00:00
Daniel Dudzic 2e7b0acce2 Filter by Rating: Add E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/7575)
* Filter by Rating: Add E2E tests
* bot: update checkstyle.xml

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-04 10:41:53 +01:00
Mike Jolley dd053d618d Fix/flakey checkout tests (https://github.com/woocommerce/woocommerce-blocks/pull/7508)
* Update installed to setup crosssells for all matching products in case of duplicates

* Improve shopper utils to wait for page elements to render

* Taxes should wait for totals wrapper

* Use shopper.block.goToShop()

* Inline docs

* Wait for errors

* partial match please fill error
2022-10-28 13:41:28 +01:00
Manish Menaria 71e77e38e0 Disable apply button when there is no change to selected filters (https://github.com/woocommerce/woocommerce-blocks/pull/7373)
* Disable apply button when there is no change to selected options

More info: https://github.com/woocommerce/woocommerce-blocks/issues/7116

* Add tests to the Filter Attribute block

Since we are making changes to the Filter Attributes block to fix issue woocommerce/woocommerce-blocks#7373, we are also adding tests to make sure the changes are providing the expected behavior

The setup-globals file was changed to add 'attributes' and 'has_filterable_products' properties to it, so it can be used in the tests.

* Merge test utils methods with attribute filter block

Removing test utils file and merging the methods with the Attribute Filter block to prevent tests from failing due to Jest configuration that only allow test files to exists inside a 'test' folder

* Remove checked.length === 0 condition

**Why was this condition needed before?**
Because when the user initially load the page, no filter is selected therefore we needed this condition to keep the Apply disabled in this case.

**Why we don't need it anymore?**
Because now in this PR we add following code:
```jsx
const activeFilters = getActiveFilters( attributeObject );
if ( activeFilters.length === checked.length ) {
	return checked.every( ( value ) =>
		activeFilters.includes( value )
	);
}
```
This will return `true` when the user initially loads the page & Apply button will become disabled. Therefore, I believe it's safe to remove `checked.length === 0` condition.

More info: https://github.com/woocommerce/woocommerce-blocks/pull/7373#discussion_r994737313

* Add filterSize param to test setup

With this configuration, it is now possible to modify the current filter size in order to improve tests

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2022-10-28 12:08:21 +05:30
Seghir Nadir 030b6f05a8 Calculate cart totals after running extensions (https://github.com/woocommerce/woocommerce-blocks/pull/7490)
* calculate cart totals afer running extensions

* update totlas call in CartUpdateCustomer

* test that cart is recalcing
2022-10-27 15:29:27 +01:00
Tung Du 5e008ad058 Fix failed E2E tests related to attribute filter block (https://github.com/woocommerce/woocommerce-blocks/pull/7472) 2022-10-25 16:12:04 +07:00
Tung Du aa8622d985 E2E tests for Product Query Block (https://github.com/woocommerce/woocommerce-blocks/pull/7386) 2022-10-14 10:25:02 +07:00
Darren Ethier b6e178fade Fix error with usage of Cart::deep_sort_with_accents (https://github.com/woocommerce/woocommerce-blocks/pull/6896)
* implement fix and tests

* fix linting issue

* fix tests

* doh add missing semi-colon

* fix tests

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2022-10-11 15:36:54 +01:00
Luigi Teschio 8c37c9411c Fix E2E test (https://github.com/woocommerce/woocommerce-blocks/pull/7206)
* WIP fix E2E test

* test now

* another attempt

* try now

* check now

* Update cart.fixture.json

* Update product-search-legacy.fixture.json

* Update product-search.fixture.json

* Update newest-products.fixture.json

* Update product-categories-list.fixture.json

* Update hand-picked-products.fixture.json

* Update featured-category.fixture.json

* Update best-selling-products.fixture.json

* Update top-rated-products.fixture.json

* Go to Mini Cart block page before executing its i18n tests

* Fix broken Mini Cart e2e tests

* Wait for selector to prevent flakiness

* try now

* try now

* try now

* add variable

* fix E2E tests

* fix js linting error

* use SHOP_CHECKOUT_BLOCK_PAGE variable

* update variable

Co-authored-by: Niels Lange <info@nielslange.de>
2022-10-10 12:42:59 +02:00
Tom Cafferkey 872788e13c Convert filter blocks to inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6978)
* register filter wrapper block

* register block variation

* rename the active filters wrapper

* prevent 404 error

* Revert "prevent 404 error"

This reverts commit 8b6cb7c6658b2a5a99b890b67f1dce8c1c51cdbf.

* render parent wrapper block

* support price filter block

* hide the active filter block from inserter

* swap the title of wrapper and inner filter block for active filters

* hide the legacy heading for the price filter

* update block title and description for active filters and price filter

* remove heading control for price filter

* remove heading control for active filters

* update pattern

* try: upgrade button

* limit the number of inner block to 2

* prevent removing the inner filter block

* Revert "prevent removing the inner filter block"

This reverts commit 83b7feed78a7a7f50fd5799d1706faa9f2fc9050.

* convert stock filter to inner block

* refactor block upgrade button to share between filter blocks

* update default heading

* update pattern

* update icon and title

* Fix stock filter error by importing translations package

* Upgrade Active Filters name to Active Filter Controls

* Add upgrade support to price filter

* Convert attribute filter to inner block (https://github.com/woocommerce/woocommerce-blocks/pull/7101)

* wip: convert attribute filter to inner block

* fix: render inner attribute filter block on the front end

* refactor: inner block wrapper, extract the attribute parsing logic into a utility

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Set correct attribute on the new filter blocks when they are upgraded

* Use the Warning component to display the upgrade message so it is consistent with Gutenberg

* address code review

* better detect legacy block to show the upgrade notice

* rename UpgradeToolbarButton to UpgradeNotice

* add upgrade notice to the stock filter block

* rename InnerBlockWrapper to BlockWrapper

* attribute-filter: control wrapper visibility

* passing block attributes down to inner active filters control block

* fix styling of inner attribute filter control block

* passing attribute to inner price filter control block

* passing down the attribute to inner stock filter control block

* remove unneccessary parsing

* use default scope for variations

* fix default attribute values

* use default block appender

* fix: lock control blocks

* remove dynamic title code from attribute filter block

* register active filters as variation and set it to the default that overrides the base block

* fix isActive for default variation

* fix: isActive logic for the active filters block

* register side effect

* fix ts error

* e2e: fix active filters block backend test

* e2e: fix frontend active filters test

* e2e: fix attribute filter test

* e2e: fix price filter test

* e2e: fix stock filter test

* e2e: update fixture

* e2e: fix attribute filter test

* remove invalid test

* e2e: update heading selector for price filter in backend test

* e2e: fixe backend price filter heading test

* fix: patterns i18n

* fix: heading level when upgrading the block

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-10-07 16:00:19 +01:00
Mike Jolley 6f93c5cf1b Store API - Cart JWT tokens/session handling (https://github.com/woocommerce/woocommerce-blocks/pull/5953)
* Re-apply token support

* Updated nonce headers

* Updated package-lock.json

* test commit to debug failing git hooks

* Revert "test commit to debug failing git hooks"

This reverts commit e64086b0a7aede154705be09c7b3433b08bc1e34.

* JsonWebToken utility class for generating and validating HS256 JWT tokens. Removed third-party JWT library.

* Add ext-hash to composer (required by hash_hmac())

* Removed unnecessary method param.

* Tests for retrieving cart contents via Cart-Token

* Removed token tests ( we can't properly test cart token functionality until we refactor the way it intercepts calls to replace the session object )

* Abstracted payload from JsonWebToken class. We can now use it to encode custom payloads and reuse them wherever we want.

* Fixed missing check for token expiration in the payload.

* MD lint error and config fix

* Update composer.lock

* Fixed bug using the wrong nonce header.

* Refactor to properly save session data based on cart token.

* Refactored DB queries to properly use prepared statement

* Removed underscore prefix for class attributes

* Fixed spaces instead of tabs indenting composer.json. Cleaned up .editorconfig

* Cleaned up borked .md comments.

* Comment for WP_SETUP_CONFIG check.

* Reverted SQL prepared statement for including table names.

* Used hash_equals() for signature comparison. Renamed some wrongly named properties.

* Updated composer.lock

* Reverted some accidentally removed lines on some documentation files.

* Reverted accidentally removed line on docs/internal-developers/testing/releases/404.md

* Changed param type from mixed to

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-10-03 11:49:32 +01:00
Thomas Roberts 3a49e0bd57 Revert "Include @wordpress/redux-routine in transformIgnorePatterns jest config"
This reverts commit 6b132358327ce9a36289e9f27defe7e28caee94a.
2022-09-28 13:45:42 +01:00
Thomas Roberts 28659ee653 Refactor registration of payment methods and update unit tests for payment data store (https://github.com/woocommerce/woocommerce-blocks/pull/6669)
* Mock getCartTotals

* Change test to use data store instead of context

* Move payment method context test to data store selectors

* Change description of test suite

* Bump commit to trigger tests

* Fix path in test

* update package lock

* Set correct state payment method reducer tests/use correct actions

* Get saved payment methods from store not context

* Mock stores and update tests to allow switching payment methods

* Update tests to get onSubmit from checkoutEventsContext

* Remove cartTotalsLoaded check from payment method initialize check

* Make PaymentMethods test wait until payments initialized

* initialize payment method data store when cart is loaded

* Remove unneeded actions and add initializePaymentMethodDataStore

* Remove check for cart totals loaded in checkPaymentMethods

* Remove updateAvilablePaymentMethods from registry

* Remove unneeded mock

* Remove unused import

* Rename imports to fix eslint errors

* Remove unused imports

* Remove return false from checkPaymentMethods

* Remove unnecessary setPaymentMethodsInitialized call

* Add todo comment to track refactoring opportunity

* Remove savedpayment methods from payment method context and rename it

* Rename payment method data context to payment method events context

* Add tests for setDefaultPaymentMethods

* Optimize the availablePaymentMethods state data

Store only the "name" attribute for now.

* Get list of payment methods from the registry instead of the store

We are using this hook to get some React elements in the payment method
object. So, we are getting the raw data directly from the registry instead
of the store.

* Fix payment state not loading on the Checkout edit page

* Handle checkout edit page case

* Fix infinite loop error on C&C Blocks

* Include @wordpress/redux-routine in transformIgnorePatterns jest config

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-09-28 13:45:42 +01:00
Niels Lange 77a2255978 Create 2e2 tests for Cross-Sells block (https://github.com/woocommerce/woocommerce-blocks/pull/6983)
* Create Cross-Sells product list

* Show “Read more” button for out-of-stock cross-sells products

* Update assets/js/blocks/cart/inner-blocks/cart-cross-sells-products/block.tsx

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

* Update assets/js/blocks/cart/cart-cross-sells-product-list/index.tsx

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

* Remove obsolete isLoading and placeholderRows

* Fix TS errors

* Rename crossSellsProduct to product

* Fix critical error

* Create 2e2 tests for Cross-Sells block

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-09-21 13:29:16 +07:00
Paulo Arromba 8a5dd65bc1 fix: Markup is visible in checkout error notices (https://github.com/woocommerce/woocommerce-blocks/pull/6800)
* Enabled __unstableHTML hidden option for HTML rendering within notices.

* Fixed margin-bottom for HTML notice content

* Fixed margin-top for HTML notice content

* Attempt to fix a broken e2e test
2022-09-20 16:54:25 +01:00
Luigi Teschio e4cd50a4ef Run test that does snapshot only when Gutenberg is disabled (https://github.com/woocommerce/woocommerce-blocks/pull/7142) 2022-09-14 09:04:15 +02:00
Luigi Teschio de433503c8 Fix e2e test - Filter products by stock block (https://github.com/woocommerce/woocommerce-blocks/pull/7137) 2022-09-13 17:16:59 +02:00
Tung Du a80426917f Product Search E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/7005) 2022-09-01 18:20:20 +07:00
Daniel W. Robert b2f98c2f51 Layout Updates to Active Filters Block (https://github.com/woocommerce/woocommerce-blocks/pull/6905)
* Reverse ordter of filter item name and close btn.

* Update layout & typography styles for block items

* Update chip ui view styles.

Additionally, add editor styles to have the editor match the rendered
frontend.

* Update additional remove button styles.

- Add hover state to remove button on chip layout.
- Update disabled styles to remove button in both layouts (mainly relevant
to the editor view).

* Adjust remove button colors.

Set hover states to shades of grey. Also set chip color and text to
match selected text color of the block.

* Update e2e test to account for new element order.

Since we're moving the remove button in the list view from the last
child node to the first child node, we need to adjust the expected order
of the active filter item text.

* Design and copy updates on the block settings

Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
2022-08-26 09:11:23 -04:00
Tung Du 6327094a49 Style the Filter by Price block based on the wrapper width (https://github.com/woocommerce/woocommerce-blocks/pull/6943) 2022-08-24 16:10:21 +07:00
Tomasz Tunik b295689571 Product search block as core/search variation (https://github.com/woocommerce/woocommerce-blocks/pull/6191)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-08-23 23:06:17 +07:00
Tom Cafferkey a07cc3c978 Update Filter by Stock block (https://github.com/woocommerce/woocommerce-blocks/pull/6883)
* Update Filter by Stock controls and UI to include custom checkbox and settings.

* Include and style Filter by Stock reset button

* Make checkbox accessible via keyboard

* Update snapshot tests for Filter Products by Stock component

* Update E2E tests with new label value

* Update label test for Apply Filters in E2E tests

* Specify checkbox type so styles are not overridden in the editor

* Update E2E test label for filter button

* Update label selector to search for containing text rather than exact match

* Escape quotation marks for label query in E2E shopper tests for Filter by Stock

* Correct typo on Filter by Stock controls

* Replace custom checkbox with CheckboxControl component from the checkout package.

* Remove opacity on product count for checkbox label so its the same color as the label.

* Update snapshot tests with new component usage for filter by stock

* Update block title from Filter Products by Stock to Filter by Stock

* Update reset button behaviour to clear selections immediately regardless of whether the Apply Filters button is active or not.

* Pass option value as ID to satisfy E2E tests

* Update snapshot tests for stock filter

* Reset checked state on reset for when they have filters checked but not applied.
2022-08-19 09:04:04 +01:00
Alba Rincón 8167f0afb4 `Filter by Attribute` block settings design update (https://github.com/woocommerce/woocommerce-blocks/pull/6912)
* Updata block title and description

* Update block settings to match designs

* Update block title in tests

* Update copy in test
2022-08-19 08:55:34 +02:00
Tung Du 0bea874c8d Fix: flaky test related to setMaxPrice (https://github.com/woocommerce/woocommerce-blocks/pull/6917) 2022-08-18 13:28:46 +02:00
Tung Du 401e7b5a70 Price Filter Block Design update (https://github.com/woocommerce/woocommerce-blocks/pull/6877)
* make toggle control full width

* add inlineInput attribute

* add inlineInput sidebar setting

* add inlineInput help text

* style the filter button

* style price input

* wip: reset button

* clicking on reset button will reset the price query

* support inline input fields

* price text styling update

* fix reset button font size

* add loading placeholder to all elements

* fix filter button style

* update range slider thumb and track style

* fix loading placeholder for non empty query

* move reset button into FilterSubmitButton component

* try: render placeholder serverside

* update filter button label

* Revert "try: render placeholder serverside"

This reverts commit 98f08efdb8048b8f78c7476b774d1128c1d31295.

* remove LoadingPlaceholder component

* remove Price: prefix from the current displayed price range

* update labels

* extract reset button as a dedicated component

* update price text section

* update reset button behavior

* avoid breaking filter submit button style for other filter blocks

* rename block to Filter by Price

* fix e2e test

* remove border support

* adjust padding for elments

* rename panel title

* Make the inline option enabled by default and fix frontend rendering

* Make the `Price Range Selector` uppercase

* Show `Reset` button only when a selection has been made

* Revert the `save` change to avoid the 'Block Recovery Prompt'

Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
2022-08-16 19:58:55 +02:00
Thomas Roberts d45ef84219 Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869)
* Add default page notice

* show notice all inner blocks

* support flow when page isnt saved

* switch from where we get the current post id

* update lock

* fix types

* Remove old compatibility notices from Cart and Checkout

* Move useCompatibilityNotice to sidebar-compatibility-notice directory

* Remove old CartCheckoutCompatibilityNotice

* Create sidebar compatibility notice hoc

* Add isCartOrCheckoutOrInnerBlock function

* Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func

* Remove BlockSettings from checkout edit and export from checkout-shared

* Change so component still renders, it is just hidden with display: none

This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time.

* Set the priorities of the hoc filters so compat notice renders first

* Make isCartOrCheckoutInnerBlock a hook

* Remove old compatibility notice related tests

* Remove BlockSettings from Cart

* Remove withDefaultNotice hoc

* Include DefaultNotice in compatibility notice

* Remove DefaultNotice from Checkout

* Rename withSidebarCompatibilityNotice to withSidebarNotices

This is because it includes the sidebar compatibility notice and the default notices

* Remove useIsCartOrCheckoutOrInnerBlock hook

* Remove compatibility notice code from tests

* Revert DefaultNotice back to the old one

* Remove unused components

* Remove withBlockSettings HOC and fix TS types

This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks

* Remove CartCheckoutFeedbackPrompt from BlockSettings

It will be included in sidebar-notices instead

* Fix TS Types in DefaultNotice

* Add BlockSettings to cart and checkout edit

* Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)

* Show "Feedback prompt" for all inner blocks

* Fix the "feedback" notice position for these blocks

The "checkout fields", "checkout billing address" and
"checkout shipping address" have the addressFields option which
gets rerendered and placed at the bottom of the inspector controls.

* Tidy up the address-fields hoc

* Use correct block name to check for billing or shipping address

* Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)"

This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f.

* Add hack to get feedback prompt to render last

* Fix TS errors for context and attributes

* Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols

* Do not include feedback prompt if on an address block or contact info

* Remove unused hoc for address fields

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 15:23:08 +01:00
Tung Du dc66942cbb Fix: Attribute filter flaky test (https://github.com/woocommerce/woocommerce-blocks/pull/6862) 2022-08-09 08:30:11 +07:00
Tung Du fcedd5174f Fix: flaky tests related to setMaxPrice (https://github.com/woocommerce/woocommerce-blocks/pull/6856) 2022-08-05 16:37:44 +07:00
Tung Du b5cc976905 E2E: Try improving product list loading state detection and fix Site Editor URL (https://github.com/woocommerce/woocommerce-blocks/pull/6811)
* e2e:try: detect loading state for product list

* fix: always use site-editor.php

* wait for price filter to be applied before checking the result
2022-08-03 16:22:37 -04:00
Tung Du 862477f9aa Remove compatibility notice from Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/6803) 2022-08-01 18:01:57 +02:00
Luigi Teschio 1761da37cd fix E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/6639) 2022-07-18 11:38:49 +02:00
Paulo Arromba 678fa6bff0 Add: Cross-sells for the Store API Cart response. (https://github.com/woocommerce/woocommerce-blocks/pull/6635)
* Added Cross-sells object and schema for the API Cart response.

* Cross-sells are now WC_Product objects that pass through the visibility filter.

* Removed redundant check.

* Updated function doc comment.

* Cleaned up imports.

* Cross-sells item schema (extension of ProductSchema) was removed, and replaced by ProductSchema itself. Cross-sells are direct product representation, and extending this goes out of scope for the task at hand.

* Unit testing for cart response containing cross-sell products.
2022-07-13 15:02:49 +01:00
Luigi Teschio 4aaaebe0c0 Disable render blockified Product Grid Block (https://github.com/woocommerce/woocommerce-blocks/pull/6660)
* Disable render blockified Product Grid Block

* try now
2022-07-06 14:16:32 +02:00
Alba Rincón 75184ae22d Add migration strategy and load blockified templates (https://github.com/woocommerce/woocommerce-blocks/pull/6538)
* Increase `schema_version` to add the new `wc_blocks_use_blockified_templates` flag

If the schema version stored on the db is <= 260 means the plugin is being updated
to the new version and we should keep using the old templates, not the blockified ones.

* After the theme is switched we check if we need to update the flag to
start loading the blockified templates or not.

* Get the templates from the blockified folder if the flag is set to true on the db

* Add temporary blockified template for testing purposes

* Inline variable

* Improve comment

* Use blockified templates on new installs with block themes only

* Don't use blockified templates when switching to a non FSE theme

* Fix condition

* Add tests for the option value

* Move the check to use blockified templates

* WIP

* WIP

* Add migration strategy

* Move the blockified templates to the templates folder and filter them depending on the option

* Fix tests and start using the Options constants

* Fix migration, the `should_use_blockified_product_grid_templates` and tests

* Rename tests and move to Utils folder

* add Migration class test

* try

* remove PHP

* add composer

* Replace the blockified templates with a temporary version

* Fix tests

* add comment

* Add feature gating for experimental builds

* Inject the package to the controller

* test

* Change blocks.ini

* debug

* Remove debug info

* fix test

* fix tests

* try now

* using composer cache

* install deps

* test

* Remove unnecessary extra key

* Add cache actions

* Undo tests change

* Fix readme format

Co-authored-by: Luigi <gigitux@gmail.com>
2022-07-06 09:51:39 +02:00
Brian 2328ca3f4f Add Footer Template Part (https://github.com/woocommerce/woocommerce-blocks/pull/6596)
* Adjust template with tagname footer

* Adjust template with tagname footer

* Adjust template with tagname footer

* Adjust template with tagname footer

* Adjust template with tagname footer

* Update e2e tests snapshots

Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-06-22 16:31:20 +02:00
Michael P. Pfeiffer 521f93619b Upgrade wp-prettier to 2.6.2 and reformat the codebase (https://github.com/woocommerce/woocommerce-blocks/pull/6566)
* Remove mixed tabs and spaces in tsconfig.json

* Update formatting in json files

* Upgrade wp-prettier to 2.6.2
2022-06-15 11:56:52 +02:00
Luigi Teschio 04ebfd2264 Fix E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/6415)
* Fix E2E tests woocommerce/woocommerce-blocks#6415

Fix E2E tests

* Add full state in customer data and exclude it from details check

* update webpack configuration

* Revert change to combobox index

* don't splitChunk frontend scripts

* simplfy output folders

* reduce minimum chunk size to 10kb

* add all inner blocks for loading

* better splitChunks

* update translation code

* wait for scripts

* try sleeping

* fix loading translation

* fix tests for mini cart

* simplfy po logic

* automate loading chunks

* rename webpack group file

* rename block.json path

* remove test

* revert changes to webpack file

* fix loading of chunks

* revert changes to assets api as well

* restore wp-env json configuration

* restore .wp-env.json

* address feedback

* add comment

* address comments

* improve utils function

* install puppeteer

Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2022-06-13 11:15:29 +02:00
Luigi Teschio abd5c6afd1 Fix ESLint: use window.localstorage instead localstorage woocommerce/woocommerce-blocks#6442 (https://github.com/woocommerce/woocommerce-blocks/pull/6540)
Fix ESLint: use window.localstorage instead localstorage
2022-06-09 14:47:17 +02:00
Seghir Nadir 238ab01ab2 Refactor webpack splitting to fix missing translation (https://github.com/woocommerce/woocommerce-blocks/pull/6420)
* don't splitChunk frontend scripts

* simplfy output folders

* reduce minimum chunk size to 10kb

* add all inner blocks for loading

* better splitChunks

* update translation code

* wait for scripts

* try sleeping

* fix loading translation

* fix tests for mini cart

* simplfy po logic

* automate loading chunks

* rename webpack group file

* rename block.json path
2022-05-23 15:58:13 +01:00
Luigi Teschio 33a9e654ca Enable ESLint for E2E folder woocommerce/woocommerce-blocks#6410 (https://github.com/woocommerce/woocommerce-blocks/pull/6413)
Enable ESLint for E2E folder; fix ESLint errors
2022-05-23 14:05:30 +02:00
Luigi Teschio 38c8a2ae32 Add E2E tests for the Active Filters Block (https://github.com/woocommerce/woocommerce-blocks/pull/6393)
* wip

* set editor using env var instead

* fix attribute missing issue when watching the test

* wip php templates test

* Add E2E tests for the Filter Products By Price Block woocommerce/woocommerce-blocks#6363

add E2E tests for the Filter Products By Price Block

* Add E2E tests for the Filter Products By Price Block woocommerce/woocommerce-blocks#6363

add E2E tests for the Filter Products By Price Block

* create clickLink util

* Add E2E tests for the Active Filters Block woocommerce/woocommerce-blocks#6377

add E2E tests for the Active Filters Block

* Add E2E tests for the Filter Products By Attribute Block woocommerce/woocommerce-blocks#6322

add E2E tests for the Filter Products By Attribute Block

* Add E2E tests for the Filter Products By Stock Block woocommerce/woocommerce-blocks#6323

add E2E tests for the Filter Products By Stock Block

* improve checks

* improve checks

* improve checks

* remove globals.d.ts file

* replace waitForTimeout

* create clickLint utils

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-05-13 15:18:51 +02:00
Luigi Teschio 07e6878700 Add E2E tests for the Filter Products By Price Block (https://github.com/woocommerce/woocommerce-blocks/pull/6373)
* Add E2E tests for the Filter Products By Price Block woocommerce/woocommerce-blocks#6363

add E2E tests for the Filter Products By Price Block

* Add E2E tests for the Filter Products By Attribute Block woocommerce/woocommerce-blocks#6322

add E2E tests for the Filter Products By Attribute Block

* Add E2E tests for the Filter Products By Stock Block woocommerce/woocommerce-blocks#6323

add E2E tests for the Filter Products By Stock Block

* improve checks

* improve checks

* remove globals.d.ts file

* replace waitForTimeout
2022-05-13 14:15:33 +02:00
Luigi Teschio ac609f05dc Add E2E tests for the Filter Products By Stock Block (https://github.com/woocommerce/woocommerce-blocks/pull/6357)
* Add E2E tests for the Filter Products By Attribute Block woocommerce/woocommerce-blocks#6322

add E2E tests for the Filter Products By Attribute Block

* Add E2E tests for the Filter Products By Stock Block woocommerce/woocommerce-blocks#6323

add E2E tests for the Filter Products By Stock Block

* improve checks

* improve checks

* remove globals.d.ts file
2022-05-13 11:11:02 +02:00
Luigi Teschio ded12079cf Add E2E tests for the Filter Products By Attribute Block (https://github.com/woocommerce/woocommerce-blocks/pull/6355)
* Add E2E tests for the Filter Products By Attribute Block woocommerce/woocommerce-blocks#6322

add E2E tests for the Filter Products By Attribute Block

* improve checks
2022-05-12 17:15:53 +02:00
Artur Piszek 62024321b9 Fix relative include paths (https://github.com/woocommerce/woocommerce-blocks/pull/6365) 2022-05-06 09:46:54 +02:00
Tarun Vijwani 51495ff32c Meaningful comment for skipping the e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/6353)
* Added meaningful comment for skipping the tests if it's a WooCommerce Core process environment.

* Fixed the flag number for MiniCart
2022-05-05 12:19:38 +04:00
Tung Du 5930ee6a94 Remove custom ensureSidebarOpened() (https://github.com/woocommerce/woocommerce-blocks/pull/6359) 2022-05-05 07:14:07 +07:00
Tarun Vijwani 02a1b9f78d Remove redundant front-end Checkout block test case (https://github.com/woocommerce/woocommerce-blocks/pull/6352)
* Removed redundant front-end test case
2022-05-04 09:58:12 +04:00
Alex Florisca 2f9b54ae03 Try to fix E2E tests once and for all (https://github.com/woocommerce/woocommerce-blocks/pull/6337)
* Try to fix account.test.js

* Remove language installations for woo core and wp core and take screenshots

* Upload screenshots to artifacts

* npm install instead of npm ci

* Upload artifacts  not matter what

* fsdf

* fsdfsf

* remove screenshoting from account.test.js and only run checkout-terms.test.js

* Print NODE_ENV

* Better handling of overriding wp-env.json

* Run all tests

* Re-enable translations for WP and Woo

* Wait for Cart & Checkout blocks to load before moving on

* Uncomment github actions

* Try to fix shipping test

* fill checkout before placing order, duuuh

* Wait until networkidel0 instead of domcontentloaded for page navigations

* Fix account.test.js

* change visitBlockPage() to  use Promise.all()

* Remove screenshot taking

* I think Promise.all() is being funny and not throwing properly, testing

* wait for checkbox to be visible before clicking

* Remove try catch around Promise.all()

* Fix linting issues

* Remove screenshot dir

* Raluca feedback:

* Timeout back to 30000

* Login to merhcant before changing settings

* merchant.logout()
2022-05-01 12:33:58 +01:00
Tom Cafferkey 6fb43ed8cb Deprecate legacy filter widgets with block alternatives (https://github.com/woocommerce/woocommerce-blocks/pull/6299)
* Transform object for woocommerce_price_filter legacy widget to be replaced with block alternative

* Filter products by price transform

* Price Filter formatting

* Set set_filterable_product_data data on the widgets screen

* Prevent rendering the Price Filter block if there are no products to filter

* Prevent Classic Price Filter Widget from being available as a widget

* Transform layered nav classic widget to attribute filter block

* Allow Filter Products by Stock block to be added as a widget

* Allow Active Filters widget to be transformed to Active Filters block

* Set showFilterButton to true and showInputFields to false in the transform of Price Filter to minic widgets more

* Change displayStyle property to be display_type instead of incorrectly using title

* mock @woocommerce/settings for has_filterable_products setting

* try: add All Products block to render that filter on the front end

* Revert "try: add All Products block to render that filter on the front end"

This reverts commit 5ad09e964b77e5c6499b4134cf58d7a6c226424d.

* try: add all product block to bypass has_filterable_products check

* fix: backend e2e test for attribute filter

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-04-27 08:36:00 +01:00
Niels Lange f10bb2da82 Critical flows: Merchant → Checkout → Can adjust T&S and Privacy Policy options (https://github.com/woocommerce/woocommerce-blocks/pull/6211)
* Add test to check if T&C and Privacy links are visible

* Fix filling wrong type of form error

With a virtual product we shouldn't need to fill the shipping details
We need to fill the billing instead

* Fix undefined 'termsCheckbox' bug

* Fix terms checkbox name

* Activate test case

* Replace static URL with dynamic one

* Convert external plugin into mock

* Fix JS linting issue

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-04-25 10:48:54 +02:00
Luigi Teschio 881c202717 Make Filter Products by Stock block compatible with PHP rendered Classic Template block (https://github.com/woocommerce/woocommerce-blocks/pull/6261)
* Enable Attribute Filter block to work with the PHP rendered Classic Template block

* Check for presence of option before rendering it

* improve filter product by attribute

* fix pagination problem

* fix check when two filter block with same attribute are used

* fix filter by stock for PHP templates

* fix naming and comment

* Update filter key in ClassicTemplate

* Update stock filter block for PHP templates when the filter button is enabled

* Remove unused useEffect and fix ESLint error

* Set active stock filter and track using local state

* ESLint fix

* Remove unncessary dependencies from useEffect

Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
2022-04-21 08:28:41 +01:00
Tarun Vijwani 3e36dd40dc Critical flows: Shopper → Checkout → Can login to existing account and can create an account (https://github.com/woocommerce/woocommerce-blocks/pull/6147)
* Added test cases for user can login and create an account from Checkout block page
2022-04-21 10:47:22 +04:00
Alex Florisca 59b4da800b Cart & Checkout translations test use nl_NL (https://github.com/woocommerce/woocommerce-blocks/pull/6267)
* Cart & Checkout translations test use the already installed language nl_NL

* Extra timeout when checking for shipping and billing addresses

* wait for selector instead of increase timeout

* Change waitForSelector selector:

* Clean up

* Increase idleTime for waitForNetworkRequest

* Fix random timeouts and increase timeout of verifying shipping option

* feedack
2022-04-19 08:56:52 +01:00
Niels Lange 75f8de911a Allow running e2e test individually (https://github.com/woocommerce/woocommerce-blocks/pull/6230)
* Allow running e2e test individually

* Adjust ignore and root paths

* Simplify jest.performance.config.js

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-04-15 09:34:18 +01:00
Luigi Teschio bac2c59daa Add Product Search Results Template (https://github.com/woocommerce/woocommerce-blocks/pull/6219)
* Add Search Result Product Template woocommerce/woocommerce-blocks#6218

Add Search Result Product Template

* update title

* add E2E test for Product Search Results template

* renaming class

* update E2E tests
2022-04-14 11:45:00 +02:00
Tung Du ad85348151 Shopper → Mini Cart → Can view translated mini cart contents block (https://github.com/woocommerce/woocommerce-blocks/pull/6214) 2022-04-13 18:51:13 +07:00
Raluca Stan 0b18ff59bd Register missing C&C inner blocks and update fallback template for older C& C versions (https://github.com/woocommerce/woocommerce-blocks/pull/6195)
* Register missing C & C inner blocks and update fallback template for older C & C versions

This will fix the issues with missing order summary inner blocks: Coupons (both in C & C blocks) and the Cart header. The issue was happening because, for example, for Cart the coupons were registred on the on frontend, but it just wasn't forced in the attributes. Because it also wasn't added to the PHP fallback layout, the render function didn't include it. For the Checkout block the coupons inner block wasn't registered at all.

* Revert changes to Checkout.php, we don't need to test for inner blocks

* Revert "Revert changes to Checkout.php, we don't need to test for inner blocks"

This reverts commit fc39535f8476d02e35353374d9434a8723458cfa.

* Fix the returned template for older Checkout block iterations

* Fix Cart and Checkout templates to accommodate the Summary order inner blocks

* Hide coupon form div from inner blocks if coubons are not enabled

* Fix checkout coupon tests in checkout

They have been written for logged in user

* Fix Order Summary Heading inner block's default text

* Update comments with better wording

* Revert "Hide coupon form div from inner blocks if coubons are not enabled"

This reverts commit ab09021b923fad4218b3016e47760ad07f6bc960.
2022-04-12 12:20:22 +01:00
Jamel Noel Reid 64fcdda420 Add Product endpoint to ExtendSchema (https://github.com/woocommerce/woocommerce-blocks/pull/6122)
* Added ProductSchema Identifier

* Updated get_extended_schema & get_item_response

* Test for extensions field on products

* Updated endpoint extend Readme
2022-04-11 17:40:26 +01:00
Alex Florisca 5c396c4e26 Tidy up and organise e2e tests (https://github.com/woocommerce/woocommerce-blocks/pull/6206)
* rename some things

* Refactor e2e tests

* remove only from checkout test

* Typo in test

* Add --testPathIgnorePatterns performance back into package.json

* Niels feedback and fix a test

* Update import from utils
2022-04-11 11:52:33 +01:00
Alex Florisca 6c2d24e3e5 Fix/e2e tests timeout issue (https://github.com/woocommerce/woocommerce-blocks/pull/6165)
* Increase timeout of translations test to 30000

* Wait for network idle in goToCart and goToCheckout

* Increase timeout to 30000

* fix E2E tests

* try fix

* test

* test

* test

* another test

* fix test

* 60s timeout

* test

* Update product constants

* Simplify orderSummary check

* Go back to page.$

Co-authored-by: Luigi <gigitux@gmail.com>
2022-04-08 14:47:49 +01:00
Alex Florisca 0c7c2db6c0 Update @woocmmerce/eslint-plugin to 2.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6203)
* Update @woocmmerce/eslint-plugin to 2.0.0

* Fixed some eslint errors

* Fix syntax errors

* Fix most linting errors

* Feedback changes

* Fix one more eslint issue
2022-04-08 14:47:19 +01:00
Thomas Roberts d7a52b6f67 Check for performance file existence before running reporter (https://github.com/woocommerce/woocommerce-blocks/pull/6189)
* Check for performance file existence before running

* check reports/performance-report.json file exists on setup

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-04-06 12:22:51 +01:00
Thomas Roberts 10793e8e18 Try adding performance tests (https://github.com/woocommerce/woocommerce-blocks/pull/6119)
* Add performance script to measure load times of cart and checkout blocks

* Temp commit

* Temp commit

* Temp commit

* Remove specific test from performance e2e command

* Add performance reporter

* Add step to clean performance file before running tests

* Add test report constant & average and logPerformanceResult test utils

* Update uses of product name constant

* Add cart coupon performance test

* Check if report file is empty before parsing

* Limit performance tests to only ones in performance directory

* Round the averages and add a linebreak after each entry in the log

* Fix formatting of report and only output after all tests

* Log each loading metric as an individual data point

* Improve formatting

* Get load times in ms from profiler

* Revert changes to fixtures

* Remove trace.json from git

* Remove checkout test file (tests not implemented)

* Check performance log file exists before truncating it

* Fix checkout coupon test

* Remove console logs

* Revert to use virtual products after rename of constant

* Ignore performance tests when running regular e2e tests

* Feedback changes

* Tidy up

* Fix packag-log.json:

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-04-04 13:30:07 +01:00
Saad Tarhi c636cb1bbe Shopper → Checkout → Can apply single-use coupon once (https://github.com/woocommerce/woocommerce-blocks/pull/6174)
* Add "single-use" coupon to the fixture data

* Create a first draft of the coupon e2e test

* Create single use coupon code constant

* Create "applyCouponFromCheckout" function

* Remove the "single-use" coupon from the fixture data

* Setup coupon creation using Woo's Rest API

* Add single-use coupon E2E test

* Move discount XPath definition to the expressions file

* Clean comments

* Remove unnecessary delay function

* Refactor to a more human friendly check

* Clear the setup in the afterAll branch (delete coupon)

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-04-01 23:09:54 +00:00
Mike Jolley eb196226d8 WIP: Add Inner blocks to order summary (https://github.com/woocommerce/woocommerce-blocks/pull/6065)
* Sub/Total/Fee inner blocks

* Row blocks within the inner block

* Update icons

* Resolve stying issues

* Remove old block

* Pin totals row

* Locking logic update

* Heading inner block

* Refactor where inner blocks are defined

* Add todos

* Todo for Consider deprecating OrderMetaSlotFill and DiscountSlotFill in favour of inner block areas.

* Improve frontend registration of components using new entrypoint

* Experiment- external block context

* Revert "Experiment- external block context"

This reverts commit 4b75668ec7eb62f065c6a488cd942a666e26204f.

* Duplicate inner blocks to avoid conflicts with context

* Remove todo

* Rename block dir

* Some test fixes

* Fix import

* fix import

* linting

* Remove unused attributes

* Optional classname

* fix coupons import

* fix shipping mocks

* Styling

* Fix selectors in e2e tests

* Add back the wc-block-components-totals-wrapper class that was used for each segment in the totals Order summary

Because, removing them was:
-  a breaking change for the old structure
- was making it harder to target the inner blocks. Before the class was used to target each segment
- it was making the wc-block-components-totals-item behave as a child or parent depending on the inner block, inconsitency

* Reuse the TotalsWrapper component for C& C blocks inner blocks

This component was removed in this PR, but  we wrap components in the Cart and Checkout sidebar in a TotalsWrapper. This will ensure consistent spacing and borders are applied to items in the sidebar.

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2022-04-01 15:45:18 +02:00
Luigi Teschio 4f2f267cf8 Add tests for the Mini Cart Block when it is added on the FSE editor. (https://github.com/woocommerce/woocommerce-blocks/pull/6000)
* Add tests for the Mini Cart Block when it is added on the FSE editor woocommerce/woocommerce-blocks#5727

Add tests for the Mini Cart Block when it is added on the FSE editor

* not hardcoding selectors

* fix typo

* restore old searchForBlock function

* add export

* Revert "restore old searchForBlock function"

This reverts commit 7049ad85bc2752ad33933eec00da9682943ec35a.

* use searchForBlock from package only for FSE pages

* add fix for GB
2022-04-01 11:23:48 +02:00
Tomasz Tunik d62a126476 Ensure e2e tests work with TS (https://github.com/woocommerce/woocommerce-blocks/pull/6173)
* Cleanup e2e jest config from moduleFileExtensions

moduleFileExtensions by default support js, ts, tsx etc.

* convert legacy-template-blocks e2e test to TS

* clean up jest.config.json moduleFileExtensions

unnecessary defaults override
2022-04-01 10:22:54 +02:00
Niels Lange 8943629a86 Shopper → Checkout → Can have different shipping and billing addresses (https://github.com/woocommerce/woocommerce-blocks/pull/5860)
* Shopper can have different shipping and billing addresses

* Shopper can have different shipping and billing addresses

* Shopper can have different shipping and billing addresses

* Correct billing field IDs

* Remove unused variable

* Remove unused timeout

* Remove unused commands

* Activate company field using setCheckbox

* Deactivate company field using unsetCheckbox

* Remove obsolete command

* Empty cart before and after each test

* Remove obsolete import

* Check billing and shipping company

* Remove manual code with unsetCheckbox

* Fill company if field exist

* Get checkbox ID from label

* Remove duplicate company field toFill method

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-31 13:10:50 +02:00
Alex Florisca 1108c9994b Fix E2E Tests on trunk (https://github.com/woocommerce/woocommerce-blocks/pull/6154)
* Fire up CI

* Increase timeout after selector
2022-03-29 16:05:11 +01:00
Alex Florisca f344d192d9 E2E tests for translated Cart & Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6101)
* Translation tests for Cart & Checkout

* Remove comments
2022-03-28 16:20:59 +01:00
Alex Florisca 2459c05d42 Critical flows: Shopper → Cart/Checkout → Can use express checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6075)
* Test if express payment button is available on cart & checkout

* Remove unused uiUnblocked
2022-03-28 14:48:21 +01:00
Tomasz Tunik f7f1b89dc5 Upgrade @wordpress/scripts and /env packages (https://github.com/woocommerce/woocommerce-blocks/pull/6114)
* upgrade wordpress/scripts to 22.3

* update jest config/setup

* add explicit-exports-references plugin

to handle payment-method-config.tsx spying on external methods
the way code is output now changed and tests like this would not
work anymore as transpilet files were no longer using exports but
local references to methods.

* missing snapshot

* make cart-products E2E test more stable

* surppress eslint error in test file

* fix css stylelint issues

* update eslint-plugin-woocommerce eslint package

* remove temp test:e2e:start script

* re-run

* add stylelint as recommended extension

* remove redundant types (provided by packages now)

* patch update @testing-library/jest-dom
2022-03-28 15:00:20 +02:00
Tomasz Tunik e821983447 Improve goToSiteEditor E2E utils (https://github.com/woocommerce/woocommerce-blocks/pull/6109)
* dry getAllTemplates util

* Improve goToSiteEditor e2e util

It will now properly wait for page to load
and critical parts to be available before
handing control over to the next steps

* adapt site editing tests to new goToSiteEditor API

* try to stabilize the saveTemplate

to early navigation was causing the dreaded
"Expected an Error, but "" was thrown"

* try stabilizing saveTemplate

* contextually group/sort params

* improve clarity of the goToSiteEditor E2E util

- adds goToSiteEditor private helper that hides the temporary need
for handling theme.php and site-editor.php paths
- adds two exported utils goToTemplatesList and goToTemplateEdit
that hide UX details of waiting ofr page to be ready on load including special
case for waitingFor templates list actions to be loaded

* put back page where it belongs 
2022-03-28 14:32:15 +02:00
Tung Du 7d60c8fc66 Fix: Mini Cart: Ability to choose the drawer behavior when user add products to cart (https://github.com/woocommerce/woocommerce-blocks/pull/6052) 2022-03-26 07:32:23 +07:00
Saad Tarhi ba2308f729 Shopper → Checkout → Can see warnings when form is incomplete (https://github.com/woocommerce/woocommerce-blocks/pull/6116)
* Create "isLoggedIn" shopper function

This function checks if a shopper is logged in

* Add "Can see warnings when form is incomplete" test

* Optimize login check and logout process for the test

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-25 18:34:17 +01:00
Tung Du ed83dfbafa Shopper → Mini Cart → Can remove product (https://github.com/woocommerce/woocommerce-blocks/pull/5937) 2022-03-24 22:37:17 +07:00
Tomasz Tunik fdb8dde033 Fix site editor E2E tests for Gutenberg latest (https://github.com/woocommerce/woocommerce-blocks/pull/6080)
* Add handling of editor context via GUTENBERG_EDITOR_CONTEXT env var
* Fix flaky tests around editing templates
* Wait for save template response to complete
2022-03-23 14:18:00 +01:00
Saad Tarhi f8c5e910d2 Shopper → Cart → Can update product quantity (https://github.com/woocommerce/woocommerce-blocks/pull/6025)
* Add XPath expressions

* Add "setCartQuantity" utility function

* Add "productIsInCart" utility function

* Add "update product qty" e2e test

* Clean up test file

* Fix test on headless mode

* Add Increase/Decrease qty test cases

* Decrease the query chain for better maintainability

* Rename expression functions/file for more clarity

* Resolve conflict with trunk

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-23 13:51:56 +01:00
Niels Lange 9346e723f3 Shopper can place an order as logged in user (https://github.com/woocommerce/woocommerce-blocks/pull/6037)
* Shopper can place an order as logged in user

* Fill billing address for logged in user

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-03-23 13:23:22 +01:00
Tarun Vijwani 532952dd31 Critical flows: Shopper → Checkout → Can view empty checkout message (https://github.com/woocommerce/woocommerce-blocks/pull/6042)
* Added new test case for Critical flows: Shopper → Checkout → Can view empty checkout message
2022-03-23 15:17:48 +04:00
Niels Lange 512ae84b09 Shopper → Checkout → Can choose payment option (https://github.com/woocommerce/woocommerce-blocks/pull/5839)
* Shopper can choose payment option

* Empty cart before and after each test

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-03-23 12:01:33 +01:00
Alba Rincón 13311e7bee Rename Legacy Template block to Classic Template block (https://github.com/woocommerce/woocommerce-blocks/pull/6021)
The internal ID has been kept after a comment by @tjcafferkey. This causes a
bit of inconsistency in the internal code, but it was deemed that it would have
been better as users who have customized templates using this
blocks ID will have saved this in their database, and it would result
in a corrupt block when loaded, and we didn't want to support both IDs at the
moment.

Otherwise, most other references to the legacy template, are now using the word
“classic”.

Co-authored-by: Alba Rincón <alba@albasauatticmbp.home>
2022-03-22 23:34:43 +01:00
Tung Du 64ae9330a2 Shopper → Mini Cart → Can see correct tax (https://github.com/woocommerce/woocommerce-blocks/pull/5979)
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-03-22 08:54:06 +07:00
Mike Jolley 8e057a03f5 Remove X- Prefixes from custom headers (https://github.com/woocommerce/woocommerce-blocks/pull/6020)
* Remove X- Prefixes from custom headers

* Fix docs

* Handle deprecated X-WC-Store-API-Nonce header if received

* Send old nonce until future version removes this

* Add todo and cut off date

* wc_deprecated_argument

* Update todo name

* typo

* Back compat in batch

* Flip Nonce logic to make it easier to support both in client bw compat logic
2022-03-11 12:07:08 +00:00
Tarun Vijwani 349c668f01 Critical flows: Shopper → Cart → Can view empty cart message (https://github.com/woocommerce/woocommerce-blocks/pull/6024)
* Added test case for Critical flows: Shopper → Cart → Can view empty cart message
2022-03-10 15:50:07 +04:00
Tarun Vijwani 0530048f4c Critical flows: Shopper → Cart → Can remove product (https://github.com/woocommerce/woocommerce-blocks/pull/6015)
* Added test case for Critical flows: Shopper → Cart → Can remove product
2022-03-10 15:47:53 +04:00
Tomasz Tunik f15d628610 Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989)
* Change atomic blocks to not use custom webpack build paths

we want to always load lazy loaded components from their default paths
to avoid having to handle importing components in different ways for
regular and atomic component packages

* Add footer parts to test themes

The Site Editor is expecting the footer parts to be there or it will try to
load them anyways and throw a 404. It's not breaking, but it's polluting
the console.

* Use REST API to tear down the templates

Previously, we used a util called `trashAllPosts` which navigated to the post UI
and deleted all the posts to tear down any side-effects of template editing tests.

However, with a [recent change](14e20f72b5),
WP Core removed the UI for those and that made our tests meet a 500 error.

Using the REST API should also make everything faster.

* Remove deprecated pupeteer waitFor usage

was still present in attribute-filter.test.js

* Update package-lock.json

* pin package versions

* Unify all atomic blocks to register on php side

* Remove Atomic Blcoks chunk_translation handling from AllBlocks

Before it was responsible for enabling translations for all the atomic blocks

* Add per atomic block chunk_translation registration

* update @wordpress/e2e-test-utils to 6.0.2

* add optional puppeteer

* pin workflows node version to 16.13.2

* upgrade package-lock

* upgrade package-lock

* set react and react-dom as peerDeps

* remove atomic block registration

Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 11:00:23 +01:00
Niels Lange d9dd7a0df6 Shopper can choose shipping option (https://github.com/woocommerce/woocommerce-blocks/pull/5844) 2022-03-09 13:23:52 +01:00
Alex Florisca fcadeaa2e1 E2E test improvements and consolidatng (https://github.com/woocommerce/woocommerce-blocks/pull/6013)
* Refactor e2e tests slightly for better efficiency

* Add "proceedToCheckout" shopper method & refactor code

* Use "beforeEach" in case we add more test cases

I've kept the "afterAll" function to reset any side effects at the end
of this file's tests

* Use "beforeEach" in "checkout-place-order-as-guest" file

* Use BASE_URL in shopper.block.goToBlockPage

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-09 10:16:24 +00:00
Alex Florisca 2e674dd6c0 Critical flow: Can see correct tax (https://github.com/woocommerce/woocommerce-blocks/pull/5900)
* Tax is displayed correctly e2e test

* Add extra utils to shopper

* add single e2e test script oin package.json

* Feedback changes from Niels

* Test tax is correct on summary page

* Check if CI test passes

* Longer timeout for tax test

* change timeout in jest config

* increate jest timeout

* Test

* Test

* Test

* setTimeout outside of tests to 120000

* Address raluca's feedback and timeout everywheregaa

* Increase timeout on  for search box

* set jest timeout to 120000

* Raluca's suggestions

* Debug

* Increase search timeout to 5000

* Only run Tax e2e tests in CI for quicker debug - REMOVE THIS

* use waitforSelector

* 30s delay for toMatchElement

* Let'shope this works

* Remove toMatchElement

* waitForSelector

* Run debug test only

* Debug tax test

* debug taxes

* shopper using toMatchElement again

* Remove the 30000 timeout delay from toMatchElement

* Run all tests but only once

* Remove tax test

* Revert "Remove tax test"

This reverts commit 7db34120e1e91f4fd26514fdb9525cac2a6066bb.

* Delete the minicart test

* Revert "Revert "Remove tax test""

This reverts commit 31dd654e52f37fcd02ccd25336958248bef495c6.

* Revert "Delete the minicart test"

This reverts commit 5595f0834a975d097a300bc0c7cbf643caa8b764.

* tax test

* block addToCart

* Put back block functions

* Refactor block.addToCart

* mini-cart e2e test uses shopper.block.emptyCart()

* only run shopper tests in CI

* Run frontend and shopper tests and change waitFor -> waitForTimeout

* Run frontend tests in CI

* Run CI e2e tests again

* Skip legacy template blocks

* Skip legacy template test but run all others

* Switch to storefront instead of twentytwentyone after legacy-template-blocks tests finish

* Tidy up

* fix typo

* Fix ESLint issue

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-08 14:50:16 +00:00
Saad Tarhi 1e15672b7b Shopper → Checkout → Can place an order as guest (https://github.com/woocommerce/woocommerce-blocks/pull/6009)
* Add "goToCheckout" method in "shopper.block"

Instead of using "shopper.goToCheckoutBlock" method, it will much easier
to maintain the following structure "shopper.block.goToCheckout"

* Create a constant for billing details

* Create "fillBillingDetails" shopper method

* Add "placeOrder" method to "shopper"

* Enable "Cash on delivery" payment method for our test

* Update "@woocommerce/e2e-utils" package

Some new useful e2e utility functions weren't avaiable in the previous version

* Add E2E test for "Can place an order as guest"

* Fix mini-cart failing E2E tests

In case this fix woocommerce/woocommerce-blocks#6006 isn't merged yet, this commit can be used to pass all
E2E tests

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-08 14:52:40 +01:00
Tung Du 75b5181e0e Shopper → Mini Cart → Can view empty cart message and start shopping button (https://github.com/woocommerce/woocommerce-blocks/pull/5918) 2022-03-08 17:01:27 +07:00
Saad Tarhi c0aec1e85b Fix mini cart failling tests (https://github.com/woocommerce/woocommerce-blocks/pull/6006)
Set the correct "emptyCart" utility function

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-08 00:09:20 +01:00
Saad Tarhi dee5032d41 Shopper → Cart → Can proceed to checkout (https://github.com/woocommerce/woocommerce-blocks/pull/5901)
* Shopper → Cart → Can proceed to checkout

* Refactor the code for E2E testing

Introduce some discussed solution to structure and optimize the code

* Resolve some conflicts with the trunk branch

* Remove method overriding and refactor code

We are trying to avoid overriding exiting E2E Woo's utility functions

Instead we can use our own "shopper.block"

* Use a consistent constant naming convention

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-07 16:23:31 +01:00
Mike Jolley eae1d75c86 Store API: Consistent error code and hook naming (https://github.com/woocommerce/woocommerce-blocks/pull/5992)
* Update error codes with `woocommerce_rest_` prefixes.

* Update action and filter hooks with woocommerce_store_api_ prefix

* Update hook docs

* Update error code mismatches

* Update hook name in tests

* update hook name in tests

* phpcs
2022-03-07 13:51:07 +00:00
Mike Jolley fd03b79995 StoreAPI: Rename namespace to remove `\Blocks` (https://github.com/woocommerce/woocommerce-blocks/pull/5982)
* Composer config

* Update namespace in deprecated.php

* Bulk update namespace

* Revert rename in deprecated class

* bw compat

* Store API: Add dedicated container and make Store API code self-contained (https://github.com/woocommerce/woocommerce-blocks/pull/5986)

* Move ArrayUtils to StoreApi

* Move PaymentContext/PaymentResult

* Move create account functionality to checkout endpoint. Update tests.

* Move get_routes_from_namespace to blocks

* Move RestApi logic within StoreApi namespace/directory

* StoreAPI Container

* Update functions

* Update extend docs

* Run Doc build script

* Missing container calls for 3rd party extensions

* Fix doc toc
2022-03-04 13:28:37 +00:00
Tung Du 892d7c268d Shopper → Mini Cart → Can update product quantity (https://github.com/woocommerce/woocommerce-blocks/pull/5963) 2022-03-04 17:40:13 +07:00
Tung Du 43529e5735 Shopper → Mini Cart → Can go to Cart page (https://github.com/woocommerce/woocommerce-blocks/pull/5977) 2022-03-04 16:57:34 +07:00
Tung Du 33ac2d5f4b Shopper → Mini Cart → Can proceed to checkout (https://github.com/woocommerce/woocommerce-blocks/pull/5978) 2022-03-03 08:24:30 +07:00
Lucio Giannotta 08a99165ca Add mock theme with Woo Templates for E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/5920)
This PR adds a block-enabled theme with templates for WooCommerce
which is intended to be used when testing the more complex scenarios
such as template fallbacks.

Additionally, since theme-dependent logic seems to be becoming more
and more useful (see woocommerce/woocommerce-blocks#5913), this PR also adds a utility function used to
explicitly declare theme dependencies of a test (`useTheme`).

Said function will activate the theme before running a given suite and then
reactivate the previous theme, as to make sure to not have any side-effects
(such as the ones described in woocommerce/woocommerce-blocks#5913 above).

Closes woocommerce/woocommerce-blocks#5660
2022-03-02 15:49:00 +01:00
Christos Lilitsas c35bf8ee67 Store API: Refactored validation handling and introduced `woocommerce_store_api_cart_errors` hook (https://github.com/woocommerce/woocommerce-blocks/pull/5904)
* Introduce 'wooocommerce_store_api_validate_cart' action

This action can be used by third party developers to add extra 'errors' in cart route responses. This is meant to function as a replacement of the legacy 'woocommerce_check_cart_items' hook.

* Introduce a new 'wooocommerce_blocks_draft_order_updated' action

The new action can be used to modify the finalized draft order object.
Additionally, developers can use it to throw a RouteException in order to prevent access to the checkout block.

The PR also shuffles some existing code that checks the order instance and sets the draft order ID before the 'woocommerce_blocks_checkout_update_order_meta' gets fired.

* Fix PHPCS

* Revert changes to Checkout route

* Add some extra content to the 'woocommerce_blocks_checkout_update_order_meta' docblock on the effect of exceptions thrown from callbacks

* Add __experimental prefix to 'wooocommerce_store_api_validate_cart' action

* Remove long ooo

* Add example

* Refactor cart error getters as wrappers to the validate functions

* Refactor stock_exceptions_to_wp_errors to return a single wp error.

* Add type hint in custom exception

* Fix namespace versioning and some minor improvements

* Move InvalidCartException catcher from AbstractCartRoute to AbstractRoute

* Introduce the __experimental_woocommerce_store_api_cart_errors filter

* Handle all notices and group them into a single WP_Error instance

* Cleanup doc and update example

* Cleanup NoticeHandler

* Fix doc

* Fix WP_Error namespace

* Update NoticeHandler unit tests

* Fix Unit tests typo

* Add docs to tests to bypass precommit scripts

* Refactor wp error grouping with merge_from

* Remove previous cart getters and refactor the get_cart_errors

* Fix CartSchema error getter and minor fixes

* Revert NoticeHandler exception namespace

* Unit test fix for get_cart_errors

* Switch back to do_action

* Update the example doc

* Duplicate use statement

* Update docblock in validate_cart() method for validation hooks

* Update action docs

* Remove __experimental prefix

Co-authored-by: Manos Psychogyiopoulos <psyx@somewherewarm.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-03-02 12:21:31 +00:00
Tung Du 22eccc8614 Shopper → Mini Cart → Can view filled mini cart contents block (https://github.com/woocommerce/woocommerce-blocks/pull/5923) 2022-03-01 18:25:13 +07:00
Mike Jolley 49b65c7bcf Refactor ExtendRestApi as ExtendSchema and expose `register_endpoint_data` as a public function (https://github.com/woocommerce/woocommerce-blocks/pull/5941)
* Create Extend class under schema namespace

* ExtendRestApi -> ExtendSchema

* ExtendSchema helper functions

* Move tests

* Fix tests

* Fix docs

* Typos

* Remove invalid param

* phpcs formatting

* Update docs/contributors/documentation-guidelines.md

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

* Update docs/extensibility/filtering-payment-methods.md

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

* Update docs/extensibility/README.md

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

* Update docs/extensibility/available-slot-fills.md

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

* Asserttrue comment

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-03-01 10:34:05 +00:00
Lucio Giannotta 8ad1dff1f4 Rename templates to more e-commerce friendly names (https://github.com/woocommerce/woocommerce-blocks/pull/5935) 2022-02-28 08:00:01 +01:00
Thomas Roberts 7915a793fa Await expectations in checkout frontend test (https://github.com/woocommerce/woocommerce-blocks/pull/5942) 2022-02-25 18:21:10 +00:00
Raluca Stan e01592e736 Add constants for C & C pages in our E2E tests (https://github.com/woocommerce/woocommerce-blocks/pull/5938)
* Add constants for C & C pages in our E2E tests

Inspired by WC E2E this will avoid going to admin to find out the links for these pages.

* Select C & C pages by using the main navigation links

* Fix function calls

* Revert back to using constants for C & C block pages' URLs

reverts 9587a0bd5efa5d97b484cd8d1bf927ff50f8e014 and bd7e2f996792d887756c0a0f4a10e6886574e77b
2022-02-25 10:44:16 +01:00
Tung Du 49c5659eb9 Shopper → Mini Cart → Can open/close the drawer (https://github.com/woocommerce/woocommerce-blocks/pull/5894) 2022-02-24 21:02:24 +07:00
Thomas Roberts bbe68f395e Change tests that use the incorrect `waitForSelector` API (https://github.com/woocommerce/woocommerce-blocks/pull/5932)
* Change tests that use the incorrect waitForSelector API

* Use .toMatchElement instead of just .toMatch

* Use sentence case for page title check
2022-02-24 11:31:26 +00:00
Thomas Roberts 918de7bc75 Ensure screenshots can be attached in jest html report (https://github.com/woocommerce/woocommerce-blocks/pull/5919)
* Ensure screenshots can be attached in jest html report

* Force tests to fail in ci

* Console log for testing

* Console log for testing

* Check on hook failure as well as test failure

* Revert "Force tests to fail in ci"

This reverts commit 6efebd63bba4792214f5b24824fb405cf38b1367.

* Take full page screenshot only when error type is not hook_failure

* Remove console log
2022-02-24 09:06:24 +00:00
Mike Jolley a58b2d0ac4 Store API: Introduce API Versioning System (https://github.com/woocommerce/woocommerce-blocks/pull/5911)
* Fix missing dependency

* Min version exceeds required 5.6

* Move exceptions

* Move schemas under V1 namespace

* Move routes to v1

* Move RouteException

* Route versioning

* Update route and schema identifiers/init

* Rework route init to support multiple versions and multiple schema

* Tests for cart routes

* Cart coupons tests

* Batch

* extensions

* Update docs

* Update remaining tests

* woocommerce_store_api_route_version was unused

* Revert unrelated change

* Fix phpcs

* Update src/StoreApi/docs/guiding-principles.md

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

* Update src/StoreApi/docs/cart-items.md

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

* Update src/StoreApi/RoutesController.php

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

* Note about v1 unversioned endpoints

* Remove unused get_route_version

* 409 comment in tests

* Remove copy pasted comments

* Update all usage to v1

* Correct namespace

* More v1 namespaces

* More missing v1

* fix mocks

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-02-23 12:00:45 +00:00
Tung Du 399a204138 Fix: Ensure `shopper.goToBlockPage` works with any theme (https://github.com/woocommerce/woocommerce-blocks/pull/5914) 2022-02-22 11:34:51 +07:00
Tung Du 47f8993a8d Shopper → Mini Cart → Can see the icon with a badge (https://github.com/woocommerce/woocommerce-blocks/pull/5877) 2022-02-22 09:50:59 +07:00
Lucio Giannotta 341a742916 E2E tests for Product Tag Template and Legacy Block (https://github.com/woocommerce/woocommerce-blocks/pull/5888)
Also: 

* Add fixtures for tags
* Teardown both categories and tags when tests are done
2022-02-21 13:26:22 +01:00
Lucio Giannotta d64ebc72dc E2E tests for Product Category Template and Legacy Block (https://github.com/woocommerce/woocommerce-blocks/pull/5820) 2022-02-21 12:38:36 +01:00
Lucio Giannotta 5de9fec527 E2E tests for Product Archive Template and Legacy Block (https://github.com/woocommerce/woocommerce-blocks/pull/5748)
Also:
* Refactors the function to add a custom paragraph
* Add front-end test for archive template
* Use WordPress data to guarantee block presence
* Use WordPress data instead of selectors to match blocks
2022-02-21 12:01:56 +01:00
Lucio Giannotta 497820dcb9 E2E tests for Single Product Template (https://github.com/woocommerce/woocommerce-blocks/pull/5722)
* Add empty block theme to mock E2E tests
* Install empty theme in the test WP instance
2022-02-21 11:01:42 +01:00
Niels Lange 6946a0c189 Remove obsolete * in comment 2022-02-14 17:55:28 +07:00
Alex Florisca 16d5e773bc Reformatted prettier files (https://github.com/woocommerce/woocommerce-blocks/pull/5735) 2022-02-07 16:59:44 +00:00
Tung Du 4dab187dbe Fix: only allow Mini Cart block in Widgets and Site Editor (https://github.com/woocommerce/woocommerce-blocks/pull/5653)
* fix: exclude Mini Cart from the blocks editor

* fix: explicitly register Mini Cart blocks for Site Editor and Widgets

* add check to loading the block on frontend

* add e2e tests for widget area

* improve test title

Co-authored-by: Luigi <gigitux@gmail.com>
2022-02-07 11:29:22 +01:00
Thomas Roberts 426eb51830 Update Checkout block E2E fixture and increase node version in GH actions (https://github.com/woocommerce/woocommerce-blocks/pull/5678)
* Remove unnecessary setup step and use node v16 in E2E action

* Ensure storefront is active

* Use new checkout fixture

* Try with only checkout test

* Update package.json

* Run all tests, not just checkout
2022-02-01 11:14:16 +00:00
Thomas Roberts afd9d42805 Add Checkout Order Summary inner block tests (https://github.com/woocommerce/woocommerce-blocks/pull/5675)
* Add fake items fixture

* Add test for rendering items in sidebar

* Add test for items with addons

* Add textContentMatcherAccrossSiblings helper

This is needed to match text when it's spread over a few elements

* Add test to ensure subtotal renders correctly

* Add test to ensure discounts are rendered correctly

* Add test to ensure fees are shown correctly

* Add test to check coupon entry form isn't present when coupons disabled

* Add more mock data to useStoreCart

* Mock useShippingDataContext

* Rename useStoreCartValue to useStoreCartReturnValue

* Remove unnecessary coupon button test

This should be tested within the TotalsCoupon component

* Add tests for shipping presence

* Add test for coupons

* Remove cart items fixtures

These are no longer needed

* Move the findByText utils to the utils folder

* Move inner blocks test to correct directory
2022-01-31 10:53:08 +00:00
Mike Jolley 7f2af8c1a6 Validate available payment methods before attempting payment or updating order statuses (https://github.com/woocommerce/woocommerce-blocks/pull/5440)
* Make payment method required

* removed unused imports

* Remove PUT method

* Validate available method when updating order

* Enable bacs for tests
2022-01-04 18:04:08 +00:00
Thomas Roberts 5036c69638 Add E2E tests for Filter blocks (Price, Attribute, and Active Filters) (https://github.com/woocommerce/woocommerce-blocks/pull/4562)
* Add clear and fill input test util

* Add tests for Filter Products by Price

* Add class name to filter products by price block in editor

* Update wp-env

* Fix formatting

* Update lock

* Revert "Update lock"

This reverts commit f4e809e000430eea3972c94fd2aea0a19ba6961b.

* Create product attributes during setup

* Remove product attributes during teardown

* Add attributes in fixture-data

* Add two new products, for attribute testing

* Load attributes into store and apply them to products

* Add class to Filter by Attribute when editing

This is so it can be targeted in E2E tests more easily.

* Add tests for Filter Product by Attribute

* Fix formatting in attribute-filter.test.js

* Add tests for active filters block

* Add doc block for ensuteCleanAttributes

* Update wording of title test in all filter block E2E

* Update test wording to read better

* Update snapshots

* Use pptr-testing-library selectors to click elements

This makes the tests easier to reason with, and lets us take a step back from the implementation details (classnames etc.)

* Add saveOrPublish test util

* Use pptr-testing-library selectors to click elements in attribute filter

* Use pptr-testing-library selectors to click elements in price filter

* Add `puppeteer-testing-library`

* Use puppeteer-testing-library API to look for H6 button

* Use correct argument in jest-puppeteer.dev.config

* Update package.json & package-lock.json

* remove tests for 5.3

* remove snapshots

* Remove ensureCleanAttributes

* Remove puppeteer-testing-library, install missing expect-puppeteer package and update tests

The puppeteer-testing-library, although added by gutenberg is not actively used.
I have removed it and realised that the added functionality can be easily replaced by expect-puppeteer.
This is a package that we specify in the jest configuration but it was not part of our package.json.
The selectors from puppeteer-testing-library have been replaced with .toClick and the utility clearAndFillInput with .toFill

The Filter by Attribute block has been skiped until tests are fixed.

* Add back setupPageSettings to jest setup

* Fix filter by attribute block test

* Fix linting error

Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2021-12-23 17:26:10 +01:00
Mike Jolley ecc80e5cff Sync order data with cart data when cart is updated from any route (https://github.com/woocommerce/woocommerce-blocks/pull/5379)
* Link order controller to cart routes

* Remove order controller from checkout route

* Fix PHP warnings in abstract schema

* Fix PHP warnings in abstract route

* Update shipping phone handling

* Includes are handled in core now

* Remove maybe_update_order_from_customer

* Add cart_updated routine to all cart routes

* Remove abstract method

* Remove test for woocommerce_blocks_cart_update_order_from_customer_request

* Remove do_order_callback
2021-12-21 13:11:51 +00:00
Mike Jolley 59c8c88438 Introduce 2 new hooks in Customer Update Route (https://github.com/woocommerce/woocommerce-blocks/pull/5345)
* Introduce woocommerce_blocks_cart_update_customer_from_request hook

* Introduce woocommerce_blocks_cart_update_order_from_customer_request

* Test actions fire

* Update hook docs
2021-12-13 13:57:45 +00:00
Luigi Teschio 13deb1b09e Mini Cart Block: render the empty state set on template parts (https://github.com/woocommerce/woocommerce-blocks/pull/5338)
* add view switcher for mini cart contents block

* editor view switcher

* update mini cart template file

* render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

render the empty state template parts for the Mini Cart Block woocommerce/woocommerce-blocks#4674

* update selector

* allow empty mini cart block to add all blocks

* fix tests; improve code style

* install @wordpress/block-editor package

* fix warning on frontend side

* block-editor package is not necessary

* merge attributes object

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2021-12-10 12:11:59 +01:00
Mike Jolley 70f0c06bf9 Fix e2e tests welcome guide/m1 mac support (https://github.com/woocommerce/woocommerce-blocks/pull/5096)
* Bump dependencies to fix e2e on m1 macs

* Disable welcome guide more reliably - see 3da717b8d0/packages/e2e-test-utils/src/create-new-post.js

* Update selectors and fixture data for cart block

* unused dep

* Remove duplicate block wrapper

* Remove unused jest configuration files

* More robust click in view switcher test

* Revert fixture data change
2021-11-09 13:18:55 +00:00
Seghir Nadir ea1e17fc81 Fix sanitization callback (https://github.com/woocommerce/woocommerce-blocks/pull/5060)
* Fix sanitization callback

* Add test case to confirm sanitization callbacks work for nested properties

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2021-11-05 15:39:08 +00:00
Mike Jolley 72cf5eade8 Remove hydration hocs in favour of apiFetch Middlewares (https://github.com/woocommerce/woocommerce-blocks/pull/5022)
* Remove withRestApiHydration

* Preload checkout data via setting - server data is required for this block

* Handle cart hydration using createPreloadingMiddleware which removes the need for HOCs

* Rename variable

* Remove withStoreCartApiHydration and timestamp checking

* Empty test file
2021-11-04 11:05:58 +00:00