From 83226fc3cb2baac6eaceee980ce6e241647ff1aa Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 15 May 2014 05:36:41 +0200 Subject: add first protractor test --- js/.jshintrc | 10 +++++++++- js/Gruntfile.js | 7 ++++++- js/README.md | 13 +++++++++++++ js/config/karma.js | 2 +- js/config/protractor.js | 13 +++++++++++++ js/tests/e2e/main.js | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 js/config/protractor.js create mode 100644 js/tests/e2e/main.js diff --git a/js/.jshintrc b/js/.jshintrc index 7d424890d..611743709 100644 --- a/js/.jshintrc +++ b/js/.jshintrc @@ -5,6 +5,14 @@ "$": true, "angular": true, "OC": true, - "app": true + "app": true, + "protractor": true, + "describe": true, + "beforeEach": true, + "module": true, + "browser": true, + "expect": true, + "By": true, + "it": true } } \ No newline at end of file diff --git a/js/Gruntfile.js b/js/Gruntfile.js index 04a48a1c4..55d607a83 100644 --- a/js/Gruntfile.js +++ b/js/Gruntfile.js @@ -76,7 +76,11 @@ module.exports = function(grunt) { ], directives: { browser: true, - predef: ['$', 'angular', 'app', 'OC'] + predef: [ + '$', 'angular', 'app', 'OC', + 'protractor', 'describe', 'beforeEach', 'module', 'it', + 'browser', 'expect', 'By' + ] } } }, @@ -84,6 +88,7 @@ module.exports = function(grunt) { all: [ '**/*.js', '!config/karma.js', + '!config/protractor.js', '!build/**/*', '!coverage/**/*', '!vendor/**/*', diff --git a/js/README.md b/js/README.md index 27c9fbd98..c4d80fd62 100644 --- a/js/README.md +++ b/js/README.md @@ -22,3 +22,16 @@ Single run mode: grunt phpunit grunt ci + +### Running e2e tests +Install protractor and set up selenium: + + sudo npm install -g protractor + sudo webdriver-manager update + +then the selenium server can be started with: + + webdriver-manager start + protractor conf/protractor.js + + diff --git a/js/config/karma.js b/js/config/karma.js index b4c3e1071..f1129a2ea 100644 --- a/js/config/karma.js +++ b/js/config/karma.js @@ -23,7 +23,7 @@ module.exports = function(config) { 'vendor/angular-route/angular-route.js', 'vendor/angular/angular-sanitize/angular-sanitize.js', 'build/app.js', - 'tests/**/*Spec.js' + 'tests/unit/**/*.js' ], diff --git a/js/config/protractor.js b/js/config/protractor.js new file mode 100644 index 000000000..759dcef6e --- /dev/null +++ b/js/config/protractor.js @@ -0,0 +1,13 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt + * @copyright Bernhard Posselt 2012, 2014 + */ +exports.config = { + seleniumAddress: 'http://localhost:4444/wd/hub', + specs: ['../tests/e2e/**/*.js'] +} \ No newline at end of file diff --git a/js/tests/e2e/main.js b/js/tests/e2e/main.js new file mode 100644 index 000000000..94e31ee62 --- /dev/null +++ b/js/tests/e2e/main.js @@ -0,0 +1,34 @@ +describe('news page', function () { + 'use strict'; + + var ptor = protractor.getInstance(); + + beforeEach(function () { + browser.ignoreSynchronization = true; + return browser.ignoreSynchronization; + }); + + beforeEach(function () { + ptor.get('http://localhost/owncloud/'); + ptor.findElement(By.id('user')).sendKeys('admin'); + ptor.findElement(By.id('password')).sendKeys('admin'); + ptor.findElement(By.id('submit')).click(); + }); + + + describe('should log in', function () { + + beforeEach(function () { + browser.ignoreSynchronization = false; + return browser.ignoreSynchronization; + }); + + it('should go to the news page', function () { + ptor.get('http://localhost/owncloud/index.php/apps/news/'); + ptor.getTitle().then(function (title) { + expect(title).toBe('News - ownCloud'); + }); + }); + + }); +}); \ No newline at end of file -- cgit v1.2.3