-
Notifications
You must be signed in to change notification settings - Fork 8
Tests: Import: AWeber #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b197209
Integration Tests
n7studios b429e8a
Tests: Import: AWeber
n7studios d9ce0d3
Merge branch 'migrate-aweber' into migrate-aweber-tests
n7studios 2063985
Added Tests
n7studios 06a3bbf
Reinstate headless mode
n7studios 81eedd7
Tests: Removed third party plugin activation/deactivation
n7studios d344c66
Coding standards
n7studios d077e2a
Merge branch 'migrate-aweber' into migrate-aweber-tests
n7studios 9df7214
Improve and clarify FromContent tests
n7studios File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
198 changes: 198 additions & 0 deletions
198
tests/EndToEnd/general/plugin-screens/PluginSettingsToolsImporterAweberCest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,198 @@ | ||
| <?php | ||
|
|
||
| namespace Tests\EndToEnd; | ||
|
|
||
| use Tests\Support\EndToEndTester; | ||
|
|
||
| /** | ||
| * Tests for the Settings > Kit > Tools > Import sections for AWeber. | ||
| * | ||
| * @since 3.1.5 | ||
| */ | ||
| class PluginSettingsToolsImporterAweberCest | ||
| { | ||
| /** | ||
| * Run common actions before running the test functions in this class. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| */ | ||
| public function _before(EndToEndTester $I) | ||
| { | ||
| // Activate Plugins. | ||
| $I->activateKitPlugin($I); | ||
| } | ||
|
|
||
| /** | ||
| * Test that AWeber Forms are replaced with Kit Forms when the Tools > AWeber: Migrate Configuration is configured. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| */ | ||
| public function testAWeberImport(EndToEndTester $I) | ||
| { | ||
| // Setup Plugin. | ||
| $I->setupKitPlugin($I); | ||
| $I->setupKitPluginResources($I); | ||
|
|
||
| // Create Aweber Forms. | ||
| $aweberFormIDs = $this->_createAWeberForms($I); | ||
|
|
||
| // Insert AWeber Form Shortcodes into Pages. | ||
| $pageIDs = $this->_createPagesWithAWeberFormShortcodes($I, $aweberFormIDs); | ||
|
|
||
| // Navigate to the Tools screen. | ||
| $I->loadKitSettingsToolsScreen($I); | ||
|
|
||
| // Select the Kit Forms to replace the AWeber Forms. | ||
| foreach ($aweberFormIDs as $aweberFormID) { | ||
| $I->selectOption('_wp_convertkit_integration_aweber_settings[' . $aweberFormID . ']', $_ENV['CONVERTKIT_API_FORM_ID']); | ||
| } | ||
|
|
||
| // Click the Migrate button. | ||
| $I->click('Migrate'); | ||
|
|
||
| // Confirm success message displays. | ||
| $I->waitForElementVisible('.notice-success'); | ||
| $I->see('AWeber forms migrated successfully.'); | ||
|
|
||
| // View the Pages, to confirm Kit Forms now display. | ||
| foreach ($pageIDs as $pageID) { | ||
| $I->amOnPage('?p=' . $pageID); | ||
| $I->seeElementInDOM('form[data-sv-form]'); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Test that the AWeber: Migrate Configuration section is not displayed when no AWeber Forms exist. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| */ | ||
| public function testAWeberImportWhenNoAWeberForms(EndToEndTester $I) | ||
| { | ||
| // Setup Plugin. | ||
| $I->setupKitPlugin($I); | ||
| $I->setupKitPluginResources($I); | ||
|
|
||
| // Navigate to the Tools screen. | ||
| $I->loadKitSettingsToolsScreen($I); | ||
|
|
||
| // Confirm no AWeber: Migrate Configuration section is displayed. | ||
| $I->dontSeeElementInDOM('#import-aweber'); | ||
| } | ||
|
|
||
| /** | ||
| * Test that the AWeber: Migrate Configuration section is not displayed when AWeber Forms exist, | ||
| * but no Pages, Posts or Custom Posts contain AWeber Form Shortcodes. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| */ | ||
| public function testAWeberImportWhenNoAWeberShortcodesInContent(EndToEndTester $I) | ||
| { | ||
| // Setup Plugin. | ||
| $I->setupKitPlugin($I); | ||
| $I->setupKitPluginResources($I); | ||
|
|
||
| // Create AWeber Forms. | ||
| $aweberFormIDs = $this->_createAWeberForms($I); | ||
|
|
||
| // Navigate to the Tools screen. | ||
| $I->loadKitSettingsToolsScreen($I); | ||
|
|
||
| // Confirm no AWeber: Migrate Configuration section is displayed, as there are no | ||
| // AWeber Form Shortcodes in the content. | ||
| $I->dontSeeElementInDOM('#import-aweber'); | ||
| } | ||
|
|
||
| /** | ||
| * Test that the AWeber: Migrate Configuration section is not displayed when no Kit Forms exist. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| */ | ||
| public function testAWeberImportWhenNoKitForms(EndToEndTester $I) | ||
| { | ||
| // Setup Plugin. | ||
| $I->setupKitPluginCredentialsNoData($I); | ||
| $I->setupKitPluginResourcesNoData($I); | ||
|
|
||
| // Navigate to the Tools screen. | ||
| $I->loadKitSettingsToolsScreen($I); | ||
|
|
||
| // Confirm no AWeber: Migrate Configuration section is displayed, as there are no | ||
| // AWeber Form Shortcodes in the content. | ||
| $I->dontSeeElementInDOM('#import-aweber'); | ||
| } | ||
|
|
||
| /** | ||
| * Create AWeber Forms. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @return array | ||
| */ | ||
| private function _createAWeberForms() | ||
| { | ||
| // AWeber doesn't cache Forms or store them in the database, so we mock the data that would be returned from their API. | ||
| return [ | ||
| '10', | ||
| '11', | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Create Pages with AWeber Form Shortcodes. | ||
| * | ||
| * @since 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| * @param array $aweberFormIDs AWeber Form IDs. | ||
| * @return array | ||
| */ | ||
| private function _createPagesWithAWeberFormShortcodes(EndToEndTester $I, $aweberFormIDs) | ||
| { | ||
| $pageIDs = array(); | ||
|
|
||
| foreach ($aweberFormIDs as $aweberFormID) { | ||
| $pageIDs[] = $I->havePostInDatabase( | ||
| [ | ||
| 'post_type' => 'page', | ||
| 'post_status' => 'publish', | ||
| 'post_title' => 'Page with AWeber Form #' . $aweberFormID, | ||
| 'post_content' => '[aweber formid="' . $aweberFormID . '"]', | ||
| 'meta_input' => [ | ||
| '_wp_convertkit_post_meta' => [ | ||
| 'form' => '0', | ||
| 'landing_page' => '', | ||
| 'tag' => '', | ||
| ], | ||
| ], | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| return $pageIDs; | ||
| } | ||
|
|
||
| /** | ||
| * 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 3.1.5 | ||
| * | ||
| * @param EndToEndTester $I Tester. | ||
| */ | ||
| public function _passed(EndToEndTester $I) | ||
| { | ||
| $I->deactivateKitPlugin($I); | ||
| $I->resetKitPlugin($I); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you moved this to the parent class, it makes more sense to name the test at that level, so
testGetGenericFormIDsFromContentvs. naming to the specific provider. I also don't see the value of testGetMC4WPFormIDsFromContent since you're exercising the same code.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to keep these, as they test using the
ConvertKit_Admin_Importer_AWeber/ConvertKit_Admin_Importer_MC4WPclasses, ensuring only the applicable shortcodes are extracted i.e. AWeber shortcodes when usingConvertKit_Admin_Importer_AWeberand Mailchimp shortcodes when using `ConvertKit_Admin_Importer_MC4WP.I've improved the tests to ensure other shortcodes aren't extracted, which hopefully means having two separate tests makes more sense here.