Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Apr 8, 2024
1 parent cf26682 commit 84f4997
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 70 deletions.
2 changes: 1 addition & 1 deletion build/2.1.9/249.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/OnboardingSPA/components/StartOptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const StartOptions = ( {
selectFlow( tab.flow );
}
} }
data-flow={ tab.flow }
>
{ tab.flow === SITEGEN_FLOW &&
showAIRecommendedBadge && (
Expand Down
126 changes: 65 additions & 61 deletions tests/cypress/integration/5-AI-SiteGen-onboarding-flow/1-fork.cy.js
Original file line number Diff line number Diff line change
@@ -1,79 +1,83 @@
// <reference types="Cypress" />

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'
);
} );
} );
8 changes: 0 additions & 8 deletions tests/cypress/integration/wp-module-support/siteGen.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand Down

0 comments on commit 84f4997

Please sign in to comment.