Skip to content

Commit

Permalink
fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeetha-nayak committed Apr 3, 2024
1 parent eac04bb commit e7abce4
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 165 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
// <reference types="Cypress" />

import { AdminBarCheck, BackButtonCheck, DarkBGCheck, DisabledNextButton, LightBGCheck, ProgressBarCheck, SkipButtonCheck } from '../wp-module-support/siteGen.cy';
import { apiList, siteGenMockAll, homePagesMock } from '../wp-module-support/MockApi.cy';
import {
AdminBarCheck,
BackButtonCheck,
DarkBGCheck,
DisabledNextButton,
LightBGCheck,
ProgressBarCheck,
SkipButtonCheck,
} from '../wp-module-support/siteGen.cy';
import {
apiList,
siteGenMockAll,
homePagesMock,
} from '../wp-module-support/MockApi.cy';

describe( 'SiteGen Site Logo Step', function () {
before( () => {
cy.intercept( apiList.sitegen, ( req ) => {
siteGenMockAll( req );
} ).as( 'sitegenCalls' );

cy.intercept( apiList.homepages, ( req ) => {
homePagesMock( req );
} ).as( 'homePageCall' );

cy.visit(
'wp-admin/?page=nfd-onboarding#/sitegen/step/site-logo'
);
cy.visit( 'wp-admin/?page=nfd-onboarding#/sitegen/step/site-logo' );
cy.wait( '@sitegenCalls', { timeout: 60000 } );
cy.wait( '@homePageCall', { timeout: 60000 } );
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// <reference types="Cypress" />

import { AdminBarCheck, DarkBGCheck, ExperienceDetails, LightBGCheck, ProgressBarCheck} from "../wp-module-support/siteGen.cy";
import {
AdminBarCheck,
DarkBGCheck,
ExperienceDetails,
LightBGCheck,
ProgressBarCheck,
} from '../wp-module-support/siteGen.cy';

describe( 'SiteGen Experience & Site Building Step', function () {
before( () => {
Expand All @@ -9,44 +15,47 @@ describe( 'SiteGen Experience & Site Building Step', function () {
);
} );

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 the Progress Bar Value', () => {
ProgressBarCheck('57.1429%');
});

it( 'Check for the existence & the count of experience level cards', () => {
cy.get( '.nfd-sg-experience-level' ).should('be.visible');
cy.get( '.nfd-sg-loader' ).should('be.visible');
cy.get( '.nfd-sg-card' ).should('be.visible');
cy.get('.nfd__option_heading_subheading__wrapper').should('have.length',3)
} );

it( 'Check each experience cards', () => {
const className = '.nfd__option_heading_subheading__wrapper'
let options = 0;
const arr = cy.get( className );
it( 'Check for the light background', () => {
LightBGCheck();
} );

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

it( 'Check for the existence & the count of experience level cards', () => {
cy.get( '.nfd-sg-experience-level' ).should( 'be.visible' );
cy.get( '.nfd-sg-loader' ).should( 'be.visible' );
cy.get( '.nfd-sg-card' ).should( 'be.visible' );
cy.get( '.nfd__option_heading_subheading__wrapper' ).should(
'have.length',
3
);
} );

it( 'Check each experience cards', () => {
const className = '.nfd__option_heading_subheading__wrapper';
let options = 0;
const arr = cy.get( className );
arr.each( () => {
if(options == 0){
ExperienceDetails(className,'Beginner',options);
};
if(options == 1){
ExperienceDetails(className,'Intermediate',options);
};
if(options == 2){
ExperienceDetails(className, 'Expert',options);
};
options+=1;
});
} );
});
if ( options == 0 ) {
ExperienceDetails( className, 'Beginner', options );
}
if ( options == 1 ) {
ExperienceDetails( className, 'Intermediate', options );
}
if ( options == 2 ) {
ExperienceDetails( className, 'Expert', options );
}
options += 1;
} );
} );
} );
161 changes: 90 additions & 71 deletions tests/cypress/integration/5-AI-SiteGen-onboarding-flow/6-preview.cy.js
Original file line number Diff line number Diff line change
@@ -1,84 +1,103 @@
// <reference types="Cypress" />

import { AdminBarCheck, DarkBGCheck, LightBGCheck, ProgressBarCheck } from "../wp-module-support/siteGen.cy";
import { apiList } from "../wp-module-support/MockApi.cy";
import {
AdminBarCheck,
DarkBGCheck,
LightBGCheck,
ProgressBarCheck,
} from '../wp-module-support/siteGen.cy';

describe( 'SiteGen Site Preview Step', function () {
before( () => {
cy.visit(
'wp-admin/index.php?page=nfd-onboarding#/sitegen/step/preview'
);
cy.wait(5000);
} );
before( () => {
cy.visit(
'wp-admin/index.php?page=nfd-onboarding#/sitegen/step/preview'
);
cy.wait( 5000 );
} );

it( 'Check for the header admin bar', () => {
AdminBarCheck();
} );
it( 'Check for the header admin bar', () => {
AdminBarCheck();
} );

it( 'Check for the existing dark background', () => {
DarkBGCheck();
} );
it( 'Check for the existing dark background', () => {
DarkBGCheck();
} );

it( 'Check for the light background', () => {
LightBGCheck();
} );
it( 'Check for the light background', () => {
LightBGCheck();
} );

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

it( 'Check for by default 3 versions should be there', () => {
cy.get('.live-preview-sitegen--selectable-card', {timeout:20000})
.should('be.visible')
.should('have.length', 3);
} );
it( 'Check for by default 3 versions should be there', () => {
cy.get( '.live-preview-sitegen--selectable-card', { timeout: 20000 } )
.should( 'be.visible' )
.should( 'have.length', 3 );
} );

it( 'Check for the favourited theme versions', () => {
cy.get('g[clip-path="url(#heart-filled_svg__a)"]').should('not.exist'); // when no fav theme is selected
cy.get( '.live-preview-sitegen--selectable-card__live-preview-container-buttons__button__icon' )
.eq(0)
.scrollIntoView()
.should('be.visible')
.click();
cy.get('g[clip-path="url(#heart-filled_svg__a)"]' , {timeout:20000} )
.should('exist');
cy.get('.live-preview-sitegen--selectable-card__live-preview-container__overlay')
.eq(0)
.scrollIntoView()
.click();
cy.reload();
cy.wait(5000);
cy.get('g[clip-path="url(#heart-filled_svg__a)"]' , {timeout:20000} )
.should('exist');
cy.go('back');
cy.reload();
} );
it( 'Check for the favourited theme versions', () => {
cy.get( 'g[clip-path="url(#heart-filled_svg__a)"]' ).should(
'not.exist'
); // when no fav theme is selected
cy.get(
'.live-preview-sitegen--selectable-card__live-preview-container-buttons__button__icon'
)
.eq( 0 )
.scrollIntoView()
.should( 'be.visible' )
.click();
cy.get( 'g[clip-path="url(#heart-filled_svg__a)"]', {
timeout: 20000,
} ).should( 'exist' );
cy.get(
'.live-preview-sitegen--selectable-card__live-preview-container__overlay'
)
.eq( 0 )
.scrollIntoView()
.click();
cy.reload();
cy.wait( 5000 );
cy.get( 'g[clip-path="url(#heart-filled_svg__a)"]', {
timeout: 20000,
} ).should( 'exist' );
cy.go( 'back' );
cy.reload();
} );

it.skip( 'Check for regenerating the new theme versions', () => {
cy.get('[aria-label="Regenerate Content"]', {timeout:20000})
.eq(1)
.wait(1000)
.click({force : true})
cy.get('[aria-label="Regenerate Content"]', {timeout:20000})
.eq(2)
.scrollIntoView()
cy.get('.live-preview-sitegen--selectable-card', {timeout:20000})
.should('be.visible')
.should('have.length', 4);
} );
it.skip( 'Check for regenerating the new theme versions', () => {
cy.get( '[aria-label="Regenerate Content"]', { timeout: 20000 } )
.eq( 1 )
.wait( 1000 )
.click( { force: true } );
cy.get( '[aria-label="Regenerate Content"]', { timeout: 20000 } )
.eq( 2 )
.scrollIntoView();
cy.get( '.live-preview-sitegen--selectable-card', { timeout: 20000 } )
.should( 'be.visible' )
.should( 'have.length', 4 );
} );

it( 'Check for the preview note at the bottom', () => {
cy.get('.nfd-onboarding-step--site-gen__preview__note')
.scrollIntoView()
.should('be.visible');
cy.get('g[id="State\\=Active"]').should('exist');
cy.get('.nfd-onboarding-step--site-gen__preview__note span').scrollIntoView().contains('Favorite');
} );
it( 'Check for the preview note at the bottom', () => {
cy.get( '.nfd-onboarding-step--site-gen__preview__note' )
.scrollIntoView()
.should( 'be.visible' );
cy.get( 'g[id="State\\=Active"]' ).should( 'exist' );
cy.get( '.nfd-onboarding-step--site-gen__preview__note span' )
.scrollIntoView()
.contains( 'Favorite' );
} );

it( 'Select any theme and go forward to the next step', () => {
cy.get('.live-preview-sitegen--selectable-card__live-preview-container__overlay', {timeout: 10000})
.eq(0)
.click();
cy.url().should('not.contain', 'sitegen/step/preview', {timeout: 20000});
} );
});
it( 'Select any theme and go forward to the next step', () => {
cy.get(
'.live-preview-sitegen--selectable-card__live-preview-container__overlay',
{ timeout: 10000 }
)
.eq( 0 )
.click();
cy.url().should( 'not.contain', 'sitegen/step/preview', {
timeout: 20000,
} );
} );
} );
12 changes: 6 additions & 6 deletions tests/cypress/integration/wp-module-support/MockApi.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const apiList = {
sitegen:
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fgenerate&flow=sitegen&_locale=user',
homepages:
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fhomepages&flow=sitegen&_locale=user',
homepagesRegenerate:
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fhomepages%2Fregenerate&flow=sitegen&_locale=user'
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fhomepages&flow=sitegen&_locale=user',
homepagesRegenerate:
'/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fsitegen%2Fhomepages%2Fregenerate&flow=sitegen&_locale=user',
};

export const siteGenMockAll = ( req ) => {
Expand All @@ -29,13 +29,13 @@ export const siteGenMockAll = ( req ) => {
'color_palette': color_palette_mock,
'sitemap': sitemap_mock,
'plugin_recommendation': plugin_recommendation_mock,
'font_pair': font_pair_mock
}
'font_pair': font_pair_mock,
};

if ( sitegen_identifiers.hasOwnProperty( requestBody.identifier ) ) {
req.reply( {
statusCode: 200,
body: sitegen_identifiers[requestBody.identifier],
body: sitegen_identifiers[ requestBody.identifier ],
headers: {
'content-type': 'application/json',
},
Expand Down
Loading

0 comments on commit e7abce4

Please sign in to comment.