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 c47626edf..0b292dde6 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 @@ -1,53 +1,68 @@ // -import { - DrawerActivityForMenu, - DrawerClose -} from '../wp-module-support/drawer.cy'; +import { DrawerClose } from '../wp-module-support/drawer.cy'; import { CheckHeadingSubheading } from '../wp-module-support/header.cy'; import { CheckHelpPanelLinks, CheckIllustrationPanel, CheckInfoPanel, - CheckIntroPanel, + CheckIntroPanel } from '../wp-module-support/sidebar.cy'; import { SocialMediaTextValidations } from '../wp-module-support/socialMedia.cy'; +import { APIList, BasicInfoAPI } from '../wp-module-support/EventsApi.cy'; describe( 'Basic Info Page', function () { + const desc = 'Welcome to WordPress'; + const title = 'Hello WordPress'; + const customCommandTimeout = 10000; + before( () => { - cy.visit( - 'wp-admin/?page=nfd-onboarding#/wp-setup/step/basic-info' - ); + cy.visit( 'wp-admin/?page=nfd-onboarding#/wp-setup/step/basic-info' ); } ); - it.skip( 'Check Drawer Activity', () => { - DrawerActivityForMenu( - 'Exit to WordPress', - ':nth-child(3)', - 'Basic Info' - ); + it( 'Check Drawer Activity', () => { + let href; + cy.get( '.nfd-onboarding-drawer__toggle' ) + .as( 'drawerOpen' ) + .invoke( 'attr', 'class' ) + .then( ( class_name ) => { + if ( ! class_name.includes( 'is-open' ) ) { + cy.get( '.nfd-onboarding-drawer__toggle-button' ).click(); + } + } ); + cy.get( '.nfd-onboarding-drawer__panel-inner', {timeout: 10000} ) + .scrollIntoView() + .should( 'be.visible' ); + + cy.get( ':nth-child(2) > .nfd-onboarding-drawer__panel-menu-link' ) + .should( 'have.class', 'active' ) + .should( 'have.text', 'Basic Info' ) + .and( 'have.attr', 'href' ) + .then( ( value ) => ( href = value ) ); + cy.url().then( ( url ) => { + expect( url ).to.include( href ); + } ); } ); - it.skip( 'Check if Header and Subheader shows up', () => { - cy.wait(3000); + it( 'Check if Header and Subheader shows up', () => { + cy.wait( 3000 ); DrawerClose(); CheckHeadingSubheading(); } ); - it.skip( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { + it( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { CheckIntroPanel( '__basic-info', 'Basic Info' ); CheckIllustrationPanel(); CheckInfoPanel(); CheckHelpPanelLinks(); } ); - it.skip( 'Check if Header has text `website` in it', () => { + it( 'Check if Header has text `website` in it', () => { cy.get( '.nfd-main-heading__title' ) - .should('be.visible') - .contains('website'); + .should( 'be.visible' ) + .contains( 'website' ); } ); - it.skip( 'Enter a Title and then Check if it reflects elsewhere', () => { - const title = 'Hello WordPress'; + it( 'Enter a Title and then Check if it reflects elsewhere', () => { const titleBox = cy.get( ':nth-child(1) > label > .nfd-input__field' ); if ( titleBox.should( 'exist' ) ) { titleBox.scrollIntoView(); @@ -62,8 +77,7 @@ describe( 'Basic Info Page', function () { } } ); - it.skip( 'Enter a Desc and then Check if it reflects elsewhere', () => { - const desc = 'Welcome to WordPress'; + it( 'Enter a Desc and then Check if it reflects elsewhere', () => { const descBox = cy.get( ':nth-child(2) > label > .nfd-input__field' ); if ( descBox.should( 'exist' ) ) { descBox.scrollIntoView(); @@ -76,7 +90,7 @@ describe( 'Basic Info Page', function () { } } ); - it.skip( 'Check if Social Media Accordion Toggles', () => { + it( 'Check if Social Media Accordion Toggles', () => { cy.get( ':nth-child(7) > .social-form__label > .social-form__label_name' ) @@ -90,41 +104,45 @@ describe( 'Basic Info Page', function () { ) .should( 'exist' ) .scrollIntoView() - .should('have.css', 'opacity', '1'); + .should( 'have.css', 'opacity', '1' ); } ); - it.skip( 'Check for the short URL tooltip & Modal exists when we use URL shortner' , () => { + it( 'Check for the short URL tooltip & Modal exists when we use URL shortner', () => { const shortURL = 'https://bit.ly'; const Tooltiptext1 = 'Short URLs are a great way to track clicks'; const ModalText1 = `It looks like you're using a URL shortener!`; - SocialMediaTextValidations(shortURL, Tooltiptext1, ModalText1 ); - }); + SocialMediaTextValidations( shortURL, Tooltiptext1, ModalText1 ); + } ); - it.skip( 'Check if the URL automatically updates http to https' , () => { + it( 'Check if the URL automatically updates http to https', () => { const sampleURL = 'http://www.facebook.com'; const socialTest = '#facebook'; - cy.get( '.social-form__top-row_icon' ).click(); - if ( cy.get(socialTest).should( 'exist' ) ) { - cy.get(socialTest).clear(); - cy.get(socialTest).type(sampleURL); - cy.get('#twitter').focus(); - cy.get(socialTest).invoke('val').should('contain', 'https://'); + cy.get( '.social-form__top-row_icon' ).click( { force: true } ); + if ( cy.get( socialTest ).should( 'exist' ) ) { + cy.get( socialTest ).clear({force: true}); + cy.get( socialTest ).type( sampleURL ); + cy.get( '#twitter' ).focus(); + cy.get( socialTest ) + .invoke( 'val' ) + .should( 'contain', 'https://' ); } } ); - it.skip( 'Check for twitter or instagram id starting with `@` to convert it to URL' , () => { + it( 'Check for twitter or instagram id starting with `@` to convert it to URL', () => { const sampleID = '@infinity'; const socialTest3 = '#instagram'; - if ( cy.get(socialTest3).should( 'exist' ) ) { - cy.get(socialTest3).clear(); - cy.get(socialTest3).type(sampleID); - cy.get('#facebook').focus(); - cy.get(socialTest3).invoke('val').should('contain', 'https://'); - + if ( cy.get( socialTest3 , { timeout: customCommandTimeout} ).should( 'exist' ) ) { + cy.get( socialTest3 ).clear({ force: true }); + cy.get( socialTest3 ).type( sampleID ); + cy.get( '#facebook' ).focus(); + cy.get( socialTest3 ) + .invoke( 'val' ) + .should( 'contain', 'https://' ); } - }); + // cy.wait( 2000 ) + } ); - it.skip( 'Check if Social Media URL checks are done', () => { + it( 'Check if Social Media URL checks are done', () => { const invalidURL = 'htt'; const validURL = 'https://www.facebook.com'; const Tooltiptext2 = 'we need the full URLs to your social profiles.'; @@ -133,11 +151,14 @@ describe( 'Basic Info Page', function () { // Facebook Social Media Component const socialTest2 = cy.get( '#twitter' ); const socialTest = cy.get( '#facebook' ); + cy.wait(3000) - if ( socialTest.should( 'exist' ) ) { - socialTest.clear(); + if ( socialTest.should( 'exist', { timeout: customCommandTimeout } ) ) { + cy.get( '#facebook' ).clear(); + cy.get( '.browser-content_social_icon.--no-url', { timeout: customCommandTimeout } ).should( 'exist' ) cy.get( - '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]' + '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]', + { timeout : customCommandTimeout } ).should( 'have.css', 'opacity', '0.5' ); socialTest2.focus(); @@ -147,13 +168,17 @@ describe( 'Basic Info Page', function () { // The URL Checker runs on a debounce // Shows the message to the User in case of Invalid URL cy.get( '.Tooltip-Wrapper', { timeout: 3000 } ).should( 'exist' ); - cy.get( '.Tooltip-Tip' , { timeout: 3000 }) - .should('be.visible') - .should('contain', Tooltiptext2); - cy.get('.navigation-buttons_next').click(); - cy.get( '.components-modal__content' ).should('be.visible'); - cy.get( '.components-modal__header-heading' ).should('have.text', ModalText2); - cy.get('.components-modal__content').type('{esc}'); + cy.get( '.Tooltip-Tip', { timeout: 3000 } ) + .should( 'be.visible' ) + .should( 'contain', Tooltiptext2 ); + cy.get( '.navigation-buttons_next' ).click(); + cy.get( '.components-modal__content' ).should( 'be.visible' ); + cy.get( '.components-modal__header-heading' ).should( + 'have.text', + ModalText2 + ); + // cy.get( '.components-modal__content' ).type( '{esc}' ); + cy.get( '.components-modal__header button' , { timeout: customCommandTimeout } ).click() cy.get( '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]' ).should( 'have.css', 'opacity', '0.75' ); @@ -165,6 +190,7 @@ describe( 'Basic Info Page', function () { cy.get( '.Tooltip-Wrapper', { timeout: 3000 } ).should( 'not.exist' ); + cy.wait( 2000 ) cy.get( '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]' ).should( 'have.css', 'opacity', '1' ); @@ -174,7 +200,7 @@ describe( 'Basic Info Page', function () { } } ); - it.skip( 'Check if Image gets Uploaded', () => { + it( 'Check if Image gets Uploaded', () => { const sampleLogo = `vendor/newfold-labs/wp-module-onboarding/tests/cypress/fixtures/image.png`; if ( @@ -205,4 +231,60 @@ describe( 'Basic Info Page', function () { } ); } } ); + + it('Test Basic Info Events API gets triggered', () => { + const socialTest = '#facebook' + const socialTest2 = '#twitter'; + const socialTest3 = '#instagram' + const socialTest4 = '#youtube'; + const socialTest5 = '#linkedin'; + const socialTest6 = '#yelp'; + const socialTest7 = '#tiktok'; + const label_keys = ['', 'title', 'tagline', 'logo_added', 'platform', 'platform', 'platform', 'platform', 'platform', 'platform', 'platform']; + const actual_values = ['', title, desc, '', 'facebook', 'twitter', 'instagram', 'youtube', 'linkedin', 'yelp', 'tiktok']; + + cy.get('.social-form__top-row_icon') + .as('socialFormToggle') + .invoke('attr', 'class') + .then((class_name) => { + if ( + !class_name.includes('social-form__top-row_icon_opened') + ) { + cy.get('@socialFormToggle').click(); + } + }); + + cy.get( socialTest ).should( 'exist' ); + cy.get( socialTest ).clear(); + cy.get( socialTest ).type( 'https://www.facebook.com/testfacebook' ); + + cy.get( socialTest2 ).should( 'exist' ); + cy.get( socialTest2 ).clear(); + cy.get(socialTest2).type('@testTweet'); + + cy.get( socialTest3 ).should( 'exist' ); + cy.get( socialTest3 ).clear(); + cy.get( socialTest3 ).type( '@testInsta' ); + + cy.get( socialTest4 ).should( 'exist' ); + cy.get( socialTest4 ).clear(); + cy.get( socialTest4 ).type( '@testYouTube' ); + + cy.get( socialTest5 ).should( 'exist' ); + cy.get( socialTest5 ).clear(); + cy.get( socialTest5 ).type( 'https://linkedin.com/in/testLinkedIn' ); + + cy.get( socialTest6 ).should( 'exist' ); + cy.get( socialTest6 ).clear(); + cy.get( socialTest6 ).type( 'https://www.yelp.com/testYelp' ); + + cy.get( socialTest7 ).should( 'exist' ); + cy.get( socialTest7 ).clear(); + cy.get( socialTest7 ).type( 'https://www.tiktok.com/testTikTok' ); + + cy.wait( 2000 ); + cy.intercept( APIList.basic_info ).as( 'events' ); + cy.get( '.navigation-buttons_next' ).click(); + BasicInfoAPI( 'basic_info', label_keys, actual_values ); + } ); } ); 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 44a87ccfa..eeb4f090a 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 @@ -1,54 +1,74 @@ // -import { DrawerActivityForMenu, DrawerClose } from '../wp-module-support/drawer.cy'; +import { DrawerClose } from '../wp-module-support/drawer.cy'; import { CheckHeadingSubheading } from '../wp-module-support/header.cy'; import { CheckHelpPanelLinks, CheckIllustrationPanel, CheckInfoPanel, - CheckIntroPanel, + CheckIntroPanel } from '../wp-module-support/sidebar.cy'; import { SocialMediaTextValidations } from '../wp-module-support/socialMedia.cy'; +import { APIList, BasicInfoAPI } from '../wp-module-support/EventsApi.cy'; describe( 'Basic Info Page', function () { + const desc = 'Welcome to WordPress'; + const title = 'Hello WordPress'; + const customCommandTimeout = 10000; + before( () => { cy.visit( 'wp-admin/?page=nfd-onboarding&flow=ecommerce#/wp-setup/step/basic-info' ); } ); - it.skip( 'Check Drawer Activity', () => { - DrawerActivityForMenu( - 'Exit to WordPress', - ':nth-child(3)', - 'Basic Info' - ); + it( 'Check Drawer Activity', () => { + let href; + cy.get( '.nfd-onboarding-drawer__toggle' ) + .as( 'drawerOpen' ) + .invoke( 'attr', 'class' ) + .then( ( class_name ) => { + if ( ! class_name.includes( 'is-open' ) ) { + cy.get( '.nfd-onboarding-drawer__toggle-button' ).click(); + } + } ); + cy.get( '.nfd-onboarding-drawer__panel-inner' , {timeout: 10000} ) + .scrollIntoView() + .should( 'be.visible' ); + + cy.get( ':nth-child(2) > .nfd-onboarding-drawer__panel-menu-link' ) + .should( 'have.class', 'active' ) + .should( 'have.text', 'Basic Info' ) + .and( 'have.attr', 'href' ) + .then( ( value ) => ( href = value ) ); + cy.url().then( ( url ) => { + expect( url ).to.include( href ); + } ); } ); - it.skip( 'Check if Header and Subheader shows up', () => { - cy.wait(3000); + it( 'Check if Header and Subheader shows up', () => { + cy.wait( 3000 ); DrawerClose(); CheckHeadingSubheading(); } ); - it.skip( 'Check if `store` appears in heading', () => { - cy.get('.nfd-main-heading__title') - .should('be.visible') - .contains('store'); + it( 'Check if `store` appears in heading', () => { + cy.get( '.nfd-main-heading__title' ) + .should( 'be.visible' ) + .contains( 'store' ); } ); - it.skip( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { + it( 'Check to make sure sidebar opens, content is in place and close sidebar', () => { CheckIntroPanel( '__basic-info', 'Basic Info' ); CheckIllustrationPanel(); CheckInfoPanel(); CheckHelpPanelLinks(); } ); - it.skip( 'Enter a Title and then Check if it reflects elsewhere', () => { - const title = 'Hello WordPress'; + it( 'Enter a Title and then Check if it reflects elsewhere', () => { const titleBox = cy.get( ':nth-child(1) > label > .nfd-input__field' ); if ( titleBox.should( 'exist' ) ) { titleBox.scrollIntoView(); - titleBox.clear({force: true}); + titleBox.clear( { force: true } ); cy.wait( 1000 ); titleBox.type( title ); @@ -59,12 +79,11 @@ describe( 'Basic Info Page', function () { } } ); - it.skip( 'Enter a Desc and then Check if it reflects elsewhere', () => { - const desc = 'Welcome to WordPress'; + it( 'Enter a Desc and then Check if it reflects elsewhere', () => { const descBox = cy.get( ':nth-child(2) > label > .nfd-input__field' ); if ( descBox.should( 'exist' ) ) { descBox.scrollIntoView(); - descBox.clear({force: true}); + descBox.clear( { force: true } ); cy.wait( 1000 ); descBox.type( desc ); @@ -73,7 +92,7 @@ describe( 'Basic Info Page', function () { } } ); - it.skip( 'Check if Social Media Accordion Toggles', () => { + it( 'Check if Social Media Accordion Toggles', () => { cy.get( ':nth-child(7) > .social-form__label > .social-form__label_name' ) @@ -81,47 +100,50 @@ describe( 'Basic Info Page', function () { .should( 'not.be.visible' ); // Open Social Media Accordion - cy.get( '.social-form__top-row_icon' ).invoke('click'); + cy.get( '.social-form__top-row_icon' ).invoke( 'click' ); cy.get( ':nth-child(7) > .social-form__label > .social-form__label_name' ) .should( 'exist' ) .scrollIntoView() - .should('have.css', 'opacity', '1'); + .should( 'have.css', 'opacity', '1' ); } ); - it.skip( 'Check for the short URL tooltip & Modal exists when we use URL shortner' , () => { + it( 'Check for the short URL tooltip & Modal exists when we use URL shortner', () => { const shortURL = 'https://bit.ly'; const Tooltiptext1 = 'Short URLs are a great way to track clicks'; const ModalText1 = `It looks like you're using a URL shortener!`; - SocialMediaTextValidations(shortURL, Tooltiptext1, ModalText1 ); - }); + SocialMediaTextValidations( shortURL, Tooltiptext1, ModalText1 ); + } ); - it.skip( 'Check if the URL automatically updates http to https' , () => { + it( 'Check if the URL automatically updates http to https', () => { const sampleURL = 'http://www.facebook.com'; const socialTest = '#facebook'; - cy.get( '.social-form__top-row_icon' ).click(); - if ( cy.get(socialTest).should( 'exist' ) ) { - cy.get(socialTest).clear(); - cy.get(socialTest).type(sampleURL); - cy.get('#twitter').focus(); - cy.get(socialTest).invoke('val').should('contain', 'https://'); + cy.get( '.social-form__top-row_icon' ).click( { force: true } ); + if ( cy.get( socialTest ).should( 'exist' ) ) { + cy.get( socialTest ).clear( { force: true } ); + cy.get( socialTest ).type( sampleURL ); + cy.get( '#twitter' ).focus(); + cy.get( socialTest ) + .invoke( 'val' ) + .should( 'contain', 'https://' ); } } ); - it.skip( 'Check for twitter or instagram id starting with `@` to convert it to URL' , () => { + it( 'Check for twitter or instagram id starting with `@` to convert it to URL', () => { const sampleID = '@infinity'; const socialTest3 = '#instagram'; - if ( cy.get(socialTest3).should( 'exist' ) ) { - cy.get(socialTest3).clear(); - cy.get(socialTest3).type(sampleID); - cy.get('#facebook').focus(); - cy.get(socialTest3).invoke('val').should('contain', 'https://'); - + if ( cy.get( socialTest3 , { timeout: customCommandTimeout } ).should( 'exist' ) ) { + cy.get( socialTest3 ).clear( { force: true } ); + cy.get( socialTest3 ).type( sampleID ); + cy.get( '#facebook' ).focus(); + cy.get( socialTest3 ) + .invoke( 'val' ) + .should( 'contain', 'https://' ); } - }); + } ); - it.skip( 'Check if Social Media URL checks are done', () => { + it( 'Check if Social Media URL checks are done', () => { const invalidURL = 'htt'; const validURL = 'https://www.facebook.com'; const Tooltiptext2 = 'we need the full URLs to your social profiles.'; @@ -130,11 +152,14 @@ describe( 'Basic Info Page', function () { // Facebook Social Media Component const socialTest2 = cy.get( '#twitter' ); const socialTest = cy.get( '#facebook' ); + cy.wait(2000) - if ( socialTest.should( 'exist' ) ) { - socialTest.clear(); + if ( socialTest.should( 'exist' , { timeout: customCommandTimeout }) ) { + cy.get( '#facebook' ).clear() + cy.get( '.browser-content_social_icon.--no-url', { timeout: customCommandTimeout } ).should( 'exist' ) cy.get( - '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]' + '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]', + { timeout : customCommandTimeout } ).should( 'have.css', 'opacity', '0.5' ); socialTest2.focus(); @@ -144,13 +169,16 @@ describe( 'Basic Info Page', function () { // The URL Checker runs on a debounce // Shows the message to the User in case of Invalid URL cy.get( '.Tooltip-Wrapper', { timeout: 3000 } ).should( 'exist' ); - cy.get( '.Tooltip-Tip' , { timeout: 3000 }) - .should('be.visible') - .should('contain', Tooltiptext2); - cy.get('.navigation-buttons_next').click(); - cy.get( '.components-modal__content' ).should('be.visible'); - cy.get( '.components-modal__header-heading' ).should('have.text', ModalText2); - cy.get('.components-modal__content').type('{esc}'); + cy.get( '.Tooltip-Tip', { timeout: 3000 } ) + .should( 'be.visible' ) + .should( 'contain', Tooltiptext2 ); + cy.get( '.navigation-buttons_next' ).click(); + cy.get( '.components-modal__content' ).should( 'be.visible' ); + cy.get( '.components-modal__header-heading' ).should( + 'have.text', + ModalText2 + ); + cy.get( '.components-modal__header button' , { timeout: customCommandTimeout } ).click() cy.get( '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]' ).should( 'have.css', 'opacity', '0.75' ); @@ -162,6 +190,7 @@ describe( 'Basic Info Page', function () { cy.get( '.Tooltip-Wrapper', { timeout: 3000 } ).should( 'not.exist' ); + cy.wait( 2000 ) cy.get( '.browser-content_social_icon[style="background-image: var(--facebook-icon);"]' ).should( 'have.css', 'opacity', '1' ); @@ -171,7 +200,7 @@ describe( 'Basic Info Page', function () { } } ); - it.skip( 'Check if Image gets Uploaded', () => { + it( 'Check if Image gets Uploaded', () => { const sampleLogo = `vendor/newfold-labs/wp-module-onboarding/tests/cypress/fixtures/image.png`; if ( @@ -202,4 +231,60 @@ describe( 'Basic Info Page', function () { } ); } } ); + + it( 'Test Basic Info Events API gets triggered', () => { + const socialTest = '#facebook' + const socialTest2 = '#twitter'; + const socialTest3 = '#instagram' + const socialTest4 = '#youtube'; + const socialTest5 = '#linkedin'; + const socialTest6 = '#yelp'; + const socialTest7 = '#tiktok'; + const label_keys = ['title', 'tagline', 'logo_added', 'platform', 'platform', 'platform', 'platform', 'platform', 'platform', 'platform']; + const actual_values = [title, desc, '', 'facebook', 'twitter', 'instagram', 'youtube', 'linkedin', 'yelp', 'tiktok']; + + cy.get( '.social-form__top-row_icon' ) + .as( 'socialFormToggle' ) + .invoke( 'attr', 'class' ) + .then( ( class_name ) => { + if ( + ! class_name.includes( 'social-form__top-row_icon_opened' ) + ) { + cy.get( '@socialFormToggle' ).click(); + } + } ); + + cy.get( socialTest ).should( 'exist' ); + cy.get( socialTest ).clear(); + cy.get( socialTest ).type( 'https://www.facebook.com/testfacebook' ); + + cy.get( socialTest2 ).should( 'exist' ); + cy.get( socialTest2 ).clear(); + cy.get(socialTest2).type('@testTweet'); + + cy.get( socialTest3 ).should( 'exist' ); + cy.get( socialTest3 ).clear(); + cy.get(socialTest3).type('@testInsta'); + + cy.get( socialTest4 ).should( 'exist' ); + cy.get( socialTest4 ).clear(); + cy.get( socialTest4 ).type( '@testYouTube' ); + + cy.get( socialTest5 ).should( 'exist' ); + cy.get( socialTest5 ).clear(); + cy.get( socialTest5 ).type( 'https://linkedin.com/in/testLinkedIn' ); + + cy.get( socialTest6 ).should( 'exist' ); + cy.get( socialTest6 ).clear(); + cy.get( socialTest6 ).type( 'https://www.yelp.com/testYelp' ); + + cy.get( socialTest7 ).should( 'exist' ); + cy.get( socialTest7 ).clear(); + cy.get( socialTest7 ).type( 'https://www.tiktok.com/testTikTok' ); + + cy.wait( 2000 ); + cy.intercept( APIList.basic_info_ecomm ).as( 'events' ); + cy.get( '.navigation-buttons_next' ).click(); + BasicInfoAPI( 'basic_info_ecomm', label_keys, actual_values ); + } ); } ); diff --git a/tests/cypress/integration/wp-module-support/EventsApi.cy.js b/tests/cypress/integration/wp-module-support/EventsApi.cy.js index 04cccbeb0..b83473289 100644 --- a/tests/cypress/integration/wp-module-support/EventsApi.cy.js +++ b/tests/cypress/integration/wp-module-support/EventsApi.cy.js @@ -1,76 +1,103 @@ +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' -} + 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' +}; export const EventsAPI = ( events_name, card_val, api_name ) => { - cy.intercept( api_name ).as( 'events' ); - cy.wait( '@events' ).then( ( requestObject ) => { - const responseBody = requestObject.request.body; - const responseData1 = responseBody[ 0 ].data; - if(events_name == 'experience_level'){ - if ( events_name in responseData1 ) { - expect( responseData1.experience_level ).equal( - card_val - ); - } else { - const responseData2 = responseBody[ 1 ].data; - if ( events_name in responseData2 ) { - expect( responseData2.experience_level ).equal( - card_val - ); - } - } - }; - if(events_name == 'top_priority'){ - if ( events_name in responseData1 ) { - expect( responseData1.top_priority ).equal( - card_val - ); - } else { - const responseData2 = responseBody[ 1 ].data; - if ( events_name in responseData2 ) { - expect( responseData2.top_priority ).equal( - card_val - ); - } - } - }; + cy.intercept( api_name ).as( 'events' ); + cy.wait( '@events' ).then( ( requestObject ) => { + const responseBody = requestObject.request.body; + const responseData1 = responseBody[ 0 ].data; + if ( events_name == 'experience_level' ) { + if ( events_name in responseData1 ) { + expect( responseData1.experience_level ).equal( card_val ); + } else { + const responseData2 = responseBody[ 1 ].data; + if ( events_name in responseData2 ) { + expect( responseData2.experience_level ).equal( card_val ); + } + } + } + if ( events_name == 'top_priority' ) { + if ( events_name in responseData1 ) { + expect( responseData1.top_priority ).equal( card_val ); + } else { + const responseData2 = responseBody[ 1 ].data; + if ( events_name in responseData2 ) { + expect( responseData2.top_priority ).equal( card_val ); + } + } + } + + if ( events_name == 'primary_type' ) { + if ( events_name in responseData1 ) { + expect( responseData1.primary_type ).equal( card_val ); + } else { + const responseData2 = responseBody[ 1 ].data; + if ( events_name in responseData2 ) { + expect( responseData2.primary_type ).equal( card_val ); + } + } + } + + if ( events_name == 'secondary_type' ) { + if ( events_name in responseData1 ) { + expect( responseData1.secondary_type ).equal( card_val ); + } else { + const responseData2 = responseBody[ 1 ].data; + if ( events_name in responseData2 ) { + expect( responseData2.secondary_type ).equal( card_val ); + } + } + } + } ); +}; - if(events_name == 'primary_type'){ - if ( events_name in responseData1 ) { - expect( responseData1.primary_type ).equal( - card_val - ); - } else { - const responseData2 = responseBody[ 1 ].data; - if ( events_name in responseData2 ) { - expect( responseData2.primary_type ).equal( - card_val - ); - } - } - }; - +export const BasicInfoAPI = ( + events_name, + label_key = [], + actual_values = [] +) => { + cy.wait( '@events' ).then( ( requestObject ) => { + const requestBody = requestObject.request.body; - if(events_name == 'secondary_type'){ - if ( events_name in responseData1 ) { - expect( responseData1.secondary_type ).equal( - card_val - ); - } else { - const responseData2 = responseBody[ 1 ].data; - if ( events_name in responseData2 ) { - expect( responseData2.secondary_type ).equal( - card_val - ); - } - } - }; -}); + label_key.forEach( ( labels, index ) => { + if ( labels == 'logo_added' ) { + expect( requestBody[ index ].action ).to.eq( 'logo_added' ); + } else { + const requestBodyData = requestBody[ index ].data; + if ( index == 0 ) { + if ( events_name == 'basic_info' ) { + expect( requestBodyData.label_key ).to.oneOf( [ + 'chapter', + 'top_priority', + ] ); + } + } else { + expect( requestBodyData.label_key ).to.eq( labels ); + expect( requestBodyData[ labels ] ).to.eq( + actual_values[ index ] + ); + } + } + } ); + } ); }; diff --git a/tests/cypress/integration/wp-module-support/drawer.cy.js b/tests/cypress/integration/wp-module-support/drawer.cy.js index 4467c0443..2b7c3d31a 100644 --- a/tests/cypress/integration/wp-module-support/drawer.cy.js +++ b/tests/cypress/integration/wp-module-support/drawer.cy.js @@ -1,7 +1,10 @@ // +const customCommandTimeout = 30000; export const CheckDrawerDisabled = () => { - cy.get( '.nfd-onboarding-drawer__toggle-button' ) + cy.get( '.nfd-onboarding-drawer__toggle-button', { + timeout: customCommandTimeout, + } ) .click() .should( 'have.class', 'is-suppressed' ); cy.get( '.nfd-onboarding-drawer__panel-scroll-container' ) @@ -65,7 +68,9 @@ export const DrawerActivityForSubMenu = ( cy.get( '.nfd-onboarding-drawer__panel-inner' ) .scrollIntoView() .should( 'be.visible' ); - cy.get( '.nfd-onboarding-drawer__panel-back' ) + cy.get( '.nfd-onboarding-drawer__panel-back', { + timeout: customCommandTimeout, + } ) .should( 'be.visible' ) .should( 'have.text', text ); cy.get( subMenuDrawer ).should( 'be.visible' ); diff --git a/tests/cypress/integration/wp-module-support/socialMedia.cy.js b/tests/cypress/integration/wp-module-support/socialMedia.cy.js index 0f88cf12f..48c75f92d 100644 --- a/tests/cypress/integration/wp-module-support/socialMedia.cy.js +++ b/tests/cypress/integration/wp-module-support/socialMedia.cy.js @@ -15,11 +15,11 @@ export const SocialMediaTextValidations = ( URL, ToolTipText, ModalHeaderText ) cy.get( '.components-modal__header-heading' ).should('have.text', ModalHeaderText); cy.get(':nth-child(2) > .components-button-group > .is-secondary').click(); cy.get(NextButton).click(); - cy.get('.components-modal__content').type('{esc}'); + cy.get('.components-modal__header button', {timeout: 10000}).click() cy.get(NextButton).click(); cy.get(':nth-child(2) > .components-button-group > .is-primary').click(); cy.url().should('not.contain', 'wp-setup/step/basic-info'); cy.go('back'); - cy.get( '.nfd-onboarding-drawer__toggle-button' ).click(); + cy.get( '.nfd-onboarding-drawer__toggle-button', { timeout: 10000 } ).click(); } };