|
@@ -22,6 +22,7 @@ import { setData as setModelData, getData as getModelData } from '@ckeditor/cked
|
|
|
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
|
|
import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
|
|
|
import { eventNameToConsumableType } from '@ckeditor/ckeditor5-engine/src/conversion/model-to-view-converters';
|
|
import { eventNameToConsumableType } from '@ckeditor/ckeditor5-engine/src/conversion/model-to-view-converters';
|
|
|
import Range from '@ckeditor/ckeditor5-engine/src/model/range';
|
|
import Range from '@ckeditor/ckeditor5-engine/src/model/range';
|
|
|
|
|
+import Position from '@ckeditor/ckeditor5-engine/src/model/position';
|
|
|
|
|
|
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification';
|
|
import Notification from '@ckeditor/ckeditor5-ui/src/notification/notification';
|
|
@@ -325,6 +326,7 @@ describe( 'ImageUploadEngine', () => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
editor.execute( 'imageUpload', { file } );
|
|
editor.execute( 'imageUpload', { file } );
|
|
|
|
|
+
|
|
|
const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
|
|
|
|
|
|
expect( loader.status ).to.equal( 'reading' );
|
|
expect( loader.status ).to.equal( 'reading' );
|
|
@@ -339,6 +341,24 @@ describe( 'ImageUploadEngine', () => {
|
|
|
sinon.assert.calledOnce( abortSpy );
|
|
sinon.assert.calledOnce( abortSpy );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ it( 'should not abort and not restart upload when image is moved', () => {
|
|
|
|
|
+ const file = createNativeFileMock();
|
|
|
|
|
+ setModelData( model, '<paragraph>{}foo bar</paragraph>' );
|
|
|
|
|
+ editor.execute( 'imageUpload', { file } );
|
|
|
|
|
+
|
|
|
|
|
+ const abortSpy = testUtils.sinon.spy( loader, 'abort' );
|
|
|
|
|
+ const loadSpy = testUtils.sinon.spy( loader, 'read' );
|
|
|
|
|
+
|
|
|
|
|
+ const image = doc.getRoot().getChild( 0 );
|
|
|
|
|
+
|
|
|
|
|
+ model.change( writer => {
|
|
|
|
|
+ writer.move( Range.createOn( image ), Position.createAt( doc.getRoot(), 2 ) );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ expect( abortSpy.called ).to.be.false;
|
|
|
|
|
+ expect( loadSpy.called ).to.be.false;
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
it( 'image should be permanently removed if it is removed by user during upload', done => {
|
|
it( 'image should be permanently removed if it is removed by user during upload', done => {
|
|
|
const file = createNativeFileMock();
|
|
const file = createNativeFileMock();
|
|
|
const notification = editor.plugins.get( Notification );
|
|
const notification = editor.plugins.get( Notification );
|