Skip to content

Commit

Permalink
Merge pull request #346 from newfold-labs/update/tests-for-testIsolation
Browse files Browse the repository at this point in the history
update cypress tests for testIsolation
  • Loading branch information
circlecube authored Nov 14, 2024
2 parents ca060c6 + 5ec24aa commit bcd9f4e
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 98 deletions.
1 change: 1 addition & 0 deletions src/app/components/app-nav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export const MobileNav = () => {
<Logo />
</div>
<button
id="nfd-app-mobile-nav"
role="button"
className="nfd-h-16 nfd-px-4 nfd-text-body nfd-flex nfd-items-center focus:nfd-outline-none focus:nfd-ring-2 focus:nfd-ring-inset focus:nfd-ring-primary"
onClick={() => { setIsOpen(true) }}
Expand Down
17 changes: 7 additions & 10 deletions tests/cypress/integration/help.cy.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
// <reference types="Cypress" />

describe('Help Page', () => {
const appId = Cypress.env( 'appId' );
const pluginId = Cypress.env( 'pluginId' );
describe('Help Page', { testIsolation: true }, () => {

before(() => {
cy.visit(`/wp-admin/admin.php?page=${pluginId}#/help`);
beforeEach(() => {
cy.wpLogin();
cy.visit(`/wp-admin/admin.php?page=${ Cypress.env( 'pluginId' ) }#/help`);
});

it('Is Accessible', () => {
cy.injectAxe();
cy.wait(500);
cy.a11y('.' + appId + '-app-body');
cy.a11y('.' + Cypress.env( 'appId' ) + '-app-body');
});

it('Phone Card Exists', () => {
it('Cards Exist', () => {
cy.get('.card-help-phone').contains('h3', 'Phone')
.scrollIntoView()
.should('be.visible');
});

it('Blog Card Exists', () => {

cy.get('.card-help-blog').contains('h3', 'Blog')
.scrollIntoView()
.should('be.visible');
Expand Down
22 changes: 11 additions & 11 deletions tests/cypress/integration/home.cy.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// <reference types="Cypress" />

describe('Home Page', function () {
const appId = Cypress.env( 'appId' );
const pluginId = Cypress.env( 'pluginId' );
describe('Home Page', { testIsolation: true }, () => {
const appClass = '.' + Cypress.env( 'appId' );

before(() => {
cy.visit(`/wp-admin/admin.php?page=${pluginId}#/home`);
beforeEach(() => {
cy.wpLogin();
cy.visit(`/wp-admin/admin.php?page=${ Cypress.env( 'pluginId' ) }#/home`);
});

it('Site Info Exists', () => {
cy.window().then((win) => {
const siteTitle = win.NewfoldRuntime.siteTitle;

cy.get('.' + appId + '-app-site-info').contains('h3', siteTitle)
cy.get( appClass + '-app-site-info').contains('h3', siteTitle)
.scrollIntoView()
.should('be.visible');
})
Expand All @@ -21,33 +21,33 @@ describe('Home Page', function () {
it('Is Accessible', () => {
cy.injectAxe();
cy.wait(500);
cy.a11y('.' + appId + '-app-body');
cy.a11y( appClass + '-app-body');
});

it('Maintenance Mode Section Exists', () => {
cy
.get('.' + appId + '-app-home-coming-soon').contains('h3', 'Site Status')
.get( appClass + '-app-home-coming-soon').contains('h3', 'Site Status')
.scrollIntoView()
.should('be.visible');
});

it('Website Content Section Exists', () => {
cy
.get('.' + appId + '-app-home-content').contains('h3', 'Website Content')
.get( appClass + '-app-home-content').contains('h3', 'Website Content')
.scrollIntoView()
.should('be.visible');
});

it('Settings and Performance Section Exists', () => {
cy
.get('.' + appId + '-app-home-settings').contains('h3', 'Settings and Performance')
.get( appClass + '-app-home-settings').contains('h3', 'Settings and Performance')
.scrollIntoView()
.should('be.visible');
});

it('Web Hosting Section Exists', () => {
cy
.get('.' + appId + '-app-home-hosting').contains('h3', 'Web Hosting')
.get( appClass + '-app-home-hosting').contains('h3', 'Web Hosting')
.scrollIntoView()
.should('be.visible');
});
Expand Down
84 changes: 38 additions & 46 deletions tests/cypress/integration/navigation.cy.js
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' );
});
});
Loading

0 comments on commit bcd9f4e

Please sign in to comment.