Add acceptance test for post notification edit [MQ-29]
This commit is contained in:
@@ -63,6 +63,7 @@ const FormFieldSelect = React.createClass({
|
||||
id={`field_${this.props.field.name}`}
|
||||
value={this.props.item[this.props.field.name] || ''}
|
||||
onChange={this.props.onValueChange}
|
||||
data-automation-id={this.props.automationId}
|
||||
{...this.props.field.validation}
|
||||
>
|
||||
{placeholder}
|
||||
|
@@ -134,6 +134,7 @@ const NotificationScheduling = React.createClass({
|
||||
field={intervalField}
|
||||
item={this.getCurrentValue()}
|
||||
onValueChange={this.handleIntervalChange}
|
||||
automationId="newsletter_interval_type"
|
||||
/>
|
||||
|
||||
{nthWeekDaySelection}
|
||||
|
104
tests/DataFactories/Newsletter.php
Normal file
104
tests/DataFactories/Newsletter.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\DataFactories;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Newsletter {
|
||||
|
||||
/** @var array */
|
||||
private $data;
|
||||
|
||||
/** @var array */
|
||||
private $options;
|
||||
|
||||
public function __construct() {
|
||||
$this->data = [
|
||||
'subject' => 'Some subject',
|
||||
'preheader' => 'Some preheader',
|
||||
'type' => 'standard',
|
||||
'status' => 'draft',
|
||||
];
|
||||
$this->options = [];
|
||||
$this->loadBodyFrom('newsletterWithALC.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function loadBodyFrom($filename) {
|
||||
$this->data['body'] = json_decode(file_get_contents(__DIR__ . '/../_data/' . $filename), true);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withSubject($subject) {
|
||||
$this->data['subject'] = $subject;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withStatus($status) {
|
||||
$this->data['status'] = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withType($type) {
|
||||
$this->data['type'] = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withPostNoticationOptions(array $options = [
|
||||
8 => 'daily', # intervalType
|
||||
9 => '0', # timeOfDay
|
||||
10 => '1', # intervalType
|
||||
11 => '0', # monthDay
|
||||
12 => '1', # nthWeekDay
|
||||
13 => '0 0 * * *', # schedule
|
||||
]) {
|
||||
return $this->withOptions($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withOptions(array $options)
|
||||
{
|
||||
$this->options = array_merge($this->options, $options);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Newsletter
|
||||
*/
|
||||
public function withDeleted() {
|
||||
$this->data['deleted_at'] = Carbon::now();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \MailPoet\Models\Newsletter
|
||||
*/
|
||||
public function create() {
|
||||
$newsletter = \MailPoet\Models\Newsletter::createOrUpdate($this->data);
|
||||
foreach ($this->options as $option_id => $option_value) {
|
||||
\MailPoet\Models\NewsletterOption::createOrUpdate(
|
||||
[
|
||||
'newsletter_id' => $newsletter->id,
|
||||
'option_field_id' => $option_id,
|
||||
'value' => $option_value,
|
||||
]
|
||||
);
|
||||
}
|
||||
return $newsletter;
|
||||
}
|
||||
}
|
377
tests/_data/newsletterWithALC.json
Normal file
377
tests/_data/newsletterWithALC.json
Normal file
@@ -0,0 +1,377 @@
|
||||
{
|
||||
"content": {
|
||||
"type": "container",
|
||||
"orientation": "vertical",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent"
|
||||
}
|
||||
},
|
||||
"blocks": [
|
||||
{
|
||||
"type": "automatedLatestContentLayout",
|
||||
"withLayout": true,
|
||||
"amount": "3",
|
||||
"contentType": "post",
|
||||
"terms": [],
|
||||
"inclusionType": "include",
|
||||
"displayType": "excerpt",
|
||||
"titleFormat": "h3",
|
||||
"titleAlignment": "left",
|
||||
"titleIsLink": false,
|
||||
"imageFullWidth": false,
|
||||
"featuredImagePosition": "alternate",
|
||||
"showAuthor": "no",
|
||||
"authorPrecededBy": "Author:",
|
||||
"showCategories": "no",
|
||||
"categoriesPrecededBy": "Categories:",
|
||||
"readMoreType": "button",
|
||||
"readMoreText": "Read more",
|
||||
"readMoreButton": {
|
||||
"type": "button",
|
||||
"text": "Read the post",
|
||||
"url": "[postLink]",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "#2ea1cd",
|
||||
"borderColor": "#0074a2",
|
||||
"borderWidth": "1px",
|
||||
"borderRadius": "5px",
|
||||
"borderStyle": "solid",
|
||||
"width": "160px",
|
||||
"lineHeight": "30px",
|
||||
"fontColor": "#ffffff",
|
||||
"fontFamily": "Verdana",
|
||||
"fontSize": "16px",
|
||||
"fontWeight": "normal",
|
||||
"textAlign": "center"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sortBy": "newest",
|
||||
"showDivider": true,
|
||||
"divider": {
|
||||
"type": "divider",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent",
|
||||
"padding": "13px",
|
||||
"borderStyle": "solid",
|
||||
"borderWidth": "3px",
|
||||
"borderColor": "#aaaaaa"
|
||||
}
|
||||
}
|
||||
},
|
||||
"backgroundColor": "#ffffff",
|
||||
"backgroundColorAlternate": "#eeeeee"
|
||||
}
|
||||
]
|
||||
},
|
||||
"globalStyles": {
|
||||
"text": {
|
||||
"fontColor": "#000000",
|
||||
"fontFamily": "Arial",
|
||||
"fontSize": "16px"
|
||||
},
|
||||
"h1": {
|
||||
"fontColor": "#111111",
|
||||
"fontFamily": "Trebuchet MS",
|
||||
"fontSize": "30px"
|
||||
},
|
||||
"h2": {
|
||||
"fontColor": "#222222",
|
||||
"fontFamily": "Trebuchet MS",
|
||||
"fontSize": "24px"
|
||||
},
|
||||
"h3": {
|
||||
"fontColor": "#333333",
|
||||
"fontFamily": "Trebuchet MS",
|
||||
"fontSize": "22px"
|
||||
},
|
||||
"link": {
|
||||
"fontColor": "#21759B",
|
||||
"textDecoration": "underline"
|
||||
},
|
||||
"wrapper": {
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"body": {
|
||||
"backgroundColor": "#eeeeee"
|
||||
}
|
||||
},
|
||||
"blockDefaults": {
|
||||
"automatedLatestContent": {
|
||||
"amount": "5",
|
||||
"withLayout": false,
|
||||
"contentType": "post",
|
||||
"inclusionType": "include",
|
||||
"displayType": "excerpt",
|
||||
"titleFormat": "h1",
|
||||
"titleAlignment": "left",
|
||||
"titleIsLink": false,
|
||||
"imageFullWidth": false,
|
||||
"featuredImagePosition": "belowTitle",
|
||||
"showAuthor": "no",
|
||||
"authorPrecededBy": "Author:",
|
||||
"showCategories": "no",
|
||||
"categoriesPrecededBy": "Categories:",
|
||||
"readMoreType": "button",
|
||||
"readMoreText": "Read more",
|
||||
"readMoreButton": {
|
||||
"text": "Read more",
|
||||
"url": "[postLink]",
|
||||
"context": "automatedLatestContent.readMoreButton",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "#2ea1cd",
|
||||
"borderColor": "#0074a2",
|
||||
"borderWidth": "1px",
|
||||
"borderRadius": "5px",
|
||||
"borderStyle": "solid",
|
||||
"width": "180px",
|
||||
"lineHeight": "40px",
|
||||
"fontColor": "#ffffff",
|
||||
"fontFamily": "Verdana",
|
||||
"fontSize": "18px",
|
||||
"fontWeight": "normal",
|
||||
"textAlign": "center"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sortBy": "newest",
|
||||
"showDivider": true,
|
||||
"divider": {
|
||||
"context": "automatedLatestContent.divider",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent",
|
||||
"padding": "13px",
|
||||
"borderStyle": "solid",
|
||||
"borderWidth": "3px",
|
||||
"borderColor": "#aaaaaa"
|
||||
}
|
||||
}
|
||||
},
|
||||
"backgroundColor": "#ffffff",
|
||||
"backgroundColorAlternate": "#eeeeee"
|
||||
},
|
||||
"automatedLatestContentLayout": {
|
||||
"amount": "5",
|
||||
"withLayout": true,
|
||||
"contentType": "post",
|
||||
"inclusionType": "include",
|
||||
"displayType": "excerpt",
|
||||
"titleFormat": "h1",
|
||||
"titleAlignment": "left",
|
||||
"titleIsLink": false,
|
||||
"imageFullWidth": false,
|
||||
"featuredImagePosition": "alternate",
|
||||
"showAuthor": "no",
|
||||
"authorPrecededBy": "Author:",
|
||||
"showCategories": "no",
|
||||
"categoriesPrecededBy": "Categories:",
|
||||
"readMoreType": "button",
|
||||
"readMoreText": "Read more",
|
||||
"readMoreButton": {
|
||||
"text": "Read more",
|
||||
"url": "[postLink]",
|
||||
"context": "automatedLatestContentLayout.readMoreButton",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "#2ea1cd",
|
||||
"borderColor": "#0074a2",
|
||||
"borderWidth": "1px",
|
||||
"borderRadius": "5px",
|
||||
"borderStyle": "solid",
|
||||
"width": "180px",
|
||||
"lineHeight": "40px",
|
||||
"fontColor": "#ffffff",
|
||||
"fontFamily": "Verdana",
|
||||
"fontSize": "18px",
|
||||
"fontWeight": "normal",
|
||||
"textAlign": "center"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sortBy": "newest",
|
||||
"showDivider": true,
|
||||
"divider": {
|
||||
"context": "automatedLatestContentLayout.divider",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent",
|
||||
"padding": "13px",
|
||||
"borderStyle": "solid",
|
||||
"borderWidth": "3px",
|
||||
"borderColor": "#aaaaaa"
|
||||
}
|
||||
}
|
||||
},
|
||||
"backgroundColor": "#ffffff",
|
||||
"backgroundColorAlternate": "#eeeeee"
|
||||
},
|
||||
"button": {
|
||||
"text": "Read the post",
|
||||
"url": "[postLink]",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "#2ea1cd",
|
||||
"borderColor": "#0074a2",
|
||||
"borderWidth": "1px",
|
||||
"borderRadius": "5px",
|
||||
"borderStyle": "solid",
|
||||
"width": "180px",
|
||||
"lineHeight": "40px",
|
||||
"fontColor": "#ffffff",
|
||||
"fontFamily": "Verdana",
|
||||
"fontSize": "18px",
|
||||
"fontWeight": "normal",
|
||||
"textAlign": "center"
|
||||
}
|
||||
},
|
||||
"type": "button"
|
||||
},
|
||||
"container": {
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent"
|
||||
}
|
||||
}
|
||||
},
|
||||
"divider": {
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent",
|
||||
"padding": "13px",
|
||||
"borderStyle": "solid",
|
||||
"borderWidth": "3px",
|
||||
"borderColor": "#aaaaaa"
|
||||
}
|
||||
},
|
||||
"type": "divider"
|
||||
},
|
||||
"footer": {
|
||||
"text": "<p><a href=\"[link:subscription_unsubscribe_url]\">Unsubscribe</a> | <a href=\"[link:subscription_manage_url]\">Manage subscription</a><br />Add your postal address here!</p>",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent"
|
||||
},
|
||||
"text": {
|
||||
"fontColor": "#222222",
|
||||
"fontFamily": "Arial",
|
||||
"fontSize": "12px",
|
||||
"textAlign": "center"
|
||||
},
|
||||
"link": {
|
||||
"fontColor": "#6cb7d4",
|
||||
"textDecoration": "none"
|
||||
}
|
||||
}
|
||||
},
|
||||
"posts": {
|
||||
"amount": "10",
|
||||
"withLayout": true,
|
||||
"contentType": "post",
|
||||
"postStatus": "publish",
|
||||
"inclusionType": "include",
|
||||
"displayType": "excerpt",
|
||||
"titleFormat": "h1",
|
||||
"titleAlignment": "left",
|
||||
"titleIsLink": false,
|
||||
"imageFullWidth": false,
|
||||
"featuredImagePosition": "alternate",
|
||||
"showAuthor": "no",
|
||||
"authorPrecededBy": "Author:",
|
||||
"showCategories": "no",
|
||||
"categoriesPrecededBy": "Categories:",
|
||||
"readMoreType": "link",
|
||||
"readMoreText": "Read more",
|
||||
"readMoreButton": {
|
||||
"text": "Read more",
|
||||
"url": "[postLink]",
|
||||
"context": "posts.readMoreButton",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "#2ea1cd",
|
||||
"borderColor": "#0074a2",
|
||||
"borderWidth": "1px",
|
||||
"borderRadius": "5px",
|
||||
"borderStyle": "solid",
|
||||
"width": "180px",
|
||||
"lineHeight": "40px",
|
||||
"fontColor": "#ffffff",
|
||||
"fontFamily": "Verdana",
|
||||
"fontSize": "18px",
|
||||
"fontWeight": "normal",
|
||||
"textAlign": "center"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sortBy": "newest",
|
||||
"showDivider": true,
|
||||
"divider": {
|
||||
"context": "posts.divider",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent",
|
||||
"padding": "13px",
|
||||
"borderStyle": "solid",
|
||||
"borderWidth": "3px",
|
||||
"borderColor": "#aaaaaa"
|
||||
}
|
||||
}
|
||||
},
|
||||
"backgroundColor": "#ffffff",
|
||||
"backgroundColorAlternate": "#eeeeee"
|
||||
},
|
||||
"social": {
|
||||
"iconSet": "default",
|
||||
"icons": [
|
||||
{
|
||||
"type": "socialIcon",
|
||||
"iconType": "facebook",
|
||||
"link": "http://www.facebook.com",
|
||||
"image": "http://localhost/wp-content/plugins/mailpoet/assets/img/newsletter_editor/social-icons/01-social/Facebook.png?mailpoet_version=3.7.8",
|
||||
"height": "32px",
|
||||
"width": "32px",
|
||||
"text": "Facebook"
|
||||
},
|
||||
{
|
||||
"type": "socialIcon",
|
||||
"iconType": "twitter",
|
||||
"link": "http://www.twitter.com",
|
||||
"image": "http://localhost/wp-content/plugins/mailpoet/assets/img/newsletter_editor/social-icons/01-social/Twitter.png?mailpoet_version=3.7.8",
|
||||
"height": "32px",
|
||||
"width": "32px",
|
||||
"text": "Twitter"
|
||||
}
|
||||
]
|
||||
},
|
||||
"spacer": {
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent",
|
||||
"height": "40px"
|
||||
}
|
||||
}
|
||||
},
|
||||
"header": {
|
||||
"text": "Display problems? <a href=\"[link:newsletter_view_in_browser_url]\">Open this email in your web browser.</a>",
|
||||
"styles": {
|
||||
"block": {
|
||||
"backgroundColor": "transparent"
|
||||
},
|
||||
"text": {
|
||||
"fontColor": "#222222",
|
||||
"fontFamily": "Arial",
|
||||
"fontSize": "12px",
|
||||
"textAlign": "center"
|
||||
},
|
||||
"link": {
|
||||
"fontColor": "#6cb7d4",
|
||||
"textDecoration": "underline"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -61,4 +61,16 @@ class AcceptanceTester extends \Codeception\Actor {
|
||||
$I->click($link, ['xpath' => '//*[text()="' . $item_name . '"]//ancestor::tr']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a value from select2 input field.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $element
|
||||
*/
|
||||
public function selectOptionInSelect2($value, $element = 'input.select2-search__field') {
|
||||
$I = $this;
|
||||
$I->fillField($element, $value);
|
||||
$I->pressKey($element, \WebDriverKeys::ENTER);
|
||||
}
|
||||
|
||||
}
|
||||
|
50
tests/acceptance/EditExistingPostNotificationEmailCest.php
Normal file
50
tests/acceptance/EditExistingPostNotificationEmailCest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Test\Acceptance;
|
||||
|
||||
use MailPoet\Test\DataFactories\Newsletter;
|
||||
|
||||
require_once __DIR__ . '/../DataFactories/Newsletter.php';
|
||||
|
||||
class EditExistingPostNotificationEmailCest {
|
||||
function editSubjectAndSchedule(\AcceptanceTester $I) {
|
||||
$I->wantTo('Edit existing post notification email');
|
||||
|
||||
$newsletter_title = 'Edit Test Post Notification';
|
||||
$newsletter_edited_title = 'Edit Test Post Notification Edited';
|
||||
|
||||
// step 1 - Prepare post notification data
|
||||
$form = new Newsletter();
|
||||
$newsletter = $form->withSubject($newsletter_title)
|
||||
->withType('notification')
|
||||
->withPostNoticationOptions()
|
||||
->create();
|
||||
|
||||
// step 2 - Open list of post notifications
|
||||
$I->login();
|
||||
$I->amOnMailpoetPage('Emails');
|
||||
$I->click('Post Notifications', '[data-automation-id="newsletters_listing_tabs"]');
|
||||
|
||||
// step 3 - Open editation of post notifcation newsletter
|
||||
$listing_automation_selector = '[data-automation-id="listing_item_' . $newsletter->id . '"]';
|
||||
$I->waitForText('Edit Test Post Notification', 10, $listing_automation_selector);
|
||||
$I->clickItemRowActionByItemName($newsletter_title, 'Edit');
|
||||
|
||||
// step 4 - Edit subject
|
||||
$title_element = '[data-automation-id="newsletter_title"]';
|
||||
$I->waitForElement($title_element);
|
||||
$I->seeInCurrentUrl('mailpoet-newsletter-editor');
|
||||
$I->fillField($title_element, $newsletter_edited_title);
|
||||
|
||||
// step 5 - Change schedule, list and activate
|
||||
$I->click('Next');
|
||||
$I->waitForElement('input.select2-search__field');
|
||||
$I->seeInCurrentUrl('#/send');
|
||||
$I->selectOption('[data-automation-id="newsletter_interval_type"]', 'Weekly on...');
|
||||
$I->selectOptionInSelect2( 'WordPress Users');
|
||||
$newsletter_listing_element = '[data-automation-id="listing_item_' . basename($I->getCurrentUrl()) . '"]';
|
||||
$I->click('Activate');
|
||||
$I->waitForElement($newsletter_listing_element);
|
||||
$I->see($newsletter_edited_title, $newsletter_listing_element);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user