Get help with testing, discuss unit testing strategies etc.


Post by nickolay »

Ok, can you post the modified example?

Post by satishkn »

pfa the modified file.
Attachments
040_editing.t.js
(2.05 KiB) Downloaded 334 times

Post by nickolay »

Sorry, very busy right now, I'll get back to you on Monday.

Post by nickolay »

Hi,

In your particular case, the correct wait function will be:
t.waitForSelectorAt(t.findCenter(firstCell), 'input', next)
In general, its more robust to use the center coordinates of elements when waiting.

Here's the full example for testing editing with RowEditor (will be included in the next release):
StartTest(function(t) {
    //=================================================================
    t.diag("Simple grid assertions");
    
    // Use a convenience method to generate the grid, keeping the test as small as possible
    var grid = t.getGrid({
        plugins     : Ext.create("Ext.grid.plugin.RowEditing", {}),
        renderTo    : document.body
    });
     
    var store                   = grid.store;
    var firstCell, dateCell
    var foundEl     
    
    t.chain(
        function (next) {
            // potentially, grid may have delayed rendering (`deferRowRender` option)  
            t.waitForRowsVisible(grid, next)
        },
        function (next) {
            firstCell = t.getFirstCell(grid);
            
            next()
        },
        {
            action  : 'doubleclick',
            // get the "target" for action "just in time" since it will be only known after 2nd step
            target  : function () { return firstCell }
        },
        function (next) {
            t.waitForSelectorAt(t.findCenter(firstCell), 'input', next)
        },
        function (next, el) {
            foundEl         = el
            
            // Clear text field
            foundEl.value   = '';
            
            next()
        },
        {
            action      : 'type',
            target      : function () { return foundEl },
            text        : 'foo'
        },
        // generally this "wait" is not required we just want to find the top-most element from the 
        // center point of the cell with date
        function (next) {
            t.waitForSelectorAt(t.findCenter(t.getCell(grid, 0, 3)), 'input', next)
        },
        function (next, el) {
            foundEl         = el
            
            // Clear text field
            foundEl.value   = '';
            
            next()
        },
        {
            action      : 'type',
            target      : function () { return foundEl },
            text        : '01/18/2009[ENTER]'
        },
        function () {
            t.is(store.first().get('name'), 'foo', 'Name was updated correctly');
            t.isDateEqual(store.first().get('lastgame'), new Date(2009, 0, 18), 'Date was updated correctly');
        }
    )
});

But, for running this example, please patch the siesta-all.js. There was a bug, and "doubleClick" action in `t.chain` was using right click. Replace line 18716:
this.test.rightClick(this.getTarget(), this.next)
with
this.test.doubleClick(this.getTarget(), this.next)

Post by satishkn »

Thanks for your response.
Will verify and let you know.

I am using 1.0.7-lite, and the line # you have mentioned doesn't correspond to the code you are indicating.

Please suggest what I should do.

-Satish

Post by satishkn »

I found the code signature in 1.0.7-lite and changed as per your instructions.

Yes. my example is working now.

(able to enter text in the cell with row editing plugin).

Thanks for your response.
-Satish

Post Reply