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

Cypress api events for site type secondary page #347

Merged
merged 6 commits into from
Nov 7, 2023
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 @@ -7,7 +7,7 @@ import {
CheckInfoPanel,
CheckIntroPanel,
} from '../wp-module-support/sidebar.cy';
import { APIList } from '../wp-module-support/EventsApi.cy';
import { APIList, EventsAPI } from '../wp-module-support/EventsApi.cy';

describe( 'Start Setup WP Experience Page', function () {
before( () => {
Expand Down Expand Up @@ -52,26 +52,6 @@ describe( 'Start Setup WP Experience Page', function () {
cy.url().should( 'contain', 'get-started/experience' );
} );

const EventsAPI = ( experience_val ) => {
cy.intercept( APIList.get_started_experience ).as( 'events' );
cy.wait( '@events' ).then( ( requestObject ) => {
const responseBody = requestObject.request.body;
const responseData1 = responseBody[ 0 ].data;
if ( 'experience_level' in responseData1 ) {
expect( responseData1.experience_level ).equal(
experience_val
);
} else {
const responseData2 = responseBody[ 1 ].data;
if ( 'experience_level' in responseData2 ) {
expect( responseData2.experience_level ).equal(
experience_val
);
}
}
} );
};

it( 'Check if events API call being made after radio buttons are clicked', () => {
let radioCount = 0;
const className = '.components-radio-control__option';
Expand All @@ -81,14 +61,14 @@ describe( 'Start Setup WP Experience Page', function () {
.eq( radioCount )
.click( { force: true } );
if ( radioCount == 0 ) {
EventsAPI( 'novice' );
EventsAPI( 'experience_level', 'novice', APIList.get_started_experience );
}
if ( radioCount == 1 ) {
EventsAPI( 'intermediate' );
EventsAPI( 'experience_level', 'intermediate', APIList.get_started_experience );
}
if ( radioCount > 1 ) {
cy.wait( 5000 );
EventsAPI( 'expert' );
EventsAPI( 'experience_level', 'expert', APIList.get_started_experience );
}
radioCount += 1;
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// <reference types="Cypress" />
import { APIList, EventsAPI } from '../wp-module-support/EventsApi.cy';
import { CheckDrawerDisabled } from '../wp-module-support/drawer.cy';
import { CheckCardHeadingSubheading } from '../wp-module-support/header.cy';
import {
Expand Down Expand Up @@ -31,6 +32,36 @@ describe( 'Get Started Site Type Primary', function () {
CheckHelpPanelLinks();
} );

it( 'Check for Event API call being made when different categories are selected', ()=>{
let categoryCount = 0;
let num = 0;
const className = '.nfd-card-pri-category';
cy.get( className ).should( 'be.visible' );
const arr = cy.get( className );
arr.each( () => {
cy.get( className )
.eq( categoryCount )
.click()
.then(($element) => {
const dataSlugText = $element.attr('data-slug');
if(num>=2){
cy.wait(4000);
}
EventsAPI('primary_type', dataSlugText, APIList.site_primary);
num+=1;
});
categoryCount += 1;
} );
} );

it( 'Check for Event API call when we enter text in input box', ()=>{
cy.get( '.nfd-setup-primary-custom__tellus-input' )
.scrollIntoView()
.should( 'be.visible' )
.type( 'Test' );
EventsAPI('primary_type', 'Test', APIList.site_primary);
} );

it( 'Check different Categories exist and is selectable', () => {
let categoryCount = 0;
const className = '.nfd-card-pri-category';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// <reference types="Cypress" />
import { APIList, EventsAPI } from '../wp-module-support/EventsApi.cy';
import { CheckDrawerDisabled } from '../wp-module-support/drawer.cy';
import { CheckCardHeadingSubheading } from '../wp-module-support/header.cy';
import {
Expand Down Expand Up @@ -31,10 +32,41 @@ describe( 'Get Started Site Type Secondary', function () {
CheckHelpPanelLinks();
} );

it( 'Check for Event API call being made when different sub-categories are selected', ()=>{
let SubcategoryCount = 0;
let num = 0;
const className = '.nfd-card-sec-category';
cy.get( className ).should( 'be.visible' );
const arr = cy.get( className );
arr.each( () => {
cy.get( className )
.eq( SubcategoryCount )
.click()
.then(($element) => {
const dataSlugText = $element.attr('data-slug');
if(num>=2){
cy.wait(5000);
}
EventsAPI('secondary_type', dataSlugText, APIList.site_secondary);
num+=1;
});
SubcategoryCount += 1;
} );
} );

it( 'Check for Event API call when we enter text in input box', ()=>{
cy.get( '.nfd-setup-primary-custom__tellus-input' )
.scrollIntoView()
.should( 'be.visible' )
.type( 'Test' );
EventsAPI('secondary_type', 'Test', APIList.site_secondary);
} );

it( 'Check different categories exist using `<` and `>`', () => {
cy.get( '.nfd-setup-secondary-categories' ).should( 'be.visible' );
const category_selected = cy.get('.category-scrolling-wrapper__type-text');
cy.get( '.category-scrolling-wrapper__left-btn' )
.scrollIntoView()
.should('be.visible')
.click();
cy.get( '.category-scrolling-wrapper__type-text' ).should('not.contain', category_selected);
Expand Down Expand Up @@ -106,7 +138,7 @@ describe( 'Get Started Site Type Secondary', function () {
cy.get( '.navigation-buttons_back' ).click();
} );

it.skip( 'Go to the previous step on clicking navigation Back', () => {
it( 'Go to the previous step on clicking navigation Back', () => {
cy.get( '.navigation-buttons_back' ).click();
cy.url().should(
'not.include',
Expand All @@ -115,7 +147,7 @@ describe( 'Get Started Site Type Secondary', function () {
cy.get( '.navigation-buttons_next' ).click();
} );

it.skip( 'Go to next step on Continue Setup', () => {
it( 'Go to next step on Continue Setup', () => {
cy.get( '.nfd-nav-card-button' ).click();
cy.url().should(
'not.include',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// <reference types="Cypress" />
import { DrawerActivityForMenu } from '../wp-module-support/drawer.cy';
import { CheckHeadingSubheading } from '../wp-module-support/header.cy';
import { EventsAPI, APIList } from '../wp-module-support/EventsApi.cy';

describe( 'Top Priority Page', function () {
before( () => {
Expand All @@ -27,6 +28,29 @@ describe( 'Top Priority Page', function () {
cy.get( '.components-button.skip-button' ).should( 'be.visible' );
} );

it( 'Check for API events when different cards are selected', ()=> {
let previewCount = 0;
const className = '.components-surface.components-card.nfd-card';
const arr = cy.get( className );
arr.each( () => {
cy.get( className )
.eq( previewCount )
.should( 'be.visible' )
.click();
if ( previewCount == 0 ) {
EventsAPI( 'top_priority', 'content', APIList.top_priority );
}
if ( previewCount == 1 ) {
EventsAPI( 'top_priority', 'store', APIList.top_priority );
}
if ( previewCount > 1 ) {
cy.wait( 5000 );
EventsAPI( 'top_priority', 'design', APIList.top_priority );
}
previewCount += 1;
});
} );

it.skip( 'Click on different cards and move on to next page', () => {
let previewCount = 0;
const className = '.components-surface.components-card.nfd-card';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CheckInfoPanel,
CheckIntroPanel,
} from '../wp-module-support/sidebar.cy';
import { APIList } from '../wp-module-support/EventsApi.cy';
import { APIList, EventsAPI } from '../wp-module-support/EventsApi.cy';

describe( 'Start Setup WP Experience Page', function () {
before( () => {
Expand Down Expand Up @@ -52,26 +52,6 @@ describe( 'Start Setup WP Experience Page', function () {
cy.url().should( 'contain', 'get-started/experience' );
} );

const EventsAPI = ( experience_val ) => {
cy.intercept( APIList.get_started_experience_ecomm ).as( 'events' );
cy.wait( '@events' ).then( ( requestObject ) => {
const responseBody = requestObject.request.body;
const responseData1 = responseBody[ 0 ].data;
if ( 'experience_level' in responseData1 ) {
expect( responseData1.experience_level ).equal(
experience_val
);
} else {
const responseData2 = responseBody[ 1 ].data;
if ( 'experience_level' in responseData2 ) {
expect( responseData2.experience_level ).equal(
experience_val
);
}
}
} );
};

it( 'Check if events API call being made after radio buttons are clicked', () => {
let radioCount = 0;
const className = '.components-radio-control__option';
Expand All @@ -81,14 +61,14 @@ describe( 'Start Setup WP Experience Page', function () {
.eq( radioCount )
.click( { force: true } );
if ( radioCount == 0 ) {
EventsAPI( 'novice' );
EventsAPI( 'experience_level', 'novice', APIList.get_started_experience_ecomm );
}
if ( radioCount == 1 ) {
EventsAPI( 'intermediate' );
EventsAPI( 'experience_level', 'intermediate', APIList.get_started_experience_ecomm );
}
if ( radioCount > 1 ) {
cy.wait( 5000 );
EventsAPI( 'expert' );
EventsAPI( 'experience_level', 'expert', APIList.get_started_experience_ecomm );
}
radioCount += 1;
} );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// <reference types="Cypress" />
import { APIList, EventsAPI } from '../wp-module-support/EventsApi.cy';
import { CheckDrawerDisabled } from '../wp-module-support/drawer.cy';
import { CheckCardHeadingSubheading } from '../wp-module-support/header.cy';
import {
Expand Down Expand Up @@ -43,6 +44,36 @@ describe( 'Get Started Site Type Primary', function () {
.should( 'have.text', 'Business' );
} );

it( 'Check for Event API call being made when different categories are selected', ()=>{
let categoryCount = 0;
let num = 0;
const className = '.nfd-card-pri-category';
cy.get( className ).should( 'be.visible' );
const arr = cy.get( className );
arr.each( () => {
cy.get( className )
.eq( categoryCount )
.click()
.then(($element) => {
const dataSlugText = $element.attr('data-slug');
if(num>=2){
cy.wait(4000);
}
EventsAPI('primary_type', dataSlugText, APIList.site_primary_ecomm);
num+=1;
});
categoryCount += 1;
} );
} );

it( 'Check for Event API call when we enter text in input box', ()=>{
cy.get( '.nfd-setup-primary-custom__tellus-input' )
.scrollIntoView()
.should( 'be.visible' )
.type( 'Test' );
EventsAPI('primary_type', 'Test', APIList.site_primary_ecomm);
} );

it( 'Check different Categories exist and is selectable', () => {
let categoryCount = 0;
const className = '.nfd-card-pri-category';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// <reference types="Cypress" />
import { APIList, EventsAPI } from '../wp-module-support/EventsApi.cy';
import { CheckDrawerDisabled } from '../wp-module-support/drawer.cy';
import { CheckCardHeadingSubheading } from '../wp-module-support/header.cy';
import {
Expand Down Expand Up @@ -45,6 +46,36 @@ describe( 'Get Started Site Type Secondary', function () {
);
} );

it( 'Check for Event API call being made when different sub-categories are selected', ()=>{
let SubcategoryCount = 0;
let num = 0;
const className = '.nfd-card-sec-category';
cy.get( className ).should( 'be.visible' );
const arr = cy.get( className );
arr.each( () => {
cy.get( className )
.eq( SubcategoryCount )
.click()
.then(($element) => {
const dataSlugText = $element.attr('data-slug');
if(num>=2){
cy.wait(5000);
}
EventsAPI('secondary_type', dataSlugText, APIList.site_secondary_ecomm);
num+=1;
});
SubcategoryCount += 1;
} );
} );

it( 'Check for Event API call when we enter text in input box', ()=>{
cy.get( '.nfd-setup-primary-custom__tellus-input' )
.scrollIntoView()
.should( 'be.visible' )
.type( 'Test' );
EventsAPI('secondary_type', 'Test', APIList.site_secondary_ecomm);
} );

it( 'Check different subCategories exist and is selectable', () => {
let categoryCount = 0;
const className = '.subCategoriesSection';
Expand Down Expand Up @@ -106,7 +137,7 @@ describe( 'Get Started Site Type Secondary', function () {
cy.get( '.navigation-buttons_back' ).click();
} );

it.skip( 'Go to the previous step on clicking navigation Back', () => {
it( 'Go to the previous step on clicking navigation Back', () => {
cy.get( '.navigation-buttons_back' ).click();
cy.url().should(
'not.include',
Expand All @@ -115,7 +146,7 @@ describe( 'Get Started Site Type Secondary', function () {
cy.get( '.navigation-buttons_next' ).click();
} );

it.skip( 'Go to next step on Continue Setup', () => {
it( 'Go to next step on Continue Setup', () => {
cy.get( '.nfd-nav-card-button' ).click();
cy.url().should(
'not.include',
Expand Down
Loading