Skip to content

Commit

Permalink
Merge pull request #403 from newfold-labs/add-initial-tests
Browse files Browse the repository at this point in the history
PRESS2-1481- The Fork Step Cypress Test
  • Loading branch information
avneet-raj authored Jan 10, 2024
2 parents 02b803c + 8b217a6 commit 13d0137
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
74 changes: 74 additions & 0 deletions tests/cypress/integration/5-AI-SiteGen-onboarding-flow/fork.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// <reference types="Cypress" />

import { AdminBarCheck, DarkBGCheck, LightBGChcek, OptionsDetails } from "../wp-module-support/siteGen.cy";

describe( 'SiteGen Fork Step', function () {
before( () => {
cy.visit(
'wp-admin/?page=nfd-onboarding#/wp-setup/step/fork'
);
} );

it( 'Check for the header admin bar', () => {
AdminBarCheck();
} );

it( 'Check for the existing dark background', () => {
DarkBGCheck();
} );

it( 'Check for the light background', () => {
LightBGChcek();
} );

it( 'Check for the heading and the title', () => {
cy.get( '.nfd-onboarding-step__heading__title' )
.should('be.visible')
.should('have.text', 'Welcome to WordPress');
} );

it ( 'Check for the subheading', () => {
cy.get( '.nfd-onboarding-step__heading__subtitle' ).should('be.visible');
} );

it ( 'Check the number of container options available', () => {
cy.get( '.nfd-onboarding-sitegen-options__container__options' )
.should( 'be.visible' )
.should('have.length', 3);
} );

it( 'Check for selection of different container options', () => {
let options = 0;
const className = '.nfd-onboarding-sitegen-options__container__options';
const arr = cy.get( className );
arr.each( () => {
if(options == 0){
OptionsDetails(className,'Build it myself',options);
cy.url().should('include', 'get-started/welcome',{
timeout: 10000,
} );
cy.go('back');
};
if(options == 1){
OptionsDetails(className,'AI Website Creator',options);
cy.url().should('include', 'sitegen/step/welcome',{
timeout: 10000,
} );
cy.go('back');
};
if(options == 2){
OptionsDetails(className, 'Hire a Pro',options);
};
options+=1;

});
});

it( 'Check for the import your WP account link at the bottom', () => {
cy.get( '.nfd-onboarding-step--site-gen__fork__importsite' )
.scrollIntoView()
.should('exist')
.should('contain', 'Already have a WordPress site')
.should('have.attr', 'href', 'https://my.bluehost.com/cgi/services/migration');
} );
});
36 changes: 36 additions & 0 deletions tests/cypress/integration/wp-module-support/siteGen.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// <reference types="Cypress" />

export const AdminBarCheck = () => {
cy.get( '.nfd-onboarding-header__admin-bar' ).should('be.visible');
};

export const DarkBGCheck = () => {
cy.wait( 2000 );
// When the page loads, it should have dark background by default
cy.get('.nfd-onboarding-sitegen-dark').should('be.visible');
};

export const LightBGChcek = () => {
cy.get( '.nfd-onboarding-toggle__theme__button__dark' )
.should( 'exist' )
.click();
cy.get( '.nfd-onboarding-sitegen-light' ).should('be.visible');
// Now changing the background back to dark
cy.get( '.nfd-onboarding-toggle__theme__button__light' )
.should( 'exist' )
.click();
cy.get('.nfd-onboarding-sitegen-dark').should('be.visible');
};

export const OptionsDetails = (className,textValue,optionsValue) => {
cy.get(className)
.eq(optionsValue)
.find('.nfd-onboarding-sitegen-options__container__heading__title')
.invoke( 'text' )
.should('contain', textValue);
if(optionsValue!=2){ // Excluding the Last Option as it takes to new tab, just validating the title text
cy.get(className)
.eq(optionsValue)
.click();
};
};

0 comments on commit 13d0137

Please sign in to comment.