Debugging a sporadic error with grid right-click

Get help with testing, discuss unit testing strategies etc.
Post Reply
User avatar
jflowers45
Posts: 43
Joined: Thu Sep 07, 2017 9:29 pm

Debugging a sporadic error with grid right-click

Post by jflowers45 » Wed May 16, 2018 2:57 am

I have a test that
1. selects two items on a grid
2. executes a right click which opens a context menu,
3. clicks one of the items in the menu.

Here's a rough idea of the code:

Code: Select all

 function(next) {
                    var items = grid.getStore().getData().items;
                    grid.getView().getSelectionModel().select([items[0],items[1]]);
                    next();
                },
                
                { waitFor: 1000}, //right click sporadically fails if I don't put this in ... 
                { rightclick: function() { return t.getCell(grid,0, 2); } },
 { click: ">>menuitem[text=Bulk Copy]", desc: "Click Bulk Copy"}
Without the waitFor:1000 (or some magic number), It sporadically fails to execute the right click and instead simply shows the message "waiting for [Object object]".

I have tried waiting for a selection change on the selectionModel, and I also tried doing a waitForTop, and neither of those solved the problem, but the arbitrary wait statement does if the # of seconds to wait is long enough.

Any ideas? I hate the idea of leaving a magic number in there but I'm out of things to try. I went into siesta-all.js to try and console.log things but I got as far as the processMouseActionSteps function at which point I didn't really know how to keep tracing in a meaningful way.

Thanks!

User avatar
mats
Premium Member
Premium Member
Posts: 15621
Joined: Sat Dec 19, 2009 11:41 pm
Location: Sweden
Contact:

Re: Debugging a sporadic error with grid right-click

Post by mats » Wed May 16, 2018 10:23 am

Yeah magic number should be removed. Any chance you can boil this down to a very simple small test case that we can run and inspect?
Tired of debugging javascript errors in web applications? Try our new error logging service RootCause, or read more on the Sencha blog

@bryntum
Facebook
API documentation

User avatar
jflowers45
Posts: 43
Joined: Thu Sep 07, 2017 9:29 pm

Re: Debugging a sporadic error with grid right-click

Post by jflowers45 » Wed May 16, 2018 7:39 pm

My first attempt at creating a simple test case outside of our app failed to cause an error, but it did spark some thought. Two more bits of info that may help:

1) Immediately prior to all of this i'm executing a remote filter

2) if I console.log the value of the cell that I'm trying to right click before I wait for the magic number, and then I log it again after I wait for the magic number, it returns different ID's. Before waiting it returns ext-element-180, and after waiting one second it returns ext-element-181.

So - why would calls to t.getCell(grid,0,2) return something different if the only thing that has happened is a 1 second wait? Sounds like a race condition ... but I've tried looking at / listening to every relevant event I can think of and I've got nothing. I did make sure that the value of the grid variable isn't changing, and I am waiting on the refresh event on the store to make sure the remote sort has already completed.

Code with addition of remote sort and console logs added. It appears that the selection of the two rows had nothing to do with it, so I removed that bit.

Code: Select all

{
                waitForEvent: function() { return [grid.getStore(), 'datachanged']; },
                desc:"filter to validated items",
                trigger:function() {
                    grid.getStore().filter([{property:"STATUS",value:"VALIDATED", operator: "like"}]);
                }
            },

 function(next) {
                console.log('cell before magic number', t.getCell(grid,0,2));
                next();
            },
            { waitFor: 1000},
            function(next) {
                console.log('cell after magic number, returns NEW dom ID! ', t.getCell(grid,0,2));
                next();
            },
            { rightclick: function() { return t.getCell(grid,0,2); }},
Any ideas would be much appreciated!

User avatar
nickolay
Core Developer
Core Developer
Posts: 3405
Joined: Mon May 16, 2011 10:48 am

Re: Debugging a sporadic error with grid right-click

Post by nickolay » Thu May 17, 2018 8:41 am

I guess, there's simply some delayed grid row refresh somewhere in Ext sources. May be try waiting for "rowupdated" event from the grid view?

Possible other solution would be to use CSS query instead of exact DOM element, since CSS query will be resolving even if original element goes out of DOM..
We offer training in both Ext JS and our products, read more here.
Read the API documentation

Post Reply