Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cypress Tests for AI siteGen flow #501

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AdminBarCheck, DarkBGCheck, LightBGCheck, OptionsDetails } from "../wp-

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);
Expand Down Expand Up @@ -49,13 +50,12 @@ describe( 'SiteGen Fork Step', function () {
arr.each( () => {
if(options == 0){
OptionsDetails(className,'Guided Configuration',options);
cy.url().should('include', 'get-started/welcome',{
timeout: 10000,
} );
cy.go('back');
};
if(options == 1){
OptionsDetails(className,'AI Website Creator',options);
cy.get(className)
.eq(options)
.click();
cy.url().should('include', 'sitegen/step/welcome',{
timeout: 10000,
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe( 'SiteGen Site Details Step', function () {
} );

it( 'Check the Progress Bar Value', () => {
ProgressBarCheck('12.5%');
ProgressBarCheck('14.2857%');
});

it( 'Check if the Next Button is disabled when no prompt is entered', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ describe( 'SiteGen Site Logo Step', function() {
} );

it( 'Check the Progress Bar Value', () => {
ProgressBarCheck( '37.5%' );
ProgressBarCheck( '42.8571%' );
} );

it( 'Check for back button and go back', () => {
BackButtonCheck( 'sitegen/step/site-logo' );
} );

it( 'Check if the heading is visible', () => {
cy.get( '.ai-heading' ).should( 'be.visible' );
cy.get( '.ai-heading', {timeout:20000} ).should( 'be.visible' );
} );

it( 'Check for the skip button and click', () => {
SkipButtonCheck( 'sitegen/step/site-logo' );
it( 'Check for the skip button', () => {
SkipButtonCheck();
} );

it( 'Check if the Next Button is disabled when there is no logo', () => {
Expand All @@ -61,6 +61,8 @@ describe( 'SiteGen Site Logo Step', function() {
.scrollIntoView()
.should( 'be.visible' );
} );
cy.get( '.nfd-onboarding-button--site-gen-next' )
.should( 'not.be.disabled' );
} );

it.skip( 'Check if the Next Button is enabled and go next', () => {
Expand Down
16 changes: 4 additions & 12 deletions tests/cypress/integration/wp-module-support/siteGen.cy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// <reference types="Cypress" />

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

export const DarkBGCheck = () => {
Expand All @@ -23,16 +23,11 @@ export const LightBGCheck = () => {
};

export const OptionsDetails = (className,textValue,optionsValue) => {
cy.get(className)
cy.get(className, {timeout:10000})
.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();
};
};

export const ProgressBarCheck = ( WidthPercent ) => {
Expand All @@ -53,13 +48,10 @@ export const BackButtonCheck = (currURL) => {
cy.go('back');
};

export const SkipButtonCheck = (currURL) => {
export const SkipButtonCheck = () => {
cy.get('.skip-button')
.should('be.visible')
.contains('Skip for now')
.click();
cy.url().should('not.contain', currURL);
cy.go('back');
.contains('Skip for now');
};

export const DisabledNextButton = () => {
Expand Down
Loading