Get help with testing, discuss unit testing strategies etc.


Post by carina »

I found the source for my problems: I hadn't used a callback function in t.click(). Instead I did a t.waitForCQ after calling t.click(). The result of this is that here:
genericMouseClick : function (el, callback, scope, clickMethod) {
...
     // the asynchronous case
     if (this.moveCursorBetweenPoints && callback) {
          this.syncCursor(data.xy, this[ clickMethod ], [ data.el, callback, scope, data.options ]);
     } else {
          this[ clickMethod ](data.el, callback, scope, data.options);
     }
}, 
the syncCursor method will not be called since there is no callback. And this somehow leads to el being undefined here after calling elementFromPoint:
 
click: function (el, callback, scope) {
            var Ext = this.getExt();
            if (el instanceof Ext.form.Field && el.inputEl) {
                el = el.inputEl;
            } else if (el instanceof Ext.Component) {
                var center = this.findCenter(el);
                el = this.elementFromPoint(center[0], center[1]);
            }
            this.SUPER(el, callback, scope);
},
Since the callback parameter is optional I expected waitForCQ to work if it was called afterwards. And it works as long as the HTML view is visible (since syncCursor is not required in that case?) that's why this looks like a small bug to me. But anyway: I found my problem and I'll just use callbacks for t.click() now everywhere. :)

Post by nickolay »

Glad you found it! :) This is definitely a bug, sorry. Can you post more information so we could reproduce it and fix (may be just post your test)? So you are doing "click" w/o callback, then waiting for component and then click again, right? and 2nd click is performed in incorrect position?

Post by carina »

Yes, I'm doing t.click() and immediately after t.waitForCQ(). I didn't need a lot of code to reproduce it:
  
StartTest(function (t) {
     t.waitForCQ('mymaincomponent', function (mymaincomponent) {
            t.diag("mymaincomponent has been loaded.");

            var myButton = mymaincomponent[0].down('button');
            t.ok(myButton, "Button was found");

            t.click(myButton);

            t.waitForCQ('someResultComponent', function (someResultComponent) {
               //this part is never executed
               t.ok(someResultComponent, "someResultComponent was found");
               t.done();
             });
        });
});
About the application that I was testing: I was setting the path to my application with the hostPageUrl option. The application contains
- a border layout
- in the center region of the border layout there is a tab panel
- the first item of the tab panel is a panel with an anchor layout
- the first item of the anchor layout is the button that should be clicked
- the button would trigger some action (switch to another tab that contains "someResultComponent")

The bug occurred when 1.) I was running only one test and the HTML view on the right side was collapsed or 2.) when I was running multiple tests that all started by clicking on that button; one of the tests (the only one that was visible while running) was usually successful, the others were not since the button was never clicked.

Let me know if there's anything else that you need to know.

Post by mats »

Any chance you can post a simple runnable test case? will be a lot of guess work otherwise to get it reproduced...

Post Reply