woocommerce/plugins/woocommerce-blocks/tests
Manish Menaria 4ca6696f12
Product Collection: Add "order" reference to Upsells and Cross-sells (#52258)
* Add order reference to Upsells and Cross-sells

- Added 'order' to usesReference in cross-sells and upsells
- Updated LinkedProductControl for order context
- Enhanced ProductCollection to handle order references

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Add PHP code for Cross-sells collection

* Fix formatting

* Add E2E tests

1. In the Cart Template, it checks that "From products in the cart" is
   selected by default for the "My Custom Collection - Cart Context".

2. In the Order Confirmation Template, it verifies that "From products
   in the order" is chosen by default for the "My Custom Collection -
   Order Context".

* Add 'block' scope to cross-sells collection

* Extract and use reference type constants

This commit extracts the REFERENCE_TYPE_CART and REFERENCE_TYPE_ORDER
constants to the top of the file and updates their usage throughout
the code, including in the getFromCurrentProductRadioLabel function.

* Align variable naming for product references in Product Collection

This commit updates the ProductCollection class to ensure consistency in
variable naming for product references across different collection types,
particularly aligning with the naming convention used in Upsells.

* Add "hadOrderReference" to conditional label display

Key changes:
- Removed `isUsesReferenceIncludesCart` parameter from `getFromCurrentProductRadioLabel`
- Introduced `hasCartReference` and `hasOrderReference` parameters for consistency
- Updated conditional logic to check for both cart and order references
- Adjusted the function call in `LinkedProductControl` to pass both new parameters

* Fallback to 0 for orderId in get_product_ids_from_order calls

---------

Co-authored-by: github-actions <github-actions@github.com>
2024-10-25 14:56:39 +05:30
..
e2e Product Collection: Add "order" reference to Upsells and Cross-sells (#52258) 2024-10-25 14:56:39 +05:30
js Monorepo: enable babel-loader and Jest caching (inc. CI) (#49656) 2024-07-19 09:40:01 +02:00
mocks/woo-test-helper Relocate helper (child) themes (#47080) 2024-05-02 21:23:52 +07:00
utils Blocks: Fix JS unit tests (#47516) 2024-05-15 16:03:11 +00:00