8
0
Просмотр исходного кода

Tests: Added an option to set the data in rich editor test.

Marek Lewandowski 5 лет назад
Родитель
Сommit
eb0412ff81
2 измененных файлов с 26 добавлено и 0 удалено
  1. 10 0
      tests/manual/performance/richeditor.html
  2. 16 0
      tests/manual/performance/richeditor.js

+ 10 - 0
tests/manual/performance/richeditor.html

@@ -1,3 +1,13 @@
+<div id="test-controls">
+	Call <code>editor.setData()</code> with:
+	<button id="small-content" data-file-name="small" disabled>small</button>
+	<button id="medium-content" data-file-name="medium" disabled>medium</button>
+	<button id="large-content" data-file-name="large" disabled>large</button>
+	HTML payload.
+</div>
+
+<hr>
+
 <div id="word-count-wrapper" style="display:none">
 	Words: <span id="word-count"></span> Characters: <span id="character-count"></span>
 </div>

+ 16 - 0
tests/manual/performance/richeditor.js

@@ -36,6 +36,8 @@ import IndentBlock from '@ckeditor/ckeditor5-indent/src/indentblock';
 import { UploadAdapterMock } from '@ckeditor/ckeditor5-upload/tests/_utils/mocks';
 import WordCount from '@ckeditor/ckeditor5-word-count/src/wordcount';
 
+import { loadPerformanceData } from '../../_utils/utils';
+
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
 		plugins: [
@@ -148,3 +150,17 @@ function addUploadMockAdapter( editor ) {
 		return new UploadAdapterMock( loader );
 	};
 }
+
+loadPerformanceData()
+	.then( fixtures => {
+		const buttons = document.querySelectorAll( '#test-controls button' );
+
+		for ( const button of buttons ) {
+			button.addEventListener( 'click', function() {
+				const content = fixtures[ this.getAttribute( 'data-file-name' ) ];
+
+				window.editor.setData( content );
+			} );
+			button.disabled = false;
+		}
+	} );