Fix failed E2E tests related to attribute filter block (https://github.com/woocommerce/woocommerce-blocks/pull/7472)

This commit is contained in:
Tung Du 2022-10-25 16:12:04 +07:00 committed by GitHub
parent f3a31a07b3
commit 5e008ad058
2 changed files with 21 additions and 5 deletions

View File

@ -23,16 +23,26 @@ describe( `${ block.name } Block`, () => {
await switchUserToAdmin();
await visitBlockPage( `${ block.name } Block` );
await page.waitForSelector( 'span.woocommerce-search-list__item-name' );
// eslint-disable-next-line jest/no-standalone-expect
await expect( page ).toClick(
'span.woocommerce-search-list__item-name',
{ text: 'Capacity' }
);
//needed for attributes list to load correctly
await page.waitForTimeout( 1000 );
// eslint-disable-next-line jest/no-standalone-expect
await expect( page ).toClick( 'button', { text: 'Done' } );
await expect( page ).toClick(
'span.woocommerce-search-list__item-name',
{ text: 'Capacity' }
);
// eslint-disable-next-line jest/no-standalone-expect
await expect( page ).toClick(
'.wp-block-woocommerce-attribute-filter button',
{ text: 'Done' }
);
await page.waitForTimeout( 30000 );
await page.waitForNetworkIdle();
} );

View File

@ -67,8 +67,14 @@ describe( `${ block.name } Block`, () => {
await insertBlock( 'All Products' );
await insertBlock( block.name );
await page.click( selectors.editor.firstAttributeInTheList );
await page.click( selectors.editor.doneButton );
const canvasEl = canvas();
// It seems that .click doesn't work well with radio input element.
await canvasEl.$eval(
block.selectors.editor.firstAttributeInTheList,
( el ) => ( el as HTMLInputElement ).click()
);
await canvasEl.click( selectors.editor.doneButton );
await publishPost();
const link = await page.evaluate( () =>