1

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.

PEC
  • 593
  • 1
  • 5
  • 16

2 Answers2

2

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.

pagep
  • 3,488
  • 1
  • 26
  • 47
  • I have tried removing t.done(), it didn't help. The event checking works, but only if I have t.done() in the last function of the chain, for some reason. I have made the changes you had suggested (except t.done()), but the test still doesn't finish. The fail/pass results are not displayed and the tick icon doesn't appear in front of the test icon in the gui (infinite lightning bolt). – PEC Jul 08 '15 at 17:58
  • You can start removing the chain steps from bottom - to see if it's problem in your test code or somewhere else. Also I suggest to write on [Siesta forum](http://www.bryntum.com/forum/). The Siesta developers usually responds to all the questions. And it will be better place for wider discussion. – pagep Jul 09 '15 at 08:21
1

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.

aszahran
  • 370
  • 2
  • 8