Siesta Ext JS test not completing

416 Views Asked by At

I am testing an Ext JS frontend with Siesta. Here is my login/logout test:

StartTest(function(t) {
    t.diag("Login/Logout");
    t.chain(
        { waitForCQ : '#loginPanel' },
        function(next) {
            t.cq1("#username").setValue();
            t.cq1("#password").setValue();
            next();
        },
        { click: '>> #username' },
        { type: '******', target : '>> #username' },
        { type: '******', target : '>> #password' },
        { click: '>> #loginButton' },
        { waitForCQ: '#mainView' },
        { click: '>> #logoutButton' },
        { waitForCQ: 'messagebox #ok' },
        function(next) {
            t.waitForEvent(Ext.globalEvents, 'logoutComplete', function () {});
            next();
        },
        { click : '>> messagebox #ok' },
        function() {
            t.done();
        }
    );
});

The test inputs the username and password into the login panel, then clicks the login button. After the main view is loaded, it logs off. For some reason, this test never finishes.

Every action in the chain is successful, but the test is still stuck running.

How can I fix this?

I am using siesta-3.0.2-lite with ExtJS 5.1.0.

2

There are 2 best solutions below

2
pagep On

1# First you can try to remove t.done() , it's not generally needed in the tests, unless you are really waiting for it. needDone in the harness settings has default value False.

2# You are using waitForEvent, this is usually done when you pass the callback there. So your function would look like this:

function(next) {
    t.waitForEvent(Ext.globalEvents, 'logoutComplete', next);
},

But if you just want to know that the event was fired, you can use function firesOnce . Don't forget that you need to register checking the event before executing the actions which triggers it.

So your code could look like this:

 function(next) {
     t.firesOnce(Ext.globalEvents, 'logoutComplete','Logout completed!');
     next();
 },
 { click: '>> #logoutButton' },
 { waitForCQ: 'messagebox #ok' },
 { click : '>> messagebox #ok' },

But I have never used Ext.globalEvents to check the events, so I am not sure if it works.

0
aszahran On

Siesta developers on the forum suggested to solve this by setting overrideSetTimeout to false in your harness config.

Harness.configure({
    ...
    overrideSetTimeout: false,
    ...
});

Siesta overrides the native "setTimeout" from the context of each test for asynchronous code tracking, but it seems to cause issues. It worked for many users on the forum, tell me if it works for you, because it did not solve my issues.

Update:

The problem on my side turned out to be due to the logout itself, which uses window.location.reload(). This makes the browser act if there are two separate pages/applications.

Apparently, you need to set separateContext option in harness object to true. This option is available only in Standard (Commercial) package.