8
0
Quellcode durchsuchen

Improved manual test with data initialization.

Szymon Kupś vor 7 Jahren
Ursprung
Commit
1720be4e99

+ 10 - 24
packages/ckeditor5-editor-classic/tests/manual/classiceditor-data.js

@@ -13,28 +13,19 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import Undo from '@ckeditor/ckeditor5-undo/src/undo';
 import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
 import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
-import testUtils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
-
-let editor, editable, observer;
 
 const data = '<h2>Hello world!</h2><p>This is an editor instance.</p>';
 
+window.editors = [];
+
 function initEditor() {
 	ClassicEditor
 		.create( data, {
 			plugins: [ Enter, Typing, Paragraph, Undo, Heading, Bold, Italic ],
 			toolbar: [ 'heading', '|', 'bold', 'italic', 'undo', 'redo' ]
 		} )
-		.then( newEditor => {
-			console.log( 'Editor was initialized', newEditor );
-			console.log( 'You can now play with it using global `editor` and `editable` variables.' );
-
-			window.editor = editor = newEditor;
-			window.editable = editable = editor.editing.view.document.getRoot();
-
-			observer = testUtils.createObserver();
-			observer.observe( 'Editable', editable, [ 'isFocused' ] );
-
+		.then( editor => {
+			window.editors.push( editor );
 			document.body.appendChild( editor.element );
 		} )
 		.catch( err => {
@@ -43,17 +34,12 @@ function initEditor() {
 }
 
 function destroyEditor() {
-	editor.destroy()
-		.then( () => {
-			editor.element.remove();
-
-			window.editor = editor = null;
-			window.editable = editable = null;
-
-			observer.stopListening();
-			observer = null;
-			console.log( 'Editor was destroyed' );
-		} );
+	window.editors.forEach( editor => {
+		editor.destroy()
+			.then( () => {
+				editor.element.remove();
+			} );
+	} );
 }
 
 document.getElementById( 'initEditor' ).addEventListener( 'click', initEditor );

+ 2 - 17
packages/ckeditor5-editor-classic/tests/manual/classiceditor-data.md

@@ -1,18 +1,3 @@
 1. Click "Init editor".
-2. Expected:
-  * Framed editor should be created.
-  * Original element should disappear.
-  * There should be a toolbar with "Bold", "Italic", "Undo" and "Redo" buttons.
-3. Click "Destroy editor".
-4. Expected:
-  * Editor should be destroyed.
-  * Original element should be visible.
-  * The element should contain its data (updated).
-  * The 'ck-body region' should be removed.
-
-## Notes:
-
-* You can play with:
-  * `editable.isReadOnly`,
-* Changes to `editable.isFocused` should be logged to the console.
-* Features should work.
+2. New editor instance should be appended to the document with initial data in it.
+3. After clicking "Destroy editor" all editors should be removed from the document.