diff --git a/tests/_assets/lena.jpg b/tests/_assets/lena.jpg new file mode 100644 index 00000000000..b7d60146595 Binary files /dev/null and b/tests/_assets/lena.jpg differ diff --git a/tests/plugins/uploadwidget/manual/__template__.html b/tests/plugins/uploadwidget/manual/__template__.html new file mode 100644 index 00000000000..83dfb61f32a --- /dev/null +++ b/tests/plugins/uploadwidget/manual/__template__.html @@ -0,0 +1,16 @@ + + + \ No newline at end of file diff --git a/tests/plugins/uploadwidget/manual/_helpers/xhr.js b/tests/plugins/uploadwidget/manual/_helpers/xhr.js new file mode 100644 index 00000000000..810b978f2b4 --- /dev/null +++ b/tests/plugins/uploadwidget/manual/_helpers/xhr.js @@ -0,0 +1,60 @@ +/** + * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or http://ckeditor.com/license + */ + +'use strict'; + +// Mock the real XMLHttpRequest so the upload test may work locally. + +window.XMLHttpRequest = function() { + var basePath = bender.config.tests[ bender.testData.group ].basePath; + + return { + open: function() {}, + + send: function() { + var total = 10259, + loaded = 0, + step = Math.round( total / 10 ), + xhr = this, + onprogress = this.onprogress, + onload = this.onload, + interval; + + // Wait 400 ms for every step. + interval = setInterval( function() { + // Add data to 'loaded' counter. + loaded += step; + if ( loaded > total ) { + loaded = total; + } + + // If file is not loaded call onprogress. + if ( loaded < total ) { + onprogress( { loaded: loaded } ); + } + // If file is loaded call onload. + else { + clearInterval( interval ); + xhr.status = 200; + xhr.responseText = JSON.stringify( { + fileName: 'smallmoon (another copy)(20).JPG', + uploaded: 1, + url: '\/' + basePath + '_assets\/lena.jpg', + error: { + number: 201, + message: '' + } + } ); + onload(); + } + }, 400 ); + }, + + // Abort should call onabort. + abort: function() { + this.onabort(); + } + }; +}; \ No newline at end of file diff --git a/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js b/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js new file mode 100644 index 00000000000..037af420e79 --- /dev/null +++ b/tests/plugins/uploadwidget/manual/_helpers/xhrerror.js @@ -0,0 +1,48 @@ +/** + * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or http://ckeditor.com/license + */ + +'use strict'; + +// Mock the real XMLHttpRequest so the upload test may show the effect of an error during upload. + +window.XMLHttpRequest = function() { + return { + open: function() {}, + + send: function() { + // Total file size. + var total = 10259, + loaded = 0, + step = Math.round( total / 10 ), + onprogress = this.onprogress, + onerror = this.onerror, + interval; + + // Wait 400 ms for every step. + interval = setInterval( function() { + // Add data to 'loaded' counter. + loaded += step; + if ( loaded > total ) { + loaded = total; + } + + // If less then 50% of file is loaded call onprogress. + if ( loaded < total / 2 ) { + onprogress( { loaded: loaded } ); + } + // If 50% of file is loaded call onerror and stop loading. + else { + clearInterval( interval ); + onerror(); + } + }, 400 ); + }, + + // Abort should call onabort. + abort: function() { + this.onabort(); + } + }; +}; \ No newline at end of file diff --git a/tests/plugins/uploadwidget/manual/error.md b/tests/plugins/uploadwidget/manual/error.md new file mode 100644 index 00000000000..06756ffe422 --- /dev/null +++ b/tests/plugins/uploadwidget/manual/error.md @@ -0,0 +1,11 @@ +@bender-tags: 4.5.0,tc,clipboard,widget,filetools +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, uploadwidget, basicstyles, image2, uploadimage, font, stylescombo, basicstyles, format, maximize, blockquote, list, table, resize, elementspath, justify +@bender-include: _helpers/xhrerror.js + +This test emulates an error during upload. When upload hits 50% an error occurs. + + * Drop an image. + * Check if `upload widget` is displayed. + * Check if image is removed after it reaches 50% of progress and no artifacts left. + * Check if you see a message about the error. \ No newline at end of file diff --git a/tests/plugins/uploadwidget/manual/image.md b/tests/plugins/uploadwidget/manual/image.md new file mode 100644 index 00000000000..43bbc735f8b --- /dev/null +++ b/tests/plugins/uploadwidget/manual/image.md @@ -0,0 +1,15 @@ +@bender-tags: clipboard, widget, filetools +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, uploadwidget, basicstyles, image, uploadimage, font, stylescombo, basicstyles, format, maximize, blockquote, list, table, resize, elementspath, justify +@bender-include: _helpers/xhr.js + +Test if photo uploading works properly: + +* Dropped image should be replaced by a temporary `upload widget` and by the final image (`image` plugin) when upload is done. +* `jpg`, `png` and `gif` files should be supported. +* Undo and redo during and after upload should work fine. +* It should be possible to format text and copy image during upload. +* If image is removed during upload, the process should be aborted. +* Check if you see a message about the progress, success and abort. + +**Note:** This test use upload mock which will show you *Lena* instead of the real uploaded image. \ No newline at end of file diff --git a/tests/plugins/uploadwidget/manual/image2.md b/tests/plugins/uploadwidget/manual/image2.md new file mode 100644 index 00000000000..c5845eb3e95 --- /dev/null +++ b/tests/plugins/uploadwidget/manual/image2.md @@ -0,0 +1,15 @@ +@bender-tags: 4.5.0, tc, clipboard, widget, filetools +@bender-ui: collapsed +@bender-ckeditor-plugins: wysiwygarea, toolbar, undo, uploadwidget, basicstyles, image2, uploadimage, font, stylescombo, basicstyles, format, maximize, blockquote, list, table, resize, elementspath, justify +@bender-include: _helpers/xhr.js + +Test if photo uploading works properly: + +* Dropped image should be replaced by a temporary `upload widget` and by the final image (`image2` plugin) when upload is dome. +* `jpg`, `png` and `gif` files should be supported. +* Undo and redo during and after upload should work fine. +* It should be possible to format text and copy image during upload. +* If image is removed during upload, the process should be aborted. +* Check if you see a message about the progress, success and abort. + +**Note:** This test use upload mock which will show you *Lena* instead of the real uploaded image. \ No newline at end of file