From 84f4997a52e02e5254e9fc8c8e39e9b8d8be4c0b Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Mon, 8 Apr 2024 17:52:53 +0530 Subject: [PATCH] Fix failing tests --- build/2.1.9/249.js | 2 +- .../components/StartOptions/index.js | 1 + .../5-AI-SiteGen-onboarding-flow/1-fork.cy.js | 126 +++++++++--------- .../wp-module-support/siteGen.cy.js | 8 -- 4 files changed, 67 insertions(+), 70 deletions(-) diff --git a/build/2.1.9/249.js b/build/2.1.9/249.js index 872655700..cce8fc927 100644 --- a/build/2.1.9/249.js +++ b/build/2.1.9/249.js @@ -1 +1 @@ -"use strict";(globalThis.webpackChunknewfold_Onboarding=globalThis.webpackChunknewfold_Onboarding||[]).push([[249],{8249:(e,n,t)=>{t.r(n),t.d(n,{default:()=>C});var o=t(1609),i=t(8468),a=t(7143),r=t(7723);var s=t(6079),d=t(148),l=t(2940),g=t(7835),u=t(1056),c=t(8744),_=t(7675),p=t(2202);const b=(0,i.memo)((({experimentVersion:e,questionnaire:n,oldFlow:t,options:s})=>{const b={badge:(0,r.__)("Fastest","wp-module-onboarding")},m=(0,d.Zp)(),[w,f]=(0,i.useState)([]),[h,E]=(0,i.useState)(!1),{brandConfig:v,hireProUrl:C,currentData:k}=(0,a.useSelect)((e=>({brandConfig:e(_.M).getNewfoldBrandConfig(),hireProUrl:e(_.M).getfullServiceCreativeTeamUrl(),currentData:e(_.M).getCurrentOnboardingData()}))),{updateAllSteps:N,updateTopSteps:x,updateRoutes:D,updateDesignRoutes:F,updateInitialize:A,setCurrentOnboardingData:S}=(0,a.useDispatch)(_.M);(0,i.useEffect)((()=>{!e||2!==e&&4!==e||([s[0],s[1]]=[s[1],s[0]]),!e||3!==e&&4!==e||E(!0),f(s)}),[e]);const V=e=>{if(!(0,l.nC)(v,e))return!1;const n=window.nfdOnboarding.currentFlow,t=(0,g.Sg)(e)();N(t.steps),x(t?.topSteps),D(t.routes),F(t?.designRoutes),c.d0!==n&&(window.nfdOnboarding.oldFlow=n),window.nfdOnboarding.currentFlow=e,k.activeFlow=e,k.continueWithoutAi=!1,S(k),c.d0!==e&&A(!0),m(t.steps[1].path)},I=e=>{let n=!1;switch(e){case"sitebuild":n="DIY",V(t);break;case"sitegen":n="AI",V(c.d0);break;case"hirepro":n="PRO",window.open(C,"_blank")}n&&(0,u.v)(new u.iC(p.Qh,n))};return e&&w&&(0,o.createElement)("div",{className:""},(0,o.createElement)("p",{className:"nfd-onboarding-sitegen-options__questionnaire"},n),(0,o.createElement)("div",{className:"nfd-onboarding-sitegen-options__container"},w.map(((e,n)=>!(e.flow===c.d0&&!(0,l.nC)(v,e.flow))&&(0,o.createElement)("div",{className:"nfd-onboarding-sitegen-options__container__options",key:n,role:"button",tabIndex:0,onClick:()=>{I(e.flow)},onKeyDown:()=>{I(e.flow)}},e.flow===c.d0&&h&&(0,o.createElement)("div",{className:"nfd-onboarding-sitegen-options__container__options--badge"},b.badge),(0,o.createElement)("h3",{className:"nfd-onboarding-sitegen-options__container__heading__title"},e.span&&(0,o.createElement)("span",{className:"nfd-onboarding-sitegen-options__container__options__span"},e.span),e.title),(0,o.createElement)("p",{className:"nfd-onboarding-sitegen-options__container__heading__subtitle"},e.subtitle))))))}));var m=t(3988),w=t(6942),f=t.n(w),h=t(8969),E=t(9269);const v=({title:e,subtitle:n})=>{const t=(0,i.useContext)(E.D),a=t?.theme||!1;return(0,o.createElement)("div",{className:"nfd-onboarding-step__heading"},(0,o.createElement)("h2",{className:"nfd-onboarding-step__heading__title"},e),n&&(0,o.createElement)("div",{className:"nfd-onboarding-step__heading__subtitle"},n,(0,o.createElement)("div",{className:f()("nfd-onboarding-step__heading__icon",a===h.Vw?"nfd-onboarding-step__heading__icon--light":null)})))},C=()=>{const[e,n]=(0,i.useState)(),{currentData:t,migrationUrl:d}=(0,a.useSelect)((e=>({currentData:e(_.M).getCurrentOnboardingData(),migrationUrl:e(_.M).getMigrationUrl()}))),{setIsHeaderEnabled:l,setSidebarActiveView:g,setHeaderActiveView:w,setDrawerActiveView:f,setIsHeaderNavigationEnabled:E,setFooterActiveView:C,setHideFooterNav:k,setCurrentOnboardingData:N}=(0,a.useDispatch)(_.M);(0,i.useEffect)((()=>{k(!0),l(!1),g(!1),E(!1),w(h.Ix),f(!1),C(h.Sr),x()}));const x=async()=>{let e=0;if(0!==t.sitegen.theForkExperimentVersion)n(t.sitegen.theForkExperimentVersion),e=t.sitegen.theForkExperimentVersion;else{e=Math.floor(5*Math.random()),n(e),t.sitegen.theForkExperimentVersion=e,N(t),await(0,s.V1)(t);const o={1:"control",2:"position",3:"badge",4:"position_badge"};(0,u.SV)(new u.iC(p.Rh,o[e],null,null,p.ft))}},D=window.nfdOnboarding?.oldFlow?window.nfdOnboarding.oldFlow:c.rA,F=()=>{(0,u.SV)(new u.iC(p.Qh,"TUTORIAL")),window.location.replace(h.R0)},A={heading:(0,r.__)("Welcome to WordPress","wp-module-onboarding"),subheading:(0,r.__)("powered by ","wp-module-onboarding"),questionnaire:(0,r.__)("Where would you like to start?","wp-module-onboarding"),options:[{title:(0,r.__)("Guided Configuration","wp-module-onboarding"),subtitle:(0,r.__)("Robust configuration guide to help you build your site","wp-module-onboarding"),flow:"sitebuild"},{title:(0,r.__)(" Website Creator","wp-module-onboarding"),subtitle:(0,r.__)("Unique AI generated content & design curated for you.","wp-module-onboarding"),span:(0,r.__)("AI","wp-module-onboarding"),flow:"sitegen"},{title:(0,r.__)("Hire a Pro","wp-module-onboarding"),subtitle:(0,r.__)("Leave it to our WordPress experts.","wp-module-onboarding"),flow:"hirepro"}],importtext:(0,r.__)("Already have a WordPress site you want to import?","wp-module-onboarding"),importlink:(0,r.__)("https://my.bluehost.com/cgi/services/migration","wp-module-onboarding"),exitToWordPress:(0,r.__)("I’m following a tutorial","wp-module-onboarding")};return(0,o.createElement)(m.A,{isCentered:!0,className:"nfd-onboarding-step--site-gen__fork"},(0,o.createElement)(v,{title:A.heading,subtitle:A.subheading}),(0,o.createElement)(b,{experimentVersion:e,questionnaire:A.questionnaire,oldFlow:D,options:A.options}),(0,o.createElement)("br",null),(0,o.createElement)("br",null),d&&(0,o.createElement)("a",{className:"nfd-onboarding-step--site-gen__fork__importsite",href:d,target:"_blank",rel:"noreferrer",onClick:()=>(0,u.v)(new u.iC(p.Qh,"MIGRATE"))},A.importtext),(0,o.createElement)("span",{role:"button",tabIndex:0,className:"nfd-onboarding-step--site-gen__fork__exit",onClick:()=>F(),onKeyDown:()=>F()},A.exitToWordPress))}}}]); \ No newline at end of file +"use strict";(globalThis.webpackChunknewfold_Onboarding=globalThis.webpackChunknewfold_Onboarding||[]).push([[249],{8249:(e,n,t)=>{t.r(n),t.d(n,{default:()=>C});var o=t(1609),i=t(8468),a=t(7143),r=t(7723);var s=t(6079),d=t(148),l=t(2940),g=t(7835),u=t(1056),c=t(8744),_=t(7675),p=t(2202);const b=(0,i.memo)((({experimentVersion:e,questionnaire:n,oldFlow:t,options:s})=>{const b={badge:(0,r.__)("Fastest","wp-module-onboarding")},m=(0,d.Zp)(),[w,f]=(0,i.useState)([]),[h,E]=(0,i.useState)(!1),{brandConfig:v,hireProUrl:C,currentData:k}=(0,a.useSelect)((e=>({brandConfig:e(_.M).getNewfoldBrandConfig(),hireProUrl:e(_.M).getfullServiceCreativeTeamUrl(),currentData:e(_.M).getCurrentOnboardingData()}))),{updateAllSteps:N,updateTopSteps:x,updateRoutes:D,updateDesignRoutes:F,updateInitialize:A,setCurrentOnboardingData:S}=(0,a.useDispatch)(_.M);(0,i.useEffect)((()=>{!e||2!==e&&4!==e||([s[0],s[1]]=[s[1],s[0]]),!e||3!==e&&4!==e||E(!0),f(s)}),[e]);const V=e=>{if(!(0,l.nC)(v,e))return!1;const n=window.nfdOnboarding.currentFlow,t=(0,g.Sg)(e)();N(t.steps),x(t?.topSteps),D(t.routes),F(t?.designRoutes),c.d0!==n&&(window.nfdOnboarding.oldFlow=n),window.nfdOnboarding.currentFlow=e,k.activeFlow=e,k.continueWithoutAi=!1,S(k),c.d0!==e&&A(!0),m(t.steps[1].path)},I=e=>{let n=!1;switch(e){case"sitebuild":n="DIY",V(t);break;case"sitegen":n="AI",V(c.d0);break;case"hirepro":n="PRO",window.open(C,"_blank")}n&&(0,u.v)(new u.iC(p.Qh,n))};return e&&w&&(0,o.createElement)("div",{className:""},(0,o.createElement)("p",{className:"nfd-onboarding-sitegen-options__questionnaire"},n),(0,o.createElement)("div",{className:"nfd-onboarding-sitegen-options__container"},w.map(((e,n)=>!(e.flow===c.d0&&!(0,l.nC)(v,e.flow))&&(0,o.createElement)("div",{className:"nfd-onboarding-sitegen-options__container__options",key:n,role:"button",tabIndex:0,onClick:()=>{I(e.flow)},onKeyDown:()=>{I(e.flow)},"data-flow":e.flow},e.flow===c.d0&&h&&(0,o.createElement)("div",{className:"nfd-onboarding-sitegen-options__container__options--badge"},b.badge),(0,o.createElement)("h3",{className:"nfd-onboarding-sitegen-options__container__heading__title"},e.span&&(0,o.createElement)("span",{className:"nfd-onboarding-sitegen-options__container__options__span"},e.span),e.title),(0,o.createElement)("p",{className:"nfd-onboarding-sitegen-options__container__heading__subtitle"},e.subtitle))))))}));var m=t(3988),w=t(6942),f=t.n(w),h=t(8969),E=t(9269);const v=({title:e,subtitle:n})=>{const t=(0,i.useContext)(E.D),a=t?.theme||!1;return(0,o.createElement)("div",{className:"nfd-onboarding-step__heading"},(0,o.createElement)("h2",{className:"nfd-onboarding-step__heading__title"},e),n&&(0,o.createElement)("div",{className:"nfd-onboarding-step__heading__subtitle"},n,(0,o.createElement)("div",{className:f()("nfd-onboarding-step__heading__icon",a===h.Vw?"nfd-onboarding-step__heading__icon--light":null)})))},C=()=>{const[e,n]=(0,i.useState)(),{currentData:t,migrationUrl:d}=(0,a.useSelect)((e=>({currentData:e(_.M).getCurrentOnboardingData(),migrationUrl:e(_.M).getMigrationUrl()}))),{setIsHeaderEnabled:l,setSidebarActiveView:g,setHeaderActiveView:w,setDrawerActiveView:f,setIsHeaderNavigationEnabled:E,setFooterActiveView:C,setHideFooterNav:k,setCurrentOnboardingData:N}=(0,a.useDispatch)(_.M);(0,i.useEffect)((()=>{k(!0),l(!1),g(!1),E(!1),w(h.Ix),f(!1),C(h.Sr),x()}));const x=async()=>{let e=0;if(0!==t.sitegen.theForkExperimentVersion)n(t.sitegen.theForkExperimentVersion),e=t.sitegen.theForkExperimentVersion;else{e=Math.floor(5*Math.random()),n(e),t.sitegen.theForkExperimentVersion=e,N(t),await(0,s.V1)(t);const o={1:"control",2:"position",3:"badge",4:"position_badge"};(0,u.SV)(new u.iC(p.Rh,o[e],null,null,p.ft))}},D=window.nfdOnboarding?.oldFlow?window.nfdOnboarding.oldFlow:c.rA,F=()=>{(0,u.SV)(new u.iC(p.Qh,"TUTORIAL")),window.location.replace(h.R0)},A={heading:(0,r.__)("Welcome to WordPress","wp-module-onboarding"),subheading:(0,r.__)("powered by ","wp-module-onboarding"),questionnaire:(0,r.__)("Where would you like to start?","wp-module-onboarding"),options:[{title:(0,r.__)("Guided Configuration","wp-module-onboarding"),subtitle:(0,r.__)("Robust configuration guide to help you build your site","wp-module-onboarding"),flow:"sitebuild"},{title:(0,r.__)(" Website Creator","wp-module-onboarding"),subtitle:(0,r.__)("Unique AI generated content & design curated for you.","wp-module-onboarding"),span:(0,r.__)("AI","wp-module-onboarding"),flow:"sitegen"},{title:(0,r.__)("Hire a Pro","wp-module-onboarding"),subtitle:(0,r.__)("Leave it to our WordPress experts.","wp-module-onboarding"),flow:"hirepro"}],importtext:(0,r.__)("Already have a WordPress site you want to import?","wp-module-onboarding"),importlink:(0,r.__)("https://my.bluehost.com/cgi/services/migration","wp-module-onboarding"),exitToWordPress:(0,r.__)("I’m following a tutorial","wp-module-onboarding")};return(0,o.createElement)(m.A,{isCentered:!0,className:"nfd-onboarding-step--site-gen__fork"},(0,o.createElement)(v,{title:A.heading,subtitle:A.subheading}),(0,o.createElement)(b,{experimentVersion:e,questionnaire:A.questionnaire,oldFlow:D,options:A.options}),(0,o.createElement)("br",null),(0,o.createElement)("br",null),d&&(0,o.createElement)("a",{className:"nfd-onboarding-step--site-gen__fork__importsite",href:d,target:"_blank",rel:"noreferrer",onClick:()=>(0,u.v)(new u.iC(p.Qh,"MIGRATE"))},A.importtext),(0,o.createElement)("span",{role:"button",tabIndex:0,className:"nfd-onboarding-step--site-gen__fork__exit",onClick:()=>F(),onKeyDown:()=>F()},A.exitToWordPress))}}}]); \ No newline at end of file diff --git a/src/OnboardingSPA/components/StartOptions/index.js b/src/OnboardingSPA/components/StartOptions/index.js index 7c1a5118d..20463ee16 100644 --- a/src/OnboardingSPA/components/StartOptions/index.js +++ b/src/OnboardingSPA/components/StartOptions/index.js @@ -149,6 +149,7 @@ const StartOptions = ( { selectFlow( tab.flow ); } } } + data-flow={ tab.flow } > { tab.flow === SITEGEN_FLOW && showAIRecommendedBadge && ( diff --git a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js index b66cf91d5..908cb9db6 100644 --- a/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js +++ b/tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js @@ -1,79 +1,83 @@ // -import { AdminBarCheck, DarkBGCheck, LightBGCheck, OptionsDetails } from "../wp-module-support/siteGen.cy"; +import { + AdminBarCheck, + DarkBGCheck, + LightBGCheck, +} from '../wp-module-support/siteGen.cy'; describe( 'SiteGen Fork Step', function () { before( () => { - cy.exec('npx wp-env run cli wp option delete nfd_module_onboarding_flow'); - cy.exec(`npx wp-env run cli wp option set _transient_nfd_site_capabilities '{"hasAISiteGen": true, "canAccessAI": true}' --format=json`); - cy.exec(`npx wp-env run cli wp option set _transient_timeout_nfd_site_capabilities 4102444800`); - cy.wait(10000); - cy.visit( - 'wp-admin/?page=nfd-onboarding#/wp-setup/step/fork' + cy.exec( + 'npx wp-env run cli wp option delete nfd_module_onboarding_flow' ); - cy.timeout(60000); - cy.wait(5000); + cy.exec( + `npx wp-env run cli wp option set _transient_nfd_site_capabilities '{"hasAISiteGen": true, "canAccessAI": true}' --format=json` + ); + cy.exec( + `npx wp-env run cli wp option set _transient_timeout_nfd_site_capabilities 4102444800` + ); + cy.wait( 10000 ); + cy.visit( 'wp-admin/?page=nfd-onboarding#/wp-setup/step/fork' ); + cy.timeout( 60000 ); + cy.wait( 10000 ); } ); - it( 'Check for the header admin bar', () => { - AdminBarCheck(); - } ); + it( 'Check for the header admin bar', () => { + AdminBarCheck(); + } ); - it( 'Check for the existing dark background', () => { + it( 'Check for the existing dark background', () => { DarkBGCheck(); } ); - it( 'Check for the light background', () => { - LightBGCheck(); - } ); + it( 'Check for the light background', () => { + LightBGCheck(); + } ); - 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 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 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 the number of container options available', () => { + cy.get( '.nfd-onboarding-sitegen-options__container__options' ) + .should( 'be.visible' ) + .should( 'have.length', 3 ); + } ); - it.skip( '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,'Guided Configuration',options); - }; - if(options == 1){ - OptionsDetails(className,'AI Website Creator',options); - cy.get(className) - .eq(options) - .click(); - 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 selection of different container options', () => { + const className = '.nfd-onboarding-sitegen-options__container__options'; + const arr = cy.get( className ); - }); - }); + arr.each( ( $element ) => { + const dataSlugText = $element.attr( 'data-flow' ); + if ( dataSlugText == 'sitegen' ) { + $element.click(); + cy.url().should( 'include', 'sitegen/step/welcome', { + timeout: 10000, + } ); + cy.go( 'back' ); + } + } ); + } ); - 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'); - } ); -}); + 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 index 6bb5ec852..5c2c1a8e5 100644 --- a/tests/cypress/integration/wp-module-support/siteGen.cy.js +++ b/tests/cypress/integration/wp-module-support/siteGen.cy.js @@ -24,14 +24,6 @@ export const LightBGCheck = () => { cy.get( '.nfd-onboarding-sitegen-dark' ).should( 'be.visible' ); }; -export const OptionsDetails = ( className, textValue, optionsValue ) => { - cy.get( className, { timeout: 10000 } ) - .eq( optionsValue ) - .find( '.nfd-onboarding-sitegen-options__container__heading__title' ) - .invoke( 'text' ) - .should( 'contain', textValue ); -}; - export const ProgressBarCheck = ( WidthPercent ) => { cy.get( '.nfd-onboarding-header__progress-bar' ).should( 'be.visible' ); cy.get( '.nfd-onboarding-header__progress-bar__progress' )