Browse Source

Tests: Performance tests are now using fixtures from a different path.

Marek Lewandowski 5 years ago
parent
commit
ee22b0a303

+ 12 - 13
tests/_utils/utils.js

@@ -43,24 +43,22 @@ export function renderPerformanceDataButtons( container ) {
 }
 
 /**
- * Loads a predefined set of performance markup files.
+ * Returns a predefined set of performance markup files.
  *
- *		loadPerformanceData()
- *			.then( fixtures => {
- *				window.editor.setData( fixtures.small );
- *				console.log( fixtures.medium );
- *			} );
+ *		const fixtures = loadPerformanceData();
+ *		window.editor.setData( fixtures.small );
+ *		console.log( fixtures.medium );
  *
- * @returns {Promise.<Object.<String, String>>}
+ * @returns {Object.<String, String>}
  */
-export function loadPerformanceData() {
-	return Promise.resolve( {
-		fullWebsitesStyled: fullWebsitesStyledFixture,
-		large: largeFixture,
-		medium: mediumFixture,
+export function getPerformanceData() {
+	return {
 		small: smallFixture,
+		medium: mediumFixture,
+		large: largeFixture,
 		smallInlineCss: smallInlineCssFixture,
-	} );
+		fullWebsitesStyled: fullWebsitesStyledFixture,
+	};
 }
 
 /**
@@ -108,6 +106,7 @@ export function createPerformanceEditor( domElement ) {
 	return ClassicEditor.create( domElement, config )
 		.then( editor => {
 			window.editor = editor;
+			return editor;
 		} )
 		.catch( err => {
 			console.error( err.stack );

+ 2 - 2
tests/manual/performance/editorinit.html

@@ -15,5 +15,5 @@
 <div id="editor_small" class="editor"></div>
 <div id="editor_medium" class="editor"></div>
 <div id="editor_large" class="editor"></div>
-<div id="editor_small-inline-css" class="editor"></div>
-<div id="editor_full-websites-styled" class="editor"></div>
+<div id="editor_smallInlineCss" class="editor"></div>
+<div id="editor_fullWebsitesStyled" class="editor"></div>

+ 51 - 53
tests/manual/performance/editorinit.js

@@ -7,65 +7,63 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
-import { loadPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
+import { getPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
 
 renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
-loadPerformanceData()
-	.then( fixtures => {
-		const buttons = document.querySelectorAll( '#test-controls button' );
+const fixtures = getPerformanceData();
+const buttons = document.querySelectorAll( '#test-controls button' );
 
-		for ( const button of buttons ) {
-			const fixtureName = button.getAttribute( 'data-file-name' );
-			const content = fixtures[ fixtureName ];
-			const editorElement = document.querySelector( `#editor_${ fixtureName }` );
+for ( const button of buttons ) {
+	const fixtureName = button.getAttribute( 'data-file-name' );
+	const content = fixtures[ fixtureName ];
+	const editorElement = document.querySelector( `#editor_${ fixtureName }` );
 
-			// Put the source content in editor-related elements ahead of time, so that potentially
-			// big `innerHTML` change does not affect the benchmark when pressing the button.
-			editorElement.innerHTML = content;
+	// Put the source content in editor-related elements ahead of time, so that potentially
+	// big `innerHTML` change does not affect the benchmark when pressing the button.
+	editorElement.innerHTML = content;
 
-			button.addEventListener( 'click', function() {
-				ClassicEditor
-					.create( editorElement, {
-						plugins: [ ArticlePluginSet ],
-						toolbar: [
-							'heading',
-							'|',
-							'bold',
-							'italic',
-							'link',
-							'bulletedList',
-							'numberedList',
-							'|',
-							'outdent',
-							'indent',
-							'|',
-							'blockQuote',
-							'insertTable',
-							'mediaEmbed',
-							'undo',
-							'redo'
-						],
-						image: {
-							toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
-						},
-						table: {
-							contentToolbar: [
-								'tableColumn',
-								'tableRow',
-								'mergeTableCells'
-							]
-						}
-					} )
-					.then( editor => {
-						window.editor = editor;
-					} )
-					.catch( err => {
-						console.error( err.stack );
-					} );
+	button.addEventListener( 'click', function() {
+		ClassicEditor
+			.create( editorElement, {
+				plugins: [ ArticlePluginSet ],
+				toolbar: [
+					'heading',
+					'|',
+					'bold',
+					'italic',
+					'link',
+					'bulletedList',
+					'numberedList',
+					'|',
+					'outdent',
+					'indent',
+					'|',
+					'blockQuote',
+					'insertTable',
+					'mediaEmbed',
+					'undo',
+					'redo'
+				],
+				image: {
+					toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
+				},
+				table: {
+					contentToolbar: [
+						'tableColumn',
+						'tableRow',
+						'mergeTableCells'
+					]
+				}
+			} )
+			.then( editor => {
+				window.editor = editor;
+			} )
+			.catch( err => {
+				console.error( err.stack );
 			} );
-
-			button.disabled = false;
-		}
 	} );
 
+	button.disabled = false;
+}
+

+ 57 - 59
tests/manual/performance/multipleeditors.js

@@ -7,73 +7,71 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
-import { loadPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
+import { getPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
 
 const editorCount = 5;
 
 renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
-loadPerformanceData()
-	.then( fixtures => {
-		const editorsWrapper = document.getElementById( 'editors-wrapper' );
-		const buttons = document.querySelectorAll( '#test-controls button' );
+const fixtures = getPerformanceData();
+const editorsWrapper = document.getElementById( 'editors-wrapper' );
+const buttons = document.querySelectorAll( '#test-controls button' );
 
-		for ( let i = 0; i < editorCount; i++ ) {
-			const editorElement = document.createElement( 'div' );
-			editorElement.setAttribute( 'id', `editor_${ i }` );
-			editorsWrapper.appendChild( editorElement );
-		}
-
-		for ( const button of buttons ) {
-			const fixtureName = button.getAttribute( 'data-file-name' );
-			const content = fixtures[ fixtureName ];
+for ( let i = 0; i < editorCount; i++ ) {
+	const editorElement = document.createElement( 'div' );
+	editorElement.setAttribute( 'id', `editor_${ i }` );
+	editorsWrapper.appendChild( editorElement );
+}
 
-			button.addEventListener( 'click', function() {
-				for ( let i = 0; i < editorCount; i++ ) {
-					const editorElement = document.querySelector( `#editor_${ i }` );
-					editorElement.innerHTML = content;
+for ( const button of buttons ) {
+	const fixtureName = button.getAttribute( 'data-file-name' );
+	const content = fixtures[ fixtureName ];
 
-					ClassicEditor
-						.create( editorElement, {
-							plugins: [ ArticlePluginSet ],
-							toolbar: [
-								'heading',
-								'|',
-								'bold',
-								'italic',
-								'link',
-								'bulletedList',
-								'numberedList',
-								'|',
-								'outdent',
-								'indent',
-								'|',
-								'blockQuote',
-								'insertTable',
-								'mediaEmbed',
-								'undo',
-								'redo'
-							],
-							image: {
-								toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
-							},
-							table: {
-								contentToolbar: [
-									'tableColumn',
-									'tableRow',
-									'mergeTableCells'
-								]
-							}
-						} )
-						.then( editor => {
-							window.editor = editor;
-						} )
-						.catch( err => {
-							console.error( err.stack );
-						} );
-				}
-			} );
+	button.addEventListener( 'click', function() {
+		for ( let i = 0; i < editorCount; i++ ) {
+			const editorElement = document.querySelector( `#editor_${ i }` );
+			editorElement.innerHTML = content;
 
-			button.disabled = false;
+			ClassicEditor
+				.create( editorElement, {
+					plugins: [ ArticlePluginSet ],
+					toolbar: [
+						'heading',
+						'|',
+						'bold',
+						'italic',
+						'link',
+						'bulletedList',
+						'numberedList',
+						'|',
+						'outdent',
+						'indent',
+						'|',
+						'blockQuote',
+						'insertTable',
+						'mediaEmbed',
+						'undo',
+						'redo'
+					],
+					image: {
+						toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ]
+					},
+					table: {
+						contentToolbar: [
+							'tableColumn',
+							'tableRow',
+							'mergeTableCells'
+						]
+					}
+				} )
+				.then( editor => {
+					window.editor = editor;
+				} )
+				.catch( err => {
+					console.error( err.stack );
+				} );
 		}
 	} );
+
+	button.disabled = false;
+}

+ 5 - 5
tests/manual/performance/paste.js

@@ -3,15 +3,15 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* globals window, document, DataTransfer */
+/* globals document, DataTransfer */
 
-import { loadPerformanceData, createPerformanceEditor, renderPerformanceDataButtons } from '../../_utils/utils';
+import { getPerformanceData, createPerformanceEditor, renderPerformanceDataButtons } from '../../_utils/utils';
 
 renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
 createPerformanceEditor( document.querySelector( '#editor' ) )
-	.then( loadPerformanceData )
-	.then( fixtures => {
+	.then( editor => {
+		const fixtures = getPerformanceData();
 		const buttons = document.querySelectorAll( '#test-controls button' );
 
 		for ( const button of buttons ) {
@@ -21,7 +21,7 @@ createPerformanceEditor( document.querySelector( '#editor' ) )
 				const data = new DataTransfer();
 				data.setData( 'text/html', fixtureHtml );
 
-				window.editor.editing.view.document.fire( 'clipboardInput', {
+				editor.editing.view.document.fire( 'clipboardInput', {
 					dataTransfer: data
 				} );
 			} );

+ 9 - 11
tests/manual/performance/richeditor.js

@@ -38,7 +38,7 @@ 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, renderPerformanceDataButtons } from '../../_utils/utils';
+import { getPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
 
 renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
@@ -157,16 +157,14 @@ function addUploadMockAdapter( editor ) {
 	};
 }
 
-loadPerformanceData()
-	.then( fixtures => {
-		const buttons = document.querySelectorAll( '#test-controls button' );
+const fixtures = getPerformanceData();
+const buttons = document.querySelectorAll( '#test-controls button' );
 
-		for ( const button of buttons ) {
-			button.addEventListener( 'click', function() {
-				const content = fixtures[ this.getAttribute( 'data-file-name' ) ];
+for ( const button of buttons ) {
+	button.addEventListener( 'click', function() {
+		const content = fixtures[ this.getAttribute( 'data-file-name' ) ];
 
-				window.editor.setData( content );
-			} );
-			button.disabled = false;
-		}
+		window.editor.setData( content );
 	} );
+	button.disabled = false;
+}

+ 5 - 5
tests/manual/performance/setdata.js

@@ -3,22 +3,22 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
 
-/* globals window, document */
+/* globals document */
 
-import { loadPerformanceData, createPerformanceEditor, renderPerformanceDataButtons } from '../../_utils/utils';
+import { getPerformanceData, createPerformanceEditor, renderPerformanceDataButtons } from '../../_utils/utils';
 
 renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
 createPerformanceEditor( document.querySelector( '#editor' ) )
-	.then( loadPerformanceData )
-	.then( fixtures => {
+	.then( editor => {
+		const fixtures = getPerformanceData();
 		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 );
+				editor.setData( content );
 			} );
 			button.disabled = false;
 		}