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' ) + ); + ?> +

+
+ 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); 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/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 new file mode 100644 index 0000000..a90ce71 --- /dev/null +++ b/tests/acceptance/general/NoticesCest.php @@ -0,0 +1,90 @@ +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); + + // 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.'); + } + + /** + * 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); + } +}