Skip to content

Commit 70474ab

Browse files
committed
Tests: Delete, don’t disconnect, accounts
1 parent 5a5ca0d commit 70474ab

3 files changed

Lines changed: 9 additions & 29 deletions

File tree

tests/EndToEnd/forms/FormCest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,9 @@ private function _wpFormsCompleteAndSubmitForm(EndToEndTester $I, int $pageID, s
812812
// Check that a review request was created.
813813
$I->reviewRequestExists($I);
814814

815-
// Disconnect the account.
816-
$I->disconnectAccount($I, $this->accountID);
817-
818-
// Check that the resources are no longer cached under the given account ID.
819-
$I->dontSeeCachedResourcesInDatabase($I, $this->accountID);
815+
// Remove the provider connection.
816+
// We don't disconnect the account, as this would now revoke the tokens and cause later tests to fail.
817+
$I->removeProviderConnection($I, $this->accountID);
820818
}
821819

822820
/**

tests/EndToEnd/general/IntegrationsCest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,7 @@ public function testCredentialsAndResourcesAreDeletedOnDisconnect(EndToEndTester
215215
$I->assertCount(0, $providers['convertkit']);
216216

217217
// Check cached resources are removed from the database on disconnection.
218-
$I->dontSeeOptionInDatabase('integrate_convertkit_wpforms_custom_fields_' . $accountID);
219-
$I->dontSeeOptionInDatabase('integrate_convertkit_wpforms_forms_' . $accountID);
220-
$I->dontSeeOptionInDatabase('integrate_convertkit_wpforms_sequences_' . $accountID);
221-
$I->dontSeeOptionInDatabase('integrate_convertkit_wpforms_tags_' . $accountID);
218+
$I->dontSeeCachedResourcesInDatabase($I, $this->accountID);
222219
}
223220

224221
/**

tests/Support/Helper/WPForms.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -565,32 +565,17 @@ public function createPageWithWPFormsShortcode($I, $formID)
565565
}
566566

567567
/**
568-
* Disconnects the given account ID via the UI in WPForms > Settings > Integrations.
568+
* Removes the given account ID from the WPForms provider settings.
569569
*
570570
* @since 1.7.0
571571
*
572572
* @param EndToEndTester $I Tester.
573573
* @param string $accountID Account ID.
574574
*/
575-
public function disconnectAccount($I, $accountID)
575+
public function removeProviderConnection($I, $accountID)
576576
{
577-
// Login as the Administrator, if we're not already logged in.
578-
if ( ! $I->amLoggedInAsAdmin($I) ) {
579-
$I->doLoginAsAdmin($I);
580-
}
581-
582-
// Click Disconnect.
583-
$I->amOnAdminPage('admin.php?page=wpforms-settings&view=integrations');
584-
$I->click('#wpforms-integration-convertkit');
585-
$I->waitForElementVisible('#wpforms-integration-convertkit .wpforms-settings-provider-accounts-list span.remove a[data-key="' . $accountID . '"]');
586-
$I->click('#wpforms-integration-convertkit .wpforms-settings-provider-accounts-list span.remove a[data-key="' . $accountID . '"]');
587-
588-
// Confirm that we want to disconnect.
589-
$I->waitForElementVisible('.jconfirm-box');
590-
$I->click('.jconfirm-box button.btn-confirm');
591-
592-
// Confirm connection is no longer listed.
593-
$I->wait(5);
594-
$I->dontSeeElementInDOM('a[data-key="' . $accountID . '"]');
577+
$providers = $I->grabOptionFromDatabase('wpforms_providers');
578+
unset($providers['convertkit'][ $accountID ]);
579+
$I->haveOptionInDatabase('wpforms_providers', $providers);
595580
}
596581
}

0 commit comments

Comments
 (0)