summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.travis.yml5
-rw-r--r--js/.jshintrc3
-rw-r--r--js/Gruntfile.js20
-rw-r--r--js/README.md6
-rw-r--r--js/config/app.js2
-rw-r--r--js/config/config.js26
-rw-r--r--js/config/karma.js14
-rw-r--r--js/config/run.js15
-rw-r--r--js/package.json5
-rw-r--r--js/service/loading.js23
-rw-r--r--js/tests/e2e/include/auth.js17
-rw-r--r--js/tests/e2e/main.js43
-rw-r--r--js/tests/unit/controller/AllItemsControllerSpec.js26
-rw-r--r--js/tests/unit/service/LoadingSpec.js24
-rw-r--r--js/tests/unit/stubs/app.js10
-rw-r--r--js/tests/unit/stubs/oc.js16
17 files changed, 211 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index 791d8d289..132b88597 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
node_modules/
*.log
/build/
+/js/coverage/
js/build/
js/*.xml
.rvm
diff --git a/.travis.yml b/.travis.yml
index a6d294524..a8c32f91c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,7 +17,7 @@ before_install:
script:
- sudo add-apt-repository -y ppa:chris-lea/node.js
- sudo apt-get update
- - sudo apt-get -y install nodejs
+ - sudo apt-get -y install nodejs chromium
- wget https://phantomjs.googlecode.com/files/phantomjs-1.9.0-linux-x86_64.tar.bz2
- tar xjf phantomjs-1.9.0-linux-x86_64.tar.bz2
- sudo ln -s $(pwd)/phantomjs-1.9.0-linux-x86_64/bin/phantomjs /usr/bin/phantomjs
@@ -31,6 +31,5 @@ script:
- sh -e /etc/init.d/xvfb start
- sudo npm install -g protractor
- sudo webdriver-manager update
- - webdriver-manager start &
- - protractor config/protractor.js
+ - grunt e2e
diff --git a/js/.jshintrc b/js/.jshintrc
index 611743709..e84a806d5 100644
--- a/js/.jshintrc
+++ b/js/.jshintrc
@@ -13,6 +13,7 @@
"browser": true,
"expect": true,
"By": true,
- "it": true
+ "it": true,
+ "inject": true
}
} \ No newline at end of file
diff --git a/js/Gruntfile.js b/js/Gruntfile.js
index 55d607a83..953976dd0 100644
--- a/js/Gruntfile.js
+++ b/js/Gruntfile.js
@@ -19,6 +19,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-wrap');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-ngmin');
+ grunt.loadNpmTasks('grunt-protractor-runner');
+ grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.initConfig({
meta: {
@@ -79,7 +81,7 @@ module.exports = function(grunt) {
predef: [
'$', 'angular', 'app', 'OC',
'protractor', 'describe', 'beforeEach', 'module', 'it',
- 'browser', 'expect', 'By'
+ 'browser', 'expect', 'By', 'inject'
]
}
}
@@ -121,7 +123,8 @@ module.exports = function(grunt) {
karma: {
unit: {
configFile: 'config/karma.js',
- browsers: ['PhantomJS']
+ browsers: ['PhantomJS'],
+ autoWatch: true
},
continuous: {
configFile: 'config/karma.js',
@@ -145,6 +148,18 @@ module.exports = function(grunt) {
options: {
colors: true
}
+ },
+ protractor_webdriver: {
+ app: {
+
+ }
+ },
+ protractor: {
+ phantomjs: {
+ options: {
+ configFile: 'config/protractor.js'
+ }
+ }
}
});
@@ -152,5 +167,6 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['jshint', 'jslint', 'concat', 'ngmin', 'wrap']);
grunt.registerTask('test', ['karma:unit']);
grunt.registerTask('ci', ['default', 'karma:continuous']);
+ grunt.registerTask('e2e', ['protractor_webdriver', 'protractor']);
}; \ No newline at end of file
diff --git a/js/README.md b/js/README.md
index c4d80fd62..911b88423 100644
--- a/js/README.md
+++ b/js/README.md
@@ -29,9 +29,7 @@ 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
+then the tests can be started with:
+ grunt e2e
diff --git a/js/config/app.js b/js/config/app.js
index 58ded6d62..97620f206 100644
--- a/js/config/app.js
+++ b/js/config/app.js
@@ -7,4 +7,4 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*/
-var app = angular.module('News', []); \ No newline at end of file
+var app = angular.module('News', ['ngRoute', 'ngSanitize']); \ No newline at end of file
diff --git a/js/config/config.js b/js/config/config.js
index dce40a0b4..1abaede89 100644
--- a/js/config/config.js
+++ b/js/config/config.js
@@ -10,8 +10,32 @@
app.config(function ($routeProvider, $provide) {
'use strict';
- $routeProvider.otherwise('/');
$provide.constant('baseUrl', OC.generateUrl(''));
+ $routeProvider
+ .when('/items', {
+ controller: 'AllItemsController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .when('/items/starred', {
+ controller: 'StarredItemsController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .when('/items/feed/:feedId', {
+ controller: 'FeedItemsController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .when('/items/folder/:folderId', {
+ controller: 'FolderItemsController',
+ templateUrl: 'content.html',
+ resolve: {}
+ })
+ .otherwise({
+ redirectTo: '/items'
+ });
+
});
diff --git a/js/config/karma.js b/js/config/karma.js
index f1129a2ea..e394b94fe 100644
--- a/js/config/karma.js
+++ b/js/config/karma.js
@@ -16,14 +16,18 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
'vendor/jquery/dist/jquery.js',
- 'vendor/momentjs/momentjs.js',
+ 'vendor/momentjs/moment.js',
'vendor/bootstrap/tooltip.js',
- 'vendor/angular',
+ 'vendor/angular/angular.js',
'vendor/angular-mocks/angular-mocks.js',
'vendor/angular-route/angular-route.js',
- 'vendor/angular/angular-sanitize/angular-sanitize.js',
- 'build/app.js',
- 'tests/unit/**/*.js'
+ 'vendor/angular-sanitize/angular-sanitize.js',
+ 'tests/unit/stubs/*.js',
+ 'controller/**/*.js',
+ 'filter/**/*.js',
+ 'service/**/*.js',
+ 'directive/**/*.js',
+ 'tests/unit/**/*Spec.js'
],
diff --git a/js/config/run.js b/js/config/run.js
index 3feca64e4..1c87228fe 100644
--- a/js/config/run.js
+++ b/js/config/run.js
@@ -7,8 +7,19 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2012, 2014
*/
-app.run(function ($rootScope) {
+app.run(function ($rootScope, $location, Loading) {
'use strict';
- $rootScope.$on('$routeChangeError');
+ $rootScope.$on('$routeChangeStart', function () {
+ Loading.isActive = true;
+ });
+
+ $rootScope.$on('$routeChangeSuccess', function () {
+ Loading.isActive = false;
+ });
+
+ // in case of wrong id etc show all items
+ $rootScope.$on('$routeChangeError', function () {
+ $location.path('/items');
+ });
}); \ No newline at end of file
diff --git a/js/package.json b/js/package.json
index fb9bb0bf6..a15820d7e 100644
--- a/js/package.json
+++ b/js/package.json
@@ -33,10 +33,13 @@
"grunt-karma": "^0.8.3",
"grunt-ngmin": "0.0.3",
"grunt-phpunit": "^0.3.3",
+ "grunt-protractor-runner": "^0.2.4",
+ "grunt-protractor-webdriver": "^0.1.6",
"grunt-wrap": "^0.3.0",
"karma": "^0.12.16",
"karma-coverage": "^0.2.1",
"karma-jasmine": "^0.1.5",
- "karma-phantomjs-launcher": "^0.1.4"
+ "karma-phantomjs-launcher": "^0.1.4",
+ "protractor": "^0.22.0"
}
}
diff --git a/js/service/loading.js b/js/service/loading.js
new file mode 100644
index 000000000..1b6ecffd0
--- /dev/null
+++ b/js/service/loading.js
@@ -0,0 +1,23 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+app.service('Loading', function () {
+ 'use strict';
+
+ this.loading = false;
+
+ this.setLoading = function (isLoading) {
+ this.loading = isLoading;
+ };
+
+ this.isLoading = function () {
+ return this.loading;
+ };
+
+}); \ No newline at end of file
diff --git a/js/tests/e2e/include/auth.js b/js/tests/e2e/include/auth.js
new file mode 100644
index 000000000..6dea83a77
--- /dev/null
+++ b/js/tests/e2e/include/auth.js
@@ -0,0 +1,17 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+
+exports.login = function (browser) {
+ browser.ignoreSynchronization = true;
+ browser.get('http://localhost/owncloud/');
+ browser.findElement(By.id('user')).sendKeys('admin');
+ browser.findElement(By.id('password')).sendKeys('admin');
+ browser.findElement(By.id('submit')).click();
+}; \ No newline at end of file
diff --git a/js/tests/e2e/main.js b/js/tests/e2e/main.js
index 94e31ee62..40ab73c38 100644
--- a/js/tests/e2e/main.js
+++ b/js/tests/e2e/main.js
@@ -1,34 +1,27 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+
+var auth = require('./include/auth.js');
+
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();
+ auth.login(browser);
});
-
- 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');
- });
+ it('should go to the news page', function () {
+ browser.get('http://localhost/owncloud/index.php/apps/news/');
+ browser.getTitle().then(function (title) {
+ expect(title).toBe('News - ownCloud');
});
-
});
+
}); \ No newline at end of file
diff --git a/js/tests/unit/controller/AllItemsControllerSpec.js b/js/tests/unit/controller/AllItemsControllerSpec.js
new file mode 100644
index 000000000..63cf55536
--- /dev/null
+++ b/js/tests/unit/controller/AllItemsControllerSpec.js
@@ -0,0 +1,26 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+describe('AllItemsController', function () {
+ 'use strict';
+
+ var controller;
+
+ beforeEach(module('News'));
+
+ beforeEach(inject(function ($controller) {
+ controller = $controller;
+ }));
+
+
+ it('should ', function () {
+ expect(controller).toBeDefined();
+ });
+
+}); \ No newline at end of file
diff --git a/js/tests/unit/service/LoadingSpec.js b/js/tests/unit/service/LoadingSpec.js
new file mode 100644
index 000000000..cae049c99
--- /dev/null
+++ b/js/tests/unit/service/LoadingSpec.js
@@ -0,0 +1,24 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+describe('Loading', function () {
+ 'use strict';
+
+ beforeEach(module('News'));
+
+ it('should be not load by default', inject(function (Loading) {
+ expect(Loading.isLoading()).toBe(false);
+ }));
+
+ it('should set loading', inject(function (Loading) {
+ Loading.setLoading(true);
+ expect(Loading.isLoading()).toBe(true);
+ }));
+
+}); \ No newline at end of file
diff --git a/js/tests/unit/stubs/app.js b/js/tests/unit/stubs/app.js
new file mode 100644
index 000000000..54135ec10
--- /dev/null
+++ b/js/tests/unit/stubs/app.js
@@ -0,0 +1,10 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngMock']); \ No newline at end of file
diff --git a/js/tests/unit/stubs/oc.js b/js/tests/unit/stubs/oc.js
new file mode 100644
index 000000000..07ac96491
--- /dev/null
+++ b/js/tests/unit/stubs/oc.js
@@ -0,0 +1,16 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+var OC = {
+ generateUrl: function () {
+ 'use strict';
+
+ return '';
+ }
+}; \ No newline at end of file