diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/fork.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/fork.cy.js new file mode 100644 index 000000000..98b9db108 --- /dev/null +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/fork.cy.js @@ -0,0 +1,74 @@ +// + +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'); + } ); +}); diff --git a/tests/cypress/integration/wp-module-support/siteGen.cy.js b/tests/cypress/integration/wp-module-support/siteGen.cy.js new file mode 100644 index 000000000..ccb6db2cc --- /dev/null +++ b/tests/cypress/integration/wp-module-support/siteGen.cy.js @@ -0,0 +1,36 @@ +// + +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(); + }; +};