Get help with testing, discuss unit testing strategies etc.


Post by marogalli »

I have a component that extends from DataView.
var view = Ext.create('Cotexo.view.Quotation.OpenedQuotationInfo', {
 renderTo: Ext.getBody()
});
t.waitForViewRendered(view,function(v) {
 var ov = v[0];
 console.log(ov);
});
I can see the view rendered, but I got Timeout for the waitForViewRendered.

How do I test a DataView?

Thanks

Post by marogalli »

I have two situation in my DataView that I want to test.

First situation : the store is empty. In this case I, through, emptyText render a message. This message contains the element id '#empty_msg.
I try to get this element using jquery in the test case but i returns empty. I used :
$('body iframe').contents().find('#empty_msg').attr('id')
When i use this in console I get the return and I can see the view rendered.

The second situation I want to check is when the store is not empty. In this case I want to check for another element.

Post by jakub »

Why do you use jQuery and not Ext for DOM query ?
JavaScript/Angular/ExtJS consulting - kuba@virtualdesign.pl

Post by nickolay »

Right now, `waitForViewRendered` waits until the view will have at least 1 item rendered. If your store is empty this will never happen and you'll get a timeout error. This is an edge case and we'll fix it in the next release.

For now, you can workaround this situation (dataview + empty store) using `waitForSelector` for example.

Post by marogalli »

Hi guys.

Thanks for the quick answer. I'd prefer using JQuery to DOM manipulation. I think it's easier and less verbose(I mean write less). Why should I use Ext? Maybe your knowledge can see beyond than mine, in this case, I would change my choices and look more at Ext.

I will test the data view in both case, using waitForSelector and waitForViewRendered (when the store is not empty) and let you know the results.

tks
Last edited by marogalli on Mon Mar 12, 2012 10:59 pm, edited 2 times in total.

Post by marogalli »

The problem is solved.

This was the solution :
t.waitForSelector("#empty_msg",function(v) {
	t.selectorExists("#empty_msg",'Empty store displays empty message.');
	view.openedInfoStore.load({
		  		params: {idCotacao: "7"}
	});
	t.waitForStoresToLoad(view.openedInfoStore,function(v) {
	   t.selectorExists("#divEscolhida",'Non empty store displays template.');
	});
});
Thanks for the help. I don't know if the solution above is the best, but it is working and I tested my two possibilities inside my DataView.

Post Reply