diff --git a/tests/cypress/integration/2-general-onboarding-flow/basic-info.cy.js b/tests/cypress/integration/2-general-onboarding-flow/basic-info.cy.js index b22f05e3c..3f0eeb45d 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/basic-info.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/basic-info.cy.js @@ -299,7 +299,7 @@ describe( 'Basic Info Page', function () { cy.get( socialTest7 ).type( 'https://www.tiktok.com/testTikTok' ); cy.wait( 2000 ); - cy.intercept( APIList.basic_info ).as( 'events' ); + cy.intercept( APIList.events_api_general_onb ).as( 'events' ); cy.get( '.navigation-buttons_next' ).click(); BasicInfoAPI( 'basic_info', label_keys, actual_values ); } ); diff --git a/tests/cypress/integration/2-general-onboarding-flow/get-started-experience.cy.js b/tests/cypress/integration/2-general-onboarding-flow/get-started-experience.cy.js index 975404122..ead064356 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/get-started-experience.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/get-started-experience.cy.js @@ -72,14 +72,14 @@ describe( 'Start Setup WP Experience Page', function () { .eq( radioCount ) .click( { force: true } ); if ( radioCount == 0 ) { - EventsAPI( 'experience_level', 'novice', APIList.get_started_experience ); + EventsAPI( 'experience_level', 'novice', APIList.events_api_general_onb ); } if ( radioCount == 1 ) { - EventsAPI( 'experience_level', 'intermediate', APIList.get_started_experience ); + EventsAPI( 'experience_level', 'intermediate', APIList.events_api_general_onb ); } if ( radioCount > 1 ) { cy.wait( 5000 ); - EventsAPI( 'experience_level', 'expert', APIList.get_started_experience ); + EventsAPI( 'experience_level', 'expert', APIList.events_api_general_onb ); } radioCount += 1; } ); diff --git a/tests/cypress/integration/2-general-onboarding-flow/site-features.cy.js b/tests/cypress/integration/2-general-onboarding-flow/site-features.cy.js index d08ca7034..ee3a5e647 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/site-features.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/site-features.cy.js @@ -9,6 +9,7 @@ import { CheckInfoPanel, CheckIntroPanel, } from '../wp-module-support/sidebar.cy'; +import { APIList, SiteFeaturesAPI } from '../wp-module-support/EventsApi.cy'; describe( 'Site Features', function () { before( () => { @@ -24,8 +25,8 @@ describe( 'Site Features', function () { it( 'Check if Header has text `site` in it', () => { cy.get( '.nfd-main-heading__title' ) - .should('be.visible') - .contains('site'); + .should( 'be.visible' ) + .contains( 'site' ); } ); it( 'Check Drawer Activity', () => { @@ -36,19 +37,18 @@ describe( 'Site Features', function () { ); } ); - if(GetPluginId()=='bluehost'){ - it( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { - CheckIntroPanel( '__site-features', 'Features' ); - CheckIllustrationPanel(); - CheckInfoPanel(); - CheckHelpPanelLinks(); - } ); - } - else{ + if ( GetPluginId() == 'bluehost' ) { + it( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { + CheckIntroPanel( '__site-features', 'Features' ); + CheckIllustrationPanel(); + CheckInfoPanel(); + CheckHelpPanelLinks(); + } ); + } else { it( 'Check to make sure Sidebar opens', () => { BasicSidebarCheck(); } ); - }; + } it( 'Check if Site Features list exists and select them', () => { let previewCount = 0; @@ -65,4 +65,26 @@ describe( 'Site Features', function () { previewCount += 1; } ); } ); + + it( 'Check if site-features GA events are triggerred', () => { + const features = [ + 'jetpack', + 'wpforms-lite', + 'google-analytics-for-wordpress', + 'wordpress-seo', + 'creative-mail-by-constant-contact', + 'optinmonster', + ]; + + // Make sure if all site-features are selected + cy.get( '.components-checkbox-control__input' ).each( ( $checkbox ) => { + if ( ! $checkbox.is( ':checked' ) ) { + cy.wrap( $checkbox ).click(); + } + } ); + + cy.intercept( APIList.events_api_general_onb ).as( 'events' ); + cy.get( '.navigation-buttons_next' ).click(); + SiteFeaturesAPI( 'feature', features ); + } ); } ); diff --git a/tests/cypress/integration/2-general-onboarding-flow/sitetype-primary.cy.js b/tests/cypress/integration/2-general-onboarding-flow/sitetype-primary.cy.js index 65cb3e615..05fec67ac 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/sitetype-primary.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/sitetype-primary.cy.js @@ -56,7 +56,7 @@ describe( 'Get Started Site Type Primary', function () { if(num>=2){ cy.wait(4000); } - EventsAPI('primary_type', dataSlugText, APIList.site_primary); + EventsAPI('primary_type', dataSlugText, APIList.events_api_general_onb); num+=1; }); categoryCount += 1; @@ -68,7 +68,7 @@ describe( 'Get Started Site Type Primary', function () { .scrollIntoView() .should( 'be.visible' ) .type( 'Test' ); - EventsAPI('primary_type', 'Test', APIList.site_primary); + EventsAPI('primary_type', 'Test', APIList.events_api_general_onb); } ); it( 'Check different Categories exist and is selectable', () => { diff --git a/tests/cypress/integration/2-general-onboarding-flow/sitetype-secondary.cy.js b/tests/cypress/integration/2-general-onboarding-flow/sitetype-secondary.cy.js index 08a956ef7..e66959fd4 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/sitetype-secondary.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/sitetype-secondary.cy.js @@ -56,7 +56,7 @@ describe( 'Get Started Site Type Secondary', function () { if(num>=2){ cy.wait(5000); } - EventsAPI('secondary_type', dataSlugText, APIList.site_secondary); + EventsAPI('secondary_type', dataSlugText, APIList.events_api_general_onb); num+=1; }); SubcategoryCount += 1; @@ -68,7 +68,7 @@ describe( 'Get Started Site Type Secondary', function () { .scrollIntoView() .should( 'be.visible' ) .type( 'Test' ); - EventsAPI('secondary_type', 'Test', APIList.site_secondary); + EventsAPI('secondary_type', 'Test', APIList.events_api_general_onb); } ); it( 'Check different categories exist using `<` and `>`', () => { diff --git a/tests/cypress/integration/2-general-onboarding-flow/top-priority.cy.js b/tests/cypress/integration/2-general-onboarding-flow/top-priority.cy.js index 8980a2b0c..5800c4af1 100644 --- a/tests/cypress/integration/2-general-onboarding-flow/top-priority.cy.js +++ b/tests/cypress/integration/2-general-onboarding-flow/top-priority.cy.js @@ -38,14 +38,14 @@ describe( 'Top Priority Page', function () { .should( 'be.visible' ) .click(); if ( previewCount == 0 ) { - EventsAPI( 'top_priority', 'content', APIList.top_priority ); + EventsAPI( 'top_priority', 'content', APIList.events_api_general_onb ); } if ( previewCount == 1 ) { - EventsAPI( 'top_priority', 'store', APIList.top_priority ); + EventsAPI( 'top_priority', 'store', APIList.events_api_general_onb ); } if ( previewCount > 1 ) { cy.wait( 5000 ); - EventsAPI( 'top_priority', 'design', APIList.top_priority ); + EventsAPI( 'top_priority', 'design', APIList.events_api_general_onb ); } previewCount += 1; }); diff --git a/tests/cypress/integration/3-ecommerce-onboarding-flow/basic-info.cy.js b/tests/cypress/integration/3-ecommerce-onboarding-flow/basic-info.cy.js index 66fab3e97..d5ca4b330 100644 --- a/tests/cypress/integration/3-ecommerce-onboarding-flow/basic-info.cy.js +++ b/tests/cypress/integration/3-ecommerce-onboarding-flow/basic-info.cy.js @@ -303,7 +303,7 @@ describe( 'Basic Info Page', function () { cy.get( socialTest7 ).type( 'https://www.tiktok.com/testTikTok' ); cy.wait( 2000 ); - cy.intercept( APIList.basic_info_ecomm ).as( 'events' ); + cy.intercept( APIList.events_api_ecomm ).as( 'events' ); cy.get( '.navigation-buttons_next' ).click(); BasicInfoAPI( 'basic_info_ecomm', label_keys, actual_values ); } ); diff --git a/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-experience.cy.js b/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-experience.cy.js index 0ff33ad1b..18deb99af 100644 --- a/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-experience.cy.js +++ b/tests/cypress/integration/3-ecommerce-onboarding-flow/get-started-experience.cy.js @@ -70,14 +70,14 @@ describe( 'Start Setup WP Experience Page', function () { .eq( radioCount ) .click( { force: true } ); if ( radioCount == 0 ) { - EventsAPI( 'experience_level', 'novice', APIList.get_started_experience_ecomm ); + EventsAPI( 'experience_level', 'novice', APIList.events_api_ecomm ); } if ( radioCount == 1 ) { - EventsAPI( 'experience_level', 'intermediate', APIList.get_started_experience_ecomm ); + EventsAPI( 'experience_level', 'intermediate', APIList.events_api_ecomm ); } if ( radioCount > 1 ) { cy.wait( 5000 ); - EventsAPI( 'experience_level', 'expert', APIList.get_started_experience_ecomm ); + EventsAPI( 'experience_level', 'expert', APIList.events_api_ecomm ); } radioCount += 1; } ); diff --git a/tests/cypress/integration/3-ecommerce-onboarding-flow/site-features.cy.js b/tests/cypress/integration/3-ecommerce-onboarding-flow/site-features.cy.js index e2b338575..30d29d368 100644 --- a/tests/cypress/integration/3-ecommerce-onboarding-flow/site-features.cy.js +++ b/tests/cypress/integration/3-ecommerce-onboarding-flow/site-features.cy.js @@ -9,6 +9,7 @@ import { CheckInfoPanel, CheckIntroPanel, } from '../wp-module-support/sidebar.cy'; +import { APIList, SiteFeaturesAPI } from '../wp-module-support/EventsApi.cy'; describe( 'Site Features', function () { before( () => { @@ -30,20 +31,18 @@ describe( 'Site Features', function () { ); } ); - if(GetPluginId()=='bluehost'){ + if ( GetPluginId() == 'bluehost' ) { it( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { CheckIntroPanel( '__site-features', 'Features' ); CheckIllustrationPanel(); CheckInfoPanel(); CheckHelpPanelLinks(); } ); - } - else{ + } else { it( 'Check to make sure Sidebar opens', () => { BasicSidebarCheck(); } ); } - it( 'Check if Site Features list exists and select them', () => { let previewCount = 0; @@ -60,4 +59,26 @@ describe( 'Site Features', function () { previewCount += 1; } ); } ); + + it( 'Check if site-features GA events are triggerred', () => { + const features = [ + 'jetpack', + 'wpforms-lite', + 'google-analytics-for-wordpress', + 'wordpress-seo', + 'creative-mail-by-constant-contact', + 'optinmonster', + ]; + + // Make sure if all site-features are selected + cy.get( '.components-checkbox-control__input' ).each( ( $checkbox ) => { + if ( ! $checkbox.is( ':checked' ) ) { + cy.wrap( $checkbox ).click(); + } + } ); + + cy.intercept( APIList.events_api_ecomm ).as( 'events' ); + cy.get( '.navigation-buttons_next' ).click(); + SiteFeaturesAPI( 'feature', features ); + } ); } ); diff --git a/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-primary.cy.js b/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-primary.cy.js index 60805caa7..7c0272b14 100644 --- a/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-primary.cy.js +++ b/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-primary.cy.js @@ -68,7 +68,7 @@ describe( 'Get Started Site Type Primary', function () { if(num>=2){ cy.wait(4000); } - EventsAPI('primary_type', dataSlugText, APIList.site_primary_ecomm); + EventsAPI('primary_type', dataSlugText, APIList.events_api_ecomm); num+=1; }); categoryCount += 1; @@ -80,7 +80,7 @@ describe( 'Get Started Site Type Primary', function () { .scrollIntoView() .should( 'be.visible' ) .type( 'Test' ); - EventsAPI('primary_type', 'Test', APIList.site_primary_ecomm); + EventsAPI('primary_type', 'Test', APIList.events_api_ecomm); } ); it( 'Check different Categories exist and is selectable', () => { diff --git a/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-secondary.cy.js b/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-secondary.cy.js index 13cb808d7..cd474bdd9 100644 --- a/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-secondary.cy.js +++ b/tests/cypress/integration/3-ecommerce-onboarding-flow/sitetype-secondary.cy.js @@ -70,7 +70,7 @@ describe( 'Get Started Site Type Secondary', function () { if(num>=2){ cy.wait(5000); } - EventsAPI('secondary_type', dataSlugText, APIList.site_secondary_ecomm); + EventsAPI('secondary_type', dataSlugText, APIList.events_api_ecomm); num+=1; }); SubcategoryCount += 1; @@ -82,7 +82,7 @@ describe( 'Get Started Site Type Secondary', function () { .scrollIntoView() .should( 'be.visible' ) .type( 'Test' ); - EventsAPI('secondary_type', 'Test', APIList.site_secondary_ecomm); + EventsAPI('secondary_type', 'Test', APIList.events_api_ecomm); } ); it( 'Check different subCategories exist and is selectable', () => { diff --git a/tests/cypress/integration/wp-module-support/EventsApi.cy.js b/tests/cypress/integration/wp-module-support/EventsApi.cy.js index b83473289..a9cc22211 100644 --- a/tests/cypress/integration/wp-module-support/EventsApi.cy.js +++ b/tests/cypress/integration/wp-module-support/EventsApi.cy.js @@ -1,24 +1,6 @@ -import { forEach } from 'lodash'; - export const APIList = { - get_started_experience: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user', - get_started_experience_ecomm: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=ecommerce&_locale=user', - top_priority: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user', - site_primary: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user', - site_primary_ecomm: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=ecommerce&_locale=user', - site_secondary: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user', - site_secondary_ecomm: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=ecommerce&_locale=user', - basic_info: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user', - basic_info_ecomm: - '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=ecommerce&_locale=user' + events_api_general_onb: '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=wp-setup&_locale=user', + events_api_ecomm: '/index.php?rest_route=%2Fnewfold-onboarding%2Fv1%2Fevents%2Fbatch&flow=ecommerce&_locale=user' }; export const EventsAPI = ( events_name, card_val, api_name ) => { @@ -101,3 +83,21 @@ export const BasicInfoAPI = ( } ); } ); }; + +export const SiteFeaturesAPI = ( label_key_value, features = [] ) => { + let index = 0; + + cy.wait( '@events' ).then( ( requestObject ) => { + const requestBody = requestObject.request.body; + expect( requestBody[ index ].action ).to.eq( 'feature_added' ); + + requestBody.forEach( () => { + const requestBodyData = requestBody[ index ].data; + expect( requestBodyData.label_key ).to.eq( label_key_value ); + expect( requestBodyData[ label_key_value ] ).to.eq( + features[ index ] + ); + index += 1; + } ); + } ); +};