Sfoglia il codice sorgente

Tests: Undo integration test is now performed synchronously.

This results with quicker testing. Also gets around the issue https://github.com/ckeditor/ckeditor5/issues/6214. I didn't dive to find out why exactly this was happening, generally the cause of it was that during `await wait()` JS interpreter would trigger a selection change event, which would be picked by our observers and set the selection back to dummy paragraph that is before the image.
Marek Lewandowski 6 anni fa
parent
commit
1daefbf35b
1 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 7 3
      packages/ckeditor5-image/tests/imageresize.js

+ 7 - 3
packages/ckeditor5-image/tests/imageresize.js

@@ -264,6 +264,7 @@ describe( 'ImageResize', () => {
 			const domParts = getWidgetDomParts( editor, widget, 'bottom-left' );
 			const initialPosition = getHandleCenterPoint( domParts.widget, 'bottom-left' );
 			const finalPointerPosition = initialPosition.clone().moveBy( 0, 10 );
+			const plugin = editor.plugins.get( 'WidgetResize' );
 
 			resizerMouseSimulator.dragTo( editor, domParts.resizeHandle, {
 				from: initialPosition,
@@ -272,11 +273,14 @@ describe( 'ImageResize', () => {
 
 			expect( '120px' ).to.be.equal( domParts.widget.style.width );
 
-			// ui#update (fired after undo changes) handling is throttled. Wait, so that it will redraw instantly.
-			await wait( 220 );
-
 			editor.commands.get( 'undo' ).execute();
 
+			// Toggle _visibleResizer to force synchronous redraw. Otherwise you'd need to wait ~200ms for
+			// throttled redraw to take place, making tests slower.
+			const visibleResizer = plugin._visibleResizer;
+			plugin._visibleResizer = null;
+			plugin._visibleResizer = visibleResizer;
+
 			const resizerWrapper = document.querySelector( '.ck-widget__resizer' );
 			const shadowBoundingRect = resizerWrapper.getBoundingClientRect();