From 03c65dd5e28360090d056fb413b5a7834ad11f11 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 8 Feb 2024 13:19:47 +0000 Subject: [PATCH 1/4] Output notice to install official add-on --- convertkit.php | 1 + includes/class-ckgf-notices.php | 84 +++++++++++++++++++++++++++++++++ readme.txt | 2 + 3 files changed, 87 insertions(+) create mode 100644 includes/class-ckgf-notices.php diff --git a/convertkit.php b/convertkit.php index 80f02a5..c0dea65 100755 --- a/convertkit.php +++ b/convertkit.php @@ -40,6 +40,7 @@ // Load files that are always used. require_once CKGF_PLUGIN_PATH . '/includes/functions.php'; require_once CKGF_PLUGIN_PATH . '/includes/class-ckgf-api.php'; +require_once CKGF_PLUGIN_PATH . '/includes/class-ckgf-notices.php'; require_once CKGF_PLUGIN_PATH . '/includes/class-wp-ckgf.php'; /** diff --git a/includes/class-ckgf-notices.php b/includes/class-ckgf-notices.php new file mode 100644 index 0000000..3ca17e6 --- /dev/null +++ b/includes/class-ckgf-notices.php @@ -0,0 +1,84 @@ + +
+

+ %s. %s', + esc_html__( 'ConvertKit Gravity Forms Add-On: Please install the official', 'convertkit' ), + esc_url( 'https://www.gravityforms.com/blog/convertkit-add-on/' ), + esc_html__( 'Gravity Forms ConvertKit Add-On', 'convertkit' ), + esc_html__( 'Your existing settings will automatically migrate once installed and active.', 'convertkit' ) + ); + ?> +

+
+ Date: Thu, 8 Feb 2024 14:34:35 +0000 Subject: [PATCH 2/4] Added tests --- .../Helper/Acceptance/ThirdPartyPlugin.php | 8 ++ tests/acceptance/general/NoticesCest.php | 89 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tests/acceptance/general/NoticesCest.php diff --git a/tests/_support/Helper/Acceptance/ThirdPartyPlugin.php b/tests/_support/Helper/Acceptance/ThirdPartyPlugin.php index 389699c..8b9486a 100644 --- a/tests/_support/Helper/Acceptance/ThirdPartyPlugin.php +++ b/tests/_support/Helper/Acceptance/ThirdPartyPlugin.php @@ -39,6 +39,10 @@ public function activateThirdPartyPlugin($I, $name) $I->seePluginActivated('gravityforms'); break; + case 'gravity-forms-convertkit-add-on': + $I->seePluginActivated('gravityformsconvertkit'); + break; + default: $I->seePluginActivated($name); break; @@ -72,6 +76,10 @@ public function deactivateThirdPartyPlugin($I, $name) $I->deactivatePlugin('gravityforms'); break; + case 'gravity-forms-convertkit-add-on': + $I->deactivatePlugin('gravityformsconvertkit'); + break; + default: $I->deactivatePlugin($name); break; diff --git a/tests/acceptance/general/NoticesCest.php b/tests/acceptance/general/NoticesCest.php new file mode 100644 index 0000000..e6e11e5 --- /dev/null +++ b/tests/acceptance/general/NoticesCest.php @@ -0,0 +1,89 @@ +activateConvertKitPlugin($I); + } + + /** + * Test that the persistent notice displays with expected wording when the Plugin is active. + * + * @since 1.4.2 + * + * @param AcceptanceTester $I Tester. + */ + public function testPersistentNoticeDisplays(AcceptanceTester $I) + { + // Confirm notice displays with expected text. + $I->seeElement('.notice-warning'); + $I->see($this->expectedNoticeText); + + // Confirm the link is valid. + $I->assertEquals( + $I->grabAttributeFrom('.notice-warning a', 'href'), + 'https://www.gravityforms.com/blog/convertkit-add-on/' + ); + + // Deactivate Plugin. + $I->deactivateConvertKitPlugin($I); + + // Confirm no notice from this Plugin displays. + $I->dontSee($this->expectedNoticeText); + } + + /** + * Test that the persistent notice does not display when the official add-on is active. + * + * @since 1.4.2 + * + * @param AcceptanceTester $I Tester. + */ + public function testPersistentNoticeNotDisplayedWhenOfficialAddonActive(AcceptanceTester $I) + { + // Activate Gravity Forms and official add-on. + $I->activateThirdPartyPlugin($I, 'gravity-forms'); + $I->activateThirdPartyPlugin($I, 'gravity-forms-convertkit-add-on'); + + // Confirm no notice from this Plugin displays. + $I->dontSee($this->expectedNoticeText); + + // Confirm the official add-on displays its notice that it deactivated this Plugin. + $I->see('In order to prevent conflicts, we disabled the existing ConvertKit for Gravity Forms plugin.'); + } + + /** + * Deactivate and reset Plugin(s) after each test, if the test passes. + * We don't use _after, as this would provide a screenshot of the Plugin + * deactivation and not the true test error. + * + * @since 1.2.2 + * + * @param AcceptanceTester $I Tester. + */ + public function _passed(AcceptanceTester $I) + { + $I->resetConvertKitPlugin($I); + } +} From 927a915bb0f995cace77f0425897f77ff921e341 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 8 Feb 2024 15:45:52 +0000 Subject: [PATCH 3/4] =?UTF-8?q?Tests:=20Don=E2=80=99t=20open=20Advanced=20?= =?UTF-8?q?Fields=20Panel,=20as=20it=E2=80=99s=20now=20open=20by=20default?= =?UTF-8?q?=20in=20GF=202.8+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/_support/Helper/Acceptance/GravityForms.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/_support/Helper/Acceptance/GravityForms.php b/tests/_support/Helper/Acceptance/GravityForms.php index 9825339..a3dad68 100644 --- a/tests/_support/Helper/Acceptance/GravityForms.php +++ b/tests/_support/Helper/Acceptance/GravityForms.php @@ -112,10 +112,6 @@ public function createGravityFormsForm($I) // Wait for the Form Edit screen to load. $I->waitForElementVisible('#no-fields'); - // Open Advanced Fields Panel. - $I->click('button[aria-controls="add_advanced_fields"]'); - $I->wait(2); - // Add Name Field. $I->click('#add_advanced_fields button[data-type="name"]'); $I->wait(2); From 6d73029cad99e67a63d2ca2cfe092e1747ee0c57 Mon Sep 17 00:00:00 2001 From: Tim Carr Date: Thu, 8 Feb 2024 15:46:14 +0000 Subject: [PATCH 4/4] Tests: Use input type=email as selector, as this is now the default for GF 2.8+ --- tests/acceptance/forms/FormCest.php | 18 +++++++++--------- tests/acceptance/general/NoticesCest.php | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/acceptance/forms/FormCest.php b/tests/acceptance/forms/FormCest.php index 3fae814..664e358 100644 --- a/tests/acceptance/forms/FormCest.php +++ b/tests/acceptance/forms/FormCest.php @@ -62,7 +62,7 @@ public function testCreateFormAndFeed(AcceptanceTester $I) // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); // Submit Form. $I->click('Submit'); @@ -135,7 +135,7 @@ public function testCreateFormAndFeedWithNoConvertKitFormSelected(AcceptanceTest // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); // Submit Form. $I->click('Submit'); @@ -320,7 +320,7 @@ public function testCreateFormAndFeedWithTagAndFieldTagSelected(AcceptanceTester // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); $I->selectOption('select.gfield_select', $_ENV['CONVERTKIT_API_ADDITIONAL_TAG_NAME']); // Submit Form. @@ -399,7 +399,7 @@ public function testCreateFormAndFeedWithFieldTagSelected(AcceptanceTester $I) // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); $I->selectOption('select.gfield_select', $_ENV['CONVERTKIT_API_ADDITIONAL_TAG_NAME']); // Submit Form. @@ -478,7 +478,7 @@ public function testCreateFormAndFeedWithInvalidFieldTagSelected(AcceptanceTeste // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); $I->selectOption( 'select.gfield_select', 'fakeTagNotInConvertKit' ); // Submit Form. @@ -557,7 +557,7 @@ public function testCreateFormAndFeedWithTagSelected(AcceptanceTester $I) // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); // Submit Form. $I->click('Submit'); @@ -641,7 +641,7 @@ public function testCreateFormAndFeedWithConditionalLogicMatching(AcceptanceTest // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); // Submit Form. $I->click('Submit'); @@ -720,7 +720,7 @@ public function testCreateFormAndFeedWithConditionalLogicDoesNotMatch(Acceptance // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); // Submit Form. $I->click('Submit'); @@ -790,7 +790,7 @@ public function testCreateFormAndFeedDisabled(AcceptanceTester $I) // Complete Form Fields. $I->fillField('.name_first input[type=text]', $firstName); $I->fillField('.name_last input[type=text]', $lastName); - $I->fillField('.ginput_container_email input[type=text]', $emailAddress); + $I->fillField('.ginput_container_email input[type=email]', $emailAddress); // Submit Form. $I->click('Submit'); diff --git a/tests/acceptance/general/NoticesCest.php b/tests/acceptance/general/NoticesCest.php index e6e11e5..a90ce71 100644 --- a/tests/acceptance/general/NoticesCest.php +++ b/tests/acceptance/general/NoticesCest.php @@ -69,6 +69,7 @@ public function testPersistentNoticeNotDisplayedWhenOfficialAddonActive(Acceptan // Confirm no notice from this Plugin displays. $I->dontSee($this->expectedNoticeText); + // When the official add-on is activated, it checks whether this Plugin is also active, deactivating it if so. // Confirm the official add-on displays its notice that it deactivated this Plugin. $I->see('In order to prevent conflicts, we disabled the existing ConvertKit for Gravity Forms plugin.'); }