Skip to content

Commit

Permalink
updates selenium webdriver which removes promise manager
Browse files Browse the repository at this point in the history
the selenium driver now returns a promise instead of doing some crazy
stack-magic.

see this issue for more information:
SeleniumHQ/selenium#2969
  • Loading branch information
Christoph Wolfes committed Feb 28, 2018
1 parent 9500405 commit bfb3361
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 90 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ node('vagrant') {

dir('integrationTests') {

docker.image('node:8.7.0-stretch').inside("-e WEBDRIVER=remote -e CES_FQDN=${cesIP} -e SELENIUM_BROWSER=chrome -e SELENIUM_REMOTE_URL=http://${seleniumChromeIP}:4444/wd/hub") {
docker.image('node:8-stretch').inside("-e WEBDRIVER=remote -e CES_FQDN=${cesIP} -e SELENIUM_BROWSER=chrome -e SELENIUM_REMOTE_URL=http://${seleniumChromeIP}:4444/wd/hub") {
sh 'yarn install'
sh 'yarn run ci-test'
}
Expand Down
46 changes: 24 additions & 22 deletions integrationTests/adminFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ module.exports = class AdminFunctions{
};

async giveAdminRights(){

await request(config.baseUrl)
.put('/usermgt/api/users/' + this.testuserName)
.auth(config.username, config.password)
Expand All @@ -72,28 +71,31 @@ module.exports = class AdminFunctions{
};

async giveAdminRightsInRedmine(){
utils.login(this.driver, '/redmine');
this.driver.get(config.baseUrl + '/redmine/users');
await utils.login(this.driver, '/redmine');
await this.driver.get(config.baseUrl + '/redmine/users');

this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
this.driver.findElement(By.linkText(this.testuserName)).click();
this.driver.wait(until.elementLocated(By.css('input[type="checkbox"]')), 5000);
await this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
await this.driver.findElement(By.linkText(this.testuserName)).click();
await this.driver.wait(until.elementLocated(By.css('input[type="checkbox"]')), 5000);
var buttonEnabled = await this.driver.findElement(By.css('input#user_admin')).isSelected();
if(!buttonEnabled) this.driver.findElement(By.css('input#user_admin')).click();
if(!buttonEnabled) {
await this.driver.findElement(By.css('input#user_admin')).click();
}
await this.driver.findElement(By.css('input[type="submit"]')).click();
await this.driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await this.driver.findElement(By.css('a.logout')).click();
};

async takeAdminRightsInRedmine(){
utils.login(this.driver, '/redmine');
this.driver.get(config.baseUrl + '/redmine/users');

this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
this.driver.findElement(By.linkText(this.testuserName)).click();
this.driver.wait(until.elementLocated(By.css('input#user_admin')), 5000);
await utils.login(this.driver, '/redmine');
await this.driver.get(config.baseUrl + '/redmine/users');
await this.driver.wait(until.elementLocated(By.linkText(this.testuserName)), 5000);
await this.driver.findElement(By.linkText(this.testuserName)).click();
await this.driver.wait(until.elementLocated(By.css('input#user_admin')), 5000);
var buttonEnabled = await this.driver.findElement(By.css('input#user_admin')).isSelected();
if(buttonEnabled) this.driver.findElement(By.css('input#user_admin')).click();
if(buttonEnabled){
await this.driver.findElement(By.css('input#user_admin')).click();
}
await this.driver.findElement(By.css('input[type="submit"]')).click();
await this.driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await this.driver.findElement(By.css('a.logout')).click();
Expand All @@ -119,11 +121,11 @@ module.exports = class AdminFunctions{

async testuserLogin() {

this.driver.get(config.baseUrl + '/redmine');
this.driver.wait(until.elementLocated(By.id('username')), 5000);
this.driver.findElement(By.id('username')).sendKeys(this.testuserName);
this.driver.findElement(By.id('password')).sendKeys(this.testuserPasswort);
this.driver.findElement(By.css('input[name="submit"]')).click();
await this.driver.get(config.baseUrl + '/redmine');
await this.driver.wait(until.elementLocated(By.id('username')), 5000);
await this.driver.findElement(By.id('username')).sendKeys(this.testuserName);
await this.driver.findElement(By.id('password')).sendKeys(this.testuserPasswort);
await this.driver.findElement(By.css('input[name="submit"]')).click();
};

async testuserLogout() {
Expand Down Expand Up @@ -156,9 +158,9 @@ module.exports = class AdminFunctions{

async getApiKeyOfTestuser(){

this.testuserLogin();
this.driver.get(config.baseUrl + config.redmineContextPath + '/my/api_key');
this.driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
await this.testuserLogin();
await this.driver.get(config.baseUrl + config.redmineContextPath + '/my/api_key');
await this.driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
const apiKey = await this.driver.findElement(By.css('div.box pre')).getText();
await this.testuserLogout();
return apiKey;
Expand Down
25 changes: 8 additions & 17 deletions integrationTests/administration-rest.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const request = require('supertest');
const config = require('./config');
const AdminFunctions = require('./adminFunctions');
const utils = require('./utils');
const webdriver = require('selenium-webdriver');
const By = webdriver.By;
const keys = webdriver.Key;
const until = webdriver.until;

jest.setTimeout(30000);
let driver;
Expand All @@ -29,9 +25,8 @@ afterEach(async() => {
describe('administration rest tests', () => {

test('rest - user is admin in general = admin in redmine', async() => {
adminFunctions.giveAdminRights();
await adminFunctions.giveAdminRights();
const apiKey = await adminFunctions.getApiKeyOfTestuser();

await adminFunctions.accessUsersJson(apiKey, 200);
});

Expand All @@ -42,46 +37,42 @@ describe('administration rest tests', () => {

test('rest - user gets admin rights in redmine', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogout();
await adminFunctions.giveAdminRightsInRedmine();
const apiKey = await adminFunctions.getApiKeyOfTestuser();

await adminFunctions.accessUsersJson(apiKey, 200);
});

test('rest - user gets admin rights in redmine and then in usermanagement = take rights in usermanagement', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogout();
await adminFunctions.giveAdminRightsInRedmine();
adminFunctions.giveAdminRights();
adminFunctions.takeAdminRights();
await adminFunctions.giveAdminRights();
await adminFunctions.takeAdminRights();
const apiKey = await adminFunctions.getApiKeyOfTestuser();

await adminFunctions.accessUsersJson(apiKey, 200);
});

test('rest - user gets admin rights in redmine = take rights in redmine', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogout();
await adminFunctions.giveAdminRightsInRedmine();
await adminFunctions.takeAdminRightsInRedmine();
const apiKey = await adminFunctions.getApiKeyOfTestuser();

await adminFunctions.accessUsersJson(apiKey, 403);
});

test('rest - user gets admin rights in redmine and then in usermanagement = take rights in redmine', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await adminFunctions.testuserLogout();
await adminFunctions.giveAdminRightsInRedmine();
adminFunctions.giveAdminRights();
await adminFunctions.giveAdminRights();
await adminFunctions.takeAdminRightsInRedmine();
const apiKey = await adminFunctions.getApiKeyOfTestuser();

await adminFunctions.accessUsersJson(apiKey, 200);
});

Expand Down
49 changes: 24 additions & 25 deletions integrationTests/administration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ let adminFunctions;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

beforeEach(async() => {
driver = utils.createDriver(webdriver);

driver = await utils.createDriver(webdriver);
adminFunctions = new AdminFunctions(driver, 'testUser', 'testUser', 'testUser', 'testUser@test.de', 'testuserpasswort');
await adminFunctions.createUser();
});

afterEach(async() => {
driver.findElement(By.css('a.logout')).click();
await driver.findElement(By.css('a.logout')).click();
await adminFunctions.removeUser();
await driver.quit();
});
Expand All @@ -30,68 +29,68 @@ describe('administration rights', () => {

test('user is admin in general = admin in redmine', async() => {

adminFunctions.giveAdminRights();
adminFunctions.testuserLogin();
await adminFunctions.giveAdminRights();
await adminFunctions.testuserLogin();
var adminrights = await adminFunctions.isAdministratorInRedmine();
expect(adminrights).toBe(true);

});

test('user is no admin in general = no admin in redmine', async() => {

adminFunctions.testuserLogin();
await adminFunctions.testuserLogin();
var adminrights = await adminFunctions.isAdministratorInRedmine();
expect(adminrights).toBe(false);
});

test('user gets admin rights in redmine', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
driver.findElement(By.css('a.logout')).click();
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await driver.findElement(By.css('a.logout')).click();
await adminFunctions.giveAdminRightsInRedmine();
adminFunctions.testuserLogin();
await adminFunctions.testuserLogin();
var adminrights = await adminFunctions.isAdministratorInRedmine();
expect(adminrights).toBe(true);

});

test('user gets admin rights in redmine and then in usermanagement = take rights in usermanagement', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
driver.findElement(By.css('a.logout')).click();
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await driver.findElement(By.css('a.logout')).click();
await adminFunctions.giveAdminRightsInRedmine();
adminFunctions.giveAdminRights();
adminFunctions.takeAdminRights();
adminFunctions.testuserLogin();
await adminFunctions.giveAdminRights();
await adminFunctions.takeAdminRights();
await adminFunctions.testuserLogin();
var adminrights = await adminFunctions.isAdministratorInRedmine();
expect(adminrights).toBe(true);

});

test('user gets admin rights in redmine = take rights in redmine', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
driver.findElement(By.css('a.logout')).click();
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await driver.findElement(By.css('a.logout')).click();
await adminFunctions.giveAdminRightsInRedmine();
await adminFunctions.takeAdminRightsInRedmine();
adminFunctions.testuserLogin();
await adminFunctions.testuserLogin();
var adminrights = await adminFunctions.isAdministratorInRedmine();
expect(adminrights).toBe(false);

});

test('user gets admin rights in redmine and then in usermanagement = take rights in redmine', async() => {

adminFunctions.testuserLogin(); // test user login to update information in redmine
driver.wait(until.elementLocated(By.css('a.logout')), 5000);
driver.findElement(By.css('a.logout')).click();
await adminFunctions.testuserLogin(); // test user login to update information in redmine
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await driver.findElement(By.css('a.logout')).click();
await adminFunctions.giveAdminRightsInRedmine();
adminFunctions.giveAdminRights();
await adminFunctions.giveAdminRights();
await adminFunctions.takeAdminRightsInRedmine();
adminFunctions.testuserLogin();
await adminFunctions.testuserLogin();
var adminrights = await adminFunctions.isAdministratorInRedmine();
expect(adminrights).toBe(true);

Expand Down
34 changes: 18 additions & 16 deletions integrationTests/cas-browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,49 @@ afterEach(() => {
describe('cas browser tests', () => {

test('redirect to cas authentication', async() => {
driver.get(config.baseUrl + config.redmineContextPath);
await driver.get(config.baseUrl + config.redmineContextPath);
const url = await driver.getCurrentUrl();

expectations.expectCasLogin(url);
});

test('cas authentication', async() => {
utils.login(driver, config.redmineContextPath);
await utils.login(driver, config.redmineContextPath);
await driver.wait(until.elementLocated(By.css('#loggedas a.user')), 5000);
const username = await driver.findElement(By.css('#loggedas a.user')).getText();

expect(username).toBe(config.username);
});

test('check cas attributes', async() => {
utils.login(driver, config.redmineContextPath);
driver.findElement(By.css('#account a.my-account')).click();

const firstname = await driver.findElement(By.id('user_firstname')).getAttribute('value');
await utils.login(driver, config.redmineContextPath);
await driver.wait(until.elementLocated(By.css('#account a.my-account')), 5000);
await driver.findElement(By.css('#account a.my-account')).click();
let firstname = await driver.findElement(By.id('user_firstname'));
firstname = await firstname.getAttribute('value');
expect(firstname).toBe(config.firstname);

const lastname = await driver.findElement(By.id('user_lastname')).getAttribute('value');
let lastname = await driver.findElement(By.id('user_lastname'));
lastname = await lastname.getAttribute('value');
expect(lastname).toBe(config.lastname);

const email = await driver.findElement(By.id('user_mail')).getAttribute('value');
let email = await driver.findElement(By.id('user_mail'));
email = await email.getAttribute('value');
expect(email).toBe(config.email);
});

test('front channel logout', async() => {
utils.login(driver, config.redmineContextPath);
driver.findElement(By.css('a.logout')).click();
await utils.login(driver, config.redmineContextPath);
await driver.wait(until.elementLocated(By.css('a.logout')), 5000);
await driver.findElement(By.css('a.logout')).click();
const url = await driver.getCurrentUrl();

expectations.expectCasLogout(url);
});

test('back channel logout', async() => {
utils.login(driver, config.redmineContextPath);
driver.get(config.baseUrl + '/cas/logout');
driver.get(config.baseUrl + config.redmineContextPath);
await utils.login(driver, config.redmineContextPath);
await driver.get(config.baseUrl + '/cas/logout');
await driver.get(config.baseUrl + config.redmineContextPath);
const url = await driver.getCurrentUrl();

expectations.expectCasLogin(url);
});

Expand Down
6 changes: 3 additions & 3 deletions integrationTests/cas-rest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('cas rest tests', () => {

test('authenticate with API key', async() => {

const driver = utils.createDriver(webdriver);
utils.login(driver, config.redmineContextPath + '/my/api_key');
driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
const driver = await utils.createDriver(webdriver);
await utils.login(driver, config.redmineContextPath + '/my/api_key');
await driver.wait(until.elementLocated(By.css('div.box pre')), 5000);
const apiKey = await driver.findElement(By.css('div.box pre')).getText();
driver.quit();

Expand Down
2 changes: 1 addition & 1 deletion integrationTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"chromedriver": "^2.33.2",
"jest": "^21.2.1",
"jest-junit": "^3.1.0",
"selenium-webdriver": "^3.6.0",
"selenium-webdriver": "4.0.0-alpha.1",
"supertest": "^3.0.0"
},
"jest-junit": {
Expand Down
10 changes: 5 additions & 5 deletions integrationTests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function createLocalDriver() {
.build();
}

exports.login = function(driver, relativeUrl) {
driver.get(config.baseUrl + relativeUrl);
driver.findElement(By.id('username')).sendKeys(config.username);
driver.findElement(By.id('password')).sendKeys(config.password);
driver.findElement(By.css('input[name="submit"]')).click();
exports.login = async function(driver, relativeUrl) {
await driver.get(config.baseUrl + relativeUrl);
await driver.findElement(By.id('username')).sendKeys(config.username);
await driver.findElement(By.id('password')).sendKeys(config.password);
await driver.findElement(By.css('input[name="submit"]')).click();
};

0 comments on commit bfb3361

Please sign in to comment.