Update test to a new component

[MAILPOET-1710]
This commit is contained in:
Pavel Dohnal
2019-02-27 18:07:35 +01:00
committed by M. Shull
parent 5df73d3e0c
commit 56680816c0
4 changed files with 34 additions and 42 deletions

View File

@@ -48,7 +48,7 @@ class ConfirmTitleAlignmentSettingsInALCBlockCest {
$I->waitForText($post_title, 60);
// assert no vertical element with two text block is present
$I->cantSeeElement('.mailpoet_container_vertical > .mailpoet_text_block + .mailpoet_text_block');
$I->cantSeeElementInDOM('.mailpoet_container_vertical > .mailpoet_text_block + .mailpoet_text_block');
}
}

View File

@@ -94,9 +94,9 @@ global.stubImage = function (defaultWidth, defaultHeight) {
testHelpers.loadTemplate('blocks/base/toolsGeneric.hbs', window, { id: 'newsletter_editor_template_tools_generic' });
testHelpers.loadTemplate('blocks/automatedLatestContent/block.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_block' });
testHelpers.loadTemplate('blocks/automatedLatestContent/widget.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_widget' });
testHelpers.loadTemplate('blocks/automatedLatestContent/settings.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_settings' });
testHelpers.loadTemplate('blocks/automatedLatestContentLayout/block.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_layout_block' });
testHelpers.loadTemplate('blocks/automatedLatestContentLayout/widget.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_layout_widget' });
testHelpers.loadTemplate('blocks/automatedLatestContentLayout/settings.hbs', window, { id: 'newsletter_editor_template_automated_latest_content_layout_settings' });
testHelpers.loadTemplate('blocks/button/block.hbs', window, { id: 'newsletter_editor_template_button_block' });
testHelpers.loadTemplate('blocks/button/widget.hbs', window, { id: 'newsletter_editor_template_button_widget' });
@@ -218,9 +218,9 @@ global.templates = {
spacerInsertion: Handlebars.compile(jQuery('#newsletter_editor_template_spacer_widget').html()),
spacerBlockSettings: Handlebars.compile(jQuery('#newsletter_editor_template_spacer_settings').html()),
automatedLatestContentBlock: Handlebars.compile(jQuery('#newsletter_editor_template_automated_latest_content_block').html()),
automatedLatestContentInsertion: Handlebars.compile(jQuery('#newsletter_editor_template_automated_latest_content_widget').html()),
automatedLatestContentBlockSettings: Handlebars.compile(jQuery('#newsletter_editor_template_automated_latest_content_settings').html()),
automatedLatestContentLayoutBlock: Handlebars.compile(jQuery('#newsletter_editor_template_automated_latest_content_layout_block').html()),
automatedLatestContentLayoutInsertion: Handlebars.compile(jQuery('#newsletter_editor_template_automated_latest_content_layout_widget').html()),
automatedLatestContentLayoutBlockSettings: Handlebars.compile(jQuery('#newsletter_editor_template_automated_latest_content_layout_settings').html()),
postsBlock: Handlebars.compile(jQuery('#newsletter_editor_template_posts_block').html()),
postsInsertion: Handlebars.compile(jQuery('#newsletter_editor_template_posts_widget').html()),

View File

@@ -1,10 +1,10 @@
import App from 'newsletter_editor/App';
import AutomatedLatestContentBlock from 'newsletter_editor/blocks/automatedLatestContent';
import AutomatedLatestContentBlock from 'newsletter_editor/blocks/automatedLatestContentLayout';
import ContainerBlock from 'newsletter_editor/blocks/container';
import Communication from 'newsletter_editor/components/communication';
/* eslint-disable-next-line max-len (ES6 -> CommonJS transform needed for inject-loader) */
import AutomatedLatestContentInjector from 'inject-loader!babel-loader?plugins[]=@babel/plugin-transform-modules-commonjs!newsletter_editor/blocks/automatedLatestContent';
import AutomatedLatestContentInjector from 'inject-loader!babel-loader?plugins[]=@babel/plugin-transform-modules-commonjs!newsletter_editor/blocks/automatedLatestContentLayout';
const expect = global.expect;
const sinon = global.sinon;
@@ -14,12 +14,12 @@ const jQuery = global.jQuery;
var EditorApplication = App;
var CommunicationComponent = Communication;
describe('Automated Latest Content Supervisor', function () {
describe('Automated Latest Content Layout Supervisor', function () {
var model;
var mock;
var module;
beforeEach(function () {
model = new AutomatedLatestContentBlock.ALCSupervisor();
model = new AutomatedLatestContentBlock.ALCLayoutSupervisor();
});
it('fetches posts in bulk from the server', function () {
@@ -35,7 +35,7 @@ describe('Automated Latest Content Supervisor', function () {
},
}).default;
model = new module.ALCSupervisor();
model = new module.ALCLayoutSupervisor();
model.refresh();
mock.verify();
@@ -64,7 +64,7 @@ describe('Automated Latest Content Supervisor', function () {
});
});
describe('Automated latest content', function () {
describe('Automated latest content layout', function () {
describe('model', function () {
var model;
var module;
@@ -78,7 +78,7 @@ describe('Automated latest content', function () {
global.stubChannel(EditorApplication);
global.stubConfig(EditorApplication);
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.SuperModel);
model = new (module.AutomatedLatestContentBlockModel)();
model = new (module.AutomatedLatestContentLayoutBlockModel)();
sandbox = sinon.sandbox.create();
});
@@ -88,8 +88,8 @@ describe('Automated latest content', function () {
sandbox.restore();
});
it('has automatedLatestContent type', function () {
expect(model.get('type')).to.equal('automatedLatestContent');
it('has automatedLatestContentLayout type', function () {
expect(model.get('type')).to.equal('automatedLatestContentLayout');
});
it('has post amount limit', function () {
@@ -129,7 +129,7 @@ describe('Automated latest content', function () {
});
it('has featured image position', function () {
expect(model.get('featuredImagePosition')).to.match(/^(aboveTitle|belowTitle|none)$/);
expect(model.get('featuredImagePosition')).to.match(/^(centered|left|right|alternate|none)$/);
});
it('has an option to display author', function () {
@@ -175,7 +175,7 @@ describe('Automated latest content', function () {
it('uses defaults from config when they are set', function () {
global.stubConfig(EditorApplication, {
blockDefaults: {
automatedLatestContent: {
automatedLatestContentLayout: {
amount: '17',
contentType: 'mailpoet_page', // 'post'|'page'|'mailpoet_page'
inclusionType: 'exclude', // 'include'|'exclude'
@@ -220,7 +220,7 @@ describe('Automated latest content', function () {
},
},
});
model = new (module.AutomatedLatestContentBlockModel)();
model = new (module.AutomatedLatestContentLayoutBlockModel)();
expect(model.get('amount')).to.equal('17');
expect(model.get('contentType')).to.equal('mailpoet_page');
@@ -254,7 +254,7 @@ describe('Automated latest content', function () {
it('accepts displayable posts', function () {
EditorApplication.getBlockTypeModel = sinon.stub()
.returns(ContainerBlock.ContainerBlockModel);
model = new (module.AutomatedLatestContentBlockModel)();
model = new (module.AutomatedLatestContentLayoutBlockModel)();
model.updatePosts([{
type: 'someCustomType',
@@ -264,7 +264,7 @@ describe('Automated latest content', function () {
expect(model.get('_container.blocks').first().get('type')).to.equal('someCustomType');
});
it('updates blockDefaults.automatedLatestContent when handling changes', function () {
it('updates blockDefaults.automatedLatestContentLayout when handling changes', function () {
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
model.set('amount', '17');
model.set('contentType', 'mailpoet_page');
@@ -283,7 +283,7 @@ describe('Automated latest content', function () {
model.set('sortBy', 'oldest');
model.set('showDivider', false);
expect(stub.callCount).to.equal(16);
expect(stub.getCall(15).args[0]).to.equal('blockDefaults.automatedLatestContent');
expect(stub.getCall(15).args[0]).to.equal('blockDefaults.automatedLatestContentLayout');
expect(stub.getCall(15).args[1]).to.deep.equal(model.toJSON());
});
});
@@ -302,8 +302,8 @@ describe('Automated latest content', function () {
global.stubConfig(EditorApplication);
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
EditorApplication.getBlockTypeView = sinon.stub().returns(Backbone.View);
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockView)({ model: model });
model = new (module.AutomatedLatestContentLayoutBlockModel)();
view = new (module.AutomatedLatestContentLayoutBlockView)({ model: model });
});
afterEach(function () {
@@ -326,7 +326,7 @@ describe('Automated latest content', function () {
global.stubConfig(EditorApplication);
EditorApplication.getBlockTypeModel = sinon.stub().returns(Backbone.Model);
EditorApplication.getBlockTypeView = sinon.stub().returns(Backbone.View);
view = new (AutomatedLatestContentBlock.AutomatedLatestContentBlockView)({
view = new (AutomatedLatestContentBlock.AutomatedLatestContentLayoutBlockView)({
model: { set: sinon.stub() },
});
});
@@ -401,8 +401,8 @@ describe('Automated latest content', function () {
});
beforeEach(function () {
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockSettingsView)({ model: model });
model = new (module.AutomatedLatestContentLayoutBlockModel)();
view = new (module.AutomatedLatestContentLayoutBlockSettingsView)({ model: model });
});
after(function () {
@@ -415,8 +415,8 @@ describe('Automated latest content', function () {
describe('once rendered', function () {
beforeEach(function () {
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockSettingsView)({ model: model });
model = new (module.AutomatedLatestContentLayoutBlockModel)();
view = new (module.AutomatedLatestContentLayoutBlockSettingsView)({ model: model });
view.render();
});
@@ -524,8 +524,8 @@ describe('Automated latest content', function () {
describe('when "title only" display type is selected', function () {
beforeEach(function () {
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockSettingsView)({ model: model });
model = new (module.AutomatedLatestContentLayoutBlockModel)();
view = new (module.AutomatedLatestContentLayoutBlockSettingsView)({ model: model });
view.render();
view.$('.mailpoet_automated_latest_content_display_type').val('titleOnly').change();
});
@@ -536,8 +536,8 @@ describe('Automated latest content', function () {
describe('when "title as list" is selected', function () {
beforeEach(function () {
model = new (module.AutomatedLatestContentBlockModel)();
view = new (module.AutomatedLatestContentBlockSettingsView)({ model: model });
model = new (module.AutomatedLatestContentLayoutBlockModel)();
view = new (module.AutomatedLatestContentLayoutBlockSettingsView)({ model: model });
view.render();
view.$('.mailpoet_automated_latest_content_display_type').val('titleOnly').change();
view.$('.mailpoet_automated_latest_content_title_format').val('ul').change();
@@ -567,14 +567,6 @@ describe('Automated latest content', function () {
});
});
});
it.skip('closes the sidepanel after "Done" is clicked', function () {
var mock = sinon.mock().once();
global.MailPoet.Modal.cancel = mock;
view.$('.mailpoet_done_editing').click();
mock.verify();
delete (global.MailPoet.Modal.cancel);
});
});
});
});

View File

@@ -356,7 +356,7 @@ const testConfig = {
'components/styles.spec.js',
'components/communication.spec.js',
'blocks/automatedLatestContent.spec.js',
'blocks/automatedLatestContentLayout.spec.js',
'blocks/button.spec.js',
'blocks/container.spec.js',
'blocks/divider.spec.js',