Przeglądaj źródła

Merge pull request #349 from ckeditor/t/334

Tests: Fixed failed tests on other browsers than Chrome when using BrowserStack. Closes #334.
Szymon Kupś 8 lat temu
rodzic
commit
8481992803

+ 20 - 2
packages/ckeditor5-ui/src/inputtext/inputtextview.js

@@ -67,12 +67,30 @@ export default class InputTextView extends View {
 				],
 				id: bind.to( 'id' ),
 				placeholder: bind.to( 'placeholder' ),
-				readonly: bind.to( 'isReadOnly' ),
-				value: bind.to( 'value' )
+				readonly: bind.to( 'isReadOnly' )
 			}
 		} );
 	}
 
+	/**
+	 * @inheritDoc
+	 */
+	render() {
+		super.render();
+
+		const setValue = value => {
+			this.element.value = ( !value && value !== 0 ) ? '' : value;
+		};
+
+		setValue( this.value );
+
+		// Bind `this.value` to the DOM element's value.
+		// We cannot use `value` DOM attribute because removing it on Edge does not clear the DOM element's value property.
+		this.on( 'change:value', ( evt, name, value ) => {
+			setValue( value );
+		} );
+	}
+
 	/**
 	 * Moves the focus to the input and selects the value.
 	 */

+ 4 - 0
packages/ckeditor5-ui/tests/inputtext/inputtextview.js

@@ -14,6 +14,10 @@ describe( 'InputTextView', () => {
 		view.render();
 	} );
 
+	afterEach( () => {
+		view.destroy();
+	} );
+
 	describe( 'constructor()', () => {
 		it( 'should creates element from template', () => {
 			expect( view.element.tagName ).to.equal( 'INPUT' );

+ 11 - 7
packages/ckeditor5-ui/tests/toolbar/contextual/contextualtoolbar.js

@@ -15,7 +15,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 
 import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
 
-/* global document, setTimeout */
+/* global document, setTimeout, window */
 
 describe( 'ContextualToolbar', () => {
 	let sandbox, editor, contextualToolbar, balloon, editorElement;
@@ -44,6 +44,10 @@ describe( 'ContextualToolbar', () => {
 
 				// Focus the engine.
 				editor.editing.view.isFocused = true;
+				editor.editing.view.getDomRoot().focus();
+
+				// Remove all selection ranges from DOM before testing.
+				window.getSelection().removeAllRanges();
 			} );
 	} );
 
@@ -119,12 +123,12 @@ describe( 'ContextualToolbar', () => {
 				// Still not yet.
 				sinon.assert.notCalled( spy );
 
-				// Another 101 ms waiting.
+				// Another waiting.
 				setTimeout( () => {
 					// And here it is.
 					sinon.assert.calledOnce( spy );
 					done();
-				}, 100 );
+				}, 110 );
 			}, 101 );
 		}, 100 );
 	} );
@@ -284,7 +288,7 @@ describe( 'ContextualToolbar', () => {
 			let showSpy;
 
 			beforeEach( () => {
-				showSpy = sinon.spy( contextualToolbar, 'show' );
+				showSpy = sandbox.spy( contextualToolbar, 'show' );
 			} );
 
 			it( 'should not be called when the editor is not focused', () => {
@@ -437,7 +441,7 @@ describe( 'ContextualToolbar', () => {
 
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 
-			const stub = sinon.stub( balloon, 'visibleView' ).get( () => contextualToolbar.toolbarView );
+			const stub = sandbox.stub( balloon, 'visibleView' ).get( () => contextualToolbar.toolbarView );
 
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
@@ -455,7 +459,7 @@ describe( 'ContextualToolbar', () => {
 
 			contextualToolbar.fire( '_selectionChangeDebounced' );
 
-			const stub = sinon.stub( balloon, 'visibleView' ).get( () => null );
+			const stub = sandbox.stub( balloon, 'visibleView' ).get( () => null );
 
 			sinon.assert.calledOnce( showPanelSpy );
 			sinon.assert.notCalled( hidePanelSpy );
@@ -471,7 +475,7 @@ describe( 'ContextualToolbar', () => {
 
 	describe( 'show event', () => {
 		it( 'should fire `show` event just before panel shows', () => {
-			const spy = sinon.spy();
+			const spy = sandbox.spy();
 
 			contextualToolbar.on( 'show', spy );
 			setData( editor.document, '<paragraph>b[a]r</paragraph>' );