From 19ce21bc3958b73ce79e71ecef71a6a24c3e03af Mon Sep 17 00:00:00 2001 From: Avneet Raj Date: Thu, 11 Jan 2024 20:30:14 +0530 Subject: [PATCH 1/4] create & add site-logo tests --- .../site-logo.cy.js | 66 +++++++++++++++++++ .../wp-module-support/siteGen.cy.js | 33 ++++++++++ 2 files changed, 99 insertions(+) create mode 100644 tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js new file mode 100644 index 000000000..d07135325 --- /dev/null +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js @@ -0,0 +1,66 @@ +// + +import { AdminBarCheck, BackButtonCheck, DarkBGCheck, DisabledNextButton, LightBGChcek, ProgressBarCheck, SkipButtonCheck } from "../wp-module-support/siteGen.cy"; + +describe( 'SiteGen Fork Step', function () { + before( () => { + cy.visit( + 'wp-admin/?page=nfd-onboarding#/sitgen/step/site-logo' + ); + } ); + + 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 the Progress Bar Value', () => { + ProgressBarCheck('33.3333%'); + }); + + it( 'Check for back button and go back', () => { + BackButtonCheck('sitgen/step/site-logo'); + } ); + + it( 'Check if the heading is visible', () => { + cy.get('.ai-heading').should('be.visible'); + } ); + + it( 'Check for the skip button and click', () => { + SkipButtonCheck('sitgen/step/site-logo'); + } ); + + it( 'Check if the Next Button is disabled when there is no logo', () => { + DisabledNextButton(); + } ); + + it( 'Check if Image gets uploaded and Next button is enabled', () => { + const sampleLogoPath = `vendor/newfold-labs/wp-module-onboarding/tests/cypress/fixtures/image.png`; + const LogoPreviewClass = '.nfd-onboarding-image-uploader--with-text__site_logo__preview'; + if( + cy.get('.nfd-onboarding-button--site-gen-next--disabled') + .should('be.visible') + ){ + cy.get(LogoPreviewClass) + .should('not.exist'); + }; + cy.get('input[type=file]', { timeout: 10000 }) + .should('exist') + .selectFile( sampleLogoPath , {force: true} ) + .then( () => { + cy.wait( 1000 ); + cy.get(LogoPreviewClass, { timeout: 10000 } ).should( 'be.visible' ); + cy.get( '.nfd-onboarding-image-uploader--with-text__site_logo__preview__reset__button' ) + .scrollIntoView() + .should( 'be.visible' ); + } ); + }); + +}); diff --git a/tests/cypress/integration/wp-module-support/siteGen.cy.js b/tests/cypress/integration/wp-module-support/siteGen.cy.js index ccb6db2cc..3db5e1fed 100644 --- a/tests/cypress/integration/wp-module-support/siteGen.cy.js +++ b/tests/cypress/integration/wp-module-support/siteGen.cy.js @@ -34,3 +34,36 @@ export const OptionsDetails = (className,textValue,optionsValue) => { .click(); }; }; + +export const ProgressBarCheck = ( WidthPercent ) => { + cy.get('.nfd-onboarding-header__progress-bar').should('be.visible'); + cy.get('.nfd-onboarding-header__progress-bar__progress') + .invoke('attr', 'style') + .then((styleAttribute) => { + const value = styleAttribute.match(/width:\s*([\d.]+%)/)[1]; + expect(value).equal(WidthPercent); + }); +}; + +export const BackButtonCheck = (currURL) => { + cy.get('.nfd-onboarding-button--dark') + .should('be.visible') + .click(); + cy.url().should('not.contain', currURL); + cy.go('back'); +}; + +export const SkipButtonCheck = (currURL) => { + cy.get('.skip-button') + .should('be.visible') + .contains('Skip for now') + .click(); + cy.url().should('not.contain', currURL); + cy.go('back'); +}; + +export const DisabledNextButton = () => { + cy.get('.nfd-onboarding-button--site-gen-next--disabled') + .should('be.visible') + .contains( 'Next' ); +}; From 93cc06baf24a11a8be4e328c910cf67163a88a83 Mon Sep 17 00:00:00 2001 From: Avneet Raj Date: Fri, 12 Jan 2024 13:17:28 +0530 Subject: [PATCH 2/4] add welcome step tests --- .../welcome.cy.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/cypress/integration/5-AI-SiteGen-onboarding-flow/welcome.cy.js diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/welcome.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/welcome.cy.js new file mode 100644 index 000000000..82f824cf1 --- /dev/null +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/welcome.cy.js @@ -0,0 +1,59 @@ +// + +import { AdminBarCheck, BackButtonCheck, DarkBGCheck, LightBGChcek, ProgressBarCheck} from "../wp-module-support/siteGen.cy"; + +describe( 'SiteGen Welcome Step', function () { + before( () => { + cy.visit( + 'wp-admin/?page=nfd-onboarding#/sitegen/step/welcome' + ); + } ); + + 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 the Progress Bar Value', () => { + ProgressBarCheck('11.1111%'); + }); + + it( 'Check for back button and go back', () => { + BackButtonCheck('sitegen/step/welcome'); + } ); + + it( 'Check for the animation', () => { + cy.get( '.nfd-onboarding-step--site-gen__welcome__container__animation' ) + .should('be.visible'); + } ); + + it( 'Check for the heading title', () => { + cy.get( '.nfd-onboarding-step--site-gen__welcome__container__heading__text' ) + .should('be.visible') + .contains('WordPress'); + } ); + + it( 'Check for the subheading title', () => { + cy.get('.nfd-onboarding-step--site-gen__welcome__container__sub-heading') + .should('exist'); + cy.get( '.nfd-onboarding-step--site-gen__welcome__container__sub-heading__text' ) + .should('be.visible') + .contains('AI'); + } ); + + it( 'Check the Get Started button', () => { + cy.get( '.nfd-onboarding-button--site-gen-next' ) + .should('be.visible') + .should('have.text','Get Started') + .click(); + cy.wait(2000); + cy.url().should('not.contain', 'sitegen/step/welcome'); + } ); +}); From c3b331e15825de91517f5e5b194b9f99a81e511e Mon Sep 17 00:00:00 2001 From: Avneet Raj Date: Fri, 12 Jan 2024 13:20:45 +0530 Subject: [PATCH 3/4] Update site-logo.cy.js --- .../integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js index d07135325..c3295c014 100644 --- a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js @@ -2,7 +2,7 @@ import { AdminBarCheck, BackButtonCheck, DarkBGCheck, DisabledNextButton, LightBGChcek, ProgressBarCheck, SkipButtonCheck } from "../wp-module-support/siteGen.cy"; -describe( 'SiteGen Fork Step', function () { +describe( 'SiteGen Site Logo Step', function () { before( () => { cy.visit( 'wp-admin/?page=nfd-onboarding#/sitgen/step/site-logo' From 6aa3c2a3d23ce1dddf2c8f456cf1010b083e8379 Mon Sep 17 00:00:00 2001 From: Avneet Raj Date: Fri, 12 Jan 2024 15:48:28 +0530 Subject: [PATCH 4/4] update logo upload step --- .../integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js index c3295c014..eb669a901 100644 --- a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/site-logo.cy.js @@ -61,6 +61,10 @@ describe( 'SiteGen Site Logo Step', function () { .scrollIntoView() .should( 'be.visible' ); } ); + cy.get('.nfd-onboarding-button--site-gen-next') + .should('not.be.disabled') + .click(); + cy.url().should('not.contain', 'sitgen/step/site-logo'); }); });