Browse Source

Fixed manual tests.

Maciej Bukowski 8 năm trước cách đây
mục cha
commit
2ea5d3bb99

+ 3 - 22
packages/ckeditor5-easy-image/tests/_utils/gettoken.js → packages/ckeditor5-easy-image/tests/_utils/gettokenurl.js

@@ -14,27 +14,8 @@ import uid from '@ckeditor/ckeditor5-utils/src/uid';
 // into a subscription at any moment, allowing you to preserve all uploaded images.
 const CLOUD_SERVICES_TOKEN_URL = 'https://j2sns7jmy0.execute-api.eu-central-1.amazonaws.com/prod/token';
 
-export default function getToken() {
-	return new Promise( ( resolve, reject ) => {
-		const xhr = new XMLHttpRequest();
-		const userId = uid();
+export default function getTokenUrl() {
+	const userId = uid();
 
-		xhr.open( 'GET', `${ CLOUD_SERVICES_TOKEN_URL }?user.id=${ userId }` );
-
-		xhr.onload = () => {
-			if ( xhr.status >= 200 && xhr.status < 300 ) {
-				const response = JSON.parse( xhr.responseText );
-
-				resolve( response.token );
-			} else {
-				reject( new Error( `XHR status: ${ xhr.status }` ) );
-			}
-		};
-
-		xhr.onerror = err => {
-			reject( err );
-		};
-
-		xhr.send( null );
-	} );
+	return `${ CLOUD_SERVICES_TOKEN_URL }?user.id=${ userId }`;
 }

+ 16 - 17
packages/ckeditor5-easy-image/tests/manual/easyimage.js

@@ -10,24 +10,23 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'
 import EasyImage from '../../src/easyimage';
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 
-import getToken from '../_utils/gettoken';
+import getTokenUrl from '../_utils/getTokenUrl';
 
-getToken()
-	.then( tokenUrl => {
-		return ClassicEditor
-			.create( document.querySelector( '#editor' ), {
-				cloudServices: {
-					tokenUrl
-				},
-				plugins: [ ArticlePluginSet, EasyImage ],
-				toolbar: [ 'headings', 'undo', 'redo', 'insertImage' ],
-				image: {
-					toolbar: [ 'imageStyleFull', 'imageStyleSide', '|', 'imageTextAlternative' ]
-				}
-			} )
-			.then( editor => {
-				window.editor = editor;
-			} );
+const tokenUrl = getTokenUrl();
+
+ClassicEditor
+	.create( document.querySelector( '#editor' ), {
+		cloudServices: {
+			tokenUrl
+		},
+		plugins: [ ArticlePluginSet, EasyImage ],
+		toolbar: [ 'headings', 'undo', 'redo', 'insertImage' ],
+		image: {
+			toolbar: [ 'imageStyleFull', 'imageStyleSide', '|', 'imageTextAlternative' ]
+		}
+	} )
+	.then( editor => {
+		window.editor = editor;
 	} )
 	.catch( err => {
 		console.error( err.stack );