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