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

Commit

Permalink
Filter Products by Price test: wait for submit button to appear befor…
Browse files Browse the repository at this point in the history
…e saving the post (III)
  • Loading branch information
Aljullu committed Mar 31, 2023
1 parent 0666043 commit d2fb4f1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
10 changes: 9 additions & 1 deletion tests/e2e/specs/shopper/filter-products-by-attribute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const block = {
classicProductsList: '.products.columns-3 > li',
filter: "input[id='128gb']",
submitButton: '.wc-block-components-filter-submit-button',
XPathSubmitButton:
"//*[contains(@class,'wc-block-components-filter-submit-button')]",
},
},
urlSearchParamWhenFilterIsApplied:
Expand All @@ -71,8 +73,8 @@ describe( `${ block.name } Block`, () => {
title: block.name,
} );

await insertBlockUsingQuickInserter( 'All Products' );
await insertBlock( block.name );
await insertBlockUsingQuickInserter( 'All Products' );
const canvasEl = canvas();

// It seems that .click doesn't work well with radio input element.
Expand Down Expand Up @@ -198,6 +200,9 @@ describe( `${ block.name } Block`, () => {
block.selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();

await canvas().waitForXPath( selectors.frontend.XPathSubmitButton );

await saveTemplate();
await goToShopPage();

Expand Down Expand Up @@ -317,6 +322,9 @@ describe( `${ block.name } Block`, () => {
block.selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();

await canvas().waitForXPath( selectors.frontend.XPathSubmitButton );

await saveOrPublish();
await page.goto( frontedPageUrl );

Expand Down
11 changes: 6 additions & 5 deletions tests/e2e/specs/shopper/filter-products-by-price.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import {
canvas,
createNewPost,
deleteAllTemplates,
insertBlock,
Expand Down Expand Up @@ -43,7 +44,7 @@ const block = {
classicProductsList: '.products.columns-3 > li',
submitButton: '.wc-block-components-filter-submit-button',
XPathSubmitButton:
"//button[contains(@class,'wc-block-components-filter-submit-button')]",
"//*[contains(@class,'wc-block-components-filter-submit-button')]",
},
},
urlSearchParamWhenFilterIsApplied: '?max_price=2',
Expand Down Expand Up @@ -77,8 +78,8 @@ describe( `${ block.name } Block`, () => {
} );

await insertBlock( block.name );
await insertBlockUsingSlash( 'All Products' );
await insertBlock( 'Active Filters' );
await insertBlockUsingSlash( 'All Products' );
await publishPost();

const link = await page.evaluate( () =>
Expand Down Expand Up @@ -200,7 +201,7 @@ describe( `${ block.name } Block`, () => {
);
await filterButtonToggle.click();

await page.waitForXPath( selectors.frontend.XPathSubmitButton );
await canvas().waitForXPath( selectors.frontend.XPathSubmitButton );

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

await insertBlock( 'Products (Beta)' );
await insertBlock( block.name );
await insertBlock( 'Active Filters' );
await insertBlock( 'Products (Beta)' );
await page.waitForNetworkIdle();
await publishPost();

Expand Down Expand Up @@ -314,7 +315,7 @@ describe( `${ block.name } Block`, () => {
);
await filterButtonToggle.click();

await page.waitForXPath( selectors.frontend.XPathSubmitButton );
await canvas().waitForXPath( selectors.frontend.XPathSubmitButton );

await saveOrPublish();
await page.goto( frontedPageUrl );
Expand Down
8 changes: 7 additions & 1 deletion tests/e2e/specs/shopper/filter-products-by-rating.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import {
canvas,
createNewPost,
deleteAllTemplates,
insertBlock,
Expand Down Expand Up @@ -45,6 +46,8 @@ const block = {
classicProductsList: '.products.columns-3 > li',
fiveStarInput: ".wc-block-rating-filter label[for='5'] input",
submitButton: '.wc-block-components-filter-submit-button',
XPathSubmitButton:
"//*[contains(@class,'wc-block-components-filter-submit-button')]",
},
},
urlSearchParamWhenFilterIsApplied: '?rating_filter=5',
Expand Down Expand Up @@ -173,6 +176,9 @@ describe( `${ block.name } Block`, () => {
selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();

await canvas().waitForXPath( selectors.frontend.XPathSubmitButton );

await saveTemplate();
await goToShopPage();

Expand Down Expand Up @@ -224,8 +230,8 @@ describe( `${ block.name } Block`, () => {
title: block.name,
} );

await insertBlock( 'Products (Beta)' );
await insertBlock( block.name );
await insertBlock( 'Products (Beta)' );
await page.waitForNetworkIdle();
await publishPost();

Expand Down
8 changes: 7 additions & 1 deletion tests/e2e/specs/shopper/filter-products-by-stock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import {
canvas,
createNewPost,
deleteAllTemplates,
insertBlock,
Expand Down Expand Up @@ -44,6 +45,8 @@ const block = {
classicProductsList: '.products.columns-3 > li',
filter: 'input[id=outofstock]',
submitButton: '.wc-block-components-filter-submit-button',
XPathSubmitButton:
"//*[contains(@class,'wc-block-components-filter-submit-button')]",
queryProductsList: '.wp-block-post-template > li',
},
},
Expand Down Expand Up @@ -178,6 +181,9 @@ describe( `${ block.name } Block`, () => {
selectors.editor.filterButtonToggle
);
await filterButtonToggle.click();

await canvas().waitForXPath( selectors.frontend.XPathSubmitButton );

await saveTemplate();
await goToShopPage();

Expand Down Expand Up @@ -230,8 +236,8 @@ describe( `${ block.name } Block`, () => {
title: block.name,
} );

await insertBlock( 'Products (Beta)' );
await insertBlock( block.name );
await insertBlock( 'Products (Beta)' );
await publishPost();

editorPageUrl = page.url();
Expand Down

0 comments on commit d2fb4f1

Please sign in to comment.