Skip to content

Commit

Permalink
Merge branch 't/16861b' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer committed Mar 9, 2017
2 parents 58726c6 + 8acc3a1 commit 96bbe7e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
13 changes: 13 additions & 0 deletions tests/plugins/uploadfile/_helpers/waitForImage.js
@@ -0,0 +1,13 @@
/* exported waitForImage */

function waitForImage( image, callback ) {
// IE needs to wait for image to be loaded so it can read width and height of the image.
if ( CKEDITOR.env.ie ) {
wait( callback, 100 );
} else {
image.on( 'load', function() {
resume( callback );
} );
wait();
}
}
10 changes: 6 additions & 4 deletions tests/plugins/uploadfile/uploadfile.js
@@ -1,7 +1,8 @@
/* bender-tags: editor,unit,clipboard,widget */
/* bender-ckeditor-plugins: uploadwidget,uploadimage,toolbar,image */
/* bender-include: %BASE_PATH%/plugins/clipboard/_helpers/pasting.js */
/* global pasteFiles */
/* bender-include: _helpers/waitForImage.js */
/* global pasteFiles, waitForImage */

'use strict';

Expand Down Expand Up @@ -158,8 +159,9 @@ bender.test( {
assert.areSame( 1, editor.editable().find( 'img[data-widget="uploadimage"]' ).count() );
assert.areSame( '', editor.getData(), 'getData on uploading.' );

// IE needs to wait for image to be loaded so it can read width and height of the image.
wait( function() {
var image = editor.editable().find( 'img[data-widget="uploadimage"]' ).getItem( 0 );

waitForImage( image, function() {
loader.url = IMG_URL;
loader.changeStatus( 'uploaded' );

Expand All @@ -169,6 +171,6 @@ bender.test( {
assert.areSame( 1, loadAndUploadCount );
assert.areSame( 0, uploadCount );
assert.areSame( 'http://foo/upload', lastUploadUrl );
}, 10 );
} );
}
} );
31 changes: 18 additions & 13 deletions tests/plugins/uploadimage/uploadimage.js
@@ -1,7 +1,8 @@
/* bender-tags: editor,unit,clipboard,widget */
/* bender-ckeditor-plugins: uploadwidget,uploadimage,toolbar,image2 */
/* bender-include: %BASE_PATH%/plugins/clipboard/_helpers/pasting.js */
/* global pasteFiles */
/* bender-include: %BASE_PATH%/plugins/uploadfile/_helpers/waitForImage.js */
/* global pasteFiles, waitForImage */

'use strict';

Expand Down Expand Up @@ -106,8 +107,9 @@
assertUploadingWidgets( editor, LOADED_IMG );
assert.areSame( '', editor.getData(), 'getData on uploading.' );

// IE needs to wait for image to be loaded so it can read width and height of the image.
wait( function() {
var image = editor.editable().find( 'img[data-widget="uploadimage"]' ).getItem( 0 );

waitForImage( image, function() {
loader.url = IMG_URL;
loader.changeStatus( 'uploaded' );

Expand All @@ -117,7 +119,7 @@
assert.areSame( 1, loadAndUploadCount );
assert.areSame( 0, uploadCount );
assert.areSame( 'http://foo/upload', lastUploadUrl );
}, 10 );
} );
},

'test finish upload notification marked as important and is visible (#13032).': function() {
Expand All @@ -138,14 +140,15 @@

assertUploadingWidgets( editor, LOADED_IMG );

// IE needs to wait for image to be loaded so it can read width and height of the image.
wait( function() {
var image = editor.editable().find( 'img[data-widget="uploadimage"]' ).getItem( 0 );

waitForImage( image, function() {
loader.url = IMG_URL;
loader.changeStatus( 'uploaded' );

assert.areSame( 1, area.notifications.length, 'Successs notification is present because it\'s important one.' );
assert.areSame( 'success', area.notifications[ 0 ].type );
}, 10 );
} );
},

'test inline with image2 (integration test)': function() {
Expand All @@ -164,8 +167,9 @@
assertUploadingWidgets( editor, LOADED_IMG );
assert.areSame( '', editor.getData(), 'getData on uploading.' );

// IE needs to wait for image to be loaded so it can read width and height of the image.
wait( function() {
var image = editor.editable().find( 'img[data-widget="uploadimage"]' ).getItem( 0 );

waitForImage( image, function() {
loader.url = IMG_URL;
loader.changeStatus( 'uploaded' );

Expand All @@ -175,7 +179,7 @@
assert.areSame( 1, loadAndUploadCount );
assert.areSame( 0, uploadCount );
assert.areSame( 'http://foo/upload?type=Images&responseType=json', lastUploadUrl );
}, 10 );
} );
},

'test paste img as html (integration test)': function() {
Expand All @@ -196,8 +200,9 @@
assertUploadingWidgets( editor, LOADED_IMG );
assert.areSame( '<p>xx</p>', editor.getData(), 'getData on uploading.' );

// IE needs to wait for image to be loaded so it can read width and height of the image.
wait( function() {
var image = editor.editable().find( 'img[data-widget="uploadimage"]' ).getItem( 0 );

waitForImage( image, function() {
loader.url = IMG_URL;
loader.changeStatus( 'uploaded' );

Expand All @@ -207,7 +212,7 @@
assert.areSame( 0, loadAndUploadCount );
assert.areSame( 1, uploadCount );
assert.areSame( 'http://foo/upload', lastUploadUrl );
}, 10 );
} );
} );
},

Expand Down

0 comments on commit 96bbe7e

Please sign in to comment.