Browse Source

Tests: Extracted a common function that renders all the fixture buttons. Also added full page paste (combined 3 different pages).

Marek Lewandowski 5 years ago
parent
commit
8c697de8f7

+ 24 - 7
tests/_utils/utils.js

@@ -14,24 +14,41 @@ import FontSize from '@ckeditor/ckeditor5-font/src/fontsize';
 import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
 import StrikeThrough from '@ckeditor/ckeditor5-basic-styles/src/strikethrough';
 
+const predefinedFiles = [
+	'small',
+	'medium',
+	'large',
+	'small-inline-css',
+	'full-websites-styled'
+];
+
+/**
+ * Renders a button for each performance fixture in a given `container`.
+ *
+ * @param {HTMLElement} container
+ */
+export function renderPerformanceDataButtons( container ) {
+	let html = '';
+
+	for ( const fixtureName of predefinedFiles ) {
+		html += `<button id="${ fixtureName }-content" data-file-name="${ fixtureName }" disabled>${ fixtureName }</button>`;
+	}
+
+	container.innerHTML = html;
+}
+
 /**
  * Loads a predefined set of performance markup files.
  *
  *		loadPerformanceData()
  *			.then( fixtures => {
  *				window.editor.setData( fixtures.small );
+ *				console.log( fixtures.medium );
  *			} );
  *
  * @returns {Promise.<Object.<String, String>>}
  */
 export function loadPerformanceData() {
-	const predefinedFiles = [
-		'small',
-		'medium',
-		'large',
-		'small-inline-css'
-	];
-
 	return Promise.all( predefinedFiles.map( fileName => getFileContents( fileName ) ) )
 		.then( responses => {
 			const returnValue = {};

File diff suppressed because it is too large
+ 5254 - 0
tests/manual/performance/_utils/full-websites-styled.txt


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

@@ -6,9 +6,7 @@
 
 <div id="test-controls">
 	Initialize editor 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>
+	<span id="fixture-buttons"></span>
 	HTML payload.
 </div>
 
@@ -17,3 +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>

+ 3 - 1
tests/manual/performance/editorinit.js

@@ -7,7 +7,9 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
-import { loadPerformanceData } from '../../_utils/utils';
+import { loadPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
+
+renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
 loadPerformanceData()
 	.then( fixtures => {

+ 2 - 6
tests/manual/performance/multipleeditors.html

@@ -1,13 +1,9 @@
 <div id="test-controls">
 	Initialize multiple editors 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>
+	<span id="fixture-buttons"></span>
 	HTML payload.
 </div>
 
 <hr>
 
-<div id="editors-wrapper">
-
-</div>
+<div id="editors-wrapper"></div>

+ 3 - 1
tests/manual/performance/multipleeditors.js

@@ -7,10 +7,12 @@
 
 import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
-import { loadPerformanceData } from '../../_utils/utils';
+import { loadPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
 
 const editorCount = 5;
 
+renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
+
 loadPerformanceData()
 	.then( fixtures => {
 		const editorsWrapper = document.getElementById( 'editors-wrapper' );

+ 1 - 3
tests/manual/performance/richeditor.html

@@ -1,8 +1,6 @@
 <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>
+	<span id="fixture-buttons"></span>
 	HTML payload.
 </div>
 

+ 3 - 1
tests/manual/performance/richeditor.js

@@ -36,7 +36,9 @@ 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';
+import { loadPerformanceData, renderPerformanceDataButtons } from '../../_utils/utils';
+
+renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {

+ 1 - 4
tests/manual/performance/setdata.html

@@ -1,9 +1,6 @@
 <div id="test-controls">
 	Call <code>editor.setData()</code> with:
-	<button id="small-content" data-file-name="small" disabled>small</button>
-	<button id="small-inline-css-content" data-file-name="small-inline-css" disabled>small-inline-css</button>
-	<button id="medium-content" data-file-name="medium" disabled>medium</button>
-	<button id="large-content" data-file-name="large" disabled>large</button>
+	<span id="fixture-buttons"></span>
 	HTML payload.
 </div>
 

+ 3 - 1
tests/manual/performance/setdata.js

@@ -5,7 +5,9 @@
 
 /* globals window, document */
 
-import { loadPerformanceData, createPerformanceEditor } from '../../_utils/utils';
+import { loadPerformanceData, createPerformanceEditor, renderPerformanceDataButtons } from '../../_utils/utils';
+
+renderPerformanceDataButtons( document.querySelector( '#fixture-buttons' ) );
 
 createPerformanceEditor( document.querySelector( '#editor' ) )
 	.then( loadPerformanceData )