Skip to content

Commit

Permalink
Merge pull request #36 from newfold-labs/update/tests
Browse files Browse the repository at this point in the history
update tests
  • Loading branch information
circlecube authored Nov 18, 2024
2 parents b0f418d + e43850f commit 14a89f3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 16 deletions.
10 changes: 5 additions & 5 deletions tests/cypress/integration/modal-notification.cy.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 52 additions & 11 deletions tests/cypress/integration/notifications.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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' )
Expand All @@ -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 (
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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 (
Expand Down

0 comments on commit 14a89f3

Please sign in to comment.