diff --git a/cypress.config.js b/cypress.config.js index d63ccccaf..db7549c17 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -77,6 +77,7 @@ module.exports = defineConfig( { excludeSpecPattern: [ 'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/4-design-steps/**', 'vendor/newfold-labs/wp-module-onboarding/tests/cypress/integration/wp-module-support/', + 'vendor/newfold-labs/wp-module-patterns/tests/cypress/integration/', ], }, retries: 1, diff --git a/tests/cypress/integration/wonder-blocks.cy.js b/tests/cypress/integration/wonder-blocks.cy.js new file mode 100644 index 000000000..0166ad902 --- /dev/null +++ b/tests/cypress/integration/wonder-blocks.cy.js @@ -0,0 +1,44 @@ +// + +describe( 'Wonder Blocks', function () { + before( () => { + cy.visit( '/wp-admin/post-new.php' ); + } ); + + it( 'Wonder Blocks button exists', () => { + cy.get( '#nfd-wba-toolbar-button' ).should( 'exist' ); + } ); + + it( 'Wonder Blocks button opens modal', () => { + cy.wait( 1000 ); + cy.get( 'body' ).click( { force: true } ); // clear welcome guide + cy.wait( 100 ); + cy.get( '#nfd-wba-toolbar-button' ).click( { force: true } ); + cy.wait( 100 ); + // body has class modal-open + cy.get( 'body' ).should( 'have.class', 'modal-open' ); + // modal window exists + cy.get( '.nfd-wba-modal[role="dialog"]' ).should( 'be.visible' ); + } ); + + it( 'Close buttons closes modal', () => { + cy.get( + '.nfd-wba-modal__header button[aria-label="Close dialog"]' + ).should( 'exist' ); + cy.get( + '.nfd-wba-modal__header button[aria-label="Close dialog"]' + ).click( { force: true } ); + cy.wait( 100 ); + cy.get( 'body' ).should( 'not.have.class', 'modal-open' ); + cy.get( '.nfd-wba-modal[role="dialog"]' ).should( 'not.exist' ); + } ); + + it( 'ESC button closes modal too', () => { + cy.get( '#nfd-wba-toolbar-button' ).click( { force: true } ); + cy.wait( 100 ); + cy.get( '.nfd-wba-modal[role="dialog"]' ).should( 'be.visible' ); + cy.get( 'body' ).type( '{esc}' ); + cy.wait( 100 ); + cy.get( '.nfd-wba-modal[role="dialog"]' ).should( 'not.exist' ); + } ); +} );