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

Basic Info GA Events API Automation #369

Merged
merged 9 commits into from
Dec 26, 2023
194 changes: 138 additions & 56 deletions tests/cypress/integration/2-general-onboarding-flow/basic-info.cy.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,68 @@
// <reference types="Cypress" />
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();
Expand All @@ -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();
Expand All @@ -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'
)
Expand All @@ -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.';
Expand All @@ -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();
Expand All @@ -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' );
Expand All @@ -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' );
Expand All @@ -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 (
Expand Down Expand Up @@ -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' );

avneet-raj marked this conversation as resolved.
Show resolved Hide resolved
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 );
} );
} );
Loading