diff --git a/assets/js/src/form/fields/select.jsx b/assets/js/src/form/fields/select.jsx index f2014ae3df..bef808654c 100644 --- a/assets/js/src/form/fields/select.jsx +++ b/assets/js/src/form/fields/select.jsx @@ -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} diff --git a/assets/js/src/newsletters/types/notification/scheduling.jsx b/assets/js/src/newsletters/types/notification/scheduling.jsx index 4bd6916b6d..a2df15fcb6 100644 --- a/assets/js/src/newsletters/types/notification/scheduling.jsx +++ b/assets/js/src/newsletters/types/notification/scheduling.jsx @@ -134,6 +134,7 @@ const NotificationScheduling = React.createClass({ field={intervalField} item={this.getCurrentValue()} onValueChange={this.handleIntervalChange} + automationId="newsletter_interval_type" /> {nthWeekDaySelection} diff --git a/tests/DataFactories/Newsletter.php b/tests/DataFactories/Newsletter.php new file mode 100644 index 0000000000..cf067fb6d3 --- /dev/null +++ b/tests/DataFactories/Newsletter.php @@ -0,0 +1,104 @@ +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; + } +} \ No newline at end of file diff --git a/tests/_data/newsletterWithALC.json b/tests/_data/newsletterWithALC.json new file mode 100644 index 0000000000..064aed8306 --- /dev/null +++ b/tests/_data/newsletterWithALC.json @@ -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": "
Unsubscribe | Manage subscription
Add your postal address here!