Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 46fdc36

Browse files
authored
Merge pull request #138 from ckeditor/t/137
Fix: The `ClassicTestEditor` should not render its UI in the `constructor()`. Closes #137.
2 parents eb43b63 + c24056f commit 46fdc36

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

tests/_utils-tests/classictesteditor.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ describe( 'ClassicTestEditor', () => {
4444
expect( editor.data.processor ).to.be.instanceof( HtmlDataProcessor );
4545
} );
4646

47-
it( 'creates editable DOM', () => {
47+
it( 'creates the instance of the editable (without rendering)', () => {
4848
const editor = new ClassicTestEditor( editorElement );
4949

5050
expect( editor.ui.view.editable ).to.be.instanceOf( InlineEditableUIView );
51+
expect( editor.ui.view.editable.isRendered ).to.be.false;
52+
} );
53+
54+
it( 'creates the #ui and ui#view (without rendering)', () => {
55+
const editor = new ClassicTestEditor( editorElement );
5156

52-
expect( editor.ui.view.editableElement.tagName ).to.equal( 'DIV' );
53-
expect( editor.ui.view.editableElement ).to.equal( editor.ui.view.editable.element );
57+
expect( editor.ui ).to.be.instanceOf( EditorUI );
58+
expect( editor.ui.view ).to.be.instanceOf( BoxedEditorUIView );
59+
expect( editor.ui.view.isRendered ).to.be.false;
60+
expect( editor.ui.view.editableElement ).to.be.undefined;
5461
} );
5562

5663
it( 'creates main root element', () => {
@@ -79,11 +86,14 @@ describe( 'ClassicTestEditor', () => {
7986
} );
8087
} );
8188

82-
it( 'creates and initializes the UI', () => {
89+
it( 'renders the view including #editable and sets #editableElement', () => {
8390
return ClassicTestEditor.create( editorElement, { foo: 1 } )
8491
.then( editor => {
85-
expect( editor.ui ).to.be.instanceOf( EditorUI );
86-
expect( editor.ui.view ).to.be.instanceOf( BoxedEditorUIView );
92+
const view = editor.ui.view;
93+
94+
expect( view.isRendered ).to.be.true;
95+
expect( view.editableElement.tagName ).to.equal( 'DIV' );
96+
expect( view.editableElement ).to.equal( view.editable.element );
8797
} );
8898
} );
8999

tests/_utils/classictesteditor.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ export default class ClassicTestEditor extends Editor {
3737

3838
// Expose properties normally exposed by the ClassicEditorUI.
3939
this.ui.view.editable = new InlineEditableUIView( this.ui.view.locale );
40-
this.ui.view.main.add( this.ui.view.editable );
41-
this.ui.view.editableElement = this.ui.view.editable.element;
4240

4341
// A helper to easily replace the editor#element with editor.editable#element.
4442
this._elementReplacer = new ElementReplacer();
@@ -66,7 +64,15 @@ export default class ClassicTestEditor extends Editor {
6664

6765
resolve(
6866
editor.initPlugins()
69-
.then( () => editor.ui.view.render() )
67+
// Simulate EditorUI.init() (e.g. like in ClassicEditorUI). The ui#view
68+
// should be rendered after plugins are initialized.
69+
.then( () => {
70+
const view = editor.ui.view;
71+
72+
view.render();
73+
view.main.add( view.editable );
74+
view.editableElement = view.editable.element;
75+
} )
7076
.then( () => {
7177
editor._elementReplacer.replace( element, editor.ui.view.element );
7278
editor.fire( 'uiReady' );

0 commit comments

Comments
 (0)