Skip to content

Commit

Permalink
Merge pull request #138 from newfold-labs/update/testisolation
Browse files Browse the repository at this point in the history
Update cypress test with testIsolation
  • Loading branch information
circlecube authored Jan 13, 2025
2 parents aa2468b + 03e2829 commit b7d672d
Showing 1 changed file with 32 additions and 35 deletions.
67 changes: 32 additions & 35 deletions tests/cypress/integration/wonder-blocks.cy.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,42 @@
// <reference types="Cypress" />

describe("WonderBlocks", function () {
before(() => {
cy.visit("/wp-admin/post-new.php");
});
describe( "WonderBlocks", { testIsolation: true }, () => {
beforeEach( () => {
cy.login( Cypress.env( "wpUsername" ), Cypress.env( "wpPassword" ) );
cy.visit( "/wp-admin/post-new.php" );
} );

it("WonderBlocks button exists", () => {
cy.get("#nfd-wba-toolbar-button").should("exist");
});
it( "WonderBlocks button present and modal functions", () => {
cy.get( "#nfd-wba-toolbar-button" ).should( "exist" );

it("WonderBlocks button opens modal", () => {
cy.wait(1000);
cy.wait( 1000 );

cy.window().then((win) => {
win.wp.data.select("core/edit-post").isFeatureActive("welcomeGuide") &&
win.wp.data.dispatch("core/edit-post").toggleFeature("welcomeGuide");
});
cy.window().then( ( win ) => {
win.wp.data.select( "core/edit-post" ).isFeatureActive( "welcomeGuide" ) &&
win.wp.data.dispatch( "core/edit-post" ).toggleFeature( "welcomeGuide" );
} );

cy.wait(100);
cy.get("#nfd-wba-toolbar-button button").click();
cy.wait(100);
cy.wait( 100 );
cy.get( "#nfd-wba-toolbar-button button" ).click();
cy.wait( 100 );
// body has class modal-open
cy.get("body").should("have.class", "modal-open");
cy.get( "body" ).should( "have.class", "modal-open" );
// modal window exists
cy.get('.nfd-wba-modal[role="dialog"]').should("be.visible");
});
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();
cy.wait(100);
cy.get("body").should("not.have.class", "modal-open");
cy.get('.nfd-wba-modal[role="dialog"]').should("not.exist");
});
// 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();
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 button").click();
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");
});
});
// ESC button closes modal too
cy.get( "#nfd-wba-toolbar-button button" ).click();
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 b7d672d

Please sign in to comment.