Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test updates and adding testIsolation #800

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -195,6 +195,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={ () => {
Expand Down
20 changes: 6 additions & 14 deletions tests/cypress/integration/help.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
const pluginNotificationsFixture = require( '../fixtures/plugin-notifications.json' );
const pluginProductsFixture = require( '../fixtures/plugin-products.json' );

describe('Help Page', function () {
describe('Help Page', { testIsolation: true }, () => {

before(() => {
beforeEach(() => {
cy.wpLogin();
cy.setRegion();
cy.setBrand();
cy.setLanguage();
Expand All @@ -17,13 +18,15 @@ describe('Help Page', function () {
},
pluginProductsFixture
).as( 'pluginProductsFixture' );

cy.intercept(
{
method: 'GET',
url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/,
},
pluginNotificationsFixture
).as( 'pluginNotificationsFixture' );

cy.visit(
'/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/help',
{
Expand All @@ -35,7 +38,6 @@ describe('Help Page', function () {
}
}
);
cy.injectAxe();

});

Expand All @@ -45,37 +47,27 @@ describe('Help Page', function () {
cy.a11y('.hgwp-app-body');
});

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

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

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

it('KB Card Exists', () => {
cy.get('.card-help-kb').contains('h3', 'Knowledge Base')
.scrollIntoView()
.should('be.visible');
});

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

it('Youtube Card Exists', () => {
cy.get('.card-help-video').contains('h3', 'Video')
.scrollIntoView()
.should('be.visible');
Expand Down
44 changes: 21 additions & 23 deletions tests/cypress/integration/home.cy.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,51 @@
// <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');
cy.injectAxe();
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');
})
});

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

it('Maintenance Mode Section Exists', () => {
it('Each Section Exists', () => {
// Maintenance Mode
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', () => {

// Website Content
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', () => {

// 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', () => {

// 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
122 changes: 38 additions & 84 deletions tests/cypress/integration/navigation.cy.js
Original file line number Diff line number Diff line change
@@ -1,159 +1,113 @@
// <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(() => {
beforeEach(() => {
cy.wpLogin();
cy.exec( 'npx wp-env run cli wp transient delete newfold_marketplace' );
cy.visit('/wp-admin/admin.php?page=' + pluginId );
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-navitem-Marketplace')
.get( appClass + '-app-navitem-Marketplace')
.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');
});

// utility nav is no more, leaving this in place in case we bring it back anytime soon.
it.skip('Utility nav links properly navigates', () => {
cy
.get('.utility-link-Performance')
.should('not.have.class', 'active');
cy
.get('.utility-link-Performance').click();
cy.wait(500);
cy.hash().should('eq', '#/performance');
cy
.get('.utility-link-Performance')
.should('have.class', 'active');

cy
.get('.utility-link-Settings').click();
cy.wait(500);
cy.hash().should('eq', '#/settings');
cy
.get('.utility-link-Settings')
.should('have.class', 'active');
cy
.get('.utility-link-Performance')
.should('not.have.class', 'active');

cy
.get('.utility-link-Help').click();
cy.wait(500);
cy.hash().should('eq', '#/help');
cy
.get('.utility-link-Help')
.should('have.class', 'active');
cy
.get('.utility-link-Settings')
.should('not.have.class', 'active');
});
it( 'Mobile nav links dispaly and link properly on mobile', () => {
cy.viewport( 'iphone-x' );
cy.get( '#nfd-app-mobile-nav' ).should( 'be.visible' );

// no mobile nav, but should probably add
it.skip('Mobile nav links dispaly for mobile', () => {
cy
.get('.mobile-toggle')
.should('not.exist');
cy.get( appClass + '-app-navitem-Home' ).should( 'not.exist' );

cy.viewport('iphone-x');
cy
.get('.mobile-toggle')
.should('be.visible');
});

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' );
});
});
9 changes: 4 additions & 5 deletions tests/cypress/integration/pages-and-posts.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
describe( 'Pages & Posts', function () {
describe( 'Pages & Posts', { testIsolation: true }, () => {
let NewfoldRuntime;

before( () => {
beforeEach( () => {
cy.wpLogin();
cy.visit(
'/wp-admin/admin.php?page=' +
Cypress.env( 'pluginId' ) +
'#/pages-and-posts'
`/wp-admin/admin.php?page=${ Cypress.env( 'pluginId' ) }#/pages-and-posts`
);
cy.window()
.its( 'NewfoldRuntime' )
Expand Down
Loading
Loading