Skip to content

Commit

Permalink
try local wonder block test replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube committed Dec 5, 2023
1 parent 2c528d7 commit 5b715c1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 44 additions & 0 deletions tests/cypress/integration/wonder-blocks.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// <reference types="Cypress" />

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' );
} );
} );

0 comments on commit 5b715c1

Please sign in to comment.