diff --git a/test/e2e/specs/editor/blocks/cover.spec.js b/test/e2e/specs/editor/blocks/cover.spec.js index 4cfac0aac032fd..cc5a7d55cb4563 100644 --- a/test/e2e/specs/editor/blocks/cover.spec.js +++ b/test/e2e/specs/editor/blocks/cover.spec.js @@ -230,7 +230,6 @@ test.describe( 'Cover', () => { test( 'z-index of Navigation block inside a Cover block is higher than the other cover inner blocks', async ( { editor, page, - coverBlockUtils, } ) => { // Insert a Cover block await editor.insertBlock( { name: 'core/cover' } ); @@ -282,15 +281,23 @@ test.describe( 'Cover', () => { .getByRole( 'button', { name: 'Open menu' } ) .click(); - const menuZIndex = await coverBlockUtils.calculateZIndexContext( - coverBlock.locator( '.wp-block-navigation__responsive-container' ) + // Locate the inner container + const innerContainer = secondCoverBlock.locator( + '.wp-block-cover__inner-container' ); - const innerBlocksZIndex = await coverBlockUtils.calculateZIndexContext( - secondCoverBlock.locator( '.wp-block-cover__inner-container' ) - ); + let isClickable; + + try { + isClickable = await innerContainer.click( { + trial: true, + timeout: 1000, // This test will always take 1 second to run. + } ); + } catch ( error ) { + isClickable = false; + } - expect( menuZIndex ).toBeGreaterThan( innerBlocksZIndex ); + expect( isClickable ).toBe( false ); } ); } ); @@ -321,27 +328,4 @@ class CoverBlockUtils { return filename; } - - async calculateZIndexContext( element ) { - const zIndexResult = await element.evaluate( ( el ) => { - let zIndex = 0; - let currentElement = el; - - while ( currentElement ) { - const computedStyle = window.getComputedStyle( currentElement ); - const zIndexValue = parseInt( computedStyle.zIndex, 10 ); - - // If the element creates a new stacking context - if ( ! isNaN( zIndexValue ) ) { - zIndex = zIndexValue; - } - - currentElement = currentElement.parentElement; // Move up the DOM tree - } - - return zIndex; - } ); - - return zIndexResult; - } }