[MAILPOET-1263] Force user to create ALC block for post notification
This commit is contained in:
@ -305,6 +305,13 @@ define([
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((App.getNewsletter().get('type') === 'notification') &&
|
||||||
|
contents.indexOf('automatedLatestContent') < 0
|
||||||
|
) {
|
||||||
|
this.showValidationError(MailPoet.I18n.t('automatedLatestContentMissing'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.hideValidationError();
|
this.hideValidationError();
|
||||||
},
|
},
|
||||||
showValidationError: function (message) {
|
showValidationError: function (message) {
|
||||||
|
@ -101,8 +101,10 @@ define([
|
|||||||
|
|
||||||
describe('view', function () {
|
describe('view', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
var newsletter = { get: sinon.stub().withArgs('type').returns('newsletter') };
|
||||||
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
|
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
|
||||||
global.stubConfig(EditorApplication);
|
global.stubConfig(EditorApplication);
|
||||||
|
EditorApplication.getNewsletter = sinon.stub().returns(newsletter);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders', function () {
|
it('renders', function () {
|
||||||
@ -110,6 +112,41 @@ define([
|
|||||||
expect(view.render).to.not.throw();
|
expect(view.render).to.not.throw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('validateNewsletter', function () {
|
||||||
|
var hideValidationErrorStub;
|
||||||
|
var view;
|
||||||
|
beforeEach(function () {
|
||||||
|
view = new (SaveComponent.SaveView)();
|
||||||
|
hideValidationErrorStub = sinon.stub(view, 'hideValidationError');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides errors for valid newsletter', function () {
|
||||||
|
view.validateNewsletter({});
|
||||||
|
expect(hideValidationErrorStub.callCount).to.be.equal(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides errors for valid post notification', function () {
|
||||||
|
var newsletter = { get: sinon.stub().withArgs('type').returns('notification') };
|
||||||
|
EditorApplication.getNewsletter = sinon.stub().returns(newsletter);
|
||||||
|
view.validateNewsletter({
|
||||||
|
content: {
|
||||||
|
blocks: [
|
||||||
|
{ type: 'automatedLatestContent' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(hideValidationErrorStub.callCount).to.be.equal(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows error for notification email type when ALC content is not present', function () {
|
||||||
|
var newsletter = { get: sinon.stub().withArgs('type').returns('notification') };
|
||||||
|
var showValidationErrorStub = sinon.stub(view, 'showValidationError');
|
||||||
|
EditorApplication.getNewsletter = sinon.stub().returns(newsletter);
|
||||||
|
view.validateNewsletter({});
|
||||||
|
expect(showValidationErrorStub.callCount).to.be.equal(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('once rendered', function () {
|
describe('once rendered', function () {
|
||||||
var view;
|
var view;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -329,6 +329,7 @@
|
|||||||
'failedToFetchRenderedPosts': __('Failed to fetch rendered posts'),
|
'failedToFetchRenderedPosts': __('Failed to fetch rendered posts'),
|
||||||
'shortcodesWindowTitle': __('Select a shortcode'),
|
'shortcodesWindowTitle': __('Select a shortcode'),
|
||||||
'unsubscribeLinkMissing': __('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.'),
|
'unsubscribeLinkMissing': __('All emails must include an "Unsubscribe" link. Add a footer widget to your email to continue.'),
|
||||||
|
'automatedLatestContentMissing': __('Please add an "Automated Latest Content" widget to the email from the right sidebar.'),
|
||||||
'newsletterPreviewEmailMissing': __('Enter an email address to send the preview newsletter to.'),
|
'newsletterPreviewEmailMissing': __('Enter an email address to send the preview newsletter to.'),
|
||||||
'newsletterPreviewSent': __('Your test email has been sent!'),
|
'newsletterPreviewSent': __('Your test email has been sent!'),
|
||||||
'templateNameMissing': __('Please add a template name'),
|
'templateNameMissing': __('Please add a template name'),
|
||||||
|
Reference in New Issue
Block a user