Commit Graph

3473 Commits

Author SHA1 Message Date
Mike Jolley c401369e04 Revert "Remove .gitattributes file (https://github.com/woocommerce/woocommerce-blocks/pull/5242)" (https://github.com/woocommerce/woocommerce-blocks/pull/6049)
This reverts commit 6ae286f670.
2022-03-14 12:42:34 +00:00
Thomas Roberts a6bff7e6e8 Change `shippingRatesLoading` to `isLoadingRates` (https://github.com/woocommerce/woocommerce-blocks/pull/5999)
* Change `shippingRatesLoading` to `isLoadingRates`

* Revert isLoadingRates back to old name in payment method interface

* Update docs with correct names returned by usePaymentMethodInterface

* Update TS to name the selectShippingRate method correctly

* Change method name on usePaymentMethodInterface back
2022-03-14 11:29:25 +00:00
Daniel Dudzic 5a8e94d86e Product Ratings: Add Global Styles font size and spacing support (https://github.com/woocommerce/woocommerce-blocks/pull/5927)
* Product Ratings: Add font size and spacing support

* Fix useTypographyProps hook

* Set SkipSerialization for Ratings block props

* Add additional hasSpacingStyleSupport check for the spacing

Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
2022-03-11 16:52:00 +01:00
Mike Jolley 011c4cb6fd Add missing chunk to register_block_type_assets 2022-03-11 15:34:25 +00:00
Albert Juhé Lluveras 0819ab2797 Correctly load JS translations from WC core (II) (https://github.com/woocommerce/woocommerce-blocks/pull/6036)
* Correctly load JS translations from WC core (II)

* typo

* empty instead of count

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-03-11 14:18:45 +00: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
Tomasz Tunik 2ad55b5b9e Fix box-sizing on Global Styles blocks with border width control (https://github.com/woocommerce/woocommerce-blocks/pull/6043)
Set box-sizing to border-box on affected blocks: Featured product, featured category, sale badge.
2022-03-11 13:01:15 +01:00
Luigi Teschio f78b2d8619 Remove not used attributes (https://github.com/woocommerce/woocommerce-blocks/pull/5974)
* Remove not used attributes woocommerce/woocommerce-blocks#5952

remove not used attributes

* remove not necessary jsdoc comments

Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
2022-03-11 12:44:51 +01:00
Tung Du 75bf08d2c9 Fix: Exclude Button block from the Empty Mini Cart Contents block insterter (https://github.com/woocommerce/woocommerce-blocks/pull/6034) 2022-03-11 08:17:37 +07:00
renovate[bot] dcec8f38b5 Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/5724)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-10 18:16:25 +01:00
Seghir Nadir d694b9b089 Ignore storybook dist folder when running eslint (https://github.com/woocommerce/woocommerce-blocks/pull/6033)
* ignore storybook dist folder

* Add reports folder to .eslintignore

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-03-10 17:25:29 +01:00
Luigi Teschio 807720a28d Remove not necessary todo woocommerce/woocommerce-blocks#5827 (https://github.com/woocommerce/woocommerce-blocks/pull/6039)
Remove not necessary todo
2022-03-10 14:53:42 +01:00
Mike Jolley 7f512d1c26 Merge branch 'trunk' of https://github.com/woocommerce/woocommerce-gutenberg-products-block into trunk 2022-03-10 13:38:55 +00:00
Mike Jolley bfdd50cb63 7.3.0-dev in package.json 2022-03-10 13:38:52 +00:00
Mike Jolley 5165611e45 Remove deprecated data controls in favour of those from the `@wordpress/data` package (https://github.com/woocommerce/woocommerce-blocks/pull/5574)
* Remove expected warnings from test suite

* Switch dispatch and select usage to `controls`, from `@wordpress/data`

* Wrap render with act

* resolveSelect to wait for resolution

* resolveSelect
2022-03-10 13:22:05 +00:00
Christos Lilitsas 28d647d02c Clear notices session after handling (https://github.com/woocommerce/woocommerce-blocks/pull/5983) 2022-03-10 12:29:58 +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
Alex Florisca a67876e7d7 Update debug script name (https://github.com/woocommerce/woocommerce-blocks/pull/6014)
* Update debug script name

* rename to test:debug
2022-03-09 15:37:36 +00:00
Mike Jolley 235f260c04 Merge branch 'trunk' of https://github.com/woocommerce/woocommerce-gutenberg-products-block into trunk 2022-03-09 12:26:19 +00:00
Mike Jolley 04df284fe0 7.3.0-dev 2022-03-09 12:26:15 +00:00
Mike Jolley c3bf23fd4e Prefetch cart and checkout block assets when cart has contents (https://github.com/woocommerce/woocommerce-blocks/pull/5553)
* Prefetch block resources when cart has contents

* Fix error when cart is undefined
2022-03-09 12:25:36 +00: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
Mike Jolley 22e206d00a Remove `internal` comments from Store API file comments (https://github.com/woocommerce/woocommerce-blocks/pull/6005)
* Remove internal comments

* Remove line break

* Notices
2022-03-09 10:20:47 +00: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
Tung Du e735ffe5c2 Refactor: Use an alternative mini cart icon to fix the Mini Cart styling issues (https://github.com/woocommerce/woocommerce-blocks/pull/5985) 2022-03-09 16:13:52 +07:00
renovate[bot] 9503f03f9b Update dependency follow-redirects to v1.14.9 (https://github.com/woocommerce/woocommerce-blocks/pull/6018)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-09 03:07:12 +00:00
renovate[bot] 072c39b269 Update dependency @types/puppeteer to v5.4.5 (https://github.com/woocommerce/woocommerce-blocks/pull/6017)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2022-03-09 03:02:53 +00:00
Tung Du 22cdefd3da Cart: Accepted Payment Methods block: Use utility instead of the local function (https://github.com/woocommerce/woocommerce-blocks/pull/6001) 2022-03-09 07:06:32 +07: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
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