Skip to content

Commit

Permalink
fix: WooCommerce E2E test for cecking WooCommerce blocks supports
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaghdam committed Dec 19, 2024
1 parent 1843e00 commit c3bccc7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/blockera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Unreleased

### Bug Fixes

- Fixed WooCommerce E2E tests for checking WooCommerce blocks support.


## 1.0.1 (2024-12-08)

### Improvements
Expand Down
40 changes: 35 additions & 5 deletions packages/blockera/js/test/editor.woocommerce.e2e.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import {
createPost,
appendBlocks,
getBlockType,
addBlockToPost,
getWPDataObject,
Expand All @@ -19,18 +20,47 @@ describe('Blockera editor bootstrapper', () => {
it('should added blockera supports on woocommerce/product-price', () => {
createPost({ postType: 'product' });

cy.get('input[name="post_title"]').type('Cap', { delay: 0 });
cy.get('input[name="post_title"]').type('Product title', { delay: 0 });
cy.get('input#publish').click();

createPost();

addBlockToPost('woocommerce/all-products');
appendBlocks(`<!-- wp:woocommerce/product-collection {"queryId":48,"query":{"perPage":9,"pages":0,"offset":0,"postType":"product","order":"asc","orderBy":"title","search":"","exclude":[],"inherit":false,"taxQuery":{},"isProductCollectionBlock":true,"featured":false,"woocommerceOnSale":false,"woocommerceStockStatus":["instock","outofstock","onbackorder"],"woocommerceAttributes":[],"woocommerceHandPickedProducts":[],"filterable":false,"relatedBy":{"categories":true,"tags":true}},"tagName":"div","displayLayout":{"type":"flex","columns":3,"shrinkColumns":true},"dimensions":{"widthType":"fill"},"queryContextIncludes":["collection"],"__privatePreviewState":{"isPreview":false,"previewMessage":"Actual products will vary depending on the page being viewed."}} -->
<div class="wp-block-woocommerce-product-collection"><!-- wp:woocommerce/product-template -->
<!-- wp:woocommerce/product-image {"imageSizing":"thumbnail","isDescendentOfQueryLoop":true} /-->
cy.getBlock('woocommerce/all-products').click();
<!-- wp:post-title {"textAlign":"center","level":3,"isLink":true,"style":{"spacing":{"margin":{"bottom":"0.75rem","top":"0"}}},"fontSize":"medium","__woocommerceNamespace":"woocommerce/product-collection/product-title"} /-->
cy.getByAriaLabel(`Edit the layout of each product`).click();
<!-- wp:woocommerce/product-price {"isDescendentOfQueryLoop":true,"textAlign":"center","fontSize":"small"} /-->
cy.getBlock('woocommerce/product-price').should('be.visible').click();
<!-- wp:woocommerce/product-button {"textAlign":"center","isDescendentOfQueryLoop":true,"fontSize":"small"} /-->
<!-- /wp:woocommerce/product-template -->
<!-- wp:query-pagination {"blockeraCompatId":"111921216455","blockeraFlexLayout":{"value":{"direction":"row","alignItems":"","justifyContent":"center"}},"layout":{"type":"flex","justifyContent":"center"}} -->
<!-- wp:query-pagination-previous /-->
<!-- wp:query-pagination-numbers /-->
<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->
<!-- wp:woocommerce/product-collection-no-results -->
<!-- wp:group {"layout":{"type":"flex","orientation":"vertical","justifyContent":"center","flexWrap":"wrap"}} -->
<div class="wp-block-group"><!-- wp:paragraph {"fontSize":"medium"} -->
<p class="has-medium-font-size"><strong>No results found</strong></p>
<!-- /wp:paragraph -->
<!-- wp:paragraph -->
<p>You can try <a class="wc-link-clear-any-filters" href="#">clearing any filters</a> or head to our <a class="wc-link-stores-home" href="#">store's home</a></p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->
<!-- /wp:woocommerce/product-collection-no-results --></div>
<!-- /wp:woocommerce/product-collection -->`);

cy.getBlock('woocommerce/product-price')
.first()
.should('be.visible')
.click();

cy.getByAriaLabel('Add New Background').should('exist');

Expand Down

0 comments on commit c3bccc7

Please sign in to comment.