Get help with testing, discuss unit testing strategies etc.


Post by proudman »

Hi all.
I provided a UI test of numberEdit field created ExtJs component and pureJS. It doesn't work correctly.
Method "type" should simulate number typing from keyboard, but it is typing any symbols passing by component logic.
Is that Siesta bug, or I use incorrect logic?

There is test code:
StartTest(function(t) {
	
   var pureInput = document.createElement("input");
	pureInput.id = "exp1-input";
	document.body.appendChild(pureInput);
	
	
	pureInput.onkeypress = function(){
		var e = window.event || e;
		var keyunicode = e.charCode || e.keyCode;
		if(!validateKey(keyunicode)){
			return false;
		}
	}
	function validateKey(keyunicode){
		var availChars = new RegExp('[\\d-.,]','gi');
		var key = String.fromCharCode(keyunicode);
		return availChars.test(key);
	}	
 
//-------------------------------------------------------------------    
	var numEdit = Ext.create('Ext.container.AbstractContainer', {
		renderTo: Ext.getBody(),
		items: [
			{ 
			 xtype: 'numberfield',
			 fieldLabel: 'Num',
			}
		]
	});	
	
	var extNumberEdit = numEdit.el.dom.getElementsByTagName("input")[0];
	
//-------------------------------------------------------------------
	t.chain(
		{
		action: 'type',
		target: pureInput, 
		text: 'some text'
		},
		{
			action: 'type',
			target: extNumberEdit,
			text: 'some text'
		},
		
		function(next){
			t.is(pureInput.value, '', "Pure JS simpleNumberEdit");
			next();
		},
		
		function(next){
			t.is(extNumberEdit.value, '', "ExtJS numberEdit");
			next();
		}
	);
});
Last edited by proudman on Tue Oct 30, 2012 10:41 am, edited 1 time in total.

Post by nickolay »

Yes, its a known limitation of events simulation in Siesta. Keyboard events simulation is a _very_ tricky topic and differs significantly across browsers.

Please file a ticket at https://www.assembla.com/spaces/bryntum/support/tickets and we'll try to revise keyboard events in Siesta in next release.

Post Reply