Add test for sender warning

[MAILPOET-1890]
This commit is contained in:
Pavel Dohnal
2019-03-25 11:10:15 +01:00
committed by M. Shull
parent 7067b82e06
commit 72fc8cecf2
4 changed files with 56 additions and 5 deletions

View File

@@ -9,7 +9,10 @@ const suggestedEmailAddress = `contact@${userHostDomain}`;
const NewInstallationWithMSSWarning = ({ emailAddress }) => ( const NewInstallationWithMSSWarning = ({ emailAddress }) => (
<React.Fragment> <React.Fragment>
<p className="sender_email_address_warning"> <p
className="sender_email_address_warning"
data-acceptance-id="freemail-sender-warning-new-installation"
>
{ReactStringReplace( {ReactStringReplace(
MailPoet.I18n.t('senderEmailAddressNewInstallWarning1'), MailPoet.I18n.t('senderEmailAddressNewInstallWarning1'),
'%originalSender', '%originalSender',
@@ -55,7 +58,12 @@ NewInstallationWithMSSWarning.propTypes = {
const OldInstallationWarning = ({ emailAddress }) => ( const OldInstallationWarning = ({ emailAddress }) => (
<React.Fragment> <React.Fragment>
<p className="sender_email_address_warning">{MailPoet.I18n.t('senderEmailAddressWarning1')}</p> <p
className="sender_email_address_warning"
data-acceptance-id="freemail-sender-warning-old-installation"
>
{MailPoet.I18n.t('senderEmailAddressWarning1')}
</p>
<p className="sender_email_address_warning"> <p className="sender_email_address_warning">
{ReactStringReplace( {ReactStringReplace(
MailPoet.I18n.t('senderEmailAddressWarning2'), MailPoet.I18n.t('senderEmailAddressWarning2'),

View File

@@ -50,6 +50,10 @@ class Settings {
return $this; return $this;
} }
function withTodayInstallationDate() {
$this->settings->set('installed_at', date("Y-m-d H:i:s"));
}
function withSkippedTutorials() { function withSkippedTutorials() {
$this->settings->set('show_intro', 0); $this->settings->set('show_intro', 0);
$this->settings->set('display_nps_poll', 0); $this->settings->set('display_nps_poll', 0);

View File

@@ -35,7 +35,8 @@ class AcceptanceTester extends \Codeception\Actor {
waitForText as _waitForText; waitForText as _waitForText;
} }
const WP_URL = 'http://test.local'; const WP_DOMAIN = 'test.local';
const WP_URL = 'http://' . self::WP_DOMAIN;
const MAIL_URL = 'http://mailhog:8025'; const MAIL_URL = 'http://mailhog:8025';
/** /**

View File

@@ -1,8 +1,14 @@
<?php <?php
namespace MailPoet\Test\Acceptance; namespace MailPoet\Test\Acceptance;
use MailPoet\Mailer\Mailer;
use MailPoet\Test\DataFactories\Settings;
require_once __DIR__ . '/../DataFactories/Settings.php';
class SettingsPageBasicsCest { class SettingsPageBasicsCest {
function checkSettingsPagesLoad(\AcceptanceTester $I) { function checkSettingsPagesLoad(\AcceptanceTester $I) {
$I->wantTo('Confirm all settings pages load correctly'); $I->wantTo('Confirm all settings pages load correctly');
$I->login(); $I->login();
@@ -27,6 +33,7 @@ class SettingsPageBasicsCest {
$I->waitForText('Activation Key'); $I->waitForText('Activation Key');
$I->seeNoJSErrors(); $I->seeNoJSErrors();
} }
function editDefaultSenderInformation(\AcceptanceTester $I) { function editDefaultSenderInformation(\AcceptanceTester $I) {
$I->wantTo('Confirm default sender information can be edited'); $I->wantTo('Confirm default sender information can be edited');
$I->login(); $I->login();
@@ -39,6 +46,7 @@ class SettingsPageBasicsCest {
$I->click('[data-automation-id="settings-submit-button"]'); $I->click('[data-automation-id="settings-submit-button"]');
$I->waitForText('Settings saved'); $I->waitForText('Settings saved');
} }
function allowSubscribeInComments(\AcceptanceTester $I) { function allowSubscribeInComments(\AcceptanceTester $I) {
$I->wantTo('Allow users to subscribe to lists in site comments'); $I->wantTo('Allow users to subscribe to lists in site comments');
$post_title = 'Hello world!'; $post_title = 'Hello world!';
@@ -64,4 +72,34 @@ class SettingsPageBasicsCest {
$I->click($post_title); $I->click($post_title);
$I->dontSee("Yes, add me to your mailing list"); $I->dontSee("Yes, add me to your mailing list");
} }
function checkSenderFreemailWarning(\AcceptanceTester $I) {
$settings = new Settings();
$settings->withSendingMethod(Mailer::METHOD_SMTP);
$settings->withTodayInstallationDate();
$I->wantTo('Confirm default sender information can be edited');
$I->login();
$I->amOnMailPoetPage('Settings');
$I->fillField(['name' => 'sender[name]'], 'Sender');
$I->fillField(['name' => 'sender[address]'], 'sender@email.com');
$I->seeElement('[data-acceptance-id="freemail-sender-warning-old-installation"]');
$I->see('contact@' . \AcceptanceTester::WP_DOMAIN);
$I->fillField(['name' => 'sender[address]'], 'sender@fake.fake');
$I->dontseeElement('[data-acceptance-id="freemail-sender-warning-old-installation"]');
$settings = new Settings();
$settings->withSendingMethodMailPoet();
$I->reloadPage();
$I->fillField(['name' => 'sender[address]'], 'sender2@email.com');
$I->seeElement('[data-acceptance-id="freemail-sender-warning-new-installation"]');
$I->fillField(['name' => 'sender[address]'], 'sender@fake.fake');
$I->dontSeeElement('[data-acceptance-id="freemail-sender-warning-new-installation"]');
}
function _after() {
$settings = new Settings();
$settings->withSendingMethod(Mailer::METHOD_SMTP);
}
} }