From be24e3c7a8f0f05a1cf4809d28d8d781efdc501d Mon Sep 17 00:00:00 2001 From: Brad Parbs Date: Mon, 4 Dec 2023 18:01:57 -0600 Subject: [PATCH 1/7] Update URL for Satis Updates the Satis url from `newfold.github.io` to the correct `newfold-labs.github.io`. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 03aaa33..8916627 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ A module for managing Newfold in-site notifications. ### 1. Add the Newfold Satis to your `composer.json`. ```bash - composer config repositories.newfold composer https://newfold.github.io/satis + composer config repositories.newfold composer https://newfold-labs.github.io/satis ``` ### 2. Require the `newfold-labs/wp-module-notifications` package. From dc1fb2fdbc18206d65c7943f4a0e426c18881542 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 13 Dec 2023 14:48:28 -0500 Subject: [PATCH 2/7] add brand plugin test workflow --- .github/workflows/brand-plugin-test.yml | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/brand-plugin-test.yml diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml new file mode 100644 index 0000000..7d9eed1 --- /dev/null +++ b/.github/workflows/brand-plugin-test.yml @@ -0,0 +1,75 @@ +name: Build and Test Module Updates in Brand Plugins +on: + pull_request: + types: [ opened, reopened, ready_for_review ] + branches: + - main + workflow_dispatch: + workflow_call: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + setup: + name: Setup + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.extract_branch.outputs.branch }} + steps: + + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + bluehost: + name: Bluehost Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'bluehost/bluehost-wordpress-plugin' + secrets: inherit + + hostgator: + name: HostGator Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-hostgator' + secrets: inherit + + web: + name: Web.com Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-web' + secrets: inherit + + crazydomains: + name: Crazy Domains Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-crazy-domains' + secrets: inherit + + mojo: + name: Mojo Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + module-repo: ${{ github.repository }} + module-branch: ${{ needs.setup.outputs.branch }} + plugin-repo: 'newfold-labs/wp-plugin-mojo' + secrets: inherit From 36ecc459f8cda2d3f3d487600b02a55f62f905c9 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 13 Dec 2023 15:14:14 -0500 Subject: [PATCH 3/7] add nvmrc file --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..6f7f377 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16 From b206b91383fed9802e44eb8105b224b3b43a1327 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 13 Dec 2023 15:17:40 -0500 Subject: [PATCH 4/7] run with synchronize --- .github/workflows/brand-plugin-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/brand-plugin-test.yml b/.github/workflows/brand-plugin-test.yml index 7d9eed1..f31d801 100644 --- a/.github/workflows/brand-plugin-test.yml +++ b/.github/workflows/brand-plugin-test.yml @@ -1,11 +1,10 @@ name: Build and Test Module Updates in Brand Plugins on: pull_request: - types: [ opened, reopened, ready_for_review ] + types: [ opened, reopened, ready_for_review, synchronize ] branches: - main workflow_dispatch: - workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} From bf265379147da299324d9d27be11cbd0c715bbda Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Wed, 13 Dec 2023 15:22:47 -0500 Subject: [PATCH 5/7] perform easy/auto lint fixes in test file --- tests/cypress/integration/notifications.cy.js | 327 +++++++++--------- 1 file changed, 170 insertions(+), 157 deletions(-) diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index 82eaa3c..60fd65f 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -1,172 +1,185 @@ // const notifications = [ - { - "id": "test-1", - "locations": [ - { - "context": Cypress.env('pluginId') + "-plugin", - "pages": "#/settings" - } - ], - "expiration": 2748863456503, - "content": "

Notice should only display on plugin app settings page<\/p><\/div>" - }, - { - "id": "test-2", - "locations": [ - { - "context": Cypress.env('pluginId') + "-plugin", - "pages": [ - "#/home/onboarding", - "#/home" - ] - } - ], - "expiration": 2749860279240, - "content": "

Here is a plugin notice it should display on home and onboarding screens only! <\/p><\/div>" - }, - { - "id": "test-3", - "locations": [ - { - "context": Cypress.env('pluginId') + "-plugin", - "pages": [ - "#/marketplace" - ] - } - ], - "expiration": 2749860279240, - "content": "

Here is a plugin notice it should display on marketplace themes screen only! <\/p><\/div>" - }, - { - "id": "test-4", - "locations": [ - { - "context": Cypress.env('pluginId') + "-plugin", - "pages": "all" - }, - { - "context": "wp-admin-notice", - "pages": "all" - } - ], - "expiration": 2749860279240, - "content": "

Here is a notice it should display everywhere in the app and in wp-admin! <\/p><\/div>" - }, - { - "id": "test-expired", - "locations": [ - { - "context": Cypress.env('pluginId') + "-plugin", - "pages": "all" - } - ], - "expiration": 1649860279240, - "content": "

Here is an expired notice it should never display anywhere even though it has location `all` <\/p><\/div>" - } + { + id: 'test-1', + locations: [ + { + context: Cypress.env( 'pluginId' ) + '-plugin', + pages: '#/settings', + }, + ], + expiration: 2748863456503, + content: + '

Notice should only display on plugin app settings page

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

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

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

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

', + }, + { + id: 'test-4', + locations: [ + { + context: Cypress.env( 'pluginId' ) + '-plugin', + pages: 'all', + }, + { + context: 'wp-admin-notice', + pages: 'all', + }, + ], + expiration: 2749860279240, + content: + '

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

', + }, + { + id: 'test-expired', + locations: [ + { + context: Cypress.env( 'pluginId' ) + '-plugin', + pages: 'all', + }, + ], + expiration: 1649860279240, + content: + '

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

', + }, ]; -describe('Notifications', () => { - let appClass = '.' + Cypress.env('appId'); - - before(() => { - - cy.intercept({ - method: 'GET', - url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/ - }, notifications ); - - cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/home', {timeout: 30000}); - - }); - - it('Is Accessible', () => { +describe( 'Notifications', () => { + const appClass = '.' + Cypress.env( 'appId' ); + + before( () => { + cy.intercept( + { + method: 'GET', + url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + }, + notifications + ); + + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home', + { timeout: 30000 } + ); + } ); + + it( 'Is Accessible', () => { cy.injectAxe(); - cy.wait(1000); - cy.checkA11y('.newfold-notifications-wrapper'); - }); - - 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`', () => { - cy.get('.newfold-notifications-wrapper #notification-test-4') - .should('be.visible') - .should('have.attr', 'data-id') - .and('equal', 'test-4'); - - cy.get('.newfold-notifications-wrapper #notification-test-4') - .contains('it should display everywhere'); - }); + cy.wait( 1000 ); + cy.checkA11y( '.newfold-notifications-wrapper' ); + } ); + + 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`', () => { + cy.get( '.newfold-notifications-wrapper #notification-test-4' ) + .should( 'be.visible' ) + .should( 'have.attr', 'data-id' ) + .and( 'equal', 'test-4' ); + + cy.get( + '.newfold-notifications-wrapper #notification-test-4' + ).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('not.exist'); + it( 'Test notification displays in plugin app for specific page (settings)', () => { + cy.get( '.newfold-notifications-wrapper #notification-test-1' ).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( appClass + '-app-navitem-Settings' ).click(); + cy.wait( 500 ); - cy.get('.newfold-notifications-wrapper #notification-test-1') + cy.get( '.newfold-notifications-wrapper #notification-test-1' ) .scrollIntoView() - .should('be.visible') - .should('have.attr', 'data-id') - .and('equal', 'test-1'); - - cy.get('.newfold-notifications-wrapper #notification-test-1') - .contains('display on plugin app settings page'); - }); - - // expired notification should not show - it('Test expired notification does not display in plugin app', () => { - cy.get('.newfold-notifications-wrapper #notification-test-expired') - .should('not.exist'); - }); - - // dismiss events triggered - it('Dismissing notification removes it from the page', () => { - - cy.intercept({ - method: 'POST', - url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, - }, { - body: {"id":"test-2"} - } ).as('dismissNotificaiton'); - - cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/home'); - - cy.get('.newfold-notifications-wrapper #notification-test-2') + .should( 'be.visible' ) + .should( 'have.attr', 'data-id' ) + .and( 'equal', 'test-1' ); + + cy.get( + '.newfold-notifications-wrapper #notification-test-1' + ).contains( 'display on plugin app settings page' ); + } ); + + // expired notification should not show + it( 'Test expired notification does not display in plugin app', () => { + cy.get( + '.newfold-notifications-wrapper #notification-test-expired' + ).should( 'not.exist' ); + } ); + + // dismiss events triggered + it( 'Dismissing notification removes it from the page', () => { + cy.intercept( + { + method: 'POST', + url: /newfold-notifications(\/|%2F)v1(\/|%2F)notifications/, + }, + { + body: { id: 'test-2' }, + } + ).as( 'dismissNotificaiton' ); + + cy.visit( + '/wp-admin/admin.php?page=' + Cypress.env( 'pluginId' ) + '#/home' + ); + + cy.get( '.newfold-notifications-wrapper #notification-test-2' ) .scrollIntoView() - .should('be.visible') - .should('have.attr', 'data-id') - .and('equal', 'test-2'); - - cy.get('.newfold-notifications-wrapper #notification-test-2') - .should('be.visible'); - cy.get('.newfold-notifications-wrapper #notification-test-2') - .contains('display on home and onboarding screens'); - - - cy.get('#notification-test-2 button.notice-dismiss[data-action="close"]').click(); - cy.wait('@dismissNotificaiton'); - - cy.get('.newfold-notifications-wrapper #notification-test-2') - .should('not.exist'); - - }); + .should( 'be.visible' ) + .should( 'have.attr', 'data-id' ) + .and( 'equal', 'test-2' ); + + cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( + 'be.visible' + ); + cy.get( + '.newfold-notifications-wrapper #notification-test-2' + ).contains( 'display on home and onboarding screens' ); + + cy.get( + '#notification-test-2 button.notice-dismiss[data-action="close"]' + ).click(); + cy.wait( '@dismissNotificaiton' ); + + cy.get( '.newfold-notifications-wrapper #notification-test-2' ).should( + 'not.exist' + ); + } ); // these can be updated later on, but currently the wp-admin tests are not loaded via the api // so we can't intercept with test notifications - it('Container Exists in wp-admin', () => { - cy.visit('/wp-admin/index.php'); - cy.get('#newfold-notifications').should('exist'); - }); - - // click events triggered - // plugin search notifications render properly - -}); \ No newline at end of file + it( 'Container Exists in wp-admin', () => { + cy.visit( '/wp-admin/index.php' ); + cy.get( '#newfold-notifications' ).should( 'exist' ); + } ); + + // click events triggered + // plugin search notifications render properly +} ); From c4c70e9b5abe81da88c53b474f20acac6bdfee39 Mon Sep 17 00:00:00 2001 From: Micah Wood Date: Mon, 15 Jan 2024 11:35:20 -0500 Subject: [PATCH 6/7] Reformat code --- includes/AdminNotices.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/AdminNotices.php b/includes/AdminNotices.php index 0d57675..4e4b8a8 100644 --- a/includes/AdminNotices.php +++ b/includes/AdminNotices.php @@ -25,18 +25,18 @@ public static function maybeRenderAdminNotices() { // Handle realtime notifications if ( 'plugin-install' === $screen->id ) { ?> - + collection(); - + // Constant container for admin notices self::openContainer(); @@ -45,9 +45,9 @@ public static function maybeRenderAdminNotices() { function ( Notification $notification ) use ( $page ) { if ( $notification->shouldShow( 'wp-admin-notice', array( 'page' => $page ) ) ) { ?> -
+
content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> -
+
id ) { From 1cb98459e7b38532ff9aab9e32cce8feb461d94b Mon Sep 17 00:00:00 2001 From: Micah Wood Date: Mon, 15 Jan 2024 11:35:37 -0500 Subject: [PATCH 7/7] Disable on post or page list view screens in the admin --- includes/AdminNotices.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/AdminNotices.php b/includes/AdminNotices.php index 4e4b8a8..c744d78 100644 --- a/includes/AdminNotices.php +++ b/includes/AdminNotices.php @@ -22,6 +22,11 @@ public static function maybeRenderAdminNotices() { return; } + // Bail if we're on a post or page list view in the admin + if ( $screen->base === 'edit' ) { + return; + } + // Handle realtime notifications if ( 'plugin-install' === $screen->id ) { ?>