Commit 840c2f25 authored by Christophe Maudoux's avatar Christophe Maudoux

Improve Protractor e2e tests (#1600)

parent 68142126
#End 2 End Testing (Protractor)
To run the end-2-end tests against the application you use [Protractor](https://github.com/angular/protractor).
## Testing with Protractor
As a one-time setup, download webdriver.
```
npm run update-webdriver
```
Start the Protractor test runner using the e2e configuration:
```
make e2e_test
```
## Devel tips
{
locator_: {
using: 'css selector',
value: '[ng-click="getLanguage(lang)"]'
},
parentElementFinder_: null,
opt_actionResult_: {
then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending]
},
opt_index_: 1,
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getOuterHtml: [Function],
getInnerHtml: [Function],
toWireValue: [Function]
}
......@@ -57,6 +57,16 @@
},
"type": "application"
},
"0008-app": {
"options": {
"description": "Explore WebSSO 2FA sessions",
"display": "auto",
"logo": "database.png",
"name": "2FA Sessions explorer",
"uri": "http://manager.example.com:__port__/2ndfa.html"
},
"type": "application"
},
"type": "category"
},
"0008-cat": {
......
......@@ -4,77 +4,11 @@
describe('00 Lemonldap::NG', function() {
describe('Auth mechanism', function() {
it('Portal should display 11 lang flags', function() {
browser.driver.get('http://auth.example.com:' + process.env.TESTWEBSERVERPORT + '/');
browser.driver.findElements(by.className('langicon')).then(function(elems) {
expect(elems.length).toEqual(11);
});
browser.driver.findElement(by.xpath("//img[@title='en']")).click();
expect(browser.driver.findElement(by.css('[trmsg="9"]')).getText()).toEqual('Authentication required');
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Create an account');
browser.driver.findElement(by.xpath("//img[@title='it']")).click();
expect(browser.driver.findElement(by.css('[trmsg="9"]')).getText()).toEqual('Autenticazione necessaria');
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Crea un account');
browser.driver.findElement(by.xpath("//img[@title='fr']")).click();
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Créer un compte');
});
it('should want to crete an account', function() {
browser.driver.findElement(by.css('[trspan="createAccount"]')).click();
expect(browser.driver.findElement(by.css('[trmsg="78"]')).getText()).toEqual('Merci de saisir vos informations');
// A four inputs form + one captcha
browser.driver.findElements(by.className('input-group')).then(function(elems) {
expect(elems.length).toEqual(4);
});
browser.driver.findElements(by.className('img-thumbnail')).then(function(elems) {
expect(elems.length).toEqual(1);
});
});
it('should want to authenticate with history', function() {
expect(browser.driver.findElement(by.css('[trspan="back2Portal"]')).getText()).toEqual('Retourner au portail');
browser.driver.findElement(by.css('[trspan="back2Portal"]')).click();
// Failed login attempt
browser.driver.findElement(by.xpath("//input[@name='user']")).sendKeys('dwho');
browser.driver.findElement(by.xpath("//input[@name='password']")).sendKeys('ohwd');
browser.driver.findElement(by.xpath("//input[@name='checkLogins']")).click();
browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
expect(browser.driver.findElement(by.css('[trmsg="5"]')).getText()).toEqual('Mot de passe ou identifiant incorrect');
browser.driver.findElement(by.css('[trspan="goToPortal"]')).click();
it('should want to authenticate', function() {
browser.driver.get('http://auth.example.com:' + process.env.TESTWEBSERVERPORT + '/');
// Login attempt
browser.driver.findElement(by.xpath("//input[@name='user']")).sendKeys('dwho');
browser.driver.findElement(by.xpath("//input[@name='password']")).sendKeys('dwho');
browser.driver.findElement(by.xpath("//input[@name='checkLogins']")).click();
browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
browser.driver.findElement(by.xpath("//img[@title='de']")).click();
expect(browser.driver.findElement(by.css('[trspan="info"]')).getText()).toEqual("Information");
browser.driver.findElements(by.xpath('//table/tbody/tr')).then(function(elems) {
expect(elems.length).toEqual(2);
});
// Expect history with one login and one failed login
browser.driver.findElements(by.xpath('//form/div/div/h3')).then(function(elems) {
expect(elems.length).toEqual(3);
expect(elems[0].getText()).toEqual('Information');
expect(elems[1].getText()).toEqual('Letzte Anmeldungen');
expect(elems[2].getText()).toEqual('Letzte fehlgeschlagene Anmeldungen');
});
browser.driver.findElements(by.xpath('//table/thead/tr/th')).then(function(elems) {
expect(elems.length).toEqual(5);
expect(elems[0].getText()).toEqual('Datum');
expect(elems[2].getText()).toEqual('Datum');
expect(elems[4].getText()).toEqual('Fehlermeldung');
});
browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) {
expect(elems.length).toEqual(5);
expect(elems[1].getText()).toEqual('127.0.0.1');
expect(elems[3].getText()).toEqual('127.0.0.1');
});
expect(browser.driver.findElement(by.css('[trspan="PE5"]')).getText()).toEqual('Benutzername oder Passwort nicht korrekt');
expect(browser.driver.findElement(by.id('timer')).getText()).toMatch(/^Du wirst in \d{2} Sekunden umgeleitet$/);
browser.driver.findElement(by.xpath("//button[@type='reset']")).click();
expect(browser.driver.findElement(by.id('timer')).isDisplayed()).toEqual(false);
browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
});
});
......
......@@ -3,7 +3,7 @@
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
describe('01 Lemonldap::NG Manager', function() {
describe('Tree display', function() {
describe('Tree display -> General Parameters', function() {
it('Main => should display 12 main nodes', function() {
browser.get('/');
expect(element.all(by.repeater('node in data track by node.id')).count()).toEqual(12);
......@@ -12,7 +12,7 @@ describe('01 Lemonldap::NG Manager', function() {
element(by.id('a-generalParameters')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(10);
});
// ** General Parameters **
// Portal
it('General Parameters > Portal -> Append 4 sub nodes', function() {
element(by.id('a-portalParams')).click();
......@@ -30,25 +30,25 @@ describe('01 Lemonldap::NG Manager', function() {
element(by.id('a-portalModules')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(21);
});
it('General Parameters > Portal > Menu > Cat. and Apps. => Append 10 sub nodes', function() {
it('General Parameters > Portal > Menu > Cat. and Apps. => Append 11 sub nodes', function() {
element(by.id('a-applicationList')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(31);
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(32);
});
it('General Parameters > Portal > Customization => Append 8 sub nodes', function() {
element(by.id('a-portalCustomization')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(39);
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(40);
});
it('General Parameters > Portal > Customization > Buttons => Append 4 sub nodes', function() {
element(by.id('a-portalButtons')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(43);
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(44);
});
it('General Parameters > Portal > Customization > Password Management => Append 3 sub nodes', function() {
element(by.id('a-passwordManagement')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(46);
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(47);
});
it('General Parameters > Portal > Customization > Other => Append 6 sub nodes', function() {
element(by.id('a-portalOther')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(52);
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(53);
});
// Authentication Parameters
it('Main => should display 12 main nodes', function() {
......@@ -210,28 +210,5 @@ describe('01 Lemonldap::NG Manager', function() {
expect(element.all(by.xpath('//tbody/tr')).count()).toEqual(2);
expect(element.all(by.xpath('//tbody/tr/td/input')).count()).toEqual(4);
});
// ** Variables **
it('Main => should display 12 main nodes', function() {
browser.get('/');
expect(element.all(by.repeater('node in data track by node.id')).count()).toEqual(12);
});
it('Variables should display 3 sub nodes', function() {
element(by.id('a-variables')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(3);
});
// ** Virtual Hosts
it('should find a rule', function() {
browser.get('/#/confs/1');
var vhs = element(by.id('a-virtualHosts'));
vhs.click();
var vh = element(by.id('a-virtualHosts/manager.example.com'));
vh.click();
var r = element(by.id('a-virtualHosts/manager.example.com/locationRules'));
r.click();
var def = element.all(by.id("t-virtualHosts/manager.example.com/locationRules/1"));
expect(def.count()).toEqual(1);
});
});
});
\ No newline at end of file
'use strict';
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
describe('01 Lemonldap::NG Manager', function() {
describe('Tree display -> Variables', function() {
it('Main => should display 12 main nodes', function() {
browser.get('/');
expect(element.all(by.repeater('node in data track by node.id')).count()).toEqual(12);
});
it('Variables should display 3 sub nodes', function() {
element(by.id('a-variables')).click();
expect(element.all(by.repeater('node in node.nodes track by node.id')).count()).toEqual(3);
});
});
});
\ No newline at end of file
'use strict';
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
describe('01 Lemonldap::NG Manager', function() {
describe('Tree display', function() {
it('Main => should display 12 main nodes', function() {
browser.get('/');
expect(element.all(by.repeater('node in data track by node.id')).count()).toEqual(12);
});
it('should find a rule', function() {
browser.get('/#/confs/1');
var vhs = element(by.id('a-virtualHosts'));
vhs.click();
var vh = element(by.id('a-virtualHosts/manager.example.com'));
vh.click();
var r = element(by.id('a-virtualHosts/manager.example.com/locationRules'));
r.click();
var def = element.all(by.id("t-virtualHosts/manager.example.com/locationRules/1"));
expect(def.count()).toEqual(1);
});
});
});
\ No newline at end of file
'use strict';
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
describe('00 Lemonldap::NG', function() {
describe('Auth mechanism', function() {
it('Portal should display 11 lang flags', function() {
browser.driver.get('http://auth.example.com:' + process.env.TESTWEBSERVERPORT + '/');
browser.driver.findElements(by.className('langicon')).then(function(elems) {
expect(elems.length).toEqual(11);
});
browser.driver.findElement(by.xpath("//img[@title='en']")).click();
expect(browser.driver.findElement(by.css('[trmsg="9"]')).getText()).toEqual('Authentication required');
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Create an account');
browser.driver.findElement(by.xpath("//img[@title='it']")).click();
expect(browser.driver.findElement(by.css('[trmsg="9"]')).getText()).toEqual('Autenticazione necessaria');
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Crea un account');
browser.driver.findElement(by.xpath("//img[@title='fr']")).click();
expect(browser.driver.findElement(by.css('[trspan="createAccount"]')).getText()).toEqual('Créer un compte');
});
it('should want to crete an account', function() {
browser.driver.findElement(by.css('[trspan="createAccount"]')).click();
expect(browser.driver.findElement(by.css('[trmsg="78"]')).getText()).toEqual('Merci de saisir vos informations');
// A four inputs form + one captcha
browser.driver.findElements(by.className('input-group')).then(function(elems) {
expect(elems.length).toEqual(4);
});
browser.driver.findElements(by.className('img-thumbnail')).then(function(elems) {
expect(elems.length).toEqual(1);
});
});
it('should want to authenticate with history', function() {
expect(browser.driver.findElement(by.css('[trspan="back2Portal"]')).getText()).toEqual('Retourner au portail');
browser.driver.findElement(by.css('[trspan="back2Portal"]')).click();
// Failed login attempt
browser.driver.findElement(by.xpath("//input[@name='user']")).sendKeys('dwho');
browser.driver.findElement(by.xpath("//input[@name='password']")).sendKeys('ohwd');
browser.driver.findElement(by.xpath("//input[@name='checkLogins']")).click();
browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
expect(browser.driver.findElement(by.css('[trmsg="5"]')).getText()).toEqual('Mot de passe ou identifiant incorrect');
browser.driver.findElement(by.css('[trspan="goToPortal"]')).click();
// Login attempt
browser.driver.findElement(by.xpath("//input[@name='user']")).sendKeys('dwho');
browser.driver.findElement(by.xpath("//input[@name='password']")).sendKeys('dwho');
browser.driver.findElement(by.xpath("//input[@name='checkLogins']")).click();
browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
browser.driver.findElement(by.xpath("//img[@title='de']")).click();
expect(browser.driver.findElement(by.css('[trspan="info"]')).getText()).toEqual("Information");
browser.driver.findElements(by.xpath('//table/tbody/tr')).then(function(elems) {
expect(elems.length).toEqual(5);
});
// Expect history with one login and one failed login
browser.driver.findElements(by.xpath('//form/div/div/h3')).then(function(elems) {
expect(elems.length).toEqual(3);
expect(elems[0].getText()).toEqual('Information');
expect(elems[1].getText()).toEqual('Letzte Anmeldungen');
expect(elems[2].getText()).toEqual('Letzte fehlgeschlagene Anmeldungen');
});
browser.driver.findElements(by.xpath('//table/thead/tr/th')).then(function(elems) {
expect(elems.length).toEqual(5);
expect(elems[0].getText()).toEqual('Datum');
expect(elems[2].getText()).toEqual('Datum');
expect(elems[4].getText()).toEqual('Fehlermeldung');
});
browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) {
expect(elems.length).toEqual(11);
expect(elems[1].getText()).toEqual('127.0.0.1');
expect(elems[3].getText()).toEqual('127.0.0.1');
});
browser.sleep(5000);
expect(browser.driver.findElement(by.css('[trspan="PE5"]')).getText()).toEqual('Benutzername oder Passwort nicht korrekt');
expect(browser.driver.findElement(by.id('timer')).getText()).toMatch(/^Du wirst in \d{2} Sekunden umgeleitet$/);
browser.driver.findElement(by.xpath("//button[@type='reset']")).click();
expect(browser.driver.findElement(by.id('timer')).isDisplayed()).toEqual(false);
browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
});
});
});
'use strict';
/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */
describe('99 Lemonldap::NG auth mechanism', function() {
it('should allow logout', function() {
browser.driver.get('http://auth.example.com:' + process.env.TESTWEBSERVERPORT + '/?logout=1');
});
});
\ No newline at end of file
#End 2 End Testing (Protractor)
To run the end-2-end tests against the application you use [Protractor](https://github.com/angular/protractor).
## Testing with Protractor
As a one-time setup, download webdriver.
```
npm run update-webdriver
```
Start the Protractor test runner using the e2e configuration:
```
make e2e_test
```
## Devel tips
{
locator_: {
using: 'css selector',
value: '[ng-click="getLanguage(lang)"]'
},
parentElementFinder_: null,
opt_actionResult_: {
then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending]
},
opt_index_: 1,
click: [Function],
sendKeys: [Function],
getTagName: [Function],
getCssValue: [Function],
getAttribute: [Function],
getText: [Function],
getSize: [Function],
getLocation: [Function],
isEnabled: [Function],
isSelected: [Function],
submit: [Function],
clear: [Function],
isDisplayed: [Function],
getOuterHtml: [Function],
getInnerHtml: [Function],
toWireValue: [Function]
}
exports.config = {
allScriptsTimeout: 11000,
specs: ['manager/*.js', 'handler/*.js'],
specs: ['handler/*.js', 'portal/*.js', 'manager/*.js' ],
//specs: ['manager/*.js'],
//specs: ['manager/00-auth.js', 'manager/01-tree.js'],
capabilities: {
'browserName': 'chrome'
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment