-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from newfold-labs/update/tests-for-testIsolation
update cypress tests for testIsolation
- Loading branch information
Showing
7 changed files
with
91 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,111 @@ | ||
// <reference types="Cypress" /> | ||
|
||
describe('Navigation', function () { | ||
const appId = Cypress.env( 'appId' ); | ||
const pluginId = Cypress.env( 'pluginId' ); | ||
describe('Navigation', { testIsolation: true }, () => { | ||
const appClass = '.' + Cypress.env( 'appId' ); | ||
|
||
before(() => { | ||
cy.visit(`/wp-admin/admin.php?page=${pluginId}#`); | ||
beforeEach(() => { | ||
cy.wpLogin(); | ||
cy.visit(`/wp-admin/admin.php?page=${ Cypress.env( 'pluginId' ) }#`); | ||
}); | ||
|
||
it( "Admin submenu shouldn't exist inside app", () => { | ||
cy.get( '#adminmenu #toplevel_page_' + pluginId + ' ul.wp-submenu' ).should( | ||
cy.get( '#adminmenu #toplevel_page_' + Cypress.env( 'pluginId' ) + ' ul.wp-submenu' ).should( | ||
'not.exist' | ||
); | ||
} ); | ||
|
||
it('Logo Links to home', () => { | ||
cy.get('.' + appId + '-logo-wrap').click(); | ||
cy.get( appClass + '-logo-wrap').click(); | ||
cy.wait(500); | ||
cy.hash().should('eq', '#/home'); | ||
}); | ||
|
||
// test main nav | ||
it('Main nav links properly navigates', () => { | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace'). | ||
.get( appClass + '-app-navitem-Marketplace'). | ||
should('not.have.class', 'active'); | ||
cy.get('.' + appId + '-app-navitem-Marketplace').click(); | ||
cy.get( appClass + '-app-navitem-Marketplace').click(); | ||
cy.wait(500); | ||
cy.hash().should('eq', '#/marketplace'); | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace') | ||
.get( appClass + '-app-navitem-Marketplace') | ||
.should('have.class', 'active'); | ||
|
||
cy.get('.' + appId + '-app-navitem-Performance').click(); | ||
cy.get( appClass + '-app-navitem-Performance').click(); | ||
cy.wait(500); | ||
cy.hash().should('eq', '#/performance'); | ||
cy | ||
.get('.' + appId + '-app-navitem-Performance') | ||
.get( appClass + '-app-navitem-Performance') | ||
.should('have.class', 'active'); | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace') | ||
.get( appClass + '-app-navitem-Marketplace') | ||
.should('not.have.class', 'active'); | ||
|
||
cy.get('.' + appId + '-app-navitem-Settings').click(); | ||
cy.get( appClass + '-app-navitem-Settings').click(); | ||
cy.wait(500); | ||
cy.hash().should('eq', '#/settings'); | ||
}); | ||
|
||
it('Subnav links properly navigates', () => { | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace') | ||
.get( appClass + '-app-navitem-Marketplace') | ||
.scrollIntoView() | ||
.should('not.have.class', 'active'); | ||
cy.get('.' + appId + '-app-navitem-Marketplace').click(); | ||
cy.get( appClass + '-app-navitem-Marketplace').click(); | ||
|
||
cy.wait(500); | ||
cy.hash().should('eq', '#/marketplace'); | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace') | ||
.get( appClass + '-app-navitem-Marketplace') | ||
.should('have.class', 'active'); | ||
|
||
cy.get('.' + appId + '-app-subnavitem-Services').click(); | ||
cy.get( appClass + '-app-subnavitem-Services').click(); | ||
cy.wait(500); | ||
cy.hash().should('eq', '#/marketplace/services'); | ||
cy | ||
.get('.' + appId + '-app-subnavitem-Services') | ||
.get( appClass + '-app-subnavitem-Services') | ||
.should('have.class', 'active'); | ||
|
||
|
||
cy.get('.' + appId + '-app-subnavitem-SEO').click(); | ||
cy.get( appClass + '-app-subnavitem-SEO').click(); | ||
cy.wait(500); | ||
cy.hash().should('eq', '#/marketplace/seo'); | ||
cy | ||
.get('.' + appId + '-app-subnavitem-SEO') | ||
.get( appClass + '-app-subnavitem-SEO') | ||
.should('have.class', 'active'); | ||
cy | ||
.get('.' + appId + '-app-subnavitem-Services') | ||
.get( appClass + '-app-subnavitem-Services') | ||
.should('not.have.class', 'active'); | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace') | ||
.get( appClass + '-app-navitem-Marketplace') | ||
.should('have.class', 'active'); | ||
|
||
cy.get('.' + appId + '-app-navitem-Performance').click(); | ||
cy.get( appClass + '-app-navitem-Performance').click(); | ||
cy.wait(500); | ||
cy | ||
.get('.' + appId + '-app-subnavitem-Services') | ||
.get( appClass + '-app-subnavitem-Services') | ||
.should('not.have.class', 'active'); | ||
cy | ||
.get('.' + appId + '-app-subnavitem-SEO') | ||
.get( appClass + '-app-subnavitem-SEO') | ||
.should('not.have.class', 'active'); | ||
cy | ||
.get('.' + appId + '-app-navitem-Marketplace') | ||
.get( appClass + '-app-navitem-Marketplace') | ||
.should('not.have.class', 'active'); | ||
}); | ||
|
||
// no mobile nav, but should probably add | ||
it.skip('Mobile nav links dispaly for mobile', () => { | ||
cy | ||
.get('.mobile-toggle') | ||
.should('not.exist'); | ||
it( 'Mobile nav links dispaly and link properly on mobile', () => { | ||
cy.get( '#nfd-app-mobile-nav' ).should( 'not.exist' ); | ||
cy.viewport( 'iphone-x' ); | ||
cy.get( '#nfd-app-mobile-nav' ).should( 'be.visible' ); | ||
|
||
cy.viewport('iphone-x'); | ||
cy | ||
.get('.mobile-toggle') | ||
.should('be.visible'); | ||
}); | ||
cy.get( appClass + '-app-navitem-Home' ).should( 'not.exist' ); | ||
|
||
it.skip('Mobile nav links properly navigates', () => { | ||
cy.get('.mobile-link-Home').should('not.exist'); | ||
cy.viewport('iphone-x'); | ||
cy.get('.mobile-toggle').click(); | ||
cy.wait(500); | ||
cy.get('.mobile-link-Home').should('be.visible'); | ||
cy.get('button[aria-label="Close"]').should('be.visible') | ||
cy.get('button[aria-label="Close"]').click(); | ||
cy.get('.mobile-link-Home').should('not.exist'); | ||
cy.get( '#nfd-app-mobile-nav' ).click(); | ||
cy.wait( 500 ); | ||
cy.get( appClass + '-app-navitem-Home' ).should( 'be.visible' ); | ||
cy.get( 'button.nfd-modal__close-button' ).should( 'be.visible' ); | ||
cy.get( 'button.nfd-modal__close-button' ).click(); | ||
cy.get( appClass + '-app-navitem-Home' ).should( 'not.exist' ); | ||
}); | ||
}); |
Oops, something went wrong.