Skip to content

Commit

Permalink
fixing tests for new ui
Browse files Browse the repository at this point in the history
  • Loading branch information
circlecube committed Nov 9, 2023
1 parent b820275 commit ea06fc0
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 106 deletions.
2 changes: 1 addition & 1 deletion tests/cypress/integration/help.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe('Help Page', () => {

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

it('Is Accessible', () => {
Expand Down
41 changes: 25 additions & 16 deletions tests/cypress/integration/home.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,50 @@
describe('Home Page', function () {

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

it('Header Exists', () => {
cy
.get('.wppm-header').contains('h2', 'MOJO')
.scrollIntoView()
.should('be.visible');

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

cy.get('.wppm-app-site-info').contains('h3', siteTitle)
.scrollIntoView()
.should('be.visible');
})
});

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

it('Web Content Section Exists', () => {
it('Maintenance Mode Section Exists', () => {
cy
.get('.wppm-section-home-content').contains('h3', 'Content')
.get('.wppm-app-home-coming-soon').contains('h3', 'Site Status')
.scrollIntoView()
.should('be.visible');
});

it('Settings Section Exists', () => {
it('Website Content Section Exists', () => {
cy
.get('.wppm-section-home-settings').contains('h3', 'Settings')
.get('.wppm-app-home-content').contains('h3', 'Website Content')
.scrollIntoView()
.should('be.visible');
});

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

it('Web Hosting Section Exists', () => {
cy
.get('.wppm-app-home-hosting').contains('h3', 'Web Hosting')
.scrollIntoView()
.should('be.visible');
});
});
89 changes: 59 additions & 30 deletions tests/cypress/integration/navigation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
describe('Navigation', function () {

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

it('Logo Links to home', () => {
Expand All @@ -25,78 +26,106 @@ describe('Navigation', function () {
// test main nav
it('Main nav links properly navigates', () => {
cy
.get('.link-Marketplace').
.get('.wppm-app-navitem-Marketplace').
should('not.have.class', 'active');
cy.get('.link-Marketplace').click();
cy.get('.wppm-app-navitem-Marketplace').click();
cy.wait(500);
cy.hash().should('eq', '#/marketplace');
cy
.get('.link-Marketplace')
.get('.wppm-app-navitem-Marketplace')
.should('have.class', 'active');
cy
.get('#adminmenu #toplevel_page_mojo ul.wp-submenu li.current a')
.should('have.attr', 'href')
.and('match', /marketplace/);

cy.get('.link-Performance').click();
cy.get('.wppm-app-navitem-Performance').click();
cy.wait(500);
cy.hash().should('eq', '#/performance');
cy
.get('.link-Performance')
.get('.wppm-app-navitem-Performance')
.should('have.class', 'active');
cy
.get('.link-Marketplace')
.get('.wppm-app-navitem-Marketplace')
.should('not.have.class', 'active');
cy
.get('#adminmenu #toplevel_page_mojo ul.wp-submenu li.current a')
.should('have.attr', 'href')
.and('match', /performance/);

cy.get('.link-Settings').click();
cy.get('.wppm-app-navitem-Settings').click();
cy.wait(500);
cy.hash().should('eq', '#/settings');
cy
.get('#adminmenu #toplevel_page_mojo ul.wp-submenu li.current a')
.should('have.attr', 'href')
.and('match', /settings/);
});

it('Utility nav links properly navigates', () => {
it('Subnav links properly navigates', () => {
cy
.get('.utility-link-Performance')
.get('.wppm-app-navitem-Marketplace')
.scrollIntoView()
.should('not.have.class', 'active');
cy
.get('.utility-link-Performance').click();
cy.get('.wppm-app-navitem-Marketplace').click();

cy.wait(500);
cy.hash().should('eq', '#/performance');
cy.hash().should('eq', '#/marketplace');
cy
.get('.utility-link-Performance')
.get('.wppm-app-navitem-Marketplace')
.should('have.class', 'active');

cy
.get('.utility-link-Settings').click();
.get('#adminmenu #toplevel_page_mojo ul.wp-submenu li.current a')
.should('have.attr', 'href')
.and('match', /marketplace/);

cy.get('.wppm-app-subnavitem-Services').click();
cy.wait(500);
cy.hash().should('eq', '#/marketplace/services');
cy
.get('.wppm-app-subnavitem-Services')
.should('have.class', 'active');
cy
.get('#adminmenu #toplevel_page_mojo ul.wp-submenu li.current a')
.should('have.attr', 'href')
.and('match', /marketplace/);
cy
.get('.wppm-app-navitem-Marketplace')
.should('have.class', 'active');


cy.get('.wppm-app-subnavitem-SEO').click();
cy.wait(500);
cy.hash().should('eq', '#/settings');
cy.hash().should('eq', '#/marketplace/seo');
cy
.get('.utility-link-Settings')
.get('.wppm-app-subnavitem-SEO')
.should('have.class', 'active');
cy
.get('.utility-link-Performance')
.get('.wppm-app-subnavitem-Services')
.should('not.have.class', 'active');

cy
.get('.utility-link-Help').click();
cy.wait(500);
cy.hash().should('eq', '#/help');
.get('#adminmenu #toplevel_page_mojo ul.wp-submenu li.current a')
.should('have.attr', 'href')
.and('match', /marketplace/);
cy
.get('.utility-link-Help')
.get('.wppm-app-navitem-Marketplace')
.should('have.class', 'active');

cy.get('.wppm-app-navitem-Performance').click();
cy.wait(500);
cy
.get('.wppm-app-subnavitem-Services')
.should('not.have.class', 'active');
cy
.get('.wppm-app-subnavitem-SEO')
.should('not.have.class', 'active');
cy
.get('.utility-link-Settings')
.get('.wppm-app-navitem-Marketplace')
.should('not.have.class', 'active');
});

it('Mobile nav links dispaly for mobile', () => {
// no mobile nav, but should probably add
it.skip('Mobile nav links dispaly for mobile', () => {
cy
.get('.mobile-toggle')
.should('not.exist');
Expand All @@ -107,14 +136,14 @@ describe('Navigation', function () {
.should('be.visible');
});

it('Mobile nav links properly navigates', () => {
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 Navigation"]').should('be.visible')
cy.get('button[aria-label="Close Navigation"]').click();
cy.get('button[aria-label="Close"]').should('be.visible')
cy.get('button[aria-label="Close"]').click();
cy.get('.mobile-link-Home').should('not.exist');
});
});
Loading

0 comments on commit ea06fc0

Please sign in to comment.