8
0
فهرست منبع

Added 3 simple manual tests.

Maciej Bukowski 7 سال پیش
والد
کامیت
59a8f7acbd

+ 6 - 0
packages/ckeditor5-autosave/tests/manual/autosave.html

@@ -0,0 +1,6 @@
+<button id="destroy-editor-button">Destroy editor</button>
+
+<div id="editor">
+	<h2>Heading 1</h2>
+	<p>Paragraph</p>
+</div>

+ 45 - 0
packages/ckeditor5-autosave/tests/manual/autosave.js

@@ -0,0 +1,45 @@
+/**
+ * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* globals document, window, console */
+
+import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
+
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import Autosave from '../../src/autosave';
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		plugins: [ ArticlePluginSet, Autosave ],
+		toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo' ],
+		image: {
+			toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ],
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
+
+		const destroyButton = document.getElementById( 'destroy-editor-button' );
+		destroyButton.addEventListener( 'click', () => editor.destroy() );
+
+		const autosave = editor.plugins.get( Autosave );
+		autosave.provider = {
+			save() {
+				const data = editor.getData();
+
+				return saveEditorContentToDatabase( data );
+			}
+		};
+	} );
+
+function saveEditorContentToDatabase( data ) {
+	return new Promise( res => {
+		window.setTimeout( () => {
+			console.log( data );
+
+			res();
+		}, 1000 );
+	} );
+}

+ 5 - 0
packages/ckeditor5-autosave/tests/manual/autosave.md

@@ -0,0 +1,5 @@
+1. Play with the editor. You should logs of the editor's data in console with 1s timeout (it simulates the back-end). You should not see logs when you changes the selection.
+
+1. Type something and quickly try to reload the page. You should see something like this: `Reload site? Changes that you made may not be saved.`.
+
+1. Type something and quickly and click the `destroy editor` button. Most recent changes should be logged to the console.