* Prepare test cases
* Shorten out the test description
* Add first test in a post with dummy expect
* Verify all content is displayed
* Add the test in Product Archive and Home Page
* Add changelog
* Add tag to Beanie product
* Switch to Beanie which is on sale to verify on sale badge
* Add comments to explain the expects
* Adjust the expected content
* Switch to lower case in expect
* Switch from woocommerce/product-summary to core/post-excerpt
* Adjust products.sh
* Improve method waiting for products to show so it;'s deterministic
* Refresh locators in template
* Remove unnecessary check
* Eslint disable: expects are extracted to function so disable eslint compaining there's no expect
* Adjust other test after amending products setup
* Change the verify happening in a wrong place
* Tests adjustments
* Revert Blog Home template before performing a test
* Fix other tests
* Add additional-checkout-fields-test-helper wp-env plugin
* Ensure Checkout page waits for email to be visible before filling
* Handle additional fields in checkout page utils
* Add test for filling additional checkout fields
* Add additional check for gov-id validation
* Close context used for plugin-checking
* Update types for additional fields to be key/value objects
* Check billing gov-id is different to shipping one
* Move additional fields plugin to inline with checkout tests
* Use additional fields plugin from local dir
* Await email input to check Checkout block is loaded
* Add test to verify error message shows when leaving a field blank
* Update comment
* Add test for checking/unchecking checkboxes
* Update check in additional field test plugin
* Change fields multiple times in one test
* Add server-side validation tests
* Get exact matches for checkout form fields
* Remove unnecessarily translated strings
* update hook in test plugin to compare to confirmation gov id
* Fill in gov ID confirmation field
* Register a field of each type in each location
* Don't validate field unless both are filled
* Fill additional fields and check their values
* Fill additional fields
* Check select values in order confirmation
* Change the values of all field types multiple times
* Make checkout wait until not calculating before submitting
* Update tests to use all additional field types
* Blur after editing select box
* Add customer area checks
* Check shipping isn't calculating before submitting
* Add merchant-side tests for additional checkout fields
* Ensure customer data is done updating before submitting
* use waitForFunction to check for updating shipping
* Add changelog
* Ensure fields are blurred before pressing button
* Update validation error check
* Add test for logged out shopper
* make specific function to wait for checkout to be finished updating
* Add test to ensure fields are saved across orders
* Add sanitize and validate callbacks to gov id fields
* Make purchase type select field required
* Add sanitization test
* Use experimental function in test plugin
* Add standalone sanitization filter test
* Update testing plugin to use new and renamed filters
* Fix typo
* Move empty value test to logged out shopper block and check empty val
* Update tests to include tests for new validation/sanitization filters
* Add verifyAdditionalFieldsDetails function to checkout page
* Use new verifyAdditionalFieldsDetails function to improve readability
* Update second test to use new function to improve readability
* Update third test to improve readability
* Update fourth function to improve readability
* Update fourth test to improve readability
* Update guest shopper test to be more readable
* Update helper function to only return value not assert
* Remove check causing test to fail in CI
* Make check for guest shopper same as logged in
* Move guest shopper tests to their own file
* Ensure unchecking checkbox works OK
* Set initial vlaue of Created filter for New Arrivals collection
* Add changelog
* Remove a check for products in tests as they may not really be displayed
* Adjust the New Arrivals test
* Adjust the tests logic after the change
* Bring back previous formatting
* Bring back function closure removed by mistake
* Unskip Mini Cart i18n test
* Install language packs before each i18n-related test suite
* Delete translations.sh
* Add changelog
* Replace deprecated WP-CLI command
* Remove obsolete WP-CLI command
* Revert "[e2e tests blocks] Configure the number of shards for each matrix project (#45212)"
This reverts commit 72789656cf.
* trigger CI
* run E2E tests
* restore ci.yml file
* trigger E2E tests
* disable E2E tests about mini cart translations
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix the setupAndFetchQueryContextURL utility
* add comment
* Remove obsolete test
* Blocks E2E: Update timeout values (#45353)
Set timeout values same as core
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Bart Kalisz <bartlomiej.kalisz@gmail.com>
* Open templates from list instead of loading the URL in block templates e2e tests
* Typo
* Clean up
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Make sure correct template is loaded
* Create a TemplateType type to avoid having to define it in several places
---------
Co-authored-by: github-actions <github-actions@github.com>
* Refactor store usage
* Prepare function resolving inherit property for additional check
* Add logic to disable sync with query if there's already one Product Collection on archive that does that
* Add changelog
* Cover the post editor case
* Add E2E test for that and small refactor in tests
* Remove duplicated import
* Fix lint problems
* Fix typo in test description
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Replace confusin abbreviation with other description
* Update the logic to be more robust and covering also the case where Product Collection blocks are nested
* Add issue reference to the comment
* Add eslint disable before ts-ignore
---------
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
* Clear billing address when useShippingAsBilling checkbox is unchecked
* Add billing address sync with server
* Add useRef hook to store previous billing address and update sync functions
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Revert "Add useRef hook to store previous billing address and update sync functions"
This reverts commit 7bc3312ab7.
* Added condition to clear address only for guest users
* Add E2E test to check billing address form is empty for Guest shopper
* Fix typo
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Updated docs-manifest.json
* Revert "Updated docs-manifest.json"
This reverts commit 20d578a9d6.
* Include company field in the E2E test
* Replace beforeAll with beforeEach
* Skip country reset to keep consistency with Shortcode Checkout
* Remove sync billing address on server
* Update E2E test to include the shipping address check
* Remove unsed imports
* Clear address fields except country and state
* Optimize the billing and shipping address check with switch statement
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* Add sharding to Blocks e2e tests
* Changelog
* Push a change to Blocks README to trigger tests
* Fix syntax
* Fixed again
* Try again
* Trying to get the shard number
* Shard names
* fix E2E test
* complete all the jobs
---------
Co-authored-by: Jon Lane <jon.lane@automattic.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* Early implementation of getting the Product Collection location/context
* Solve the problem of async fetch in the hook
* Improve typing
* Import core data store instead of hardcoding store name
* Recognise Product Category and Product Tag
* Remove attr property from archive location data
* Unify states naming
* Add TODO entry
* Display the info about the location of Product Collection
* Improve the typing
* Recognise if Product Collection is nested in Single Product block
* Improve cases descriptions and add some defaults to potentially undefined values
* Change the taxonomies sourceData
* Recognise Mini Cart as Cart context
* Recognise attribute as archive contect but no taxonomy
* Refactor the function into single useEffect and clean it up
* Fix typo
* Remove unnecessary import
* Stop rendering the output in Editor (it was for demo purposes)
* Pass location data to Product Template query in Editor
* Replace templateSlugs literal strings with object reference
* Rename parseResponse function to more specific name getIdFromResponse
* Add dpeendency array to useEffect
* Refactor templates detection
* Use full taxonomy names instead of shortcuts
* Write down scenarios to test
* Working scenario
* Change the verification way for more robust
* Add more robust methods to include Single Product block
* Add test Product Collection in Single Product block in a Single Product Template
* Imprvoe the order of veryfing the requests
* Fix linter issues. Although that makes code less readable
* Improve the useGetLocation typing so it's more generic
* Rework the E2E tests regarding location of Product Collection and limit their number
* Bring back necessary eslint-disable
* Remove unused imports
* Uncomment line required for other tests
* Add changelog
* Rename constant from BLOCK_NAME to BLOCK_SLUG as it's a slug
* Add a BLOCK_NAME constant and replace the literal block name usages in E2E tests
* Fix post merge issues
* Fix test after merge
* Adjust the tests to kick off waiting for request before action that triggers them
* Make attributes available in rest_product_query hook
This commit introduces the 'includeInQueryContext' attribute to the 'woocommerce/product-collection' block and updates the 'woocommerce/product-template' block to consume this new attribute.
Key Changes:
1. `woocommerce/product-collection` Block:
- A new attribute 'includeInQueryContext' is added in `block.json`. This attribute is designed to hold a list of attribute names relevant for the query context.
- The 'includeInQueryContext' attribute is included in the `providesContext` field to ensure its availability to child blocks.
- In `constants.ts`, default values for 'includeInQueryContext' are defined, specifying 'collection' and 'id' as initial attributes.
- The `types.ts` file is updated with a comment explaining the purpose of 'includeInQueryContext'.
2. `woocommerce/product-template` Block:
- Modified `block.json` to utilize the 'includeInQueryContext' context provided by the parent `woocommerce/product-collection` block.
- The `edit.tsx` file is updated to handle the new context. It uses a newly added utility function `useProductCollectionBlockAttributes` from `utils.tsx` to access parent block attributes.
- The `utils.tsx` file is introduced, containing the `useProductCollectionBlockAttributes` hook. This hook is responsible for finding the parent 'woocommerce/product-collection' block and returning its attributes.
- Within `edit.tsx`, logic is added to create a query context object based on the attributes specified in 'includeInQueryContext', enhancing the block's ability to dynamically adapt to changes.
* Remove commented code
* Rename query context attribute and optimize parent block detection
This commit introduces two significant changes aimed at improving code readability and efficiency.
1. **Renaming of Query Context Attribute:**
- The attribute `includeInQueryContext` has been renamed to `queryContextIncludes` across various files, including block JSON configurations and TypeScript definitions. This change makes the attribute's purpose more intuitive, indicating it specifies which attributes to include in the query context.
2. **Optimized Parent Block Detection:**
- Replaced the use of `getBlockParents` with `getBlockParentsByBlockName` in utility functions to find the closest Product Collection block. This optimization allows for a more direct and efficient way to identify the relevant parent block by specifying the block name, reducing unnecessary iterations and improving code performance.
* Streamline query context construction in product template
Key Changes:
- **Introduction of `useProductCollectionQueryContext` Hook:** This new hook takes the `clientId` and `queryContextIncludes` as inputs and returns a query context object. It encapsulates the logic for fetching parent product collection block attributes and constructing the query context accordingly. This abstraction simplifies the edit component's logic, focusing on the essentials and improving code readability.
- **Optimization of Parent Block Detection:** The hook uses `getBlockParentsByBlockName` to accurately and efficiently find the closest parent `Product Collection` block, minimizing the overhead previously associated with traversing the block hierarchy.
* Always include `collection` and `id` in query context
* Minor refactor
* Enhance query context handling for more maintainable code
- Introduced `DEFAULT_QUERY_CONTEXT_ATTRIBUTES` in `edit.tsx` to maintain a clear list of default query context attributes.
- Modified `ProductTemplateEdit` to automatically include these default attributes in `queryContextIncludes`, ensuring they are always part of the query context without manual initialization.
- Simplified `useProductCollectionQueryContext` in `utils.tsx` by removing static initialization of 'collection' and 'id', relying instead on the dynamic addition of necessary attributes from `queryContextIncludes`.
This refactor enhances the maintainability and clarity of the code, ensuring a solid foundation for future enhancements and features.
* Add E2E tests for Product Collection query context
- Added a new test suite 'Query Context in Editor' to validate the correctness of query context parameters when the Product Collection block is used. This suite ensures that:
- For the 'Product Catalog', only the ID is sent in the query context, confirming that collection-specific parameters are excluded when not relevant.
- For collections such as 'On Sale', the collection name is correctly passed in the query context, validating that the block dynamically adjusts query parameters based on its settings.
- Introduced a new utility method `setupAndFetchQueryContextURL` in `product-collection.page.ts`. This method automates the setup of a post with the Product Collection block and fetches the URL with query context parameters, facilitating the validation of query context handling.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix edge case when `queryContextIncludes` is not defined
- Initializing `queryContextIncludes` with a default empty array directly in the destructuring assignment of the component's props. This approach ensures that `queryContextIncludes` is always an array, simplifying downstream logic.
- Creating a new constant `queryContextIncludesWithDefaults` to hold the combination of `queryContextIncludes` and `DEFAULT_QUERY_CONTEXT_ATTRIBUTES`. This step avoids directly mutating the `queryContextIncludes` prop, aligning with best practices for functional purity and making the code easier to understand and debug.
- Updating the `useProductCollectionQueryContext` hook call to use `queryContextIncludesWithDefaults`. This ensures that the default query context attributes are consistently included without altering the original prop.
These adjustments not only enhance the code's maintainability but also ensure more predictable behavior by avoiding side effects related to parameter mutation.
---------
Co-authored-by: github-actions <github-actions@github.com>
* Remove global pageObject action from Product Collection tests and add it as before all for specific tests
* Replace beforeAll with beforeEach
* Adjust the beforeEach usage
* Add changelog
* Refresh locators when adding Single Product block as it's not initialised in pageObject
* Change method dedicated to templates to one dedicated to posts
* Remove 'get_block_template' backwards compatibility check
* Add back get_block_template as a deprecated function
* Deprecate BlockTemplateUtils::filter_block_templates_by_feature_flag()
* Replace 'default template' with 'fallback template'
* Only load BlockTemplatesController in block themes
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Remove unnecessary WP version comparison
* Revert "Only load BlockTemplatesController in block themes"
This reverts commit 8e1ed347d61b7ae5e8b8b96fa73b410565570f01.
* Remove deprecated functions, as they are marked as internal
---------
Co-authored-by: github-actions <github-actions@github.com>
* Improve password-protected Single Product block template to verify correct template is displayed after correct password is introduced
* Add changelog entry
* Add automated tests to verify specific product templates are rendered
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Improve Product Collection test when nested in Single Product block, previous version was flakyu
* Add changelog
* Move the priovate method below the comment starting private methods
* Remove unnecessary wait
* Simplify add template title and description
* Add template title and description on 'get_block_template' hook. Fixes#42221
* Add tests
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix test in template parts
* Use BlockTemplateUtils::template_has_title when possible
* Add test also when saving the default WooCommerce template
---------
Co-authored-by: github-actions <github-actions@github.com>
* fix error on decimal input for the Number of Thumbnails setting
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add e2e tests for password-protected Single Product block template
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix tests
---------
Co-authored-by: github-actions <github-actions@github.com>
* Initial approach to fix incorrect product data displayed in Product Collection in context of Single Product block
* Remove the BlockCOntextProvider
* Add Block context for title and summary
* Add changelog
* Improve typing
* Add E2E test with Product Collection inside Single Product block
* Improve insertBLock function description
* Make productPrices selector in Product Collectionmore specific
* Extract components props into a types
* Rename block template customization test files
* Move Checkout Header template part tests to parameterized tests
* Make it so 'userText' in tests is different in each template, so prevent false positives
* Move Mini-Cart template part tests to parameterized tests
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Make sure there are products in cart before going to the Checkout template
---------
Co-authored-by: github-actions <github-actions@github.com>
* Migrate coupon- and shipping-related tests
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix prettier issue
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add theme-customization e2e tests to Cart and Checkout templates
* Add theme-customization e2e tests to Order Confirmation template
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Update after rebase
* Make it so Order Confirmation template tests are also part of the parameterized tests
* Use CUSTOMIZABLE_WC_TEMPLATES constant instead of defining the templates again
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix wrong template slug
* Rename 'default' to 'fallback' template
---------
Co-authored-by: github-actions <github-actions@github.com>
* Avoid duplicate templates appearing on the Site Editor when the WooCommerce template and the theme template have been customized by the user
* Add tests
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Clean up templates after running all tests to increase speed
* Fix comment linting
* Fix addToCart() util with the classic template
* Remove unnecessary condition
---------
Co-authored-by: github-actions <github-actions@github.com>
* Move Cart, Checkout and Order Confirmation template customization tests to the parameterized tests file
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Clean up order-confirmation.block_theme.spec.ts file
---------
Co-authored-by: github-actions <github-actions@github.com>
* Remove docs plugin from monorepo
* Add language to md-docs readme
* Fix lint error in blocks
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>