From d72f5a1e9806864e7cd1279db05bbfcc6d3148a6 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 24 Aug 2023 15:45:09 -0400 Subject: [PATCH 1/3] use appid for selector --- 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 af03291..d98f4d6 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -42,7 +42,7 @@ describe('Notifications', () => { .should('not.exist'); // cy.visit('/wp-admin/admin.php?page=' + Cypress.env('pluginId') + '#/settings'); - cy.get('.wppbh-app-navitem-Settings').click(); + cy.get('.' + Cypress.env('appId') + '-app-navitem-Settings').click(); cy.wait(500); cy.get('.newfold-notifications-wrapper #notification-test-1') From 259233aeaa23f557c68527b02b89ddfe9ff183d9 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 24 Aug 2023 15:45:41 -0400 Subject: [PATCH 2/3] move test notification fixture into js file so we can use env var to set context --- tests/cypress/fixtures/notifications.json | 66 ------------------ tests/cypress/integration/notifications.cy.js | 67 ++++++++++++++++++- 2 files changed, 66 insertions(+), 67 deletions(-) delete mode 100644 tests/cypress/fixtures/notifications.json diff --git a/tests/cypress/fixtures/notifications.json b/tests/cypress/fixtures/notifications.json deleted file mode 100644 index 22b0ffc..0000000 --- a/tests/cypress/fixtures/notifications.json +++ /dev/null @@ -1,66 +0,0 @@ -[ - { - "id": "test-1", - "locations": [ - { - "context": "bluehost-plugin", - "pages": "#/settings" - } - ], - "expiration": 2748863456503, - "content": "

Notice should only display on plugin app settings page<\/p><\/div>" - }, - { - "id": "test-2", - "locations": [ - { - "context": "bluehost-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": "bluehost-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": "bluehost-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": "bluehost-plugin", - "pages": "all" - } - ], - "expiration": 1649860279240, - "content": "

Here is an expired notice it should never display anywhere even though it has location `all` <\/p><\/div>" - } -] \ No newline at end of file diff --git a/tests/cypress/integration/notifications.cy.js b/tests/cypress/integration/notifications.cy.js index d98f4d6..0dbf6e5 100644 --- a/tests/cypress/integration/notifications.cy.js +++ b/tests/cypress/integration/notifications.cy.js @@ -1,5 +1,70 @@ // -const notifications = require('../fixtures/notifications.json'); +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>" + } +]; describe('Notifications', () => { From 7371df706f75b3cf4a79eebbb083a6c183e262c3 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Thu, 24 Aug 2023 15:51:04 -0400 Subject: [PATCH 3/3] update module test data --- includes/NotificationsRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/NotificationsRepository.php b/includes/NotificationsRepository.php index 53728af..09edea6 100644 --- a/includes/NotificationsRepository.php +++ b/includes/NotificationsRepository.php @@ -100,7 +100,7 @@ public static function get_test_notification_data() { 'pages' => '#/help', ] ], - 'expiration' => 1649860279240, + 'expiration' => 1749860279240, 'content' => '

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

', ]; $results[] = [ @@ -141,7 +141,7 @@ public static function get_test_notification_data() { 'locations' => [ [ 'pages' => ["#/marketplace/services"], - 'context' => "web-plugin" + 'context' => container()->plugin()->id . "-plugin" ], [ 'pages' => 'index.php',