diff --git a/packages/blocks/core/js/wordpress/home-link/test/block.blocks.e2e.cy.js b/packages/blocks/core/js/wordpress/home-link/test/block.blocks.e2e.cy.js index a7e168fe0..5b64c15ae 100644 --- a/packages/blocks/core/js/wordpress/home-link/test/block.blocks.e2e.cy.js +++ b/packages/blocks/core/js/wordpress/home-link/test/block.blocks.e2e.cy.js @@ -7,52 +7,69 @@ import { openInnerBlocksExtension, } from '@blockera/dev-cypress/js/helpers'; -describe('Home Link Block', () => { - beforeEach(() => { - createPost(); - }); +describe( + 'Home Link Block', + { + defaultCommandTimeout: 50000, + }, + () => { + beforeEach(() => { + createPost(); + }); + + it('Block should be supported + switch to parent should work', () => { + appendBlocks(''); + + cy.getBlock('core/navigation').click(); - it('Block should be supported + switch to parent should work', () => { - appendBlocks(''); + // Make sure the tree is visible (Ajax call done) + cy.get('.block-editor-list-view-tree').should('be.visible'); - cy.getBlock('core/navigation').click(); + cy.get('.block-editor-list-view-tree').within(() => { + // Open blocks menu + cy.get('[aria-label="Add block"]').first().click(); + }); - // Open blocks menu - cy.get('[aria-label="Add block"]').first().click(); + // search for home link + cy.get('.block-editor-inserter__popover input[type="search"]').type( + 'Home Link' + ); - // search for custom link - cy.get('input[type="search"]:focus').last().type('Home Link'); + // insert + cy.get('button.editor-block-list-item-home-link').last().click(); - // insert - cy.get('button.editor-block-list-item-home-link').last().click(); + // switch to target block + cy.getBlock('core/home-link').first().click(); - // switch to target block - cy.getBlock('core/home-link').first().click(); + // assert block card + cy.get('.blockera-extension-block-card.master-block-card').should( + 'exist' + ); - // assert block card - cy.get('.blockera-extension-block-card.master-block-card').should( - 'exist' - ); + // switch to parent navigation block + cy.get('.blockera-extension-block-card.master-block-card').within( + () => { + cy.get( + 'button[data-test="back-to-parent-navigation"]' + ).should('exist'); + cy.get( + 'button[data-test="back-to-parent-navigation"]' + ).click(); + } + ); - // switch to parent navigation block - cy.get('.blockera-extension-block-card.master-block-card').within( - () => { - cy.get('button[data-test="back-to-parent-navigation"]').should( - 'exist' + // + // Assert block switched to parent navigation block + // + cy.get('.blockera-extension-block-card.master-block-card').should( + 'not.exist' + ); + cy.get('.block-editor-block-card').should('exist'); + cy.get('.block-editor-block-card').within(() => { + cy.get('.block-editor-block-card__title').contains( + 'Navigation' ); - cy.get('button[data-test="back-to-parent-navigation"]').click(); - } - ); - - // - // Assert block switched to parent navigation block - // - cy.get('.blockera-extension-block-card.master-block-card').should( - 'not.exist' - ); - cy.get('.block-editor-block-card').should('exist'); - cy.get('.block-editor-block-card').within(() => { - cy.get('.block-editor-block-card__title').contains('Navigation'); + }); }); - }); -}); + } +); diff --git a/packages/blocks/core/js/wordpress/navigation-link/test/block.blocks.e2e.cy.js b/packages/blocks/core/js/wordpress/navigation-link/test/block.blocks.e2e.cy.js index 22882e905..a64b34e1b 100644 --- a/packages/blocks/core/js/wordpress/navigation-link/test/block.blocks.e2e.cy.js +++ b/packages/blocks/core/js/wordpress/navigation-link/test/block.blocks.e2e.cy.js @@ -7,55 +7,74 @@ import { openInnerBlocksExtension, } from '@blockera/dev-cypress/js/helpers'; -describe('Navigation Link Block', () => { - beforeEach(() => { - createPost(); - }); +describe( + 'Navigation Link Block', + { + defaultCommandTimeout: 50000, + }, + () => { + beforeEach(() => { + createPost(); + }); + + it('Block should be supported + switch to parent should work', () => { + appendBlocks(''); + + cy.getBlock('core/navigation').click(); - it('Block should be supported + switch to parent should work', () => { - appendBlocks(''); + // Make sure the tree is visible (Ajax call done) + cy.get('.block-editor-list-view-tree').should('be.visible'); - cy.getBlock('core/navigation').click(); + cy.get('.block-editor-list-view-tree').within(() => { + // Open blocks menu + cy.get('[aria-label="Add block"]').first().click(); + }); - // Open blocks menu - cy.get('[aria-label="Add block"]').first().click(); + // search for custom link + cy.get('.block-editor-inserter__popover input[type="search"]').type( + 'Custom Link' + ); - // search for custom link - cy.get('input[type="search"]:focus').last().type('Custom Link'); + // insert + cy.get('button.editor-block-list-item-navigation-link') + .last() + .click(); - // insert - cy.get('button.editor-block-list-item-navigation-link').last().click(); + // enter link value + cy.get('input[type="text"]:focus').type('#test{enter}'); - // enter link value - cy.get('input[type="text"]:focus').type('#test{enter}'); + // switch to target block + cy.getBlock('core/navigation-link').first().click(); - // switch to target block - cy.getBlock('core/navigation-link').first().click(); + // assert block card + cy.get('.blockera-extension-block-card.master-block-card').should( + 'exist' + ); - // assert block card - cy.get('.blockera-extension-block-card.master-block-card').should( - 'exist' - ); + // switch to parent navigation block + cy.get('.blockera-extension-block-card.master-block-card').within( + () => { + cy.get( + 'button[data-test="back-to-parent-navigation"]' + ).should('exist'); + cy.get( + 'button[data-test="back-to-parent-navigation"]' + ).click(); + } + ); - // switch to parent navigation block - cy.get('.blockera-extension-block-card.master-block-card').within( - () => { - cy.get('button[data-test="back-to-parent-navigation"]').should( - 'exist' + // + // Assert block switched to parent navigation block + // + cy.get('.blockera-extension-block-card.master-block-card').should( + 'not.exist' + ); + cy.get('.block-editor-block-card').should('exist'); + cy.get('.block-editor-block-card').within(() => { + cy.get('.block-editor-block-card__title').contains( + 'Navigation' ); - cy.get('button[data-test="back-to-parent-navigation"]').click(); - } - ); - - // - // Assert block switched to parent navigation block - // - cy.get('.blockera-extension-block-card.master-block-card').should( - 'not.exist' - ); - cy.get('.block-editor-block-card').should('exist'); - cy.get('.block-editor-block-card').within(() => { - cy.get('.block-editor-block-card__title').contains('Navigation'); + }); }); - }); -}); + } +);