Skip to content

Commit

Permalink
KEYCLOAK-6464 Stabilize logout in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vmuzikar committed Feb 9, 2018
1 parent 3eb99ae commit 28e2968
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 1 addition & 4 deletions test/keycloak-connect-web-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,12 @@ test('Should login with admin credentials', t => {
});

test('User should be forbidden to access restricted page', t => {
t.plan(1);

page.get(app.port, '/restricted');
page.login('alice', 'password');

return page.body().getText().then(text => {
t.equal(text, 'Access denied', 'Message should be access denied');
}).then(() => {
page.get(app.port, '/logout');
return page.logout(app.port); // we need to wait a bit until the logout is fully completed
});
});

Expand Down
15 changes: 15 additions & 0 deletions test/utils/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ ConsolePage.prototype.login = function (user, pass) {
driver.findElement(By.name('login')).click();
};

/**
* Logouts directly with support for a wait period
*
* @param port
* @returns {Promise<any>}
*/
ConsolePage.prototype.logout = function (port) {
this.get(port, '/logout');
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 2000);
});
};

ConsolePage.prototype.body = () => {
return driver.findElement(By.tagName('pre'));
};
Expand Down

0 comments on commit 28e2968

Please sign in to comment.