Fix broken integration & acceptance tests
This commit is contained in:
committed by
David Remer
parent
93eb0813f9
commit
2d4e8f4df6
@@ -3,6 +3,7 @@
|
||||
namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use Codeception\Util\Locator;
|
||||
use MailPoet\Captcha\CaptchaConstants;
|
||||
use MailPoet\Test\DataFactories\Settings;
|
||||
|
||||
/**
|
||||
@@ -32,6 +33,8 @@ class CreateNewWordPressUserCest {
|
||||
$i->click('[data-automation-id="settings-submit-button"]'); //save settings
|
||||
$i->waitForElementNotVisible('#mailpoet_loading');
|
||||
|
||||
$this->settings->withCaptchaType(CaptchaConstants::TYPE_DISABLED);
|
||||
|
||||
// create a wp user via registration
|
||||
// Note: Xpath used to avoid flakyness and to pass multisite testing where we have different registration page designs
|
||||
$i->logOut();
|
||||
|
@@ -3,19 +3,29 @@
|
||||
namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use Codeception\Util\Locator;
|
||||
use MailPoet\Captcha\CaptchaConstants;
|
||||
use MailPoet\Test\DataFactories\Segment;
|
||||
use MailPoet\Test\DataFactories\Settings;
|
||||
|
||||
/**
|
||||
* @group frontend
|
||||
*/
|
||||
class SubscribeOnRegistrationPageCest {
|
||||
private Settings $settings;
|
||||
|
||||
public function before() {
|
||||
$this->settings = new Settings();
|
||||
}
|
||||
|
||||
public function allowSubscribeOnRegistrationPage(\AcceptanceTester $i) {
|
||||
$i->wantTo('Allow users to subscribe to lists on site registration page');
|
||||
|
||||
//create a list for this test
|
||||
$segmentFactory = new Segment();
|
||||
$regseg = 'RegistrationPageSignup';
|
||||
$segment1 = $segmentFactory->withName($regseg)->create();
|
||||
$regpageuseremail = 'registerpagesignup@fake.fake';
|
||||
|
||||
$i->login();
|
||||
//Go to settings
|
||||
$i->amOnMailPoetPage('Settings');
|
||||
@@ -24,6 +34,9 @@ class SubscribeOnRegistrationPageCest {
|
||||
//save settings
|
||||
$i->click('[data-automation-id="settings-submit-button"]');
|
||||
$i->waitForText('Settings saved');
|
||||
|
||||
$this->settings->withCaptchaType(CaptchaConstants::TYPE_DISABLED);
|
||||
|
||||
$i->logOut();
|
||||
$i->amOnPage('/wp-login.php?action=register');
|
||||
$i->waitForElement(['css' => '.registration-form-mailpoet']);
|
||||
@@ -41,6 +54,7 @@ class SubscribeOnRegistrationPageCest {
|
||||
$i->click('Next');
|
||||
$i->waitForText('muregisterpagesignup is your new username');
|
||||
}
|
||||
|
||||
$i->login();
|
||||
$i->amOnMailPoetPage('Subscribers');
|
||||
$i->waitForText('registerpagesignup@fake.fake');
|
||||
@@ -51,6 +65,7 @@ class SubscribeOnRegistrationPageCest {
|
||||
public function sendConfirmationEmailOnRegistration(\AcceptanceTester $i) {
|
||||
$i->wantTo('send confirmation email on user registration when no additional lists');
|
||||
$userEmail = 'registerpagesignupconfirmation@fake.fake';
|
||||
|
||||
$i->login();
|
||||
//Go to settings
|
||||
$i->amOnMailPoetPage('Settings');
|
||||
@@ -58,6 +73,9 @@ class SubscribeOnRegistrationPageCest {
|
||||
//save settings
|
||||
$i->click('[data-automation-id="settings-submit-button"]');
|
||||
$i->waitForText('Settings saved');
|
||||
|
||||
$this->settings->withCaptchaType(CaptchaConstants::TYPE_DISABLED);
|
||||
|
||||
$i->logOut();
|
||||
$i->amOnPage('/wp-login.php?action=register');
|
||||
$i->waitForElement(['css' => '.registration-form-mailpoet']);
|
||||
@@ -75,6 +93,7 @@ class SubscribeOnRegistrationPageCest {
|
||||
$i->click('Next');
|
||||
$i->waitForText('muregisterpagesignupconfirmation is your new username');
|
||||
}
|
||||
|
||||
$i->checkEmailWasReceived('Confirm your subscription');
|
||||
$i->click(Locator::contains('span.subject', 'Confirm your subscription'));
|
||||
$i->switchToIframe('#preview-html');
|
||||
|
@@ -110,7 +110,7 @@ class ManageSubscriptionLinkCest {
|
||||
$i->selectOption('[data-automation-id="subscriber-status"]', 'Subscribed');
|
||||
$i->click('Save');
|
||||
$i->waitForText('Subscriber was updated successfully!');
|
||||
$i->amOnUrl(\AcceptanceTester::WP_URL . '/?mailpoet_page=subscriptions&mailpoet_router&endpoint=subscription&action=unsubscribe&data=');
|
||||
$i->amOnUrl(\AcceptanceTester::WP_URL . '/?mailpoet_page=template&mailpoet_router&endpoint=subscription&action=unsubscribe&data=');
|
||||
$i->waitForElementVisible('.mailpoet_page-template-default');
|
||||
// we will verify only a portion of the full sentence
|
||||
// since there is a microscopic difference between blockbased and non-block theme
|
||||
|
@@ -4,6 +4,7 @@ namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use AcceptanceTester;
|
||||
use Codeception\Util\Locator;
|
||||
use MailPoet\Captcha\CaptchaConstants;
|
||||
use MailPoet\DI\ContainerWrapper;
|
||||
use MailPoet\Subscribers\SubscribersRepository;
|
||||
use MailPoet\Test\DataFactories\Newsletter;
|
||||
@@ -25,6 +26,7 @@ class SubscriberCookieCest {
|
||||
|
||||
(new Settings())
|
||||
->withSubscribeOnRegisterEnabled()
|
||||
->withCaptchaType(CaptchaConstants::TYPE_DISABLED)
|
||||
->withTransactionEmailsViaMailPoet();
|
||||
|
||||
$email = 'test-user@example.com';
|
||||
@@ -67,7 +69,6 @@ class SubscriberCookieCest {
|
||||
$i->fillField('Password', $password);
|
||||
$i->click('Log In');
|
||||
$i->waitForText('Dashboard');
|
||||
|
||||
}
|
||||
// subscriber cookie should be set right after signup
|
||||
$this->checkSubscriberCookie($i, $email);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use MailPoet\Captcha\CaptchaConstants;
|
||||
use MailPoet\Entities\SubscriberEntity;
|
||||
use MailPoet\Test\DataFactories\Settings;
|
||||
|
||||
@@ -19,8 +20,9 @@ class WooMyAccountRegistrationCest {
|
||||
public function _before(\AcceptanceTester $i) {
|
||||
$i->activateWooCommerce();
|
||||
$this->settingsFactory = new Settings();
|
||||
$this->settingsFactory->withWooCommerceListImportPageDisplayed(true);
|
||||
$this->settingsFactory->withCookieRevenueTrackingDisabled();
|
||||
$this->settingsFactory->withWooCommerceListImportPageDisplayed(true)
|
||||
->withCookieRevenueTrackingDisabled()
|
||||
->withCaptchaType(CaptchaConstants::TYPE_DISABLED);
|
||||
}
|
||||
|
||||
public function registerOptInDisabled(\AcceptanceTester $i) {
|
||||
|
@@ -11,6 +11,7 @@ use MailPoet\API\JSON\SuccessResponse;
|
||||
use MailPoet\API\JSON\v1\Subscribers;
|
||||
use MailPoet\Captcha\CaptchaConstants;
|
||||
use MailPoet\Captcha\CaptchaSession;
|
||||
use MailPoet\Config\Populator;
|
||||
use MailPoet\DI\ContainerWrapper;
|
||||
use MailPoet\Entities\CustomFieldEntity;
|
||||
use MailPoet\Entities\FormEntity;
|
||||
@@ -740,17 +741,21 @@ class SubscribersTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItCannotSubscribeWithoutBuiltInCaptchaWhenEnabled() {
|
||||
$this->diContainer->get(Populator::class)->up();
|
||||
|
||||
$this->settings->set('captcha', ['type' => CaptchaConstants::TYPE_BUILTIN]);
|
||||
$email = 'toto@mailpoet.com';
|
||||
(new SubscriberFactory())
|
||||
->withEmail($email)
|
||||
->withCountConfirmations(1)
|
||||
->create();
|
||||
|
||||
$response = $this->endpoint->subscribe([
|
||||
$this->obfuscatedEmail => $email,
|
||||
'form_id' => $this->form->getId(),
|
||||
$this->obfuscatedSegments => [$this->segment1->getId(), $this->segment2->getId()],
|
||||
]);
|
||||
|
||||
verify($response->status)->equals(APIResponse::STATUS_BAD_REQUEST);
|
||||
verify($response->errors[0]['message'])->equals('Please fill in the CAPTCHA.');
|
||||
$this->settings->set('captcha', []);
|
||||
@@ -888,12 +893,11 @@ class SubscribersTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testThirdPartiesCanInterruptSubscriptionProcess() {
|
||||
|
||||
$expectedErrorMessage = 'ErrorMessage';
|
||||
|
||||
\MailPoet\WP\add_action(
|
||||
'mailpoet_subscription_before_subscribe',
|
||||
function($data) use ($expectedErrorMessage) {
|
||||
function ($data) use ($expectedErrorMessage) {
|
||||
throw new UnexpectedValueException($expectedErrorMessage);
|
||||
}
|
||||
);
|
||||
|
@@ -5,6 +5,7 @@ namespace Mailpoet\Test\Captcha\Validator;
|
||||
use MailPoet\Captcha\CaptchaSession;
|
||||
use MailPoet\Captcha\Validator\CaptchaValidator;
|
||||
use MailPoet\Captcha\Validator\ValidationError;
|
||||
use MailPoet\Config\Populator;
|
||||
use MailPoet\Entities\SubscriberIPEntity;
|
||||
use MailPoet\Test\DataFactories\Subscriber as SubscriberFactory;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
@@ -29,6 +30,8 @@ class BuiltInCaptchaValidatorTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testEmptyCaptchaThrowsError() {
|
||||
$this->diContainer->get(Populator::class)->up();
|
||||
|
||||
try {
|
||||
$this->testee->validate(['captcha_session_id' => '123']);
|
||||
} catch (ValidationError $error) {
|
||||
@@ -50,6 +53,8 @@ class BuiltInCaptchaValidatorTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testThrowsErrorWhenCaptchaHasTimedOut() {
|
||||
$this->diContainer->get(Populator::class)->up();
|
||||
|
||||
$sessionId = '123';
|
||||
$this->session->setCaptchaHash($sessionId, ['phrase' => null]);
|
||||
try {
|
||||
@@ -81,7 +86,7 @@ class BuiltInCaptchaValidatorTest extends \MailPoetTest {
|
||||
public function testItTakesFilterIntoAccountToDisableCaptcha() {
|
||||
$wp = new WPFunctions;
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$filter = function() {
|
||||
$filter = function () {
|
||||
return 1;
|
||||
};
|
||||
$wp->addFilter('mailpoet_subscription_captcha_recipient_limit', $filter);
|
||||
|
Reference in New Issue
Block a user