Get help with testing, discuss unit testing strategies etc.


Post by supersaiyen »

Live view of bug at: Link Removed Once fixed.

Notice it says all tests pass, but t.pass (0010_StoreLoad.t.js : 9) never is written to the console.

Seems to never call the next action:

index.html
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<title>Playground</title>
		<link rel="stylesheet" href="https://cdn.sencha.io/touch/sencha-touch-2.0.0/resources/css/sencha-touch.css" type="text/css">
		<script type="text/javascript" src="https://cdn.sencha.io/touch/sencha-touch-2.0.0/sencha-touch-all-debug.js"></script>
		<script type="text/javascript" src="app.js"></script>
	</head>
	<body></body>
</html>
app.js
Ext.define('Playground.model.Planet', {
    extend: 'Ext.data.Model',
    config: {
        fields: ['name', 'disclosure']
    }
});

Ext.define('Playground.store.Planets', {
	extend : 'Ext.data.Store',
	config : {
		model : 'Playground.model.Planet',
		//autoLoad: true,
		proxy : {
			type : 'ajax',
			url : 'planets.json'
		}
	}
});
			
Ext.application({
	name : 'Playground',
	
	stores: ['Planets'],
	
	launch : function() {
		
		Ext.Viewport.add([{
			xtype : 'container',
			layout: {
				type: 'fit'
			},
			items : [{
				xtype : 'toolbar',
				docked:'top',
				items : [{
					xtype : 'label',
					html : 'Store Filter Test',
					style : 'color:white;'
				},{
					xtype:'searchfield',
					listeners:{
						keyup:function(searchfield){
							var search = searchfield.getValue().toLowerCase().trim();
							var store = Ext.getStore("Planets");
							store.clearFilter();
							store.filter([{
								filterFn : function(item) {
									var name = (item.get('name') || "");
									return name.toLowerCase().indexOf(search) != -1;
								}
							}]);//any match, case insensitive
						},
						clearicontap:function(){
							var store = Ext.getStore("Planets");
							store.clearFilter();
						}
					}
				}]
			}, {
				xtype : 'list',
				onItemDisclosure: true,
				itemTpl : '<div class="item">{name}</div>',
				store: 'Planets'
			}]
		}]);
	}
});
/test/index.html
<!DOCTYPE html>
<html>
    <head>
    	<!-- Ext JS library -->
    	<link rel="stylesheet" type="text/css" href="https://cdn.sencha.io/ext-4.0.7-gpl/resources/css/ext-all.css">
    	<script type="text/javascript" src="https://cdn.sencha.io/ext-4.0.7-gpl/ext-all-debug.js"></script>
        
        <!-- Siesta Library -->
        <link rel="stylesheet" type="text/css" href="../siesta/resources/css/siesta-all.css">
        <script type="text/javascript" src="../siesta/siesta-all.js"></script>
        
        <script type="text/javascript" src="index.js"></script>
    </head>
    
    <body>
    </body>
</html>
test/index.js
var Harness = Siesta.Harness.Browser.ExtJS;

Harness.configure({
    title       : 'Test Test Suite',
    
    preload : [
    	"../resources/css/sencha-touch.css",
        "../sencha/sencha-touch-debug.js"
    ]
    
});

Harness.start(
    {
        group               : 'Application',
        
        // need to set the `preload` to empty array - to avoid the double loading of dependencies
        preload             : [],
        
        items : [
            {
                hostPageUrl         : '../index.html',
                url                 : 'tests/functional/0010_StoreLoad.t.js',
                viewportWidth		: 320,
                viewportHeight		: 460
            }
        ]
    }
);
tests/functional/0010_StoreLoad.t.js
StartTest(function(t) {
	t.waitForCQ('list', function() {
		t.chain(function(next) {
			//Need to wait for the store to load.
			var planetStore = Ext.getStore('Planets');
			t.waitForStoresToLoad([planetStore], next);
			planetStore.load();
		}, function(next) {
			t.pass("Store has loaded successfully");
		}, function() {
			//done
		});
	}, function() {
		// done
	});
});
Last edited by supersaiyen on Thu Apr 26, 2012 2:43 pm, edited 1 time in total.

Post by mats »

Fixed! Cause was the ST config system that we didn't take into account. Thanks for the awesome report :)

Post by supersaiyen »

Great! I'm going to pull down the live example then. Cheers.

Post Reply