* Parse categories coming from the back-end as a json array
The category ids that come from php are in json array format (e.g. '[40,41]'),
so it's necessary to parse them and convert them into a js array before
processing them. Otherwise the api request will fail.
* Only parse category ids if not undefined
This PR adds image editing controls to the Featured Product block. In particular, user can now:
* Rotate the image
* Crop the image
* Change the aspect ratio of the image
* Zoom the image
Each edit gets saved in the database as a new image.
* 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()
* Updates to release checklist to clarify testers, blockers, etc.
* Specify that commits related to failing PRs need to be reverted
* Update PR & Release templates
Release template
- the Write testing notes has been moved to the PR template, and removed from the release checklist
- mention that common functionality should be tested by both porters
- update the instructions on how to create the WC PR's changelog
Pull request template
- better visibility for the feature flag/experimental changes
- add before/after table for screenshots
- add WooCommerce Visibility to help with the changelog of the WC PR
- add an extra check to not include a PR in The testing notes
* Remove duplication on pinging porters for testing
* Clarify PR author is the responsible to fix failing PRs
* Update .github/patch-initial-checklist.md
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
* Update .github/release-initial-checklist.md
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
* Include information about testing the Store API
* Add information about logging issues that appear during testing
* Fix punctuation
* Remove Manual Testing section from PR template
* Close milestones when creating the release branch
* Add create a milestone for the next version step
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
* Start using the `block.json` metadata file for the `Featured Category` block
* Get default attributes from the `block.json` file
* Remove unnecessary `get_block_metadata_defaults` function
* Add alt attribute to the block.json file
* Remove unused imports
* Start using the `block.json` metadata file for the `Feature Product` block
* Get default attributes from the block.json file
* Add removed comment
* Remove unnecessary `get_block_metadata_defaults` function
* Add alt default to block.json
* Add new `alt` attribute to Media Settings
Allow to define an alt text for the Feature Product block
* Simplify on change
* Improve alt description and use name instead of short description
Short description can contain html and images, so it's not adequate to use on the alt attribute
* 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>
* 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>
* make active filters block work with PHP templates
* use getSettingWithCoercion
* redirect to the base url when clicking Clear All link
* fix: eslint error and warning
* Move redirect logic to its own callback
* Update comment for updateAttributeFilter
* Remove condition for updating state for active filters only when filter button is not available
* Replace onSubmit with updateAttributeFilter
* Update logic lost in merge
* Replace checked stateful data with activeFilters data from URL
* Remove catalog_visibility from filteredCounts useCollectionData query for PHP templates
* Set the min and max price from the URL to make the active filters work with PHP templates
* Extract price formatting into a separate function
* Rename the `hasSetPriceDefault` variable and improve comments
Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
* 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>
* Enable more options for the Featured Category block
* Fix the focal point picker
* Fix the resizeable handle
* Fix the overlay and move to own section
* Enable gradient and duotone
* Add padding and fix min height
* Export ConstrainedResizeable from Featured Product
* Wrap duotone in feature plugin flag
* Add support for `border-radius`
* Change prop order
* Add SSR for new options on Featured Category block
* Optional chaining on border radius
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
* Add default to overlay and height
* Optional chaining on border radius for Featured Product block
* Fix gradient persistence and default overlay discrepacies
* Explicitly add box-sizing to the featured-product/category wrapper
Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>
If the Featured Product block was added but not modified at all,
the block would not match the editor on the front end.
This was due to the fact that, on the frontend, the
block is SSR and was missing some defaults which
were present in JS.
* 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
* Add has_filterable_products data to the AllProducts block to be used by product filter blocks
* Add has_filterable_products data to the ClassicTemplate block to be used by product filter blocks
* Add ClassicTemplatesCompatibility class which will add necessary data to the front-end of core PHP templates of Classic Themes for filter blocks being used as widgets.
* Update comment of set_php_template_data method on ClassicTemplatesCompatibility class
* Move conditional checking if the current theme is a block theme in ClassicTemplatesCompatibility class
* Add correct context to checkout and cart errors from API
* Correct typo in add-to-cart context
* Add correct context in add to cart form
* Add correct context in add to cart form
* Add correct context in Checkout State
* 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
Co-authored-by: Luigi <gigitux@gmail.com>
* Empty commit for release pull request
* Add Changelog to readme.txt
* Update WC tested and required versions
* Add testing notes
* 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.
(cherry picked from commit 0b18ff59bd)
* Update the zip file link
* Update testing instructions
* Remove experimental build related PR from testing notes
* Fix/order summary sidebar css (https://github.com/woocommerce/woocommerce-blocks/pull/6231)
* Add box sizing to Totals item
* Add some unit tests for Order summary blocks
* Fix Proceed to checkout button size
(cherry picked from commit d22ce7cd0b)
* Update the WC required/tested versions
* Mini Cart Contents: Use block pattern to make the empty cart message translatable (https://github.com/woocommerce/woocommerce-blocks/pull/6248)
* try: use block pattern to make empty cart message translatable
* Update src/BlockTypes/MiniCart.php
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* rename function
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Luigi <gigitux@gmail.com>
(cherry picked from commit 93ad72f6ff)
* Update the release's ZIP file
* Update testing notes
In woocommerce/woocommerce-blocks#6065, for Cart only Order Summary Heading & Coupon form can
be removed, and for Checkout only the Coupon form.
* Update the testing notes
Remove woocommerce/woocommerce-blocks#5870 testing notes because they can't be tested as a user
* Update Testing notes
Add screenshots to the woocommerce/woocommerce-blocks#5967 testing notes
* Remove woocommerce/woocommerce-blocks#6166 testing instructions
We reverted this PR
* Revert (https://github.com/woocommerce/woocommerce-blocks/pull/6166) (https://github.com/woocommerce/woocommerce-blocks/pull/6253)
Revert "Prevent Featured Product block from breaking when product is out of stock + hidden
from catalog (https://github.com/woocommerce/woocommerce-blocks/pull/6166)"
This reverts commit 92387e2
(cherry picked from commit c586b1a5f3)
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Raluca Stan <ralucastn@gmail.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* try: use block pattern to make empty cart message translatable
* Update src/BlockTypes/MiniCart.php
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* rename function
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Luigi <gigitux@gmail.com>
* Add support for overlay color and duotone
* Add support for custom inner padding
* Wrap all block experimental features in `isFeaturePluginBuild`
* Fix resizable container min height
The container now resizes if, e.g., padding is increased, and can't be resized down
with the handle to a height lower than it's minimum size determined by content and
padding box.
* Fix resizable handle not being fully visible
Previously, `overflow: hidden` was needed because the height constraint and
padding could push the content out of the container. Now this should not be
possible.
* Add an option to the block to decide how is the image fitted to the container
* 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.
* Remove the ToggleButtonControl in favor of ToggleGroupControl
* Remove ESLint errors. Use experimental feature as this is low risk
* Fix the 'Expected preceding comment block' ESLint error
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* 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
* 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>
* Make useStoreNotices interact directly with the store
* Get/set error notices directly in store in paymentMethodDataContext
* Add hasNoticesOfType util
* Remove useStoreNotices and interact directly with data store
* Create/remove notices directly in store
* Remove tests for useStoreNotices
* Add tests for notices util
* Use setIsSuppressed from useStoreNoticesContext
* remove useStoreNotices hook
* Update context typedef to define only isSuppressed and setIsSuppressed
* Remove all values from StoreNoticesContext besides setIsSuppressed
* Wrap Cart and Checkout blocks in StoreNoticesProvider (for isSuppressed)
* Make StoreNoticesContainer a named export
This is required so we can import it from @wooommerce/base-context
* Change addErrorNotice to createErrorNotice to match store action
* Remove unnecessary StoreNoticeProviders and pass only context to container
* Accept a context in StoreNoticesContainer
* Pass relevant context to StoreNoticesContainer
* Add function to remove notices by status
* Prevent checkout from breaking when removing notices during processing
* Prevent TS error about not included path
* Add StoreNoticesContainer to single product block
* Add StoreNoticesContainer to All Products Block
* Ensure errors are shown when using All Products & Single Product Blocks
* Add a context arg to removeNoticesByStatus
* Use correct contexts for all products and single product block
* Update tests to reflect new context argument
* Re-add missing block file for order-summary
* Remove block file for order-summary
* Send context to useStoreCartCoupons to show errors correctly
* 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>
* 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>
* Rename `Product Title` `Content` panel to `Link settings`
* Rename toggle `Link to Product Page` to `Make title a link`
* Remove help text
* Add `rel` and `linkTarget` to the `Product Title` settings
* Add `rel` and `linkTarget` to the `Product Title` block
* Only add the `target` attribute if the title is rendered as a link
* Keep the `nofollow` in rel as it was before
* Make `linkTarget` and `rel` optional
To not change the html generated for other components also using `ProductName`
* Add tests fotr the `Title` component
* Improve rel condition
* Extract `linkRel` variable
* Remove unnecessary undefined
* Remove the default value for `linkTarget`
Since it is the default behavior of the browsers, we don't need it.
* Remove the `nofollow` rel value
It was decided to remove it since it's a link to internal pages.
See the PR discussion for more context.
* Remove the `rel` option
It does not have much sense to have it since it's always an internal link.
See the PR discussion for more context.
* Clean-up `rel` related code
* 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>
* 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>
* 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
* 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
* Prevent accessing the first element of the `parentProduct` array if empty
* Include all products regardless of their `stock_status`
By default, the `/wc/store/v1/products` endpoint does not return products with
`outofstock` stock status. We want the users to be able to select any product
regardless of its stock status, we need to explicitly request them using the
`stock_status` query param.
* Use the optional chaining operator
Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
* 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>
* Empty commit for release pull request
* Updated changelog
* Prepare the Mini Cart block for Feature Plugin (https://github.com/woocommerce/woocommerce-blocks/pull/6127)
* Release notes
* Update plugin url
* Add 730 to README testing
* Remove PR from testing notes and changelog
* Remove PR from testing notes
* Allow memoized filters to re-run if `defaultArg` changes (https://github.com/woocommerce/woocommerce-blocks/pull/6102)
* Check the last defaultArg to decide whether we re-run filters
* Fake commit to make CI run
* Revert change to .gitignore to make CI run
* Update testing instructions
* Update testing instructions
* Update download link
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* 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
* 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 ⚡️
* 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>
* Filter Products by Attribute: Fix dropdown search case sensitivity handling
* Refactor the dropdown search logic and add an isCaseSensitive option
* Dropdown search: Match against the name rather than value
* Clean up and refactor the search dropdown code
* Add handling of editor context via GUTENBERG_EDITOR_CONTEXT env var
* Fix flaky tests around editing templates
* Wait for save template response to complete
* 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>
* Update actions/setup-node to v2 and to use ,nvmrc file
* Fix order of actions for Bundle Size workflow
* Use actions/setup-node cache instead of actions/cache
+ ensure we always install with npm ci
* restore linting setup job to cache npm
* Don't install ndb in CI
Move ndb package to optionalDependencies and update
the CI workflows to not install optional dependencies
* Update actions/setup-node to v3
* Update actions/checkout to v3
* Update download and upload-artifact actions to v3
* Update actions/stale to v5
* Create the CurrencyCode and use it for the currency `code` instead of the type `string`
Using the CurrencyCode type, the allowed values for the `code` property are restricted
to the ISO 4217 codes and not any string.
* Add and remove some currency codes to match the ones on WooCommerce
The WooCommerce supported list can be found here: https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce/includes/wc-core-functions.php#L475
* Use CurrencyCode type on CurrencyInfo and CurrencyResponse instead of string
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>
* Make shipping address field optional on checkout routes
* Make update_customer_from_request use billing for shipping if omitted
* making shipping optional when needed
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
* 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
* 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>
* 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
* 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>
* 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
* 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>
* 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>
* 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>
* 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 fixwoocommerce/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>
* 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
* 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
* 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>
* 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>
* 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>
* 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>
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).
Closeswoocommerce/woocommerce-blocks#5660
* 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
* 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>
* 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>
* 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>
* 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
* 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
* 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
* 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>
* 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>
* 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
* adds toolbar option to remove custom image
removing custom image will reset it back to the default
product image if available
* update copy as per discussion
went with just Reset as it is commonly used in WordPress
and will have translation available
* Add address-related items to wc/store/cart data store
* include shippingAsBilling in return value of useCustomerData
* 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 the updating customer data work from the useCustomerData hook
* Remove shippingAsBilling from previousCustomerData ref type
* Add useShippingAsBillingCheckbox hook
* Control shippingAsBilling from single hook
* Remove checkbox handling from useCheckoutAddress
* Remove CustomerDataContext typedef
* Merge with woocommerce/woocommerce-blocks#5810 changes
* Move shipping as billing to checkout state context provider
* Unused import
* Subscribe to changes
* Only receiveCartContents when updating customer data via checkout
* Cache customerDataToUpdate
* rename debounced function
* Combine customerDataType and customerDataContextType
* Change case of CustomerDataType
* debouncedUpdateCustomerData typo
* Fix notice context
* Clean up inline docs for push changes
* Comment on dirty state
* Phone is always set
* shippingAddress is never undefined
* setBillingPhone
* receiveCartContents explanation
* Tweak customerData to avoid null
* useShippingAsBilling
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* fix Global Styles for Product Image, Product Category List and Product Tag List blocks
fix Global Styles for Product Image, Product Category List and Product Tag List blocks
* Block style font-size was applying wrong value for fontSize
* Add missing __experimentalSkipSerialization to Category List
Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
* Pass context information about containing block to the existing Slots
* Fix images added to the Slots docs
* Use the parent's block name for the context prop passed to Slot fills
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
* Add wc-block-mini-cart__contents class for the Mini Cart block woocommerce/woocommerce-blocks#5418
Add wc-block-mini-cart__contents class for the Mini Cart block
* removed comment
* Fix All Products block pagination not showing up (https://github.com/woocommerce/woocommerce-blocks/pull/5850)
* Fix regression for Twenty Twenty-Two theme with sale prices being underlined (https://github.com/woocommerce/woocommerce-blocks/pull/5851)
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
* Product title: add support global style woocommerce/woocommerce-blocks#4965
* add specific type
* add custom save function
* Rating Product block: add support for global style woocommerce/woocommerce-blocks#4965
Rating Product block: add support for global style
* add feature flag
* fix import after merge
* fix global style css generation
* restore css for classic product rating html element
* don't apply the global style to PHP blocks
* remove registration
* Product title: add support global style woocommerce/woocommerce-blocks#4965
* add specific type
* add custom save function
* move hooks in a specific folder
* Tag List block: add support for global style woocommerce/woocommerce-blocks#4965
Tag List Block: add support for global style
* add feature flag
* Product title: add support global style woocommerce/woocommerce-blocks#4965
* add specific type
* Enable global style for category list block woocommerce/woocommerce-blocks#4965
Enable global style for category list block
* fix import after merge
* add save function
* add feature flag
* Refactor maybe_return_blocks_template to get_woocommerce_block_file_template
* Remove unused method and rename get_woocommerce_block_file_template to get_block_file_template
* Account for product-archive template fallbacks
* Fix bug with clearing customizations of templates using the deprecated plugin ID
* Convert radio component to TS and support uncontrolled components
* Further radio control to typescript changes
* Combine useSelectShippingRate and useSelectShippingRates
* Remove useSelectShippingRate hook
* Move local radio checked state to PackageRates
* This is a Controlled component - update inline docs
* useSelectShippingRates -> useSelectShippingRate rename
* Add the correct appender button for non empty groups
* Revert "Add the correct appender button for non empty groups"
This reverts commit 4b41d7d7f82461813b3464d1b4f931c442bce3be.
* Force position relative for custom InnerBlocks.ButtonBlockAppender appenders.
Removing InnerBlocks.ButtonBlockAppender from renderAppender = {InnerBlocks.ButtonBlockAppender } results in the black appender button beeing shown only when the block is selected, and we need the appender to be visible by default.
* Remove api hydration for the Mini Cart Block woocommerce/woocommerce-blocks#5729
Remove api hydration for the Mini Cart Block
* fix PHP error
* send event when the button is clicked
* fix import order
* Add hover & focus styles for component buttons
We are using an old version of the "@wordpress/component" package,
that's why we are not getting the latest style fixes from Gutenberg.
The reason to not using the latest version is that we had some issues
with the bundle size.
The current solution is to set our own focus & hover styles
* Replace raw value with Sass variable
* Fix hover style for the mini cart block
We don't have the outlined button yet. This styles is unique for the
mini cart button.
To refactor this code, maybe we should create a reusable outlined button
* Add variant to the Woo Block Button component
To refactor our code, adding a "variant" prop looks logical since we are
have already "contained" & "outlined" buttons. So, for future need for an
outlined button, no need to manually apply the same style again.
The "contained" variant is set by default for legacy reasons. Our Button
component was first built as a contained one.
* Fix height difference: oulined & contained buttons
The outlined buttons have more height because of the added border value.
To fix it we can replace the border with the inner shadow.
Co-authored-by: Saad Tarhi <saad.tarhi@automattic.com>