Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Wait for canvas before enabling Apply Filters button
Browse files Browse the repository at this point in the history
  • Loading branch information
Aljullu committed Apr 2, 2023
1 parent c025afa commit ab5e5b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions tests/e2e/specs/shopper/filter-products-by-attribute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
switchUserToAdmin,
publishPost,
} from '@wordpress/e2e-test-utils';
import { selectBlockByName } from '@woocommerce/blocks-test-utils';

/**
* Internal dependencies
Expand All @@ -20,6 +19,7 @@ import {
saveTemplate,
useTheme,
waitForAllProductsBlockLoaded,
waitForCanvas,
insertAllProductsBlock,
enableApplyFiltersButton,
} from '../../utils';
Expand Down Expand Up @@ -185,9 +185,8 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId,
} );

await selectBlockByName( block.slug );

await enableApplyFiltersButton();
await waitForCanvas();
await enableApplyFiltersButton( block.slug );

await saveTemplate();
await goToShopPage();
Expand Down Expand Up @@ -300,9 +299,9 @@ describe( `${ block.name } Block`, () => {

it( 'should refresh the page only if the user clicks on button', async () => {
await page.goto( editorPageUrl );
await selectBlockByName( block.slug );

await enableApplyFiltersButton();
await waitForCanvas();
await enableApplyFiltersButton( block.slug );

await saveOrPublish();
await page.goto( frontedPageUrl );
Expand Down
11 changes: 5 additions & 6 deletions tests/e2e/specs/shopper/filter-products-by-price.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
switchUserToAdmin,
publishPost,
} from '@wordpress/e2e-test-utils';
import { selectBlockByName } from '@woocommerce/blocks-test-utils';

/**
* Internal dependencies
Expand All @@ -18,6 +17,7 @@ import {
goToTemplateEditor,
saveTemplate,
useTheme,
waitForCanvas,
waitForAllProductsBlockLoaded,
insertAllProductsBlock,
enableApplyFiltersButton,
Expand Down Expand Up @@ -179,9 +179,8 @@ describe( `${ block.name } Block`, () => {
postId: productCatalogTemplateId,
} );

await selectBlockByName( block.slug );

await enableApplyFiltersButton();
await waitForCanvas();
await enableApplyFiltersButton( block.slug );

await saveTemplate();
await goToShopPage();
Expand Down Expand Up @@ -284,8 +283,8 @@ describe( `${ block.name } Block`, () => {
it( 'should refresh the page only if the user click on button', async () => {
await page.goto( editorPageUrl );

await selectBlockByName( block.slug );
await enableApplyFiltersButton();
await waitForCanvas();
await enableApplyFiltersButton( block.slug );

await saveOrPublish();
await page.goto( frontedPageUrl );
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/specs/shopper/filter-products-by-rating.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ describe( `${ block.name } Block`, () => {
} );

await waitForCanvas();
await selectBlockByName( block.slug );
await enableApplyFiltersButton();
await enableApplyFiltersButton( block.slug );

await saveTemplate();
await goToShopPage();
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/specs/shopper/filter-products-by-stock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ describe( `${ block.name } Block`, () => {
} );

await waitForCanvas();
await selectBlockByName( block.slug );
await enableApplyFiltersButton();
await enableApplyFiltersButton( block.slug );

await saveTemplate();
await goToShopPage();
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '@wordpress/e2e-test-utils';
import { addQueryArgs } from '@wordpress/url';
import { WP_ADMIN_DASHBOARD } from '@woocommerce/e2e-utils';
import { selectBlockByName } from '@woocommerce/blocks-test-utils';
import fs from 'fs';

/**
Expand Down Expand Up @@ -504,7 +505,8 @@ export const insertAllProductsBlock = async () => {
insertButton?.click();
};

export const enableApplyFiltersButton = async () => {
export const enableApplyFiltersButton = async ( blockSlug ) => {
await selectBlockByName( blockSlug );
await ensureSidebarOpened();
await switchBlockInspectorTab( 'Settings' );

Expand Down

0 comments on commit ab5e5b8

Please sign in to comment.