From c8380094653b0e09c1144742c69bd1cb03692b80 Mon Sep 17 00:00:00 2001 From: asr0393 Date: Wed, 16 Oct 2024 20:13:07 +0530 Subject: [PATCH 01/12] Verifying AI popup for six month old unlaunched sites - PS0-2221 --- tests/cypress/integration/notifications.cy.js | 149 ++++++++++++++---- 1 file changed, 119 insertions(+), 30 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 8674bd4..6df329f 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -1,7 +1,20 @@ -// -const notifications = [ + // + const notifications = [ { id: 'test-1', + locations: [ + { + context: Cypress.env( 'pluginId' ) + '-plugin', + pages: [ '#/home' ], + }, + ], + expiration: 2748820256, + + content: + '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • Preview different layouts and designs in minutes
  • Customize the colors and fonts
  • Site headlines, text, and imagery generated automatically
  • Multiple site designs for you to choose from
' + }, + { + id: 'test-2', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', @@ -13,7 +26,7 @@ const notifications = [ '

Notice should only display on plugin app settings page

', }, { - id: 'test-2', + id: 'test-3', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', @@ -25,7 +38,7 @@ const notifications = [ '

Here is a plugin notice it should display on home and onboarding screens only!

', }, { - id: 'test-3', + id: 'test-4', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', @@ -37,7 +50,7 @@ const notifications = [ '

Here is a plugin notice it should display on marketplace themes screen only!

', }, { - id: 'test-4', + id: 'test-5', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', @@ -53,7 +66,7 @@ const notifications = [ '

Here is a notice it should display everywhere in the app and in wp-admin!

', }, { - id: 'test-5', + id: 'test-6', locations: [ { context: Cypress.env( 'pluginId' ) + '-app-nav', @@ -76,18 +89,20 @@ const notifications = [ content: '

Here is an expired notice it should never display anywhere even though it has location `all`

', }, -]; + ]; -describe( 'Notifications', () => { + describe( 'Notifications', () => { const appClass = '.' + Cypress.env( 'appId' ); before( () => { cy.exec( 'npx wp-env run cli wp transient delete newfold_notifications', {failOnNonZeroExit: false} ); cy.visit( '/wp-admin/index.php' ); + cy.intercept( { method: 'GET', url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + }, notifications ).as( 'notifications' ); @@ -96,35 +111,109 @@ describe( 'Notifications', () => { '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home', { timeout: 30000 } ); - - cy.wait( '@notifications' ); + cy.wait( '@notifications' ) + cy.wait( 2000 ); } ); + + it( 'Is Accessible', () => { cy.injectAxe(); cy.wait( 1000 ); - cy.checkA11y( '.newfold-notifications-wrapper' ); + cy.checkA11y( '.ai-sitegen-modal__header' ); } ); + + + it('Test AI popup appears for the sixmonthold sites and Close button icon is clicked',() => { + cy.get('img[class="ai-sitegen-modal__content__right-section__heading__ai-icon"]') + .should('exist'); + cy.get( '.newfold-notifications-wrapper #notification-test-1' ) + cy.get('.ai-sitegen-modal').should('exist') + .scrollTo('bottom'); + + cy.get('.ai-sitegen-modal__footer').should('exist') + cy.get('.ai-sitegen-modal__footer__content').should('exist') + cy.get('.ai-sitegen-modal__footer__content__heading') + .should('be.visible') + .and('contain.text', 'Included FREE in your plan!'); + cy.get('.ai-sitegen-modal__footer__content__buttons').eq(0).should('exist') + cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible').click(); + cy.get('.ai-sitegen-modal').should('not.visible'); + }); + + it('Should redirect to AI onboarding when TRY NOW button is clicked', () => { + cy.intercept( + { + method: 'GET', + url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + + }, + notifications + ).as( 'notifications' ); + cy.reload(); + cy.wait( '@notifications' ); + cy.wait( 2000 ); + cy.get('.ai-sitegen-modal__footer__content__buttons__try-now').as('trynow') + .should('be.visible') + .and('contain', 'TRY NOW') + .scrollIntoView() + .click(); + cy.url().should('include','/index.php?page=nfd-onboarding#/wp-setup/step/fork'); + cy.get('.nfd-onboarding-sitegen-options__option--large').should('be.visible'); + }); + + it('Should close the modal when NO THANKS button is clicked', () => { + + cy.visit( '/wp-admin/index.php' ); + + cy.intercept( + { + method: 'GET', + url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + + }, + notifications + ).as( 'notifications' ); + + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home', + { timeout: 30000 } + ); + cy.wait( '@notifications' ); + cy.wait( 2000 ); + cy.get('button.ai-sitegen-modal__footer__content__buttons__no-thanks') + .should('be.visible') + .and('contain', 'NO, THANKS') + .scrollIntoView().click(); + cy.get('.ai-sitegen-modal').should('not.visible'); + }); + + it( 'Container Exists in plugin app', () => { - cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ); + cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ) + } ); + + + // notification renders in all app for `all` it( 'Test notification displays in plugin app with `all`', () => { - cy.get( '.newfold-notifications-wrapper #notification-test-4' ) + cy.get( '.newfold-notifications-wrapper #notification-test-5' ) .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-4' ); + .and( 'equal', 'test-5' ); cy.get( - '.newfold-notifications-wrapper #notification-test-4' + '.newfold-notifications-wrapper #notification-test-5' ).contains( 'it should display everywhere' ); } ); + // notification renders only on specified app page it( 'Test notification displays in plugin app for specific page (settings)', () => { - cy.get( '.newfold-notifications-wrapper #notification-test-1' ).should( + cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( 'not.exist' ); @@ -132,26 +221,26 @@ describe( 'Notifications', () => { cy.get( appClass + '-app-navitem-Settings' ).click(); cy.wait( 500 ); - cy.get( '.newfold-notifications-wrapper #notification-test-1' ) + cy.get( '.newfold-notifications-wrapper #notification-test-2' ) .scrollIntoView() .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-1' ); + .and( 'equal', 'test-2' ); cy.get( - '.newfold-notifications-wrapper #notification-test-1' + '.newfold-notifications-wrapper #notification-test-2' ).contains( 'display on plugin app settings page' ); } ); // notification renders on the side nav it( 'Test notification displays in app side nav', () => { - cy.get( '.newfold-nav-notifications-wrapper #notification-test-5' ) + cy.get( '.newfold-nav-notifications-wrapper #notification-test-6' ) .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-5' ); + .and( 'equal', 'test-6' ); cy.get( - '.newfold-nav-notifications-wrapper #notification-test-5' + '.newfold-nav-notifications-wrapper #notification-test-6' ).contains( 'display in the app side nav' ); } ); @@ -170,33 +259,33 @@ describe( 'Notifications', () => { url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, }, { - body: { id: 'test-2' }, + body: { id: 'test-3' }, } ).as( 'dismissNotificaiton' ); cy.visit( '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' ); - - cy.get( '.newfold-notifications-wrapper #notification-test-2' ) + cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible').click(); + cy.get( '.newfold-notifications-wrapper #notification-test-3' ) .scrollIntoView() .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-2' ); + .and( 'equal', 'test-3' ); - cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( + cy.get( '.newfold-notifications-wrapper #notification-test-3' ).should( 'be.visible' ); cy.get( - '.newfold-notifications-wrapper #notification-test-2' + '.newfold-notifications-wrapper #notification-test-3' ).contains( 'display on home and onboarding screens' ); cy.get( - '#notification-test-2 button.notice-dismiss[data-action="close"]' + '#notification-test-3 button.notice-dismiss[data-action="close"]' ).click(); cy.wait( '@dismissNotificaiton' ); - cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( + cy.get( '.newfold-notifications-wrapper #notification-test-3' ).should( 'not.exist' ); } ); From b3eec3afc8b03f1087776812928bbb444468e36f Mon Sep 17 00:00:00 2001 From: asr0393 Date: Thu, 17 Oct 2024 19:09:23 +0530 Subject: [PATCH 02/12] Code pushed after fixing the issue (removed Line no.269) --- tests/cypress/integration/notifications.cy.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 6df329f..0f95d4d 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -266,7 +266,6 @@ cy.visit( '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' ); - cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible').click(); cy.get( '.newfold-notifications-wrapper #notification-test-3' ) .scrollIntoView() .should( 'be.visible' ) From 7040713f6f0b7ef8e424fc34c01cd7733ccfc370 Mon Sep 17 00:00:00 2001 From: asr0393 Date: Thu, 24 Oct 2024 19:15:25 +0530 Subject: [PATCH 03/12] if the ai popup is seen added a if condition to close. --- tests/cypress/integration/notifications.cy.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 0f95d4d..bc95b79 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -90,10 +90,9 @@ '

Here is an expired notice it should never display anywhere even though it has location `all`

', }, ]; - + describe( 'Notifications', () => { const appClass = '.' + Cypress.env( 'appId' ); - before( () => { cy.exec( 'npx wp-env run cli wp transient delete newfold_notifications', {failOnNonZeroExit: false} ); cy.visit( '/wp-admin/index.php' ); @@ -140,6 +139,7 @@ cy.get('.ai-sitegen-modal__footer__content__buttons').eq(0).should('exist') cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible').click(); cy.get('.ai-sitegen-modal').should('not.visible'); + }); it('Should redirect to AI onboarding when TRY NOW button is clicked', () => { @@ -164,7 +164,6 @@ }); it('Should close the modal when NO THANKS button is clicked', () => { - cy.visit( '/wp-admin/index.php' ); cy.intercept( @@ -253,6 +252,12 @@ // dismiss events triggered it( 'Dismissing notification removes it from the page', () => { + cy.get('body').then(($body) => { + if ($body.find('.ai-sitegen-modal').length > 0 && $body.find('.ai-sitegen-modal').is(':visible')) { + // If modal exists and is visible, close it + cy.get('button.ai-sitegen-modal__header__close-button').click(); + } + }); cy.intercept( { method: 'POST', From c6820ffe4b54075101f77dc55a476cd47c534147 Mon Sep 17 00:00:00 2001 From: asr0393 Date: Fri, 25 Oct 2024 13:17:30 +0530 Subject: [PATCH 04/12] Added fix for Brand specific condition for ai popup testcases --- tests/cypress/integration/notifications.cy.js | 16 +++++++++++++++- .../integration/wp-module-support/pluginID.cy.js | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/cypress/integration/wp-module-support/pluginID.cy.js diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index bc95b79..5f52742 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -1,4 +1,7 @@ // + import { GetPluginId } from './wp-module-support/pluginID.cy'; + const pluginId = GetPluginId(); + const notifications = [ { id: 'test-1', @@ -125,6 +128,8 @@ it('Test AI popup appears for the sixmonthold sites and Close button icon is clicked',() => { + //const pluginId = GetPluginId(); + if ( pluginId == 'bluehost' ) { cy.get('img[class="ai-sitegen-modal__content__right-section__heading__ai-icon"]') .should('exist'); cy.get( '.newfold-notifications-wrapper #notification-test-1' ) @@ -139,10 +144,12 @@ cy.get('.ai-sitegen-modal__footer__content__buttons').eq(0).should('exist') cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible').click(); cy.get('.ai-sitegen-modal').should('not.visible'); - + } }); it('Should redirect to AI onboarding when TRY NOW button is clicked', () => { + //const pluginId = GetPluginId(); + if ( pluginId == 'bluehost' ) { cy.intercept( { method: 'GET', @@ -161,9 +168,12 @@ .click(); cy.url().should('include','/index.php?page=nfd-onboarding#/wp-setup/step/fork'); cy.get('.nfd-onboarding-sitegen-options__option--large').should('be.visible'); + } }); it('Should close the modal when NO THANKS button is clicked', () => { + //const pluginId = GetPluginId(); + if ( pluginId == 'bluehost' ) { cy.visit( '/wp-admin/index.php' ); cy.intercept( @@ -186,9 +196,11 @@ .and('contain', 'NO, THANKS') .scrollIntoView().click(); cy.get('.ai-sitegen-modal').should('not.visible'); + } }); + it( 'Container Exists in plugin app', () => { cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ) @@ -252,12 +264,14 @@ // dismiss events triggered it( 'Dismissing notification removes it from the page', () => { + if ( pluginId == 'bluehost' ) { cy.get('body').then(($body) => { if ($body.find('.ai-sitegen-modal').length > 0 && $body.find('.ai-sitegen-modal').is(':visible')) { // If modal exists and is visible, close it cy.get('button.ai-sitegen-modal__header__close-button').click(); } }); + } cy.intercept( { method: 'POST', diff --git a/tests/cypress/integration/wp-module-support/pluginID.cy.js b/tests/cypress/integration/wp-module-support/pluginID.cy.js new file mode 100644 index 0000000..04dceca --- /dev/null +++ b/tests/cypress/integration/wp-module-support/pluginID.cy.js @@ -0,0 +1,8 @@ +// +export const GetPluginId = () => { + return Cypress.env('pluginId'); +} + +export const getAppId = () => { + return Cypress.env('appId'); +} \ No newline at end of file From d3557e7328e612732264bfdd40938fc4b550c7e0 Mon Sep 17 00:00:00 2001 From: asr0393 Date: Fri, 25 Oct 2024 15:41:41 +0530 Subject: [PATCH 05/12] Removed brand specific condition for dismiss notification testcase --- tests/cypress/integration/notifications.cy.js | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 5f52742..e6aff09 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -124,9 +124,9 @@ cy.wait( 1000 ); cy.checkA11y( '.ai-sitegen-modal__header' ); } ); - + it('Test AI popup appears for the sixmonthold sites and Close button icon is clicked',() => { //const pluginId = GetPluginId(); if ( pluginId == 'bluehost' ) { @@ -148,8 +148,7 @@ }); it('Should redirect to AI onboarding when TRY NOW button is clicked', () => { - //const pluginId = GetPluginId(); - if ( pluginId == 'bluehost' ) { + if ( pluginId == 'bluehost' ) { cy.intercept( { method: 'GET', @@ -172,10 +171,8 @@ }); it('Should close the modal when NO THANKS button is clicked', () => { - //const pluginId = GetPluginId(); - if ( pluginId == 'bluehost' ) { + if ( pluginId == 'bluehost' ) { cy.visit( '/wp-admin/index.php' ); - cy.intercept( { method: 'GET', @@ -200,16 +197,12 @@ }); - - it( 'Container Exists in plugin app', () => { + it( 'Container Exists in plugin app', () => { cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ) } ); - - - - // notification renders in all app for `all` + // notification renders in all app for `all` it( 'Test notification displays in plugin app with `all`', () => { cy.get( '.newfold-notifications-wrapper #notification-test-5' ) .should( 'be.visible' ) @@ -264,14 +257,12 @@ // dismiss events triggered it( 'Dismissing notification removes it from the page', () => { - if ( pluginId == 'bluehost' ) { cy.get('body').then(($body) => { if ($body.find('.ai-sitegen-modal').length > 0 && $body.find('.ai-sitegen-modal').is(':visible')) { - // If modal exists and is visible, close it cy.get('button.ai-sitegen-modal__header__close-button').click(); } }); - } + cy.intercept( { method: 'POST', From 5fcca5014fdc9cbf01a44621fabbc5882a8db8db Mon Sep 17 00:00:00 2001 From: asr0393 Date: Fri, 25 Oct 2024 20:22:45 +0530 Subject: [PATCH 06/12] Added fix to close the unexpected aipopup on the specific page (settings) test --- tests/cypress/integration/notifications.cy.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index e6aff09..e24cb05 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -217,6 +217,11 @@ // notification renders only on specified app page it( 'Test notification displays in plugin app for specific page (settings)', () => { + cy.get('body').then(($body) => { + if ($body.find('.ai-sitegen-modal').length > 0 && $body.find('.ai-sitegen-modal').is(':visible')) { + cy.get('button.ai-sitegen-modal__header__close-button').click(); + } + }); cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( 'not.exist' ); From e0a2128d5d5e1fe79e505ac97b341f3a0c25eac6 Mon Sep 17 00:00:00 2001 From: asr0393 Date: Tue, 29 Oct 2024 10:03:54 +0530 Subject: [PATCH 07/12] Added a fix -alt texts four 4 images where a11y error is noticed at web.com --- tests/cypress/integration/notifications.cy.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index e24cb05..eb2234b 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -14,7 +14,7 @@ expiration: 2748820256, content: - '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • Preview different layouts and designs in minutes
  • Customize the colors and fonts
  • Site headlines, text, and imagery generated automatically
  • Multiple site designs for you to choose from
' + '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • first tick Preview different layouts and designs in minutes
  • second tick Customize the colors and fonts
  • third tick Site headlines, text, and imagery generated automatically
  • fourth tick Multiple site designs for you to choose from
' }, { id: 'test-2', @@ -117,25 +117,19 @@ cy.wait( 2000 ); } ); - - - it( 'Is Accessible', () => { + it( 'Is Accessible', () => { cy.injectAxe(); cy.wait( 1000 ); - cy.checkA11y( '.ai-sitegen-modal__header' ); + cy.checkA11y('.newfold-notifications-wrapper') } ); - - it('Test AI popup appears for the sixmonthold sites and Close button icon is clicked',() => { - //const pluginId = GetPluginId(); if ( pluginId == 'bluehost' ) { + cy.get( '.newfold-notifications-wrapper #notification-test-1' ) cy.get('img[class="ai-sitegen-modal__content__right-section__heading__ai-icon"]') - .should('exist'); - cy.get( '.newfold-notifications-wrapper #notification-test-1' ) + .should('exist'); cy.get('.ai-sitegen-modal').should('exist') .scrollTo('bottom'); - cy.get('.ai-sitegen-modal__footer').should('exist') cy.get('.ai-sitegen-modal__footer__content').should('exist') cy.get('.ai-sitegen-modal__footer__content__heading') @@ -199,8 +193,7 @@ it( 'Container Exists in plugin app', () => { cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ) - - } ); + } ); // notification renders in all app for `all` it( 'Test notification displays in plugin app with `all`', () => { From f6fa12d7dc7460cb8f28ba186625996f45130e9f Mon Sep 17 00:00:00 2001 From: asr0393 Date: Wed, 30 Oct 2024 09:45:41 +0530 Subject: [PATCH 08/12] Added ScrollIntoView for 3 undetected element on AI popup for BH --- tests/cypress/integration/notifications.cy.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index eb2234b..399642e 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -136,7 +136,8 @@ .should('be.visible') .and('contain.text', 'Included FREE in your plan!'); cy.get('.ai-sitegen-modal__footer__content__buttons').eq(0).should('exist') - cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible').click(); + cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible') + .scrollIntoView().click(); cy.get('.ai-sitegen-modal').should('not.visible'); } }); @@ -154,11 +155,10 @@ cy.reload(); cy.wait( '@notifications' ); cy.wait( 2000 ); - cy.get('.ai-sitegen-modal__footer__content__buttons__try-now').as('trynow') + cy.get('.ai-sitegen-modal__footer__content__buttons__try-now') .should('be.visible') .and('contain', 'TRY NOW') - .scrollIntoView() - .click(); + .scrollIntoView().click(); cy.url().should('include','/index.php?page=nfd-onboarding#/wp-setup/step/fork'); cy.get('.nfd-onboarding-sitegen-options__option--large').should('be.visible'); } From 13f83183a0be700be217d307ae64a67dbf98ab61 Mon Sep 17 00:00:00 2001 From: asr0393 Date: Wed, 30 Oct 2024 10:29:31 +0530 Subject: [PATCH 09/12] Rearranged scrollIntoView ordertobe be before visibility --- tests/cypress/integration/notifications.cy.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 399642e..cf45e4a 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -136,8 +136,7 @@ .should('be.visible') .and('contain.text', 'Included FREE in your plan!'); cy.get('.ai-sitegen-modal__footer__content__buttons').eq(0).should('exist') - cy.get('button.ai-sitegen-modal__header__close-button').should('be.visible') - .scrollIntoView().click(); + cy.get('button.ai-sitegen-modal__header__close-button').scrollIntoView().should('be.visible').click(); cy.get('.ai-sitegen-modal').should('not.visible'); } }); @@ -155,10 +154,10 @@ cy.reload(); cy.wait( '@notifications' ); cy.wait( 2000 ); - cy.get('.ai-sitegen-modal__footer__content__buttons__try-now') + cy.get('button.ai-sitegen-modal__footer__content__buttons__try-now').scrollIntoView() .should('be.visible') .and('contain', 'TRY NOW') - .scrollIntoView().click(); + .click(); cy.url().should('include','/index.php?page=nfd-onboarding#/wp-setup/step/fork'); cy.get('.nfd-onboarding-sitegen-options__option--large').should('be.visible'); } @@ -182,10 +181,10 @@ ); cy.wait( '@notifications' ); cy.wait( 2000 ); - cy.get('button.ai-sitegen-modal__footer__content__buttons__no-thanks') + cy.get('button.ai-sitegen-modal__footer__content__buttons__no-thanks').scrollIntoView() .should('be.visible') .and('contain', 'NO, THANKS') - .scrollIntoView().click(); + .click(); cy.get('.ai-sitegen-modal').should('not.visible'); } }); From 85a8c10a8d7b9ef3b0d06e64ebdb018c87aa790e Mon Sep 17 00:00:00 2001 From: asr0393 Date: Wed, 30 Oct 2024 12:41:42 +0530 Subject: [PATCH 10/12] in content-test1, removed asset() from src as there is complete url of the image --- tests/cypress/integration/notifications.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index cf45e4a..c4d5bea 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -14,7 +14,7 @@ expiration: 2748820256, content: - '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • first tick Preview different layouts and designs in minutes
  • second tick Customize the colors and fonts
  • third tick Site headlines, text, and imagery generated automatically
  • fourth tick Multiple site designs for you to choose from
' + '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • first tick Preview different layouts and designs in minutes
  • second tick Customize the colors and fonts
  • third tick Site headlines, text, and imagery generated automatically
  • fourth tick Multiple site designs for you to choose from
' }, { id: 'test-2', From 3dcfb5c51e3b9ed3aa775ac9793480eef10afe97 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 31 Oct 2024 10:19:16 -0400 Subject: [PATCH 11/12] only add ai notification on bluehost and only run ai related tests on bluehost update notice id to reflect content rather than number for clarity lint auto-fixes in test file consistently use cypress env value for pluginId, no external support file necessary --- tests/cypress/integration/notifications.cy.js | 298 ++++++++++-------- .../wp-module-support/pluginID.cy.js | 8 - 2 files changed, 162 insertions(+), 144 deletions(-) delete mode 100644 tests/cypress/integration/wp-module-support/pluginID.cy.js diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index c4d5bea..4191a94 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -1,23 +1,19 @@ - // - import { GetPluginId } from './wp-module-support/pluginID.cy'; - const pluginId = GetPluginId(); - - const notifications = [ +// +const aiNotification = { + id: 'test-ai', + locations: [ + { + context: Cypress.env( 'pluginId' ) + '-plugin', + pages: [ '#/home' ], + }, + ], + expiration: 2748820256, + content: + '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • first tick Preview different layouts and designs in minutes
  • second tick Customize the colors and fonts
  • third tick Site headlines, text, and imagery generated automatically
  • fourth tick Multiple site designs for you to choose from
', +}; +const notifications = [ { - id: 'test-1', - locations: [ - { - context: Cypress.env( 'pluginId' ) + '-plugin', - pages: [ '#/home' ], - }, - ], - expiration: 2748820256, - - content: - '

Building your WordPress site just got easier.

Easily design and launch a stylish WordPress website with our AI WonderSuite tools.

Watch again

Description of SVG Website Creator for WordPress

Tell our AI engine what kind of site you want to create and let it handle the content and design for you:

Using the AI Site Generator is easy!

  • first tick Preview different layouts and designs in minutes
  • second tick Customize the colors and fonts
  • third tick Site headlines, text, and imagery generated automatically
  • fourth tick Multiple site designs for you to choose from
' - }, - { - id: 'test-2', + id: 'test-settings', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', @@ -29,16 +25,16 @@ '

Notice should only display on plugin app settings page

', }, { - id: 'test-3', + id: 'test-home', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', - pages: [ '#/home/onboarding', '#/home' ], + pages: [ '#/home' ], }, ], expiration: 2749860279, content: - '

Here is a plugin notice it should display on home and onboarding screens only!

', + '

Here is a plugin notice it should display on home screen only!

', }, { id: 'test-4', @@ -53,7 +49,7 @@ '

Here is a plugin notice it should display on marketplace themes screen only!

', }, { - id: 'test-5', + id: 'test-everywhere', locations: [ { context: Cypress.env( 'pluginId' ) + '-plugin', @@ -69,7 +65,7 @@ '

Here is a notice it should display everywhere in the app and in wp-admin!

', }, { - id: 'test-6', + id: 'test-side-nav', locations: [ { context: Cypress.env( 'pluginId' ) + '-app-nav', @@ -92,156 +88,181 @@ content: '

Here is an expired notice it should never display anywhere even though it has location `all`

', }, - ]; - - describe( 'Notifications', () => { +]; +// add ai notificaiton for bluehost +if ( Cypress.env( 'pluginId' ) === 'bluehost' ) { + notifications.push( aiNotification ); +} + +describe( 'Notifications', () => { const appClass = '.' + Cypress.env( 'appId' ); before( () => { - cy.exec( 'npx wp-env run cli wp transient delete newfold_notifications', {failOnNonZeroExit: false} ); + cy.exec( + 'npx wp-env run cli wp transient delete newfold_notifications', + { failOnNonZeroExit: false } + ); cy.visit( '/wp-admin/index.php' ); - + cy.intercept( { method: 'GET', url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, - }, notifications ).as( 'notifications' ); cy.visit( - '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home', - { timeout: 30000 } + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' ); - cy.wait( '@notifications' ) cy.wait( 2000 ); + cy.wait( '@notifications' ); } ); - it( 'Is Accessible', () => { + it( 'Is Accessible', () => { cy.injectAxe(); - cy.wait( 1000 ); - cy.checkA11y('.newfold-notifications-wrapper') + cy.wait( 3000 ); + cy.checkA11y( '.newfold-notifications-wrapper' ); } ); - - it('Test AI popup appears for the sixmonthold sites and Close button icon is clicked',() => { - if ( pluginId == 'bluehost' ) { - cy.get( '.newfold-notifications-wrapper #notification-test-1' ) - cy.get('img[class="ai-sitegen-modal__content__right-section__heading__ai-icon"]') - .should('exist'); - cy.get('.ai-sitegen-modal').should('exist') - .scrollTo('bottom'); - cy.get('.ai-sitegen-modal__footer').should('exist') - cy.get('.ai-sitegen-modal__footer__content').should('exist') - cy.get('.ai-sitegen-modal__footer__content__heading') - .should('be.visible') - .and('contain.text', 'Included FREE in your plan!'); - cy.get('.ai-sitegen-modal__footer__content__buttons').eq(0).should('exist') - cy.get('button.ai-sitegen-modal__header__close-button').scrollIntoView().should('be.visible').click(); - cy.get('.ai-sitegen-modal').should('not.visible'); - } - }); - it('Should redirect to AI onboarding when TRY NOW button is clicked', () => { - if ( pluginId == 'bluehost' ) { - cy.intercept( - { - method: 'GET', - url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, - - }, - notifications - ).as( 'notifications' ); - cy.reload(); - cy.wait( '@notifications' ); - cy.wait( 2000 ); - cy.get('button.ai-sitegen-modal__footer__content__buttons__try-now').scrollIntoView() - .should('be.visible') - .and('contain', 'TRY NOW') - .click(); - cy.url().should('include','/index.php?page=nfd-onboarding#/wp-setup/step/fork'); - cy.get('.nfd-onboarding-sitegen-options__option--large').should('be.visible'); - } - }); + // AI notification for bluehost only + if ( Cypress.env( 'pluginId' ) === 'bluehost' ) { + it( 'Test AI popup appears for the six month old sites and Close button icon is clicked', () => { + cy.get( '.newfold-notifications-wrapper #notification-test-ai' ); + cy.get( + 'img[class="ai-sitegen-modal__content__right-section__heading__ai-icon"]' + ).should( 'exist' ); + cy.get( '.ai-sitegen-modal' ) + .should( 'exist' ) + .scrollTo( 'bottom' ); + cy.get( '.ai-sitegen-modal__footer' ).should( 'exist' ); + cy.get( '.ai-sitegen-modal__footer__content' ).should( 'exist' ); + cy.get( '.ai-sitegen-modal__footer__content__heading' ) + .should( 'be.visible' ) + .and( 'contain.text', 'Included FREE in your plan!' ); + cy.get( '.ai-sitegen-modal__footer__content__buttons' ) + .eq( 0 ) + .should( 'exist' ); + cy.get( 'button.ai-sitegen-modal__header__close-button' ) + .scrollIntoView() + .should( 'be.visible' ) + .click(); + cy.get( '.ai-sitegen-modal' ).should( 'not.visible' ); + } ); - it('Should close the modal when NO THANKS button is clicked', () => { - if ( pluginId == 'bluehost' ) { - cy.visit( '/wp-admin/index.php' ); - cy.intercept( - { - method: 'GET', - url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, - - }, - notifications - ).as( 'notifications' ); + it( 'Should redirect to AI onboarding when TRY NOW button is clicked', () => { + cy.intercept( + { + method: 'GET', + url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + }, + notifications + ).as( 'notifications' ); + cy.reload(); + cy.wait( '@notifications' ); + cy.wait( 2000 ); + cy.get( + 'button.ai-sitegen-modal__footer__content__buttons__try-now' + ) + .scrollIntoView() + .should( 'be.visible' ) + .and( 'contain', 'TRY NOW' ) + .click(); + cy.url().should( + 'include', + '/index.php?page=nfd-onboarding#/wp-setup/step/fork' + ); + cy.get( '.nfd-onboarding-sitegen-options__option--large' ).should( + 'be.visible' + ); + } ); - cy.visit( - '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home', - { timeout: 30000 } - ); - cy.wait( '@notifications' ); - cy.wait( 2000 ); - cy.get('button.ai-sitegen-modal__footer__content__buttons__no-thanks').scrollIntoView() - .should('be.visible') - .and('contain', 'NO, THANKS') - .click(); - cy.get('.ai-sitegen-modal').should('not.visible'); - } - }); + it( 'Should close the modal when NO THANKS button is clicked', () => { + cy.visit( '/wp-admin/index.php' ); + cy.intercept( + { + method: 'GET', + url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + }, + notifications + ).as( 'notifications' ); + cy.visit( + '/wp-admin/admin.php?page=' + + Cypress.env( 'pluginId' ) + + '#/home', + { timeout: 30000 } + ); + cy.wait( '@notifications' ); + cy.wait( 2000 ); + cy.get( + 'button.ai-sitegen-modal__footer__content__buttons__no-thanks' + ) + .scrollIntoView() + .should( 'be.visible' ) + .and( 'contain', 'NO, THANKS' ) + .click(); + cy.get( '.ai-sitegen-modal' ).should( 'not.visible' ); + } ); + } - it( 'Container Exists in plugin app', () => { - cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ) - } ); + it( 'Container Exists in plugin app', () => { + cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ); + } ); - // notification renders in all app for `all` + // notification renders in all app for `all` it( 'Test notification displays in plugin app with `all`', () => { - cy.get( '.newfold-notifications-wrapper #notification-test-5' ) + cy.get( '.newfold-notifications-wrapper #notification-test-everywhere' ) .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-5' ); + .and( 'equal', 'test-everywhere' ); cy.get( - '.newfold-notifications-wrapper #notification-test-5' + '.newfold-notifications-wrapper #notification-test-everywhere' ).contains( 'it should display everywhere' ); } ); - // notification renders only on specified app page it( 'Test notification displays in plugin app for specific page (settings)', () => { - cy.get('body').then(($body) => { - if ($body.find('.ai-sitegen-modal').length > 0 && $body.find('.ai-sitegen-modal').is(':visible')) { - cy.get('button.ai-sitegen-modal__header__close-button').click(); + cy.get( 'body' ).then( ( $body ) => { + if ( + $body.find( '.ai-sitegen-modal' ).length > 0 && + $body.find( '.ai-sitegen-modal' ).is( ':visible' ) + ) { + cy.get( + 'button.ai-sitegen-modal__header__close-button' + ).click(); } - }); - cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( - 'not.exist' - ); + } ); + cy.get( + '.newfold-notifications-wrapper #notification-test-settings' + ).should( 'not.exist' ); // cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/settings'); cy.get( appClass + '-app-navitem-Settings' ).click(); cy.wait( 500 ); - cy.get( '.newfold-notifications-wrapper #notification-test-2' ) + cy.get( '.newfold-notifications-wrapper #notification-test-settings' ) .scrollIntoView() .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-2' ); + .and( 'equal', 'test-settings' ); cy.get( - '.newfold-notifications-wrapper #notification-test-2' + '.newfold-notifications-wrapper #notification-test-settings' ).contains( 'display on plugin app settings page' ); } ); // notification renders on the side nav it( 'Test notification displays in app side nav', () => { - cy.get( '.newfold-nav-notifications-wrapper #notification-test-6' ) + cy.get( + '.newfold-nav-notifications-wrapper #notification-test-side-nav' + ) .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-6' ); + .and( 'equal', 'test-side-nav' ); cy.get( - '.newfold-nav-notifications-wrapper #notification-test-6' + '.newfold-nav-notifications-wrapper #notification-test-side-nav' ).contains( 'display in the app side nav' ); } ); @@ -254,46 +275,51 @@ // dismiss events triggered it( 'Dismissing notification removes it from the page', () => { - cy.get('body').then(($body) => { - if ($body.find('.ai-sitegen-modal').length > 0 && $body.find('.ai-sitegen-modal').is(':visible')) { - cy.get('button.ai-sitegen-modal__header__close-button').click(); + cy.get( 'body' ).then( ( $body ) => { + if ( + $body.find( '.ai-sitegen-modal' ).length > 0 && + $body.find( '.ai-sitegen-modal' ).is( ':visible' ) + ) { + cy.get( + 'button.ai-sitegen-modal__header__close-button' + ).click(); } - }); - + } ); + cy.intercept( { method: 'POST', url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, }, { - body: { id: 'test-3' }, + body: { id: 'test-home' }, } ).as( 'dismissNotificaiton' ); cy.visit( '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' ); - cy.get( '.newfold-notifications-wrapper #notification-test-3' ) + cy.get( '.newfold-notifications-wrapper #notification-test-home' ) .scrollIntoView() .should( 'be.visible' ) .should( 'have.attr', 'data-id' ) - .and( 'equal', 'test-3' ); + .and( 'equal', 'test-home' ); - cy.get( '.newfold-notifications-wrapper #notification-test-3' ).should( - 'be.visible' - ); cy.get( - '.newfold-notifications-wrapper #notification-test-3' + '.newfold-notifications-wrapper #notification-test-home' + ).should( 'be.visible' ); + cy.get( + '.newfold-notifications-wrapper #notification-test-home' ).contains( 'display on home and onboarding screens' ); cy.get( - '#notification-test-3 button.notice-dismiss[data-action="close"]' + '#notification-test-home button.notice-dismiss[data-action="close"]' ).click(); cy.wait( '@dismissNotificaiton' ); - cy.get( '.newfold-notifications-wrapper #notification-test-3' ).should( - 'not.exist' - ); + cy.get( + '.newfold-notifications-wrapper #notification-test-home' + ).should( 'not.exist' ); } ); // these can be updated later on, but currently the wp-admin tests are not loaded via the api diff --git a/tests/cypress/integration/wp-module-support/pluginID.cy.js b/tests/cypress/integration/wp-module-support/pluginID.cy.js deleted file mode 100644 index 04dceca..0000000 --- a/tests/cypress/integration/wp-module-support/pluginID.cy.js +++ /dev/null @@ -1,8 +0,0 @@ -// -export const GetPluginId = () => { - return Cypress.env('pluginId'); -} - -export const getAppId = () => { - return Cypress.env('appId'); -} \ No newline at end of file From b076afb2960fa6d96803ecf13a768087e2b4272c Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 31 Oct 2024 11:12:32 -0400 Subject: [PATCH 12/12] update home notice expected text to match updated text this was changed in the previous commit because the onboarding screen is no longer in the app and it was updated to remove the page and content to reflect that. --- tests/cypress/integration/notifications.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 4191a94..4493197 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -310,7 +310,7 @@ describe( 'Notifications', () => { ).should( 'be.visible' ); cy.get( '.newfold-notifications-wrapper #notification-test-home' - ).contains( 'display on home and onboarding screens' ); + ).contains( 'display on home screen only' ); cy.get( '#notification-test-home button.notice-dismiss[data-action="close"]'