From b6d00880da3071dfeb98fb1086b064df86d6c1fc Mon Sep 17 00:00:00 2001 From: Luigi <gigitux@gmail.com> Date: Thu, 19 Oct 2023 10:36:04 +0200 Subject: [PATCH] fix E2E tests --- ...rge-image.block_theme.side_effects.spec.ts | 22 ++++++++++--------- ...t-gallery.block_theme.side_effects.spec.ts | 4 +--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/e2e/tests/product-gallery/inner-blocks/product-gallery-large-image/product-gallery-large-image.block_theme.side_effects.spec.ts b/tests/e2e/tests/product-gallery/inner-blocks/product-gallery-large-image/product-gallery-large-image.block_theme.side_effects.spec.ts index f709eb38fa9..71f347a8de3 100644 --- a/tests/e2e/tests/product-gallery/inner-blocks/product-gallery-large-image/product-gallery-large-image.block_theme.side_effects.spec.ts +++ b/tests/e2e/tests/product-gallery/inner-blocks/product-gallery-large-image/product-gallery-large-image.block_theme.side_effects.spec.ts @@ -99,9 +99,7 @@ test.describe( `${ blockData.name }`, () => { } ); // img[style] is the selector because the style attribute is Interactivity API. - const imgElement = blockFrontend.locator( - 'img[style]:not([hidden])' - ); + const imgElement = blockFrontend.locator( 'img' ).first(); const style = await imgElement.evaluate( ( el ) => el.style ); await expect( style.transform ).toBe( 'scale(1)' ); @@ -137,14 +135,18 @@ test.describe( `${ blockData.name }`, () => { page: 'frontend', } ); - // img[style] is the selector because the style attribute is added by Interactivity API. In this case, the style attribute should not be added. - const imgElement = blockFrontend.locator( - 'img[style]:not([hidden])' + const imgElement = blockFrontend.locator( 'img' ).first(); + const style = await imgElement.evaluate( ( el ) => el.style ); + + await expect( style.transform ).toBe( '' ); + + await imgElement.hover(); + + const styleOnHover = await imgElement.evaluate( + ( el ) => el.style ); - await expect( imgElement ).toBeHidden(); - await expect( - blockFrontend.locator( 'img:not([hidden])' ) - ).toBeVisible(); + + await expect( styleOnHover.transform ).toBe( '' ); } ); } ); } ); diff --git a/tests/e2e/tests/product-gallery/product-gallery.block_theme.side_effects.spec.ts b/tests/e2e/tests/product-gallery/product-gallery.block_theme.side_effects.spec.ts index 909bc39527e..17a58caa4bb 100644 --- a/tests/e2e/tests/product-gallery/product-gallery.block_theme.side_effects.spec.ts +++ b/tests/e2e/tests/product-gallery/product-gallery.block_theme.side_effects.spec.ts @@ -34,9 +34,7 @@ const test = base.extend< { pageObject: ProductGalleryPage } >( { export const getVisibleLargeImageId = async ( mainImageBlockLocator: Locator ) => { - const mainImage = mainImageBlockLocator.locator( - 'img:not([hidden])' - ) as Locator; + const mainImage = mainImageBlockLocator.locator( 'img' ).first() as Locator; const mainImageContext = ( await mainImage.getAttribute( 'data-wc-context'