From e43850fad8d2bf11292b8913ff478d6a8796c0ff Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Fri, 15 Nov 2024 14:18:50 -0500 Subject: [PATCH] update tests --- .../integration/modal-notification.cy.js | 10 +-- tests/cypress/integration/notifications.cy.js | 63 +++++++++++++++---- 2 files changed, 57 insertions(+), 16 deletions(-) diff --git a/tests/cypress/integration/modal-notification.cy.js b/tests/cypress/integration/modal-notification.cy.js index 88fb247..b4f132d 100644 --- a/tests/cypress/integration/modal-notification.cy.js +++ b/tests/cypress/integration/modal-notification.cy.js @@ -20,6 +20,7 @@ describe( 'AI Notification', { testIsolation: true }, () => { beforeEach( () => { wpLogin(); wpCli( 'transient delete newfold_notifications' ); + cy.visit( '/wp-admin/index.php' ); } ); // AI notification for bluehost only @@ -32,10 +33,9 @@ describe( 'AI Notification', { testIsolation: true }, () => { }, modalNotification ).as( 'notifications' ); + cy.visit( - '/wp-admin/admin.php?page=' + - Cypress.env( 'pluginId' ) + - '#/home' + `/wp-admin/admin.php?page=${ Cypress.env( 'pluginId' ) }#/home` ); cy.wait( '@notifications' ); cy.get( '.newfold-notifications-wrapper #notification-test-ai' ); @@ -74,7 +74,7 @@ describe( 'AI Notification', { testIsolation: true }, () => { '#/home' ); cy.wait( '@notifications' ); - cy.wait( 2000 ); + cy.wait( 500 ); cy.get( 'button.ai-sitegen-modal__footer__content__buttons__try-now' ) @@ -99,7 +99,7 @@ describe( 'AI Notification', { testIsolation: true }, () => { '#/home' ); cy.wait( '@notifications' ); - cy.wait( 2000 ); + cy.wait( 500 ); cy.get( 'button.ai-sitegen-modal__footer__content__buttons__no-thanks' ) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index c637701..cb12b19 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -84,20 +84,11 @@ describe( 'Notifications', { testIsolation: true }, () => { beforeEach( () => { wpLogin(); wpCli( 'transient delete newfold_notifications' ); - 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' - ); + cy.visit( '/wp-admin/index.php' ); } ); it( 'Container Exists in plugin app and is accessible', () => { - cy.wait( '@notifications' ); + cy.visit( '/wp-admin/index.php' ); cy.injectAxe(); cy.wait( 1000 ); cy.get( '.newfold-notifications-wrapper' ).should( 'have.length', 1 ); @@ -106,6 +97,16 @@ describe( 'Notifications', { testIsolation: true }, () => { // notification renders in all app for `all` it( 'Test notification displays in plugin app with `all`', () => { + 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' + ); cy.wait( '@notifications' ); cy.get( '.newfold-notifications-wrapper #notification-test-everywhere' ) .should( 'be.visible' ) @@ -119,6 +120,16 @@ describe( 'Notifications', { testIsolation: true }, () => { // notification renders only on specified app page it( 'Test notification displays in plugin app for specific page (settings)', () => { + 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' + ); cy.wait( '@notifications' ); cy.get( 'body' ).then( ( $body ) => { if ( @@ -152,6 +163,16 @@ describe( 'Notifications', { testIsolation: true }, () => { // notification renders on the side nav it( 'Test notification displays in app side nav', () => { + 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' + ); cy.wait( '@notifications' ); cy.get( '.newfold-nav-notifications-wrapper #notification-test-side-nav' @@ -167,6 +188,16 @@ describe( 'Notifications', { testIsolation: true }, () => { // expired notification should not show it( 'Test expired notification does not display in plugin app', () => { + 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' + ); cy.wait( '@notifications' ); cy.get( '.newfold-notifications-wrapper #notification-test-expired' @@ -175,6 +206,16 @@ describe( 'Notifications', { testIsolation: true }, () => { // dismiss events triggered it( 'Dismissing notification removes it from the page', () => { + 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' + ); cy.wait( '@notifications' ); cy.get( 'body' ).then( ( $body ) => { if (