Commit 5dfb50ce authored by Christophe Maudoux's avatar Christophe Maudoux

WIP - Improve e2e tests (#1600)

parent 8c36bab6
...@@ -120,6 +120,7 @@ VHOSTLISTEN="*:$(PORT)" ...@@ -120,6 +120,7 @@ VHOSTLISTEN="*:$(PORT)"
TESTWEBSERVER=apache TESTWEBSERVER=apache
TESTWEBSERVERPORT=19876 TESTWEBSERVERPORT=19876
TESTUSESSL=0 TESTUSESSL=0
E2E_TESTS='portal/*.js'
# LDAP backend test # LDAP backend test
LLNGTESTLDAP_SLAPD_BIN=/usr/sbin/slapd LLNGTESTLDAP_SLAPD_BIN=/usr/sbin/slapd
...@@ -548,7 +549,7 @@ launch_protractor: ...@@ -548,7 +549,7 @@ launch_protractor:
# Start e2e tests # Start e2e tests
# NB: you must have protractor installed (using npm install -g protractor) # NB: you must have protractor installed (using npm install -g protractor)
# and have run update-webdriver at least once and have a node.js > 4.0 # and have run update-webdriver at least once and have a node.js > 4.0
@TESTWEBSERVERPORT=$(TESTWEBSERVERPORT) protractor e2e-tests/protractor-conf.js @E2E_TESTS=$(E2E_TESTS) TESTWEBSERVERPORT=$(TESTWEBSERVERPORT) protractor e2e-tests/protractor-conf.js
stop_web_server: stop_web_server:
# Stop web server # Stop web server
...@@ -568,7 +569,7 @@ plackup: ...@@ -568,7 +569,7 @@ plackup:
-F >e2e-tests/conf/fastcgi.log 2>&1 & -F >e2e-tests/conf/fastcgi.log 2>&1 &
install_test: install_test:
@TESTWEBSERVERPORT=$(PORT) protractor e2e-tests/protractor-conf.js @E2E_TESTS=$(E2E_TESTS) TESTWEBSERVERPORT=$(PORT) protractor e2e-tests/protractor-conf.js
# Install targets # Install targets
# --------------- # ---------------
......
...@@ -33,7 +33,7 @@ describe('00 Lemonldap::NG', function() { ...@@ -33,7 +33,7 @@ describe('00 Lemonldap::NG', function() {
it('should want to authenticate with history', function() { it('should want to authenticate with history', function() {
expect(browser.driver.findElement(by.css('[trspan="back2Portal"]')).getText()).toEqual('Retourner au portail'); expect(browser.driver.findElement(by.css('[trspan="back2Portal"]')).getText()).toEqual('Retourner au portail');
browser.driver.findElement(by.css('[trspan="back2Portal"]')).click(); browser.driver.findElement(by.css('[trspan="back2Portal"]')).click();
// Failed login attempt // Failed login attempt
browser.driver.findElement(by.xpath("//input[@name='user']")).sendKeys('dwho'); 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='password']")).sendKeys('ohwd');
...@@ -41,7 +41,7 @@ describe('00 Lemonldap::NG', function() { ...@@ -41,7 +41,7 @@ describe('00 Lemonldap::NG', function() {
browser.driver.findElement(by.xpath("//button[@type='submit']")).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'); expect(browser.driver.findElement(by.css('[trmsg="5"]')).getText()).toEqual('Mot de passe ou identifiant incorrect');
browser.driver.findElement(by.css('[trspan="goToPortal"]')).click(); browser.driver.findElement(by.css('[trspan="goToPortal"]')).click();
// Login attempt // Login attempt
browser.driver.findElement(by.xpath("//input[@name='user']")).sendKeys('dwho'); 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='password']")).sendKeys('dwho');
...@@ -49,8 +49,10 @@ describe('00 Lemonldap::NG', function() { ...@@ -49,8 +49,10 @@ describe('00 Lemonldap::NG', function() {
browser.driver.findElement(by.xpath("//button[@type='submit']")).click(); browser.driver.findElement(by.xpath("//button[@type='submit']")).click();
browser.driver.findElement(by.xpath("//img[@title='de']")).click(); browser.driver.findElement(by.xpath("//img[@title='de']")).click();
expect(browser.driver.findElement(by.css('[trspan="info"]')).getText()).toEqual("Information"); expect(browser.driver.findElement(by.css('[trspan="info"]')).getText()).toEqual("Information");
// Two entries
browser.driver.findElements(by.xpath('//table/tbody/tr')).then(function(elems) { browser.driver.findElements(by.xpath('//table/tbody/tr')).then(function(elems) {
expect(elems.length).toEqual(5); expect(elems.length).toEqual(2);
}); });
// Expect history with one login and one failed login // Expect history with one login and one failed login
...@@ -67,11 +69,11 @@ describe('00 Lemonldap::NG', function() { ...@@ -67,11 +69,11 @@ describe('00 Lemonldap::NG', function() {
expect(elems[4].getText()).toEqual('Fehlermeldung'); expect(elems[4].getText()).toEqual('Fehlermeldung');
}); });
browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) { browser.driver.findElements(by.xpath('//table/tbody/tr/td')).then(function(elems) {
expect(elems.length).toEqual(11); expect(elems.length).toEqual(5);
expect(elems[1].getText()).toEqual('127.0.0.1'); expect(elems[1].getText()).toEqual('127.0.0.1');
expect(elems[3].getText()).toEqual('127.0.0.1'); expect(elems[3].getText()).toEqual('127.0.0.1');
expect(elems[4].getText()).toEqual('Benutzername oder Passwort nicht korrekt');
}); });
browser.sleep(5000);
expect(browser.driver.findElement(by.css('[trspan="PE5"]')).getText()).toEqual('Benutzername oder Passwort nicht korrekt'); 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$/); 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(); browser.driver.findElement(by.xpath("//button[@type='reset']")).click();
......
exports.config = { exports.config = {
allScriptsTimeout: 11000, allScriptsTimeout: 11000,
specs: ['handler/*.js', 'portal/*.js', 'manager/*.js' ], specs: process.env.E2E_TESTS,
//specs: ['manager/*.js'], //specs: ['handler/*.js', 'portal/*.js', 'manager/*.js' ],
//specs: ['manager/00-auth.js', 'manager/01-tree.js'], capabilities: {
capabilities: {
'browserName': 'chrome' '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