Commit Graph

3842 Commits

Author SHA1 Message Date
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
Luigi Teschio fc01576a38 Additional classes are visible on frontend page woocommerce/woocommerce-blocks#5881 (https://github.com/woocommerce/woocommerce-blocks/pull/5991)
Additional classes are visible on frontend page
2022-03-08 14:24:52 +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
Tomasz Tunik 6e185e0e2b Move __experimentalSelector outside of hasSpacingStyleSupport check (https://github.com/woocommerce/woocommerce-blocks/pull/6011) 2022-03-08 10:38:42 +01: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
Luigi Teschio 4b80f92c02 Add feature gate for enabling the global styles for Product Sale Badge block only for the feature plugin (https://github.com/woocommerce/woocommerce-blocks/pull/6008)
* Add feature gate for the global styles for Product Sale Badge block woocommerce/woocommerce-blocks#6007

Add feature gate for the global styles for Product Sale Badge block

* add a check for the spacing support
2022-03-07 18:39:11 +01:00
Luigi Teschio 299f5e1bfa Hide Mini Cart Block on Cart and Checkout page (https://github.com/woocommerce/woocommerce-blocks/pull/5996)
* Hide Mini Cart Block on cart and checkout page woocommerce/woocommerce-blocks#5931

hide Mini Cart Block on cart and checkout page

* instead to not render nothing, use visibility hidden
2022-03-07 17:29:06 +01:00
Saad Tarhi c122008d70 Test Google's "ndb" E2E testing tool (https://github.com/woocommerce/woocommerce-blocks/pull/5997)
* install ndb as a development dependency

* Add "debug" script to package.json to launch "ndb"

* Create a minimal test example

This test file is used as an example, we will add later a script in
package.json to call only this file

* Create a temporary npm script to run it from "ndb"

We want to be able to run only a selected file using "ndb", so we need to
create an npm script for it

* Clean up test file

* Clean up & ready PR to merge

Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>
2022-03-07 17:10:17 +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
Alex Florisca e14448e151 Update testing instructions for 6.8.0 and 6.9.0 releases (https://github.com/woocommerce/woocommerce-blocks/pull/5855)
* Update testing instructions for 6.9.0 release

* Edit 6.8.0 testing notes

* Update 6.8.0 testing docs
2022-03-07 12:06:50 +00:00
Thomas Roberts 6b8ef2773a Try move shipping related dat to a `@wordpress/data` store (https://github.com/woocommerce/woocommerce-blocks/pull/5896)
* Add address-related items to wc/store/cart data store

* Add useUpdateCustomerData hook

This allows us to have a single hook responsible for updating the customer information on the server.

* Add useUpdateCustomerData hook in Checkout block

* Remove shippingAsBilling from previousCustomerData ref type

* Add useShippingAsBillingCheckbox hook

* Remove checkbox handling from useCheckoutAddress

* Merge with woocommerce/woocommerce-blocks#5810 changes

* Move shipping as billing to checkout state context provider

* Subscribe to changes

* Cache customerDataToUpdate

* Combine customerDataType and customerDataContextType

* Fix notice context

* Clean up inline docs for push changes

* Add useShippingData hook

* Add shipping related selectors to cart store

* Update useShippingDataContext to useCustomerData hook

* Update uses of useShippingDataContext to get data from hook instead

* Remove rogue linebreak

* Re-add linebreak

* Re-add linebreak, remove shippingAsBilling

* Re-add linebreak

* Use useShippingData and useCustomerData instead of context

* Fix fromEntriesPolyfill to use number or undefined as an index option

* Convert derive-selected-shipping-rates to TS

* Add SelectShippingRateType

* Get needsShipping from new hook and not context

* Get address data from useCustomerData instead of useShippingDataContext

* Move selectedRates, selectShippingRate and isSelectingRate

* Remove items from ShippingDatacontext that are available in data stores

* Get shipping data from stores, not context in payment method interface

* Consider shipping rates to be loading if customer data is updating

* Get rates from useShippingData hook instead of context

* Fix incorrect TypeScript types and incorrectly named destructure

* Move useShippingData into shipping folder

* Update tests to mock useShippingData instead of context

* Remove empty string fallback from shipping phone

* Get types from Cart declaration instead of Picking them

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-03-04 17:43:45 +00:00
Thomas Roberts 719c7f7c23 [Experiment] Try to memoize/cache filter results so that we don't call third party filters too often (https://github.com/woocommerce/woocommerce-blocks/pull/5143)
* Add memoized/cached filter runs

* Add function to check equality of object's members

* Add function to check equality of arg and extensions vs prev values for a filter name

* Memoize/Cache values of previously run filters

* Add docs and null check to shallow equality check

* Update packages/checkout/filter-registry/index.ts

Co-authored-by: Raluca Stan <ralucastn@gmail.com>

Co-authored-by: Raluca Stan <ralucastn@gmail.com>
2022-03-04 14:42:38 +00:00
Thomas Roberts db1989aefb Remove `fromEntriesPolyfill` (https://github.com/woocommerce/woocommerce-blocks/pull/5981)
* Remove fromEntriesPolyfill

* Remove further instances of fromEntriesPolyfill
2022-03-04 14:42:16 +00:00
Mike Jolley 9157930349 Remove v1 from Store Keys (https://github.com/woocommerce/woocommerce-blocks/pull/5987) 2022-03-04 14:03:52 +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
Mike Jolley c612b28e46 Remove lodash forEach usage (https://github.com/woocommerce/woocommerce-blocks/pull/5965)
* Remove lodash forEach usage

* Store built parents rather than deleting them
2022-03-04 12:04:15 +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
Luigi Teschio 31b179eb49 Revert "Add wc-block-mini-cart__contents class for the Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/5800)" (https://github.com/woocommerce/woocommerce-blocks/pull/5984)
This reverts commit 54ce880762.
2022-03-03 09:52:51 +01: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
colinleroy 6f8a3b14af Avoid crash in InboxNotifications if woocommerce-admin is entirely disabled. (https://github.com/woocommerce/woocommerce-blocks/pull/5954)
* Avoid calling plugin_dir_url a lot

* Fix crash if woocommerce admin is disabled

With Woocommerce's PR
https://github.com/woocommerce/woocommerce/pull/31991 applied, if
woocommerce admin is disabled via the woocommerce_admin_disabled
filter, the InboxNotifications block could crash.

* Fix coding style

* Simplify code path

* Remove unused initialization
2022-03-02 12:28:18 +00: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
renovate[bot] 78a4c060a3 Update dependency @types/lodash to v4.14.179 (https://github.com/woocommerce/woocommerce-blocks/pull/5976)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-02 11:37:57 +00:00
Tom Cafferkey e8855a5af3 Full Store Editing: Technical documentation (https://github.com/woocommerce/woocommerce-blocks/pull/5939)
* templates README and block-template-controller README

* Add execution scenario to block template controller readme

* Amend return value to block template controller readme

* Add source file link to block template controller docs

* LegacyTemplate.php overview

* Legacy Template JavaScript block README

* Update requirements of templates feature

* Doc updates based on feedback, and change Legacy Template references to Classic Template in anticipation of naming convention updates

* Update classic-template.md README

* Reword part of the add_block_templates section

* Update assets/js/blocks/legacy-template/README.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update docs/readme.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update docs/templates/README.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update docs/templates/README.md

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>

* Update README for blocktemplatecontroller

* Review feedback for Woo FSE technical documentation

Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
2022-03-02 08:57:53 +00:00
renovate[bot] d54383b417 Update dependency @types/jquery to v3.5.14 (https://github.com/woocommerce/woocommerce-blocks/pull/5975)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-02 04:39:06 +00:00
dependabot[bot] 6bdd1e648b Bump url-parse from 1.5.3 to 1.5.10 (https://github.com/woocommerce/woocommerce-blocks/pull/5955)
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.3 to 1.5.10.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.5.3...1.5.10)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-01 17:19:47 +01:00
Luigi Teschio 0f52c23eb4 Add font-style and font-weight support for ProductCategory List woocommerce/woocommerce-blocks#5670 (https://github.com/woocommerce/woocommerce-blocks/pull/5928)
Add font-style and font-weight support for ProductCategory List
2022-03-01 15:50:56 +01: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
Michael P. Pfeiffer cabf4e7db6 Update to dev version 2022-03-01 12:15:30 +01:00
github-actions[bot] 537e0a3536 Release: 7.1.0 (https://github.com/woocommerce/woocommerce-blocks/pull/5959)
* Empty commit for release pull request

* Add Changelog to readme.txt

* Update allow-plugins list as release build doesnt work otherwise

* Add testing instructions

* Update testing instructions

* Update version number in README.md

Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>

* Add phpcodesniffer to Composer allow-plugins

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Michael P. Pfeiffer <michael@cssconf.eu>
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-03-01 12:10:42 +01: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
Luigi Teschio 6fbb97f043 Add margin support on the Product Image block (https://github.com/woocommerce/woocommerce-blocks/pull/5925)
* Add margin support on the Product Image block woocommerce/woocommerce-blocks#5671

Add margin support on the Product Image block

* fix tests

* more specific selector

* update mixin
2022-02-28 18:41:10 +01:00
Mike Jolley 4927605129 Use text indent in input fields instead of padding (https://github.com/woocommerce/woocommerce-blocks/pull/5947) 2022-02-28 17:16:31 +00:00
Tomasz Tunik 475b50573d Global Styles support for Product Price block (https://github.com/woocommerce/woocommerce-blocks/pull/5950)
* Add Global Styles support to product price block

- This comes sat a cost of losing control over regular vs sale price
- This includes refactor of attribute from align to textAlign
   which is a reserved supports feature attribute and textAlign is
   used across the Gutenberg project

* Add experimentalSelector and register as PHP block

This is required to make the GlobalStyles work inside of
the InnerContent block. Ie. All Products block.

* move sharedConfig supports outside of isFeaturePluginBuild check

* restore regularPriceClassName

* remove douplicated block registration on php side
2022-02-28 12:36:55 +01:00
Tomasz Tunik 61427b9e60 Change label from Remove to Reset (https://github.com/woocommerce/woocommerce-blocks/pull/5951)
This is to reflect how we agreed it would be best
  when working on Featured Product block
2022-02-28 11:39:52 +01: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
Tom Cafferkey c1bba93a20 Determine if we need to load the mini-cart from the theme (https://github.com/woocommerce/woocommerce-blocks/pull/5946) 2022-02-25 16:49:25 +00:00
Tarun Vijwani 55c3ec201f Add Testing Details In Contributors Guide (https://github.com/woocommerce/woocommerce-blocks/pull/5879)
* Add testing details in contributors guide
2022-02-25 18:51:58 +04:00
Marko Kaznovac 4a32932469 Change `curl` example calls to use `sh` code block (https://github.com/woocommerce/woocommerce-blocks/pull/5944) 2022-02-25 13:21:50 +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
Daniel Dudzic 5a3c7be9a4 Revise Storybook entries for Checkout Blocks/totals components (https://github.com/woocommerce/woocommerce-blocks/pull/5853)
* Revise Storybook entries for Checkout Blocks/totals components

Revise Storybook entries for Checkout Blocks/totals components

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

* Fix a typo in the Item label value

* set disable value for description and disable control for 'showRateAfterTaxName' prop

Co-authored-by: Luigi Teschio <gigitux@gmail.com>
2022-02-25 09:58:09 +01:00
Mike Jolley 528137c3b0 Fix spelling of two action hooks in Store API (https://github.com/woocommerce/woocommerce-blocks/pull/5926)
* Deprecate and rename hooks with incorrect spelling

* Update docs
2022-02-24 15:25:40 +00:00
Luigi Teschio 8caaeec998 Add Global Styles support for the Add To Cart Button block woocommerce/woocommerce-blocks#5666 (https://github.com/woocommerce/woocommerce-blocks/pull/5816)
* Add Global Styles support for the Add To Cart Button block woocommerce/woocommerce-blocks#5666

Add Global Styles support for the Add To Cart Button block

* remove support to font size

* try: fix the style override issue for add to cart button (https://github.com/woocommerce/woocommerce-blocks/pull/5843)

* restore typography support

* fix font weight

* add support for font weight

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-02-24 15:35:23 +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
renovate[bot] e2618a2e31 Update dependency follow-redirects [SECURITY] (https://github.com/woocommerce/woocommerce-blocks/pull/5929)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-02-24 12:13:11 +00:00
Albert Juhé Lluveras f3f2dd76f5 Correctly load JS translations from WC core (https://github.com/woocommerce/woocommerce-blocks/pull/5910)
* Correctly load JS translations from WC core

* Needs wp-i18n dependency to load later

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-02-24 12:37:11 +01: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